From 8bb452e4f7c022085ec69551d477df20d8025c85 Mon Sep 17 00:00:00 2001 From: zmagod Date: Mon, 12 Dec 2016 10:30:03 +0100 Subject: [PATCH] trim long names [fixes SCI-774] adds secondary navigation and sidebar [fixes SCI-775] --- .../stylesheets/sample_types_groups.scss | 5 ++++ app/controllers/sample_groups_controller.rb | 9 ++++++++ app/controllers/sample_types_controller.rb | 9 ++++++++ app/helpers/application_helper.rb | 16 +++++++++++++ .../sample_groups/_sample_group.html.erb | 2 +- app/views/sample_groups/index.html.erb | 10 ++++++-- app/views/sample_types/_sample_type.html.erb | 2 +- app/views/sample_types/index.html.erb | 10 ++++++-- app/views/shared/_samples.html.erb | 5 +++- .../shared/_secondary_navigation.html.erb | 23 ++++++++++++++----- 10 files changed, 78 insertions(+), 13 deletions(-) diff --git a/app/assets/stylesheets/sample_types_groups.scss b/app/assets/stylesheets/sample_types_groups.scss index 7ec134c07..3131cb6c0 100644 --- a/app/assets/stylesheets/sample_types_groups.scss +++ b/app/assets/stylesheets/sample_types_groups.scss @@ -3,6 +3,11 @@ .sample_types_groups_list { margin-top: 50px; + .sample-type-group-name { + display: inline-block; + width: 80%; + } + li { border-bottom: 1px solid $color-alto; padding: 15px 5px; diff --git a/app/controllers/sample_groups_controller.rb b/app/controllers/sample_groups_controller.rb index 62b558055..3a28ab19c 100644 --- a/app/controllers/sample_groups_controller.rb +++ b/app/controllers/sample_groups_controller.rb @@ -2,6 +2,8 @@ class SampleGroupsController < ApplicationController before_action :load_vars_nested before_action :check_create_permissions before_action :set_sample_group, except: [:create, :index] + before_action :set_project_my_module, only: :index + layout 'fluid' def create @sample_group = SampleGroup.new(sample_group_params) @@ -112,6 +114,13 @@ class SampleGroupsController < ApplicationController private + def set_project_my_module + @project = Project.find_by_id(params[:project_id]) if params[:project_id] + @my_module = MyModule + .find_by_id(params[:my_module_id]) if params[:my_module_id] + render_403 unless @project || @my_module + end + def set_sample_group @sample_group = SampleGroup.find_by_id(params[:id]) end diff --git a/app/controllers/sample_types_controller.rb b/app/controllers/sample_types_controller.rb index f726ebf6c..e4b8a5035 100644 --- a/app/controllers/sample_types_controller.rb +++ b/app/controllers/sample_types_controller.rb @@ -2,6 +2,8 @@ class SampleTypesController < ApplicationController before_action :load_vars_nested before_action :check_create_permissions before_action :set_sample_type, except: [:create, :index] + before_action :set_project_my_module, only: :index + layout 'fluid' def create @sample_type = SampleType.new(sample_type_params) @@ -112,6 +114,13 @@ class SampleTypesController < ApplicationController private + def set_project_my_module + @project = Project.find_by_id(params[:project_id]) if params[:project_id] + @my_module = MyModule + .find_by_id(params[:my_module_id]) if params[:my_module_id] + render_403 unless @project || @my_module + end + def load_vars_nested @organization = Organization.find_by_id(params[:organization_id]) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c8fa861cd..ea83d099f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -11,4 +11,20 @@ module ApplicationHelper controller_name == 'projects' || (controller_name == 'reports' && action_name == 'index') end + + def sample_types_page_project? + controller_name == 'sample_types' && !(defined? @my_module) + end + + def sample_groups_page_project? + controller_name == 'sample_groups' && !(defined? @my_module) + end + + def sample_types_page_my_module? + controller_name == 'sample_types' && defined? @my_module + end + + def sample_groups_page_my_module? + controller_name == 'sample_groups' && defined? @my_module + end end diff --git a/app/views/sample_groups/_sample_group.html.erb b/app/views/sample_groups/_sample_group.html.erb index 3bad4a827..48318da16 100644 --- a/app/views/sample_groups/_sample_group.html.erb +++ b/app/views/sample_groups/_sample_group.html.erb @@ -5,7 +5,7 @@ organization_sample_group_destroy_confirmation_path(organization, sample_group) %>" data-color="<%= sample_group.color %>"> - <%= sample_group.name %> + <%= sample_group.name %> <%= bootstrap_form_for [organization, sample_group], remote: true do |f| %> diff --git a/app/views/sample_groups/index.html.erb b/app/views/sample_groups/index.html.erb index 5c388d800..0362ab91b 100644 --- a/app/views/sample_groups/index.html.erb +++ b/app/views/sample_groups/index.html.erb @@ -1,14 +1,20 @@ <% provide(:head_title, t('sample_groups.index.head_title')) %> +<%= render partial: "shared/sidebar" %> +<%= render partial: "shared/secondary_navigation" %> <% if current_organization %>
diff --git a/app/views/sample_types/_sample_type.html.erb b/app/views/sample_types/_sample_type.html.erb index 580020d74..ee967bd3f 100644 --- a/app/views/sample_types/_sample_type.html.erb +++ b/app/views/sample_types/_sample_type.html.erb @@ -6,7 +6,7 @@ data-delete="<%= organization_sample_type_destroy_confirmation_path(organization, sample_type) %>"> - <%= sample_type.name %> + <%= sample_type.name %> diff --git a/app/views/sample_types/index.html.erb b/app/views/sample_types/index.html.erb index 12af18ff1..4f0da5c58 100644 --- a/app/views/sample_types/index.html.erb +++ b/app/views/sample_types/index.html.erb @@ -1,14 +1,20 @@ <% provide(:head_title, t('sample_types.index.head_title')) %> +<%= render partial: "shared/sidebar" %> +<%= render partial: "shared/secondary_navigation" %> <% if current_organization %>
diff --git a/app/views/shared/_samples.html.erb b/app/views/shared/_samples.html.erb index 5eca59032..8f61b3956 100644 --- a/app/views/shared/_samples.html.erb +++ b/app/views/shared/_samples.html.erb @@ -66,7 +66,10 @@ <% if can_add_sample_related_things_to_organization %> <% end %> diff --git a/app/views/shared/_secondary_navigation.html.erb b/app/views/shared/_secondary_navigation.html.erb index 289256ac2..b684178a5 100644 --- a/app/views/shared/_secondary_navigation.html.erb +++ b/app/views/shared/_secondary_navigation.html.erb @@ -22,7 +22,9 @@ <% end %> - <% if project_page? %> + <% if project_page? || + sample_types_page_project? || + sample_groups_page_project? %>
  • @@ -37,7 +39,8 @@ <% end %> <% end %> - <% if experiment_page? || module_page? %> + <% if experiment_page? || + module_page? %> <% if !module_page? %>
  • <%= fa_icon 'fa-flask' %> @@ -67,7 +70,9 @@