Highlight selected item in proposition navigation

It is standard practice when using GOV.UK template to highlight the
selected navigation item in the propositional navigation (black bar) by
colouring it blue.

This commit adds a new subclass of `Navigation` with the mapping needed
to decide which pages belong to which item in the navigation (or none
at all).
This commit is contained in:
Chris Hill-Scott
2018-04-25 11:11:37 +01:00
parent e1fd63e184
commit 8a7525a809
4 changed files with 328 additions and 34 deletions

View File

@@ -7,6 +7,7 @@ class Navigation:
mapping = {}
exclude = {}
selected_attribute = "class=selected"
def __init__(self):
self.mapping = {
@@ -30,10 +31,232 @@ class Navigation:
def is_selected(self, navigation_item):
if request.endpoint in self.mapping[navigation_item]:
return "class=selected"
return self.selected_attribute
return ''
class HeaderNavigation(Navigation):
selected_attribute = "class=active"
mapping = {
'support': {
'bat_phone',
'feedback',
'old_feedback',
'old_submit_feedback',
'support',
'thanks',
'triage',
},
'features': {
'features',
'roadmap',
'security',
'terms',
'using_notify',
},
'pricing': {
'pricing',
},
'documentation': {
'documentation',
'integration_testing',
},
'user-profile': {
'user_profile',
'user_profile_email',
'user_profile_email_authenticate',
'user_profile_email_confirm',
'user_profile_mobile_number',
'user_profile_mobile_number_authenticate',
'user_profile_mobile_number_confirm',
'user_profile_name',
'user_profile_password',
},
'platform-admin': {
'add_organisation',
'create_email_branding',
'email_branding',
'live_services',
'organisations',
'platform_admin',
'suspend_service',
'trial_services',
'update_email_branding',
'view_provider',
'view_providers',
},
'sign-in': {
'sign_in',
'two_factor',
'two_factor_email',
'two_factor_email_sent',
'verify',
'verify_email',
'verify_mobile',
},
}
exclude = {
'accept_invite',
'accept_org_invite',
'action_blocked',
'add_service',
'add_service_template',
'add_template_by_type',
'agreement',
'api_callbacks',
'api_documentation',
'api_integration',
'api_keys',
'archive_service',
'callbacks',
'cancel_invited_org_user',
'cancel_invited_user',
'cancel_job',
'check_and_resend_text_code',
'check_and_resend_verification_code',
'check_messages',
'check_messages_preview',
'check_notification',
'choose_account',
'choose_service',
'choose_template',
'confirm_edit_organisation_name',
'confirm_redact_template',
'conversation',
'conversation_reply',
'conversation_reply_with_template',
'conversation_updates',
'cookies',
'create_api_key',
'delete_service_template',
'delivery_and_failure',
'delivery_status_callback',
'design_content',
'download_agreement',
'download_notifications_csv',
'edit_organisation_name',
'edit_provider',
'edit_service_template',
'edit_user_org_permissions',
'edit_user_permissions',
'email_not_received',
'email_template',
'error',
'forgot_password',
'get_example_csv',
'get_notifications_as_json',
'go_to_dashboard_after_tour',
'inbound_sms_admin',
'inbox',
'inbox_download',
'inbox_updates',
'index',
'information_risk_management',
'information_security',
'invite_org_user',
'invite_user',
'letter_jobs',
'link_service_to_organisation',
'manage_org_users',
'manage_users',
'monthly',
'new_password',
'old_integration_testing',
'old_roadmap',
'old_service_dashboard',
'old_terms',
'old_using_notify',
'organisation_dashboard',
'organisation_settings',
'received_text_messages_callback',
'redact_template',
'register',
'register_from_invite',
'register_from_org_invite',
'registration_continue',
'remove_user_from_organisation',
'remove_user_from_service',
'request_to_go_live',
'resend_email_link',
'resend_email_verification',
'resume_service',
'revoke_api_key',
'send_messages',
'send_notification',
'send_one_off',
'send_one_off_step',
'send_test',
'send_test_preview',
'send_test_step',
'service_add_email_reply_to',
'service_add_letter_contact',
'service_add_sms_sender',
'service_dashboard',
'service_dashboard_updates',
'service_edit_email_reply_to',
'service_edit_letter_contact',
'service_edit_sms_sender',
'service_email_reply_to',
'service_letter_contact_details',
'service_name_change',
'service_name_change_confirm',
'service_set_auth_type',
'service_set_email',
'service_set_email_branding',
'service_set_inbound_number',
'service_set_inbound_sms',
'service_set_international_sms',
'service_set_letter_contact_block',
'service_set_letters',
'service_set_reply_to_email',
'service_set_sms',
'service_set_sms_prefix',
'service_settings',
'service_sms_senders',
'service_switch_can_send_email',
'service_switch_can_send_precompiled_letter',
'service_switch_can_send_sms',
'service_switch_email_auth',
'service_switch_live',
'service_switch_research_mode',
'services_or_dashboard',
'set_free_sms_allowance',
'set_letter_branding',
'set_organisation_type',
'set_sender',
'set_template_sender',
'show_accounts_or_dashboard',
'sign_out',
'start_job',
'start_tour',
'styleguide',
'submit_request_to_go_live',
'temp_service_history',
'template_history',
'template_usage',
'trial_mode',
'usage',
'view_job',
'view_job_csv',
'view_job_updates',
'view_jobs',
'view_letter_notification_as_preview',
'view_letter_template_preview',
'view_notification',
'view_notification_updates',
'view_notifications',
'view_notifications_csv',
'view_template',
'view_template_version',
'view_template_version_preview',
'view_template_versions',
'whitelist',
}
class MainNavigation(Navigation):
mapping = {