Browse Source

update routes

CLDC-1324
Kat 2 years ago
parent
commit
c5997981c4
  1. 2
      app/controllers/form_controller.rb
  2. 2
      app/helpers/tasklist_helper.rb
  3. 2
      app/models/form.rb
  4. 4
      config/routes.rb

2
app/controllers/form_controller.rb

@ -13,7 +13,7 @@ class FormController < ApplicationController
session[:errors] = session[:fields] = nil
redirect_to(successful_redirect_path)
else
redirect_path = @log.not_started? ? "#{@log.model_name.param_key}s_new_#{@page.id}_path" : "#{@log.model_name.param_key}_#{@page.id}_path"
redirect_path = @log.not_started? ? "#{@log.model_name.param_key}_new_#{@page.id}_path" : "#{@log.model_name.param_key}_#{@page.id}_path"
mandatory_questions_with_no_response.map do |question|
@log.errors.add question.id.to_sym, question.unanswered_error_message
end

2
app/helpers/tasklist_helper.rb

@ -20,7 +20,7 @@ module TasklistHelper
if log.id
send(path, log)
else
"/#{log.lettings? ? 'lettings' : 'sales'}-logs/new/#{next_question_page(subsection, log, current_user)}"
"/#{log.class.name.underscore.dasherize}/new/#{next_question_page(subsection, log, current_user)}"
end
end

2
app/models/form.rb

@ -76,7 +76,7 @@ class Form
if nxt_page == :check_answers
"#{type}_log_#{subsection_for_page(page).id}_check_answers_path"
else
log.id ? "#{type}_log_#{nxt_page}_path" : "#{type}_logs_new_#{nxt_page}_path"
log.id ? "#{type}_log_#{nxt_page}_path" : "#{type}_log_new_#{nxt_page}_path"
end
end

4
config/routes.rb

@ -31,8 +31,8 @@ Rails.application.routes.draw do
FormHandler.instance.forms.each do |_key, form|
form.pages.map do |page|
get "/lettings-logs/new/#{page.id.to_s.dasherize}", to: "form#show_page"
get "/sales-logs/new/#{page.id.to_s.dasherize}", to: "form#show_page"
get "/lettings-log/new/#{page.id.to_s.dasherize}", to: "form#show_page"
get "/sales-log/new/#{page.id.to_s.dasherize}", to: "form#show_page"
end
end

Loading…
Cancel
Save