Browse Source

Improvements

CLDC-3740-Replace-you-didnt-answer-with-link
Manny Dinssa 1 week ago
parent
commit
b64d73d942
  1. 6
      app/helpers/locations_helper.rb
  2. 4
      app/helpers/merge_requests_helper.rb
  3. 2
      app/helpers/organisations_helper.rb
  4. 2
      app/helpers/user_helper.rb
  5. 2
      app/views/locations/check_answers.html.erb
  6. 6
      app/views/locations/show.html.erb
  7. 2
      app/views/organisations/show.html.erb
  8. 4
      app/views/users/show.html.erb

6
app/helpers/locations_helper.rb

@ -8,6 +8,10 @@ module LocationsHelper
selection_options(%w[Yes No]) selection_options(%w[Yes No])
end end
def location_editable_attributes
%w[postcode name units type_of_unit mobility_standards]
end
def type_of_units_selection def type_of_units_selection
selection_options(Location.type_of_units) selection_options(Location.type_of_units)
end end
@ -64,7 +68,7 @@ module LocationsHelper
send("scheme_location_#{attribute}_path", location.scheme, location, referrer: "check_answers", route: params[:route]) send("scheme_location_#{attribute}_path", location.scheme, location, referrer: "check_answers", route: params[:route])
end end
def location_action_text_helper(attr, location) def location_action_text(attr, location)
return "" if attr[:value].blank? || (attr[:attribute] == "availability" && location.startdate.blank?) return "" if attr[:value].blank? || (attr[:attribute] == "availability" && location.startdate.blank?)
"Change" "Change"

4
app/helpers/merge_requests_helper.rb

@ -20,7 +20,7 @@ module MergeRequestsHelper
messages[page] || "Enter #{lowercase_first_letter(page.humanize)}" messages[page] || "Enter #{lowercase_first_letter(page.humanize)}"
end end
def merge_request_action_text_helper(attribute, merge_request) def merge_request_action_text(attribute, merge_request)
merge_request.send(attribute).present? || (attribute == "helpdesk_ticket" && merge_request.has_helpdesk_ticket == false) ? "Change" : "" merge_request.send(attribute).present? || (attribute == "helpdesk_ticket" && merge_request.has_helpdesk_ticket == false) ? "Change" : ""
end end
@ -96,7 +96,7 @@ module MergeRequestsHelper
def merge_request_action(merge_request, page, attribute = nil) def merge_request_action(merge_request, page, attribute = nil)
attribute = page if attribute.nil? attribute = page if attribute.nil?
unless merge_request.status == "request_merged" || merge_request.status == "processing" unless merge_request.status == "request_merged" || merge_request.status == "processing"
{ text: merge_request_action_text_helper(attribute, merge_request), href: send("#{page}_merge_request_path", merge_request, referrer: "check_answers"), visually_hidden_text: page.humanize } { text: merge_request_action_text(attribute, merge_request), href: send("#{page}_merge_request_path", merge_request, referrer: "check_answers"), visually_hidden_text: page.humanize }
end end
end end

2
app/helpers/organisations_helper.rb

@ -55,7 +55,7 @@ module OrganisationsHelper
govuk_button_link_to "Delete this organisation", delete_confirmation_organisation_path(organisation), warning: true govuk_button_link_to "Delete this organisation", delete_confirmation_organisation_path(organisation), warning: true
end end
def organisation_action_text_helper(attr, organisation) def organisation_action_text(attr, organisation)
return "" if attr[:value].blank? || (attr[:attribute] == "phone" && organisation.phone.blank?) return "" if attr[:value].blank? || (attr[:attribute] == "phone" && organisation.phone.blank?)
"Change" "Change"

2
app/helpers/user_helper.rb

@ -90,7 +90,7 @@ module UserHelper
end end
end end
def user_action_text_helper(user, attribute) def user_action_text(user, attribute)
return "Change" if %w[role phone].include?(attribute) && user.send(attribute).present? return "Change" if %w[role phone].include?(attribute) && user.send(attribute).present?
"" ""

2
app/views/locations/check_answers.html.erb

@ -30,7 +30,7 @@
<% row.with_value { details_html(attr, @location) if user_can_edit_scheme?(current_user, @scheme) } %> <% row.with_value { details_html(attr, @location) if user_can_edit_scheme?(current_user, @scheme) } %>
<% end %> <% end %>
<% if LocationPolicy.new(current_user, @location).update? %> <% if LocationPolicy.new(current_user, @location).update? %>
<% row.with_action(text: location_action_text_helper(attr, @location), href: location_edit_path(@location, attr[:attribute])) %> <% row.with_action(text: location_action_text(attr, @location), href: location_edit_path(@location, attr[:attribute])) %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>

6
app/views/locations/show.html.erb

@ -34,11 +34,7 @@
<%= row.with_value { details_html(attr, @location) } %> <%= row.with_value { details_html(attr, @location) } %>
<% end %> <% end %>
<% if LocationPolicy.new(current_user, @location).update? %> <% if LocationPolicy.new(current_user, @location).update? %>
<% %w[postcode name units type_of_unit mobility_standards].each do |attribute| %> <%= row.with_action(text: "Change", href: location_action_link(attr, @scheme, @location, current_user)) if location_editable_attributes.include?(attr[:attribute]) %>
<% if attr[:attribute] == attribute %>
<%= row.with_action(text: "Change", href: location_action_link(attr, @scheme, @location, current_user)) %>
<% end %>
<% end %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>

2
app/views/organisations/show.html.erb

@ -24,7 +24,7 @@
<% row.with_key { attr[:name] } %> <% row.with_key { attr[:name] } %>
<% row.with_value { details_html(attr, @organisation) } %> <% row.with_value { details_html(attr, @organisation) } %>
<% row.with_action( <% row.with_action(
text: organisation_action_text_helper(attr, @organisation), text: organisation_action_text(attr, @organisation),
visually_hidden_text: attr[:name].to_s.humanize.downcase, visually_hidden_text: attr[:name].to_s.humanize.downcase,
href: edit_organisation_path(@organisation), href: edit_organisation_path(@organisation),
html_attributes: { "data-qa": "change-#{attr[:name].downcase}" }, html_attributes: { "data-qa": "change-#{attr[:name].downcase}" },

4
app/views/users/show.html.erb

@ -55,7 +55,7 @@
row.with_value { user_details_html(@user, current_user, "phone") } row.with_value { user_details_html(@user, current_user, "phone") }
if UserPolicy.new(current_user, @user).edit_telephone_numbers? if UserPolicy.new(current_user, @user).edit_telephone_numbers?
row.with_action( row.with_action(
text: user_action_text_helper(@user, "phone"), text: user_action_text(@user, "phone"),
visually_hidden_text: "telephone number", visually_hidden_text: "telephone number",
href: aliased_user_edit(@user, current_user), href: aliased_user_edit(@user, current_user),
html_attributes: { "data-qa": "change-telephone-number" }, html_attributes: { "data-qa": "change-telephone-number" },
@ -98,7 +98,7 @@
row.with_value { user_details_html(@user, current_user, "role") } row.with_value { user_details_html(@user, current_user, "role") }
if UserPolicy.new(current_user, @user).edit_roles? if UserPolicy.new(current_user, @user).edit_roles?
row.with_action( row.with_action(
text: user_action_text_helper(@user, "role"), text: user_action_text(@user, "role"),
visually_hidden_text: "role", visually_hidden_text: "role",
href: aliased_user_edit(@user, current_user), href: aliased_user_edit(@user, current_user),
html_attributes: { "data-qa": "change-role" }, html_attributes: { "data-qa": "change-role" },

Loading…
Cancel
Save