Browse Source

Use dahes in URLs for case log routes

pull/128/head
Paul Robert Lloyd 3 years ago
parent
commit
4005e3accb
  1. 2
      app/helpers/check_answers_helper.rb
  2. 2
      app/helpers/tasklist_helper.rb
  3. 2
      app/javascript/controllers/soft_validations_controller.js
  4. 4
      app/models/form.rb
  5. 2
      app/views/form/_check_answers_table.html.erb
  6. 2
      app/views/layouts/application.html.erb
  7. 12
      config/routes.rb
  8. 4
      docs/api/DLUHC-CORE-Data.v1.json

2
app/helpers/check_answers_helper.rb

@ -16,7 +16,7 @@ private
def create_next_missing_question_link(subsection, case_log) def create_next_missing_question_link(subsection, case_log)
pages_to_fill_in = subsection.unanswered_questions(case_log).map(&:page) pages_to_fill_in = subsection.unanswered_questions(case_log).map(&:page)
url = "/case_logs/#{case_log.id}/#{pages_to_fill_in.first.id}" url = "/case-logs/#{case_log.id}/#{pages_to_fill_in.first.id.to_s.dasherize}"
govuk_link_to("Answer the missing questions", url).html_safe govuk_link_to("Answer the missing questions", url).html_safe
end end
end end

2
app/helpers/tasklist_helper.rb

@ -40,6 +40,6 @@ module TasklistHelper
else else
"#" "#"
end end
govuk_link_to(subsection.label, next_page_path, class: "task-name") govuk_link_to(subsection.label, next_page_path.to_s.dasherize, class: "task-name")
end end
end end

2
app/javascript/controllers/soft_validations_controller.js

@ -4,7 +4,7 @@ export default class extends Controller {
static targets = [ "override" ] static targets = [ "override" ]
initialize() { initialize() {
let url = window.location.href + "/soft_validations" let url = window.location.href + "/soft-validations"
let div = this.overrideTarget let div = this.overrideTarget
fetch(url, { headers: { accept: "application/json" } }) fetch(url, { headers: { accept: "application/json" } })
.then(response => response.json()) .then(response => response.json())

4
app/models/form.rb

@ -12,11 +12,11 @@ class Form
end end
def get_subsection(id) def get_subsection(id)
subsections.find { |s| s.id == id } subsections.find { |s| s.id == id.to_s.underscore }
end end
def get_page(id) def get_page(id)
pages.find { |p| p.id == id } pages.find { |p| p.id == id.to_s.underscore }
end end
def subsection_for_page(page) def subsection_for_page(page)

2
app/views/form/_check_answers_table.html.erb

@ -6,6 +6,6 @@
<%= question.answer_label(@case_log) %> <%= question.answer_label(@case_log) %>
</dd> </dd>
<dd class="govuk-summary-list__actions"> <dd class="govuk-summary-list__actions">
<%= govuk_link_to(question.update_answer_link_name(@case_log), "/case_logs/#{@case_log.id}/#{question.page.id}").html_safe %> <%= govuk_link_to(question.update_answer_link_name(@case_log), "/case-logs/#{@case_log.id}/#{question.page.id.to_s.dasherize}").html_safe %>
</dd> </dd>
</div> </div>

2
app/views/layouts/application.html.erb

@ -37,7 +37,7 @@
service_url: '/' service_url: '/'
) do |component| ) do |component|
if current_user.nil? if current_user.nil?
component.navigation_item(text: 'Case logs', href: '/case_logs') component.navigation_item(text: 'Case logs', href: case_logs_path)
elsif elsif
component.navigation_item(text: 'Your organisation', href: "/organisations/#{current_user.organisation.id}") component.navigation_item(text: 'Your organisation', href: "/organisations/#{current_user.organisation.id}")
component.navigation_item(text: 'Your account', href: '/users/account') component.navigation_item(text: 'Your account', href: '/users/account')

12
config/routes.rb

@ -30,10 +30,10 @@ Rails.application.routes.draw do
end end
end end
resources :case_logs do resources :case_logs, :path => '/case-logs' do
collection do collection do
post "/bulk_upload", to: "bulk_upload#bulk_upload" post "/bulk-upload", to: "bulk_upload#bulk_upload"
get "/bulk_upload", to: "bulk_upload#show" get "/bulk-upload", to: "bulk_upload#show"
end end
member do member do
@ -41,12 +41,12 @@ Rails.application.routes.draw do
end end
form.pages.map do |page| form.pages.map do |page|
get page.id.to_s, to: "case_logs##{page.id}" get page.id.to_s.dasherize, to: "case_logs##{page.id}"
get "#{page.id}/soft_validations", to: "soft_validations#show" if page.has_soft_validations? get "#{page.id.to_s.dasherize}/soft-validations", to: "soft_validations#show" if page.has_soft_validations?
end end
form.subsections.map do |subsection| form.subsections.map do |subsection|
get "#{subsection.id}/check_answers", to: "case_logs#check_answers" get "#{subsection.id.to_s.dasherize}/check-answers", to: "case_logs#check_answers"
end end
end end
end end

4
docs/api/DLUHC-CORE-Data.v1.json

@ -12,7 +12,7 @@
} }
], ],
"paths": { "paths": {
"/case_logs/:id": { "/case-logs/:id": {
"parameters": [], "parameters": [],
"get": { "get": {
"summary": "Get Case Log Info by Case Log ID", "summary": "Get Case Log Info by Case Log ID",
@ -180,7 +180,7 @@
] ]
} }
}, },
"/case_logs": { "/case-logs": {
"post": { "post": {
"summary": "Create New Case Log", "summary": "Create New Case Log",
"operationId": "post-caselog", "operationId": "post-caselog",

Loading…
Cancel
Save