Browse Source
* CLDC-2494: WIP * CLDC-2494: wip * CLDC-2494: page work in progress * cleanup * Add a path for duplicate logs * Display all duplicate logs * Move a test * Display duplicate check answers for logs * Add buttons to delete duplicates * Add a route for sales logs duplicates * Update duplicated page to work for sales logs * lint * Add auth * Rebase updates * Update displayed questions * Add delete duplicates page * Update page content for when there are multiple duplicates * Add auth to the path * Update delete button to use delete controller * Update page for sales logs * Update styling * Update success banner for deleting duplicates * Typo * Render not found if there are no duplicate logs * rebase changes * Rebase changes * Update back and cancel links * Update the duplicate journey after deleting logs * Update change button routing * Refactor tests * Add content for no duplicates * Update params * Refactor tests and paths * Update params to include original_log_id from the beginning * Rename file * lint * Add full stop after deletion messages * Add caption and update duplicate log IDs in the banner * lint * Styling --------- Co-authored-by: Aaron Spencer <aaron.spencer@softwire.com>revert-CLDC-2310
kosiakkatrina
1 year ago
committed by
GitHub
21 changed files with 512 additions and 133 deletions
@ -0,0 +1,25 @@ |
|||||||
|
module DuplicateLogsHelper |
||||||
|
include GovukLinkHelper |
||||||
|
|
||||||
|
def duplicate_logs_continue_button(all_duplicates, duplicate_log, original_log_id) |
||||||
|
if all_duplicates.count > 1 |
||||||
|
return govuk_button_link_to "Keep this log and delete duplicates", url_for( |
||||||
|
controller: "duplicate_logs", |
||||||
|
action: "delete_duplicates", |
||||||
|
"#{duplicate_log.class.name.underscore}_id": duplicate_log.id, |
||||||
|
original_log_id:, |
||||||
|
) |
||||||
|
end |
||||||
|
|
||||||
|
if original_log_id == duplicate_log.id |
||||||
|
govuk_button_link_to "Back to Log #{duplicate_log.id}", send("#{duplicate_log.class.name.underscore}_path", duplicate_log) |
||||||
|
else |
||||||
|
type = duplicate_log.lettings? ? "lettings" : "sales" |
||||||
|
govuk_button_link_to "Back to #{type} logs", url_for(duplicate_log.class) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
def duplicate_logs_action_href(log, page_id, original_log_id) |
||||||
|
send("#{log.model_name.param_key}_#{page_id}_path", log, referrer: "interruption_screen", original_log_id:) |
||||||
|
end |
||||||
|
end |
@ -1,20 +0,0 @@ |
|||||||
<% content_for :title, "Check duplicate logs" %> |
|
||||||
<div class="govuk-grid-row"> |
|
||||||
<div class="govuk-grid-column-two-thirds"> |
|
||||||
<%= govuk_panel( |
|
||||||
classes: "app-panel--interruption", |
|
||||||
) do %> |
|
||||||
<p class="govuk-heading-l">These logs are duplicates</p> |
|
||||||
<p class="govuk-body-l">These logs have the same values for the following fields. Choose one to keep or correct the answers.</p> |
|
||||||
<% end %> |
|
||||||
|
|
||||||
<% @all_duplicates.each_with_index do |log, index| %> |
|
||||||
<%= render partial: "duplicate_log", locals: { log: log } %> |
|
||||||
<%= render partial: "duplicate_log_check_answers", locals: { log: log } %> |
|
||||||
<%= govuk_button_link_to "Keep this log and delete duplicates", "#" %> |
|
||||||
<% if index < @all_duplicates.count - 1 %> |
|
||||||
<hr class="govuk-section-break govuk-section-break--visible govuk-section-break--m"> |
|
||||||
<% end %> |
|
||||||
<% end %> |
|
||||||
</div> |
|
||||||
</div> |
|
@ -0,0 +1,27 @@ |
|||||||
|
<% content_for :title, "Check duplicate logs" %> |
||||||
|
<div class="govuk-grid-row"> |
||||||
|
<div class="govuk-grid-column-two-thirds"> |
||||||
|
<% if @all_duplicates.count > 1 %> |
||||||
|
<%= govuk_panel( |
||||||
|
classes: "app-panel--interruption", |
||||||
|
) do %> |
||||||
|
<p class="govuk-heading-l">These logs are duplicates</p> |
||||||
|
<p class="govuk-body-l">These logs have the same values for the following fields. Choose one to keep or correct the answers.</p> |
||||||
|
<% end %> |
||||||
|
<% else %> |
||||||
|
<h1 class="govuk-heading-l">Make sure these answers are correct</h1> |
||||||
|
<p class="govuk-body"> |
||||||
|
This log had the same answers but it is no longer a duplicate. Make sure the answers are correct. |
||||||
|
</p> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<% @all_duplicates.each_with_index do |log, index| %> |
||||||
|
<%= render partial: "duplicate_log", locals: { log: } %> |
||||||
|
<%= render partial: "duplicate_log_check_answers", locals: { log: } %> |
||||||
|
<%= duplicate_logs_continue_button(@all_duplicates, log, @original_log_id) %> |
||||||
|
<% if index < @all_duplicates.count - 1 %> |
||||||
|
<hr class="govuk-section-break govuk-section-break--visible govuk-section-break--m"> |
||||||
|
<% end %> |
||||||
|
<% end %> |
||||||
|
</div> |
||||||
|
</div> |
@ -0,0 +1,40 @@ |
|||||||
|
<% content_for :before_content do %> |
||||||
|
<% content_for :title, "Are you sure you want to delete #{@duplicate_logs.count == 1 ? 'this duplicate log' : 'these duplicate logs'}?" %> |
||||||
|
<%= govuk_back_link href: @log.lettings? ? lettings_log_duplicate_logs_path(@log) : sales_log_duplicate_logs_path(@log) %> |
||||||
|
<% end %> |
||||||
|
|
||||||
|
<div class="govuk-grid-row"> |
||||||
|
<div class="govuk-grid-column-two-thirds-from-desktop"> |
||||||
|
<span class="govuk-caption-l">Delete duplicate logs</span> |
||||||
|
<h1 class="govuk-heading-l"> |
||||||
|
<%= content_for(:title) %> |
||||||
|
</h1> |
||||||
|
|
||||||
|
<%= govuk_warning_text(text: "You will not be able to undo this action.") %> |
||||||
|
|
||||||
|
<p class="govuk-body govuk-!-margin-bottom-2"> |
||||||
|
<%= @duplicate_logs.count == 1 ? "This log" : "These logs" %> will be deleted: |
||||||
|
</p> |
||||||
|
<ul class="govuk-list govuk-!-margin-bottom-6"> |
||||||
|
<% @duplicate_logs.each do |duplicate_log| %> |
||||||
|
<li> |
||||||
|
<strong> |
||||||
|
<%= govuk_link_to "Log #{duplicate_log.id}", url_for(duplicate_log) %> |
||||||
|
</strong> |
||||||
|
</li> |
||||||
|
<% end %> |
||||||
|
</ul> |
||||||
|
|
||||||
|
<div class="govuk-button-group"> |
||||||
|
<%= govuk_button_to @duplicate_logs.count == 1 ? "Delete this log" : "Delete these logs", |
||||||
|
send("delete_logs_#{@log.class.name.underscore}s_path"), |
||||||
|
method: "delete", |
||||||
|
params: { ids: @duplicate_logs.map(&:id), original_log_id: @original_log_id, remaining_log_id: @log.id } %> |
||||||
|
<%= govuk_button_link_to( |
||||||
|
"Cancel", |
||||||
|
send("#{@log.class.name.underscore}_duplicate_logs_path", @log), |
||||||
|
secondary: true, |
||||||
|
) %> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
Loading…
Reference in new issue