-
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.
GL-103: Add Admin UI for creating category assessment data
- Loading branch information
Showing
8 changed files
with
150 additions
and
1 deletion.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
app/controllers/green_lanes/category_assessments_controller.rb
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,27 @@ | ||
module GreenLanes | ||
class Theme | ||
include Her::JsonApi::Model | ||
use_api Her::XI_API | ||
|
||
MAX_LENGTH = 50 | ||
|
||
attributes :section, | ||
:subsection, | ||
:theme, | ||
:description, | ||
:category, | ||
:created_at, | ||
:updated_at | ||
|
||
collection_path '/admin/themes' | ||
|
||
def label | ||
"#{category} - #{short_theme}" | ||
end | ||
|
||
private | ||
def short_theme | ||
theme.length > MAX_LENGTH ? "#{theme[0...MAX_LENGTH]}..." : theme | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<%= govuk_form_for category_assessment, as: :category_assessment do |f| %> | ||
|
||
<%= f.govuk_text_field :measure_type_id, | ||
label: { text: 'Measure Type Id' }, | ||
width: 'one-half' %> | ||
|
||
<%= f.govuk_text_field :regulation_id, | ||
label: { text: 'Regulation Id' }, | ||
width: 'one-half' %> | ||
|
||
<%= f.govuk_text_field :regulation_role, | ||
label: { text: 'Regulation Role' }, | ||
width: 'one-half' %> | ||
|
||
<%= f.govuk_collection_select :theme_id, | ||
@themes, | ||
:id, | ||
:label, | ||
options: { include_blank: 'Select Theme' }, | ||
label: { text: 'Select Theme' } %> | ||
|
||
<%= submit_and_back_buttons f, green_lanes_category_assessments_path %> | ||
<% 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
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 @@ | ||
<%= govuk_breadcrumbs 'Category Assessments': green_lanes_category_assessments_path %> | ||
|
||
<h2>New Category Assessment</h2> | ||
|
||
<%= render 'form', category_assessment: @category_assessment %> |
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,22 @@ | ||
FactoryBot.define do | ||
factory :green_lanes_theme, class: 'GreenLanes::Theme' do | ||
sequence(:id) { |n| n } | ||
section { 1 } | ||
sequence(:subsection) { |n| n } | ||
sequence(:theme) { |n| "Theme #{n}" } | ||
description { 'Some description' } | ||
category { 2 } | ||
|
||
trait :category1 do | ||
category { 1 } | ||
end | ||
|
||
trait :category2 do | ||
category { 2 } | ||
end | ||
|
||
trait :category3 do | ||
category { 3 } | ||
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