Skip to content

Commit

Permalink
Merge branch 'develop' into feature/2269-update-login-page
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyevil authored Oct 19, 2023
2 parents 03c1fff + ac3a0b7 commit 0876a09
Show file tree
Hide file tree
Showing 14 changed files with 377 additions and 306 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ def ingredients_from_csv

def csv_header_template
if component.range?
headers = ["Ingredient name", "Minimum % w/w", "Maximum % w/w", "Exact % w/w", "CAS number", "Does NPIS need to know about it?"]
headers = ["Ingredient name", "Minimum % w/w", "Maximum % w/w", "Exact % w/w", "CAS number", "Does the NPIS need to be notified about this ingredient?"]
else
headers = ["Ingredient name", "% w/w", "CAS number", "Does NPIS need to know about it?"]
headers = ["Ingredient name", "% w/w", "CAS number", "Does the NPIS need to be notified about this ingredient?"]
headers << "Is it used for different shades?" if multiple_shades?
end

Expand Down
213 changes: 61 additions & 152 deletions cosmetics-web/app/helpers/responsible_persons/notifications_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,110 +26,77 @@ def notification_summary_references_rows(notification)
].compact
end

def notification_step_action(notification, step)
return {} unless notification.editable?

{
items: [
{
href: responsible_person_notification_product_path(notification.responsible_person, notification, step),
text: "Edit",
visuallyHiddenText: step&.to_s&.humanize&.downcase,
classes: ["govuk-link--no-visited-state"],
},
],
}
end

def notification_product_kit_step_action(notification)
return {} unless notification.editable?

{
items: [
{
href: new_responsible_person_notification_product_kit_path(notification.responsible_person, notification),
text: "Edit",
visuallyHiddenText: "mixed items",
classes: ["govuk-link--no-visited-state"],
},
],
}
end

def notification_summary_product_rows(notification)
[
{
key: { text: "Product name" },
value: { text: notification.product_name },
actions: {
items: [
{
href: responsible_person_notification_product_path(notification.responsible_person, notification, :add_product_name),
text: "Edit",
visuallyHiddenText: "product name",
classes: ["govuk-link--no-visited-state"],
},
],
},
actions: notification_step_action(notification, :add_product_name),
},
if notification.industry_reference.present?
{
key: { text: "Internal reference number" },
value: { text: notification.industry_reference },
actions: {
items: [
{
href: responsible_person_notification_product_path(notification.responsible_person, notification, :add_internal_reference),
text: "Edit",
visuallyHiddenText: "internal reference",
classes: ["govuk-link--no-visited-state"],
},
],
},
actions: notification_step_action(notification, :add_internal_reference),
}
end,
unless notification.under_three_years.nil?
{
key: { text: "For children under 3" },
value: { text: notification.under_three_years ? "Yes" : "No" },
actions: {
items: [
{
href: responsible_person_notification_product_path(notification.responsible_person, notification, :under_three_years),
text: "Edit",
visuallyHiddenText: "under three years",
classes: ["govuk-link--no-visited-state"],
},
],
},
actions: notification_step_action(notification, :under_three_years),
}
end,
{
key: { text: "Number of items" },
value: { text: notification.components.length },
actions: {
items: [
{
href: responsible_person_notification_product_path(notification.responsible_person, notification, :single_or_multi_component),
text: "Edit",
visuallyHiddenText: "number of items",
classes: ["govuk-link--no-visited-state"],
},
],
},
actions: notification_step_action(notification, :single_or_multi_component),
},
{
key: { text: "Shades" },
value: { html: display_shades(notification) },
actions: {
items: [
{
href: responsible_person_notification_product_path(notification.responsible_person, notification, :shades),
text: "Edit",
visuallyHiddenText: "shades",
classes: ["govuk-link--no-visited-state"],
},
],
},
actions: notification_step_action(notification, :shades),
},
{
key: { text: "Label" },
value: { html: render("notifications/product_details_label_images",
notification:) },
actions: {
items: [
{
href: responsible_person_notification_product_path(notification.responsible_person, notification, :add_product_image),
text: "Edit",
visuallyHiddenText: "product image",
classes: ["govuk-link--no-visited-state"],
},
],
},
actions: notification_step_action(notification, :add_product_image),
},
{
key: { text: "Are the items mixed?" },
value: { text: notification.components_are_mixed ? "Yes" : "No" },
actions: {
items: [
{
href: new_responsible_person_notification_product_kit_path(notification.responsible_person, notification),
text: "Edit",
visuallyHiddenText: "mixed items",
classes: ["govuk-link--no-visited-state"],
},
],
},
actions: notification_product_kit_step_action(notification),
},
if can_view_product_ingredients? && notification.ph_min_value.present?
{
Expand Down Expand Up @@ -190,6 +157,21 @@ def notification_summary_search_result_rows(notification)
].compact
end

def notification_summary_component_action(component, step)
return {} unless component.notification.editable?

{
items: [
{
href: responsible_person_notification_component_build_path(component.notification.responsible_person, component.notification, component, step),
text: "Edit",
visuallyHiddenText: "#{component.name} category",
classes: ["govuk-link--no-visited-state"],
},
],
}
end

def notification_summary_component_rows(component, include_shades: true)
cmrs = component.cmrs
nano_materials = component.nano_materials
Expand All @@ -202,16 +184,7 @@ def notification_summary_component_rows(component, include_shades: true)
entities_list: component.shades,
list_classes: "",
list_item_classes: "") },
actions: {
items: [
{
href: responsible_person_notification_component_build_path(component.notification.responsible_person, component.notification, component, :number_of_shades),
text: "Edit",
visuallyHiddenText: "#{component.name} category",
classes: ["govuk-link--no-visited-state"],
},
],
},
actions: notification_summary_component_action(component, :number_of_shades),
}
end,
{
Expand All @@ -233,16 +206,7 @@ def notification_summary_component_rows(component, include_shades: true)
entities_list: nano_materials_details(nano_materials),
list_classes: "",
list_item_classes: "") },
actions: {
items: [
{
href: responsible_person_notification_component_build_path(component.notification.responsible_person, component.notification, component, :select_nanomaterials),
text: "Edit",
visuallyHiddenText: "select nanomaterials",
classes: ["govuk-link--no-visited-state"],
},
],
},
actions: notification_summary_component_action(component, :select_nanomaterials),
},
if nano_materials.non_standard.any?
{
Expand All @@ -257,47 +221,20 @@ def notification_summary_component_rows(component, include_shades: true)
{
key: { text: "Application instruction" },
value: { text: get_exposure_routes_names(component.exposure_routes) },
actions: {
items: [
{
href: responsible_person_notification_component_build_path(component.notification.responsible_person, component.notification, component, :add_exposure_routes),
text: "Edit",
visuallyHiddenText: "exposure root",
classes: ["govuk-link--no-visited-state"],
},
],
},
actions: notification_summary_component_action(component, :add_exposure_routes),
}
end,
if nano_materials.present?
{
key: { text: "Exposure condition" },
value: { text: get_exposure_condition_name(component.exposure_condition) },
actions: {
items: [
{
href: responsible_person_notification_component_build_path(component.notification.responsible_person, component.notification, component, :add_exposure_condition),
text: "Edit",
visuallyHiddenText: "exposure condition",
classes: ["govuk-link--no-visited-state"],
},
],
},
actions: notification_summary_component_action(component, :add_exposure_condition),
}
end,
{
key: { text: "Category of product" },
value: { text: get_category_name(component.root_category) },
actions: {
items: [
{
href: responsible_person_notification_component_build_path(component.notification.responsible_person, component.notification, component, :select_root_category),
text: "Edit",
visuallyHiddenText: "#{component.name} category",
classes: ["govuk-link--no-visited-state"],
},
],
},
actions: notification_summary_component_action(component, :select_root_category),
},
{
key: { text: "Category of #{get_category_name(component.root_category)&.downcase&.singularize}" },
Expand All @@ -310,48 +247,20 @@ def notification_summary_component_rows(component, include_shades: true)
{
key: { text: "Physical form" },
value: { text: get_physical_form_name(component.physical_form) },
actions: {
items: [
{
href: responsible_person_notification_component_build_path(component.notification.responsible_person, component.notification, component, :add_physical_form),
text: "Edit",
visuallyHiddenText: "physical form",
classes: ["govuk-link--no-visited-state"],
},
],
},

actions: notification_summary_component_action(component, :add_physical_form),
},
if can_view_product_ingredients?
{
key: { text: "Special applicator" },
value: { text: component.special_applicator.present? ? "Yes" : "No" },
actions: {
items: [
{
href: responsible_person_notification_component_build_path(component.notification.responsible_person, component.notification, component, :contains_special_applicator),
text: "Edit",
visuallyHiddenText: "contains special applicator",
classes: ["govuk-link--no-visited-state"],
},
],
},
actions: notification_summary_component_action(component, :contains_special_applicator),
}
end,
if can_view_product_ingredients? && component.special_applicator.present?
{
key: { text: "Applicator type" },
value: { text: component_special_applicator_name(component) },
actions: {
items: [
{
href: responsible_person_notification_component_build_path(component.notification.responsible_person, component.notification, component, :select_special_applicator_type),
text: "Edit",
visuallyHiddenText: "select special applicator type",
classes: ["govuk-link--no-visited-state"],
},
],
},
actions: notification_summary_component_action(component, :select_special_applicator_type),
}
end,
if can_view_product_ingredients? && component.acute_poisoning_info.present?
Expand Down Expand Up @@ -535,7 +444,7 @@ def ph_row_text_value(component)
end

def ph_row_actions(component)
return {} unless component.ph_required?
return {} if !component.ph_required? || !component.notification.editable?

{
items: [
Expand Down
Loading

0 comments on commit 0876a09

Please sign in to comment.