Browse Source

enough changes to go to the new log page

CLDC-1324-remove-not-started-status-no-rebase
JG 2 years ago
parent
commit
3b6df70fc9
  1. 9
      app/controllers/lettings_logs_controller.rb
  2. 3
      app/controllers/logs_controller.rb
  3. 8
      app/helpers/tasklist_helper.rb
  4. 2
      app/views/logs/edit.html.erb
  5. 2
      app/views/logs/index.html.erb
  6. 2
      config/routes.rb

9
app/controllers/lettings_logs_controller.rb

@ -49,7 +49,11 @@ class LettingsLogsController < LogsController
end
def edit
@log = current_user.lettings_logs.find_by(id: params[:id])
@log = if new_log_request?
LettingsLog.new
else
current_user.lettings_logs.find_by(id: params[:id])
end
if @log
render "logs/edit", locals: { current_user: }
else
@ -84,6 +88,9 @@ class LettingsLogsController < LogsController
def csv_confirmation; end
private
def new_log_request?
request.path.include?("new")
end
def permitted_log_params
params.require(:lettings_log).permit(LettingsLog.editable_fields)

3
app/controllers/logs_controller.rb

@ -15,8 +15,7 @@ private
respond_to do |format|
format.html do
log.save!
redirect_to post_create_redirect_url(log)
redirect_to new_log_lettings_logs_path
end
format.json do
if log.save

8
app/helpers/tasklist_helper.rb

@ -16,8 +16,12 @@ module TasklistHelper
"#{log.class.name.underscore}_#{subsection.id}_check_answers_path"
else
"#{log.class.name.underscore}_#{next_question_page(subsection, log, current_user)}_path"
end
send(path, log)
end
if log.id
send(path, log)
else
"/logs/new/#{next_question_page(subsection, log, current_user)}"
end
end
def next_question_page(subsection, log, current_user)

2
app/views/logs/edit.html.erb

@ -1,4 +1,4 @@
<% content_for :title, "Log #{@log.id}" %>
<% content_for :title, "Log #{@log.id ? @log.id : "new"}" %>
<% content_for :breadcrumbs, govuk_breadcrumbs(breadcrumbs: {
"Logs" => @log.lettings? ? lettings_logs_path : sales_logs_path,
content_for(:title) => "",

2
app/views/logs/index.html.erb

@ -8,7 +8,7 @@
<div class="app-filter-layout" data-controller="filter-layout">
<div class="govuk-button-group app-filter-toggle">
<% if current_page?(:controller => 'lettings_logs', :action => 'index') %>
<%= govuk_button_to "Create a new lettings log", lettings_logs_path %>
<%= govuk_button_to "Create a new lettings log", create_new_log_lettings_logs_path, method: :get %>
<% end %>
<% if FeatureToggle.sales_log_enabled? && current_page?(:controller => 'sales_logs', :action => 'index') %>
<%= govuk_button_to "Create a new sales log", sales_logs_path %>

2
config/routes.rb

@ -80,6 +80,8 @@ Rails.application.routes.draw do
resources :lettings_logs, path: "/lettings-logs" do
collection do
get "create-new-log", to: "lettings_logs#create"
get "new-log", to: "lettings_logs#show"
post "bulk-upload", to: "bulk_upload#bulk_upload"
get "bulk-upload", to: "bulk_upload#show"
get "csv-download", to: "lettings_logs#download_csv"

Loading…
Cancel
Save