Latest updates
This commit is contained in:
@@ -94,7 +94,7 @@ header {
|
||||
background: var(--accent-bg);
|
||||
border-bottom: 1px solid var(--border);
|
||||
text-align: center;
|
||||
padding: 2rem 0.5rem;
|
||||
padding: 0;
|
||||
width: 100vw;
|
||||
position: relative;
|
||||
box-sizing: border-box;
|
||||
@@ -119,14 +119,14 @@ main {
|
||||
h1,
|
||||
h2,
|
||||
h3 {
|
||||
line-height: 1.1;
|
||||
line-height: 0.1;
|
||||
}
|
||||
|
||||
/* Format navigation */
|
||||
nav {
|
||||
font-size: 1rem;
|
||||
line-height: 2;
|
||||
padding: 1rem 0;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
nav a {
|
||||
@@ -164,7 +164,7 @@ h1 {
|
||||
var(--base-fontsize) * var(--header-scale) * var(--header-scale) *
|
||||
var(--header-scale) * var(--header-scale)
|
||||
);
|
||||
margin-top: calc(var(--line-height) * 1.5rem);
|
||||
margin-top: calc(var(--line-height) * 1.1rem);
|
||||
}
|
||||
|
||||
h2 {
|
||||
@@ -179,7 +179,7 @@ h3 {
|
||||
font-size: calc(
|
||||
var(--base-fontsize) * var(--header-scale) * var(--header-scale)
|
||||
);
|
||||
margin-top: calc(var(--line-height) * 1.5rem);
|
||||
margin-top: calc(var(--line-height) * 1.1rem);
|
||||
}
|
||||
|
||||
h4 {
|
||||
@@ -525,3 +525,7 @@ pre code {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
nav>form {
|
||||
display:inline;
|
||||
}
|
||||
|
||||
75
app/controllers/cafs_controller.rb
Normal file
75
app/controllers/cafs_controller.rb
Normal file
@@ -0,0 +1,75 @@
|
||||
class CafsController < ApplicationController
|
||||
before_action :set_caf, only: %i[ show edit update destroy ]
|
||||
before_action :set_company
|
||||
|
||||
# GET /cafs or /cafs.json
|
||||
def index
|
||||
@cafs = Caf.all
|
||||
end
|
||||
|
||||
# GET /cafs/1 or /cafs/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /cafs/new
|
||||
def new
|
||||
@caf = Caf.new
|
||||
end
|
||||
|
||||
# GET /cafs/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /cafs or /cafs.json
|
||||
def create
|
||||
@caf = Caf.new(caf_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @caf.save
|
||||
format.html { redirect_to caf_url(@caf), notice: "Caf was successfully created." }
|
||||
format.json { render :show, status: :created, location: @caf }
|
||||
else
|
||||
format.html { render :new, status: :unprocessable_entity }
|
||||
format.json { render json: @caf.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /cafs/1 or /cafs/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @caf.update(caf_params)
|
||||
format.html { redirect_to caf_url(@caf), notice: "Caf was successfully updated." }
|
||||
format.json { render :show, status: :ok, location: @caf }
|
||||
else
|
||||
format.html { render :edit, status: :unprocessable_entity }
|
||||
format.json { render json: @caf.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /cafs/1 or /cafs/1.json
|
||||
def destroy
|
||||
@caf.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to cafs_url, notice: "Caf was successfully destroyed." }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_caf
|
||||
@caf = Caf.find(params[:id])
|
||||
end
|
||||
|
||||
def set_company
|
||||
@company = Company.find(params[:company_id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def caf_params
|
||||
params.require(:caf).permit(:company_id, :name, :description)
|
||||
end
|
||||
end
|
||||
70
app/controllers/companies_controller.rb
Normal file
70
app/controllers/companies_controller.rb
Normal file
@@ -0,0 +1,70 @@
|
||||
class CompaniesController < ApplicationController
|
||||
before_action :set_company, only: %i[ show edit update destroy ]
|
||||
|
||||
# GET /companies or /companies.json
|
||||
def index
|
||||
@companies = Company.all
|
||||
end
|
||||
|
||||
# GET /companies/1 or /companies/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /companies/new
|
||||
def new
|
||||
@company = Company.new
|
||||
end
|
||||
|
||||
# GET /companies/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /companies or /companies.json
|
||||
def create
|
||||
@company = Company.new(company_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @company.save
|
||||
format.html { redirect_to company_url(@company), notice: "Company was successfully created." }
|
||||
format.json { render :show, status: :created, location: @company }
|
||||
else
|
||||
format.html { render :new, status: :unprocessable_entity }
|
||||
format.json { render json: @company.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /companies/1 or /companies/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @company.update(company_params)
|
||||
format.html { redirect_to company_url(@company), notice: "Company was successfully updated." }
|
||||
format.json { render :show, status: :ok, location: @company }
|
||||
else
|
||||
format.html { render :edit, status: :unprocessable_entity }
|
||||
format.json { render json: @company.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /companies/1 or /companies/1.json
|
||||
def destroy
|
||||
@company.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to companies_url, notice: "Company was successfully destroyed." }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_company
|
||||
@company = Company.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def company_params
|
||||
params.require(:company).permit(:name)
|
||||
end
|
||||
end
|
||||
2
app/helpers/cafs_helper.rb
Normal file
2
app/helpers/cafs_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module CafsHelper
|
||||
end
|
||||
3
app/models/caf.rb
Normal file
3
app/models/caf.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class Caf < ApplicationRecord
|
||||
belongs_to :company
|
||||
end
|
||||
@@ -1,4 +1,5 @@
|
||||
class Company < ApplicationRecord
|
||||
has_many :cafs
|
||||
has_and_belongs_to_many :users
|
||||
validates :name, presence: true
|
||||
validates :name, uniqueness: true
|
||||
|
||||
17
app/views/cafs/_caf.html.erb
Normal file
17
app/views/cafs/_caf.html.erb
Normal file
@@ -0,0 +1,17 @@
|
||||
<div id="<%= dom_id caf %>">
|
||||
<p>
|
||||
<strong>Company:</strong>
|
||||
<%= caf.company_id %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Name:</strong>
|
||||
<%= caf.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Description:</strong>
|
||||
<%= caf.description %>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
2
app/views/cafs/_caf.json.jbuilder
Normal file
2
app/views/cafs/_caf.json.jbuilder
Normal file
@@ -0,0 +1,2 @@
|
||||
json.extract! caf, :id, :company_id, :name, :description, :created_at, :updated_at
|
||||
json.url caf_url(caf, format: :json)
|
||||
30
app/views/cafs/_form.html.erb
Normal file
30
app/views/cafs/_form.html.erb
Normal file
@@ -0,0 +1,30 @@
|
||||
<%= form_for( [company, caf] ) do |form| %>
|
||||
<% if caf.errors.any? %>
|
||||
<div style="color: red">
|
||||
<h2><%= pluralize(caf.errors.count, "error") %> prohibited this caf from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% caf.errors.each do |error| %>
|
||||
<li><%= error.full_message %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= form.hidden_field :company_id, value: company.id %>
|
||||
|
||||
|
||||
<div>
|
||||
<%= form.label :name, style: "display: block" %>
|
||||
<%= form.text_field :name %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.label :description, style: "display: block" %>
|
||||
<%= form.text_area :description %>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= form.submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
10
app/views/cafs/edit.html.erb
Normal file
10
app/views/cafs/edit.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<h1>Editing caf</h1>
|
||||
|
||||
<%= render "form", caf: @caf %>
|
||||
|
||||
<br>
|
||||
|
||||
<div>
|
||||
<%= link_to "Show this caf", @caf %> |
|
||||
<%= link_to "Back to cafs", cafs_path %>
|
||||
</div>
|
||||
14
app/views/cafs/index.html.erb
Normal file
14
app/views/cafs/index.html.erb
Normal file
@@ -0,0 +1,14 @@
|
||||
<p style="color: green"><%= notice %></p>
|
||||
|
||||
<h1>Cafs</h1>
|
||||
|
||||
<div id="cafs">
|
||||
<% @cafs.each do |caf| %>
|
||||
<%= render caf %>
|
||||
<p>
|
||||
<%= link_to "Show this caf", caf %>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%= link_to "New caf", new_company_caf_path(@company) %>
|
||||
1
app/views/cafs/index.json.jbuilder
Normal file
1
app/views/cafs/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @cafs, partial: "cafs/caf", as: :caf
|
||||
9
app/views/cafs/new.html.erb
Normal file
9
app/views/cafs/new.html.erb
Normal file
@@ -0,0 +1,9 @@
|
||||
<h1>New caf</h1>
|
||||
|
||||
<%= render partial: "form", locals: { company: @company, caf: @caf } %>
|
||||
|
||||
<br>
|
||||
|
||||
<div>
|
||||
<%= link_to "Back to cafs", company_cafs_path(@company) %>
|
||||
</div>
|
||||
10
app/views/cafs/show.html.erb
Normal file
10
app/views/cafs/show.html.erb
Normal file
@@ -0,0 +1,10 @@
|
||||
<p style="color: green"><%= notice %></p>
|
||||
|
||||
<%= render @caf %>
|
||||
|
||||
<div>
|
||||
<%= link_to "Edit this caf", edit_caf_path(@caf) %> |
|
||||
<%= link_to "Back to cafs", cafs_path %>
|
||||
|
||||
<%= button_to "Destroy this caf", @caf, method: :delete %>
|
||||
</div>
|
||||
1
app/views/cafs/show.json.jbuilder
Normal file
1
app/views/cafs/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.partial! "cafs/caf", caf: @caf
|
||||
@@ -1,5 +1,4 @@
|
||||
<h1>CAF Compliance Tracking</h1>
|
||||
<h2>By Hidden Agenda Ltd</h2>
|
||||
|
||||
<% if !user_signed_in? %>
|
||||
Not Signed in.
|
||||
@@ -7,11 +6,28 @@ Not Signed in.
|
||||
<% else %>
|
||||
<%#= current_user.roletxt %>
|
||||
<% if current_user.admin? %>
|
||||
<h2>Companies</h2>
|
||||
<%= link_to "Add Company", new_company_path %>
|
||||
|
||||
<h3>Companies <small><%= link_to "Add Company", new_company_path %></small></h3>
|
||||
<ul>
|
||||
<% @companies.each do |company| %>
|
||||
<li><%= company.name %> <%= link_to "Edit", edit_company_path(company) %>
|
||||
<ul>
|
||||
<% company.users.each do |user|%>
|
||||
<li><%= user.email %></li>
|
||||
<% end %>
|
||||
<li>Add user</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<% company.cafs.each do |caf| %>
|
||||
<li><%= caf.name %>
|
||||
<% end %>
|
||||
<li><%= link_to "Add CAF", new_company_caf_path(company) %></li>
|
||||
</ul>
|
||||
<% end %>
|
||||
</ul>
|
||||
<p>
|
||||
<%= link_to "Add User" %>
|
||||
</p>
|
||||
|
||||
<% end %>
|
||||
|
||||
<% if current_user.user? %>
|
||||
|
||||
Reference in New Issue
Block a user