-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
472 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
class RequiredReportsController < ApplicationController | ||
before_action :set_required_report, only: [:show, :edit, :update, :destroy] | ||
|
||
# GET /required_reports | ||
# GET /required_reports.json | ||
def index | ||
@required_reports = RequiredReport.all | ||
end | ||
|
||
# GET /required_reports/1 | ||
# GET /required_reports/1.json | ||
def show | ||
end | ||
|
||
# GET /required_reports/new | ||
def new | ||
@required_report = RequiredReport.new | ||
end | ||
|
||
# GET /required_reports/1/edit | ||
def edit | ||
end | ||
|
||
# POST /required_reports | ||
# POST /required_reports.json | ||
def create | ||
@required_report = RequiredReport.new(required_report_params) | ||
|
||
respond_to do |format| | ||
if @required_report.save | ||
format.html { redirect_to @required_report, notice: 'Required report was successfully created.' } | ||
format.json { render :show, status: :created, location: @required_report } | ||
else | ||
format.html { render :new } | ||
format.json { render json: @required_report.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /required_reports/1 | ||
# PATCH/PUT /required_reports/1.json | ||
def update | ||
respond_to do |format| | ||
if @required_report.update(required_report_params) | ||
format.html { redirect_to @required_report, notice: 'Required report was successfully updated.' } | ||
format.json { render :show, status: :ok, location: @required_report } | ||
else | ||
format.html { render :edit } | ||
format.json { render json: @required_report.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /required_reports/1 | ||
# DELETE /required_reports/1.json | ||
def destroy | ||
@required_report.destroy | ||
respond_to do |format| | ||
format.html { redirect_to required_reports_url, notice: 'Required report was successfully destroyed.' } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_required_report | ||
@required_report = RequiredReport.find(params[:id]) | ||
end | ||
|
||
# Never trust parameters from the scary internet, only allow the white list through. | ||
def required_report_params | ||
params.require(:required_report).permit(:agency, :name, :description, :local_law, :charter_and_code, :frequency, :frequency_integer, :other_frequency_description, :start_date, :end_date, :last_published_date) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module RequiredReportsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class RequiredReport < ApplicationRecord | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<%= simple_form_for @required_report do |f| %> | ||
<% if required_report.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(required_report.errors.count, "error") %> prohibited this required_report from being saved:</h2> | ||
|
||
<ul> | ||
<% required_report.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<%= f.input :name, | ||
as: :string, | ||
input_html: { class: 'form-control' } | ||
%> | ||
|
||
<%= f.input :agency, | ||
as: :select, | ||
collection: AgenciesService.select_all_options, | ||
include_blank: true, | ||
input_html: { class: 'form-control' } | ||
%> | ||
|
||
<%= f.input :description, | ||
as: :string, | ||
input_html: { class: 'form-control' } | ||
%> | ||
|
||
<%= f.input :local_law, | ||
as: :string, | ||
input_html: { class: 'form-control' } | ||
%> | ||
|
||
<%= f.input :charter_and_code, | ||
as: :string, | ||
input_html: { class: 'form-control' } | ||
%> | ||
|
||
<%= f.input :frequency, | ||
as: :string, | ||
input_html: { class: 'form-control' } | ||
%> | ||
|
||
<%= f.input :frequency_integer, | ||
as: :integer, | ||
input_html: { class: 'form-control' } | ||
%> | ||
|
||
<%= f.input :other_frequency_description, | ||
as: :string, | ||
input_html: { class: 'form-control' } | ||
%> | ||
|
||
<%= f.input :start_date, | ||
as: :string, | ||
input_html: { class: 'form-control', multiple: false, placeholder: 'YYYY-MM-DD' } | ||
%> | ||
|
||
<%= f.input :end_date, | ||
as: :string, | ||
input_html: { class: 'form-control', multiple: false, placeholder: 'YYYY-MM-DD' } | ||
%> | ||
|
||
<div class="actions"> | ||
<%= f.button :submit %> | ||
</div> | ||
|
||
<script> | ||
$('#required_report_start_date').inputmask( | ||
{ | ||
alias: 'datetime', | ||
inputFormat: 'yyyy-mm-dd', | ||
placeholder: '_', | ||
showMaskOnHover: false, | ||
min: '01/01/1600' | ||
}); | ||
|
||
$('#required_report_end_date').inputmask( | ||
{ | ||
alias: 'datetime', | ||
inputFormat: 'yyyy-mm-dd', | ||
placeholder: '_', | ||
showMaskOnHover: false, | ||
min: '01/01/1600' | ||
}); | ||
</script> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
json.extract! required_report, :id, :agency, :name, :description, :local_law, :charter_and_code, :frequency, :frequency_integer, :other_frequency_description, :start_date, :end_date, :last_published_date, :created_at, :updated_at | ||
json.url required_report_url(required_report, format: :json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Editing Required Report</h1> | ||
|
||
<%= render 'form', required_report: @required_report %> | ||
|
||
<%= link_to 'Show', @required_report %> | | ||
<%= link_to 'Back', required_reports_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<h1>Required Reports</h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Agency</th> | ||
<th>Name</th> | ||
<th>Description</th> | ||
<th>Local law</th> | ||
<th>Charter and code</th> | ||
<th>Frequency</th> | ||
<th>Frequency integer</th> | ||
<th>Other frequency description</th> | ||
<th>Start date</th> | ||
<th>End date</th> | ||
<th>Last published date</th> | ||
<th colspan="3"></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @required_reports.each do |required_report| %> | ||
<tr> | ||
<td><%= required_report.agency %></td> | ||
<td><%= required_report.name %></td> | ||
<td><%= required_report.description %></td> | ||
<td><%= required_report.local_law %></td> | ||
<td><%= required_report.charter_and_code %></td> | ||
<td><%= required_report.frequency %></td> | ||
<td><%= required_report.frequency_integer %></td> | ||
<td><%= required_report.other_frequency_description %></td> | ||
<td><%= required_report.start_date %></td> | ||
<td><%= required_report.end_date %></td> | ||
<td><%= required_report.last_published_date %></td> | ||
<td><%= link_to 'Show', required_report %></td> | ||
<td><%= link_to 'Edit', edit_required_report_path(required_report) %></td> | ||
<td><%= link_to 'Destroy', required_report, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<br> | ||
|
||
<%= link_to 'New Required Report', new_required_report_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.array! @required_reports, partial: 'required_reports/required_report', as: :required_report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>New Required Report</h1> | ||
|
||
<%= render 'form', required_report: @required_report %> | ||
|
||
<%= link_to 'Back', required_reports_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<strong>Agency:</strong> | ||
<%= @required_report.agency %> | ||
</p> | ||
|
||
<p> | ||
<strong>Name:</strong> | ||
<%= @required_report.name %> | ||
</p> | ||
|
||
<p> | ||
<strong>Description:</strong> | ||
<%= @required_report.description %> | ||
</p> | ||
|
||
<p> | ||
<strong>Local law:</strong> | ||
<%= @required_report.local_law %> | ||
</p> | ||
|
||
<p> | ||
<strong>Charter and code:</strong> | ||
<%= @required_report.charter_and_code %> | ||
</p> | ||
|
||
<p> | ||
<strong>Frequency:</strong> | ||
<%= @required_report.frequency %> | ||
</p> | ||
|
||
<p> | ||
<strong>Frequency integer:</strong> | ||
<%= @required_report.frequency_integer %> | ||
</p> | ||
|
||
<p> | ||
<strong>Other frequency description:</strong> | ||
<%= @required_report.other_frequency_description %> | ||
</p> | ||
|
||
<p> | ||
<strong>Start date:</strong> | ||
<%= @required_report.start_date %> | ||
</p> | ||
|
||
<p> | ||
<strong>End date:</strong> | ||
<%= @required_report.end_date %> | ||
</p> | ||
|
||
<p> | ||
<strong>Last published date:</strong> | ||
<%= @required_report.last_published_date %> | ||
</p> | ||
|
||
<%= link_to 'Edit', edit_required_report_path(@required_report) %> | | ||
<%= link_to 'Back', required_reports_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.partial! "required_reports/required_report", required_report: @required_report |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class CreateRequiredReports < ActiveRecord::Migration[5.1] | ||
def change | ||
create_table :required_reports do |t| | ||
t.string :agency, null: false | ||
t.string :name, null: false | ||
t.string :description | ||
t.string :local_law | ||
t.string :charter_and_code | ||
t.string :frequency | ||
t.integer :frequency_integer | ||
t.string :other_frequency_description | ||
t.date :start_date, null: false | ||
t.date :end_date | ||
t.date :last_published_date | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.