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)
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
end
end

2
app/helpers/tasklist_helper.rb

@ -40,6 +40,6 @@ module TasklistHelper
else
"#"
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

2
app/javascript/controllers/soft_validations_controller.js

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

4
app/models/form.rb

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

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

@ -6,6 +6,6 @@
<%= question.answer_label(@case_log) %>
</dd>
<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>
</div>

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

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

12
config/routes.rb

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

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

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

Loading…
Cancel
Save