Browse Source

enough changes to go to the new sales log page as well

CLDC-1324-remove-not-started-status-no-rebase
JG 2 years ago
parent
commit
52301c4785
  1. 2
      app/controllers/logs_controller.rb
  2. 12
      app/controllers/sales_logs_controller.rb
  3. 2
      app/views/logs/index.html.erb
  4. 5
      config/routes.rb

2
app/controllers/logs_controller.rb

@ -15,7 +15,7 @@ private
respond_to do |format|
format.html do
redirect_to new_log_lettings_logs_path
redirect_to ( request.path.include?("sales") ? new_log_sales_logs_path : new_log_lettings_logs_path)
end
format.json do
if log.save

12
app/controllers/sales_logs_controller.rb

@ -28,7 +28,11 @@ class SalesLogsController < LogsController
end
def edit
@log = current_user.sales_logs.find_by(id: params[:id])
@log = if new_log_request?
SalesLog.new
else
current_user.sales_logs.find_by(id: params[:id])
end
if @log
render "logs/edit", locals: { current_user: }
else
@ -43,4 +47,10 @@ class SalesLogsController < LogsController
def permitted_log_params
params.require(:sales_log).permit(SalesLog.editable_fields)
end
private
def new_log_request?
request.path.include?("new")
end
end

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

@ -11,7 +11,7 @@
<%= 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 %>
<%= govuk_button_to "Create a new sales log", create_new_log_sales_logs_path, method: :get %>
<% end %>
<%#= govuk_link_to "Upload logs", bulk_upload_lettings_logs_path %>
</div>

5
config/routes.rb

@ -106,6 +106,11 @@ Rails.application.routes.draw do
end
resources :sales_logs, path: "/sales-logs" do
collection do
get "create-new-log", to: "sales_logs#create"
get "new-log", to: "sales_logs#show"
end
FormHandler.instance.sales_forms.each do |_key, form|
form.pages.map do |page|
get page.id.to_s.dasherize, to: "form#show_page"

Loading…
Cancel
Save