Browse Source
* DIsplay missing stock owners banner * Extract the helpdesk url constant * Add test, fix copy order * Display banner to support * Hide duplicate logs banner if other banners are presentpull/2091/head
kosiakkatrina
1 year ago
committed by
GitHub
18 changed files with 180 additions and 18 deletions
@ -0,0 +1,10 @@
|
||||
<% if display_banner? %> |
||||
<%= govuk_notification_banner(title_text: "Important") do %> |
||||
<p class="govuk-notification-banner__heading govuk-!-width-full" style="max-width: fit-content"> |
||||
<%= header_text %> |
||||
<p> |
||||
<p style="max-width: fit-content"> |
||||
<%= banner_text %> |
||||
</p> |
||||
<% end %> |
||||
<% end %> |
@ -0,0 +1,61 @@
|
||||
class MissingStockOwnersBannerComponent < ViewComponent::Base |
||||
include Rails.application.routes.url_helpers |
||||
|
||||
attr_reader :user, :organisation |
||||
|
||||
def initialize(user:, organisation: nil) |
||||
@user = user |
||||
@organisation = organisation || user.organisation |
||||
|
||||
super |
||||
end |
||||
|
||||
def display_banner? |
||||
return false if DataProtectionConfirmationBannerComponent.new(user:, organisation:).display_banner? |
||||
|
||||
!organisation.holds_own_stock? && organisation.stock_owners.empty? && organisation.absorbed_organisations.empty? |
||||
end |
||||
|
||||
def header_text |
||||
if user.data_coordinator? || user.support? |
||||
"Your organisation does not own stock. You must #{add_stock_owner_link} before you can create logs.".html_safe |
||||
else |
||||
"Your organisation does not own stock. You must add a stock owner before you can create logs.".html_safe |
||||
end |
||||
end |
||||
|
||||
def banner_text |
||||
if user.data_coordinator? || user.support? |
||||
"If your organisation does own stock, #{contact_helpdesk_link} to update your details.".html_safe |
||||
else |
||||
"Ask a data coordinator to add a stock owner. Find your data coordinators on the #{users_link}.</br></br> |
||||
If your organisation does own stock, #{contact_helpdesk_link} to update your details.".html_safe |
||||
end |
||||
end |
||||
|
||||
private |
||||
|
||||
def add_stock_owner_link |
||||
govuk_link_to( |
||||
"add a stock owner", |
||||
stock_owners_add_organisation_path(id: organisation.id), |
||||
class: "govuk-notification-banner__link govuk-!-font-weight-bold", |
||||
) |
||||
end |
||||
|
||||
def contact_helpdesk_link |
||||
govuk_link_to( |
||||
"contact the helpdesk", |
||||
GlobalConstants::HELPDESK_URL, |
||||
class: "govuk-notification-banner__link govuk-!-font-weight-bold", |
||||
) |
||||
end |
||||
|
||||
def users_link |
||||
govuk_link_to( |
||||
"users page", |
||||
users_path, |
||||
class: "govuk-notification-banner__link govuk-!-font-weight-bold", |
||||
) |
||||
end |
||||
end |
@ -0,0 +1,3 @@
|
||||
module GlobalConstants |
||||
HELPDESK_URL = "https://dluhcdigital.atlassian.net/servicedesk/customer/portal/6/group/11".freeze |
||||
end |
Loading…
Reference in new issue