From 6131b6c0b76f8590a6872daa0c5d92be6378d477 Mon Sep 17 00:00:00 2001 From: Anton Date: Tue, 26 Jul 2022 13:52:40 +0200 Subject: [PATCH] Add new templates section and navigation [SCI-7017] --- app/controllers/label_templates_controller.rb | 15 +++++++++++++++ app/controllers/protocols_controller.rb | 2 ++ app/helpers/left_menu_bar_helper.rb | 3 ++- app/permissions/team.rb | 4 ++++ app/views/label_templates/index.html.erb | 8 ++++++++ app/views/protocols/index.html.erb | 6 +++++- app/views/protocols/show.html.erb | 4 ++++ .../shared/sidebar/_templates_sidebar.html.erb | 12 ++++++++++++ config/locales/en.yml | 6 +++++- config/routes.rb | 2 ++ 10 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 app/controllers/label_templates_controller.rb create mode 100644 app/views/label_templates/index.html.erb create mode 100644 app/views/shared/sidebar/_templates_sidebar.html.erb diff --git a/app/controllers/label_templates_controller.rb b/app/controllers/label_templates_controller.rb new file mode 100644 index 000000000..1439528bf --- /dev/null +++ b/app/controllers/label_templates_controller.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class LabelTemplatesController < ApplicationController + before_action :check_view_permissions + + layout 'fluid' + + def index; end + + private + + def check_view_permissions + render_403 unless can_view_label_templates?(current_team) + end +end diff --git a/app/controllers/protocols_controller.rb b/app/controllers/protocols_controller.rb index 20349cc65..c02c10e2a 100644 --- a/app/controllers/protocols_controller.rb +++ b/app/controllers/protocols_controller.rb @@ -76,6 +76,8 @@ class ProtocolsController < ApplicationController before_action :set_importer, only: %i(load_from_file import) + layout 'fluid' + def index; end def datatable diff --git a/app/helpers/left_menu_bar_helper.rb b/app/helpers/left_menu_bar_helper.rb index 32229e95f..e4f074077 100644 --- a/app/helpers/left_menu_bar_helper.rb +++ b/app/helpers/left_menu_bar_helper.rb @@ -14,7 +14,8 @@ module LeftMenuBarHelper def templates_are_selected? # TODO - controller_name == 'protocols' + controller_name == 'protocols' || + controller_name == 'label_templates' end def reports_are_selected? diff --git a/app/permissions/team.rb b/app/permissions/team.rb index a58184cae..88b7117f5 100644 --- a/app/permissions/team.rb +++ b/app/permissions/team.rb @@ -56,6 +56,10 @@ Canaid::Permissions.register_for(Team) do can :manage_reports do |user, team| user.is_normal_user_or_admin_of_team?(team) end + + can :view_label_templates do |user, team| + user.is_normal_user_or_admin_of_team?(team) + end end Canaid::Permissions.register_for(ProjectFolder) do diff --git a/app/views/label_templates/index.html.erb b/app/views/label_templates/index.html.erb new file mode 100644 index 000000000..daab4ba32 --- /dev/null +++ b/app/views/label_templates/index.html.erb @@ -0,0 +1,8 @@ +<% if current_team %> + <% provide(:sidebar_title, t('sidebar.templates.sidebar_title')) %> + <%= content_for :sidebar do %> + <%= render partial: "/shared/sidebar/templates_sidebar", locals: {active: :label} %> + <% end %> +
+
+<% end %> diff --git a/app/views/protocols/index.html.erb b/app/views/protocols/index.html.erb index 7efe8dc2d..5533c0564 100644 --- a/app/views/protocols/index.html.erb +++ b/app/views/protocols/index.html.erb @@ -5,7 +5,11 @@ <% provide(:head_title, t("protocols.index.head_title")) %> <% if current_team %> -
+ <% provide(:sidebar_title, t('sidebar.templates.sidebar_title')) %> + <%= content_for :sidebar do %> + <%= render partial: "/shared/sidebar/templates_sidebar", locals: {active: :protocol} %> + <% end %> +