Skip to content

Commit

Permalink
Merge pull request #2340 from ministryofjustice/check-your-claim-page…
Browse files Browse the repository at this point in the history
…-changes

Check your claim page changes
  • Loading branch information
lostie authored May 14, 2018
2 parents c61d83f + 2dfcbf5 commit 5f969e0
Show file tree
Hide file tree
Showing 157 changed files with 2,366 additions and 1,175 deletions.
1 change: 1 addition & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Metrics/MethodLength:
- 'app/interfaces/api/helpers/api_helper.rb'
- 'app/models/ability.rb'
- 'app/models/allocation.rb'
- 'app/models/claim/base_claim.rb'
- 'app/models/claim/transfer_brain_data_item.rb'
- 'app/models/claim/transfer_brain_data_item_collection.rb'
- 'app/models/claims/calculations.rb'
Expand Down
22 changes: 22 additions & 0 deletions app/assets/stylesheets/v1/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,25 @@ form{

.highlight { background-color: #ffffca }

a.link-change {
float: right;
font-size: 19px;
line-height: 1.31579;
&:hover {
color: #2b8cc4;
}
@media (max-width: 640px) {
font-size: 16px;
line-height: 1.25;
}
}

a.link-delete {
color: #b10e1e;
position: relative;
padding: .526315em 0em .263157em;
border: none;
&:hover {
color: #df3034;
}
}
8 changes: 4 additions & 4 deletions app/assets/stylesheets/v1/moj/_forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ form {
margin: 20px 0 !important;
}
}
}

.form-buttons * {
margin-right: 10px;
display: inline-block;
}
.form-buttons * {
margin-right: 10px;
display: inline-block;
}

.expense-group {
Expand Down
55 changes: 54 additions & 1 deletion app/assets/stylesheets/v1/moj/_tables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -296,4 +296,57 @@ table{
td {
padding: em(12, 16) em(20, 16) em(9, 16) 0;
}
}
}

table.summary, table.nested-summary {
width: 100%;
margin-bottom: 1em;
background-color: #fff;
border-collapse: collapse;
border-top: none;

caption {
@include core-19;
font-weight: 700;
text-align: left;
padding-bottom: $gutter-half/2;
}

thead th {
padding-top: $gutter-half;
padding-bottom: $gutter-half;
vertical-align: bottom;
}

tbody {
tr:nth-child(odd) {
background: transparent;
}

th {
@include core-19;
font-weight: 700;
color: $text-colour;
background: transparent;

&:first-child {
width: 33%;
padding-left: 0;
}
}

td {
@include core-19;
}
}
}

table.nested-summary {
tbody {
tr:last-child {
th, td {
border-bottom: 0;
}
}
}
}
23 changes: 11 additions & 12 deletions app/controllers/external_users/certifications_controller.rb
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
class ExternalUsers::CertificationsController < ExternalUsers::ApplicationController
before_action :set_claim, only: %i[new create update]
before_action :redirect_already_certified, only: %i[new create]
before_action :redirect_if_not_valid, only: %i[new create]

def new
redirect_to external_users_claim_path(@claim), alert: t('shared.certification.alert') if @claim.submitted?

@claim.force_validation = true
if @claim.valid?
build_certification
track_visit({
url: 'external_user/%{type}/claim/%{action}/certification',
title: '%{action_t} %{type} claim certification'
}, claim_tracking_substitutions)
else
redirect_to edit_polymorphic_path(@claim), alert: 'Claim is not in a state to be submitted'
end
build_certification
track_visit({
url: 'external_user/%{type}/claim/%{action}/certification',
title: '%{action_t} %{type} claim certification'
}, claim_tracking_substitutions)
end

def create
Expand All @@ -38,6 +32,11 @@ def redirect_already_certified
redirect_to external_users_claim_path(@claim), alert: t('shared.certification.alert') if @claim.submitted?
end

def redirect_if_not_valid
return if @claim.invalid_steps.empty?
redirect_to summary_external_users_claim_path(@claim), alert: t('shared.certification.invalid_claim')
end

def notify_legacy_importers
NotificationQueue::AwsClient.new.send!(@claim)
Rails.logger.info "Successfully sent #{log_suffix}"
Expand Down
29 changes: 24 additions & 5 deletions app/controllers/external_users/claims_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class ResourceClassNotDefined < StandardError; end

before_action :set_and_authorize_claim, only: %i[show edit update unarchive clone_rejected destroy summary
confirmation show_message_controls messages disc_evidence]
before_action :redirect_unless_editable, only: %i[edit update]
before_action :set_form_step, only: %i[edit]
before_action :redirect_unless_editable, only: %i[edit update]
before_action :generate_form_id, only: %i[new edit]
before_action :initialize_submodel_counts

Expand Down Expand Up @@ -426,7 +426,7 @@ def submitting_to_laa?
end

def continue_claim?
params.key?(:commit_continue) || params.key?(:commit_stage_1)
params.key?(:commit_continue)
end

def render_action_with_resources(action)
Expand All @@ -448,7 +448,7 @@ def redirect_to_next_step
title: '%{action_t} %{type} claim page %{step}'
}, claim_tracking_substitutions)

redirect_to edit_polymorphic_path(@claim, step: @claim.next_step!)
redirect_to edit_polymorphic_path(@claim, step: @claim.next_step)
end

def render_or_redirect(result)
Expand Down Expand Up @@ -506,7 +506,26 @@ def claim_tracking_substitutions
end

def redirect_unless_editable
return if @claim.editable?
redirect_to external_users_claims_url, notice: 'Can only edit "draft" claims'
return if @claim.current_step_editable?
error_code = !@claim.editable? ? :not_editable : :dependencies_missing
options = redirect_options_for(error_code)
redirect_to options[:url], alert: options[:message]
end

def redirect_options_for(error_code)
{
not_editable: {
url: external_users_claims_url,
message: t('errors.not_editable', scope: default_scope)
},
dependencies_missing: {
url: summary_external_users_claim_path(@claim),
message: t('errors.dependencies_missing', scope: default_scope)
}
}[error_code&.to_sym]
end

def default_scope
%i[external_users claims]
end
end
11 changes: 11 additions & 0 deletions app/helpers/external_users/claims_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,15 @@ def supplier_number_hint
'Admin users can add more LGFS supplier numbers on the Manage provider page'
end
end

def external_users_claim_path_for_state(claim)
claim.draft? ? summary_external_users_claim_path(claim) : external_users_claim_path(claim)
end

def url_for_referrer(referrer, claim)
return unless claim
{
'summary' => summary_external_users_claim_path(claim)
}[referrer.to_s]
end
end
28 changes: 17 additions & 11 deletions app/models/claim/advocate_claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,32 @@ class AdvocateClaim < BaseClaim
condition: ->(claim) { !claim.fixed_fee_case? }
},
{
to_stage: :basic_and_fixed_fees,
to_stage: :fixed_fees,
condition: ->(claim) { claim.fixed_fee_case? }
}
]
],
dependencies: %i[case_details]
},
{
name: :offence_details,
transitions: [
{ to_stage: :basic_and_fixed_fees }
]
{ to_stage: :basic_fees }
],
dependencies: %i[case_details defendants]
},
{
name: :basic_and_fixed_fees,
name: :basic_fees,
transitions: [
{ to_stage: :miscellaneous_fees }
]
],
dependencies: %i[case_details defendants offence_details]
},
{
name: :fixed_fees,
transitions: [
{ to_stage: :miscellaneous_fees }
],
dependencies: %i[case_details defendants]
},
{
name: :miscellaneous_fees,
Expand All @@ -138,7 +148,7 @@ def assign_total_attrs
# left it here mostly to ensure the new changes do
# not impact anything API related
return if from_api?
assign_fees_total(%i[basic fixed misc]) if fees_changed?
assign_fees_total(%i[basic_fees fixed_fees misc_fees]) if fees_changed?
assign_expenses_total if expenses_changed?
return unless total_changes_required?
assign_total
Expand All @@ -161,10 +171,6 @@ def fixed_fees_changed?
fixed_fees.any?(&:changed?)
end

def expenses_changed?
expenses.any?(&:changed?)
end

def eligible_case_types
CaseType.agfs
end
Expand Down
18 changes: 7 additions & 11 deletions app/models/claim/advocate_interim_claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,23 @@ class AdvocateInterimClaim < BaseClaim
{
name: :defendants,
transitions: [
{
to_stage: :offence_details,
condition: ->(claim) { !claim.fixed_fee_case? }
},
{
to_stage: :basic_and_fixed_fees,
condition: ->(claim) { claim.fixed_fee_case? }
}
]
{ to_stage: :offence_details }
],
dependencies: %i[case_details]
},
{
name: :offence_details,
transitions: [
{ to_stage: :interim_fees }
]
],
dependencies: %i[case_details defendants]
},
{
name: :interim_fees,
transitions: [
{ to_stage: :travel_expenses }
]
],
dependencies: %i[case_details defendants offence_details]
},
{
name: :travel_expenses,
Expand Down
42 changes: 40 additions & 2 deletions app/models/claim/base_claim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,38 @@ def step_back?
previous_step.present?
end

def next_step?
next_step.present?
end

def invalid_steps
@invalid_steps ||= Claims::ValidateAllSteps.call(self)
end

def accessible_step?(step)
full_submission_flow.include?(step)
end

def editable_step?(step)
Claims::CheckStepEditability.call(self, step).valid?
end

def current_step_editable?
editable_step?(current_step)
end

def missing_dependencies_for(step)
Claims::CheckStepEditability.call(self, step).invalid_dependencies
end

def misc_fees_changed?
misc_fees.any?(&:changed?)
end

def expenses_changed?
expenses.any?(&:changed?)
end

# Override the corresponding method in the subclass
def agfs?
false
Expand Down Expand Up @@ -436,14 +464,23 @@ def submission_current_flow
submission_stages.path_until(form_step)
end

def full_submission_flow
submission_stages.path_until(submission_stages.last&.to_sym)
end

def previous_step
return unless form_step
submission_stages.previous_stage(form_step)
submission_stages.previous_stage(form_step)&.to_sym
end

def next_step
return unless form_step
submission_stages.next_stage(form_step)&.to_sym
end

def next_step!
return unless form_step
self.form_step = submission_stages.next_stage(form_step)
self.form_step = next_step
end

def from_api?
Expand Down Expand Up @@ -552,6 +589,7 @@ def self.fee_associations
end

def disk_evidence_reference
return unless case_number && id
"#{case_number}/#{id}"
end

Expand Down
Loading

0 comments on commit 5f969e0

Please sign in to comment.