scinote-web/app/helpers/left_menu_bar_helper.rb

99 lines
2.5 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2018-03-14 21:33:34 +08:00
module LeftMenuBarHelper
def left_menu_elements
[
{
url: dashboard_path,
name: t('left_menu_bar.dashboard'),
2023-06-08 23:33:50 +08:00
icon: 'sn-icon-dashboard',
active: dashboard_are_selected?,
submenu: []
}, {
url: projects_path,
name: t('left_menu_bar.projects'),
2023-06-08 23:33:50 +08:00
icon: 'sn-icon-projects',
active: projects_are_selected?,
submenu: []
}, {
url: repositories_path,
name: t('left_menu_bar.repositories'),
2023-06-08 23:33:50 +08:00
icon: 'sn-icon-inventory',
active: repositories_are_selected? || storage_locations_are_selected?,
submenu: [{
url: repositories_path,
name: t('left_menu_bar.items'),
active: repositories_are_selected?
}, {
url: storage_locations_path,
name: t('left_menu_bar.locations'),
active: storage_locations_are_selected?
}]
}, {
url: "#",
name: t('left_menu_bar.templates'),
2023-06-08 23:33:50 +08:00
icon: 'sn-icon-protocols-templates',
active: protocols_are_selected? || label_templates_are_selected?,
submenu: [{
url: protocols_path,
name: t('left_menu_bar.protocol'),
active: protocols_are_selected?
}, {
url: label_templates_path,
name: t('left_menu_bar.label'),
active: label_templates_are_selected?
}]
}, {
url: reports_path,
name: t('left_menu_bar.reports'),
2023-06-08 23:33:50 +08:00
icon: 'sn-icon-reports',
active: reports_are_selected?,
submenu: []
}, {
url: global_activities_path,
name: t('left_menu_bar.activities'),
2023-06-08 23:33:50 +08:00
icon: 'sn-icon-activities',
active: activities_are_selected?,
submenu: []
}
]
end
2020-02-13 20:50:29 +08:00
def dashboard_are_selected?
controller_name == 'dashboards'
end
2018-03-14 21:33:34 +08:00
def projects_are_selected?
controller_name.in? %w(projects experiments my_modules)
end
def repositories_are_selected?
controller_name == 'repositories'
end
def storage_locations_are_selected?
controller_name == 'storage_locations'
end
def protocols_are_selected?
controller_name == 'protocols'
end
def label_templates_are_selected?
controller_name == 'label_templates'
2018-03-14 21:33:34 +08:00
end
def reports_are_selected?
2018-03-20 20:53:11 +08:00
# TODO
2018-03-14 21:33:34 +08:00
controller_name == 'reports'
end
def settings_are_selected?
controller_name.in? %(registrations preferences addons teams connected_accounts webhooks)
2018-03-14 21:33:34 +08:00
end
def activities_are_selected?
controller_name == 'global_activities'
2018-03-14 21:33:34 +08:00
end
end