From ca4c91be40ad7708ae67eab2f2e966d1890d2cb6 Mon Sep 17 00:00:00 2001 From: Magdalena Kafka Date: Fri, 13 Nov 2015 11:54:51 +0100 Subject: [PATCH 1/3] Use single select for roles on member screen --- app/assets/stylesheets/content/_select2.scss | 4 ++++ .../_member_form_non_impaired.html.erb | 22 +++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/assets/stylesheets/content/_select2.scss b/app/assets/stylesheets/content/_select2.scss index ac2e1a01c4..13e78cebc7 100644 --- a/app/assets/stylesheets/content/_select2.scss +++ b/app/assets/stylesheets/content/_select2.scss @@ -335,3 +335,7 @@ $se2-arrow-button-width: 32px; } } } + +.select2-search-choice-close { + top: 3px; +} diff --git a/app/views/members/_member_form_non_impaired.html.erb b/app/views/members/_member_form_non_impaired.html.erb index 52cb8af8e6..57f5337ef2 100644 --- a/app/views/members/_member_form_non_impaired.html.erb +++ b/app/views/members/_member_form_non_impaired.html.erb @@ -38,7 +38,7 @@ See doc/COPYRIGHT.rdoc for more details.
-
+
<% user_id_title = I18n.t(:label_principal_search) @@ -60,16 +60,20 @@ See doc/COPYRIGHT.rdoc for more details.
-
+
<%= styled_label_tag :member_role_ids, l(:label_role_search) %> - <% options = roles.collect { |obj| [obj.name, obj.id] } %> - <%= select_tag 'member[role_ids]', options_for_select(options), - multiple: true, - no_label: true, - title: l(:label_role_search), - tabIndex: 0, - class: 'form--select' %> +
+
+ <% options = roles.collect { |obj| [obj.name, obj.id] } %> + <%= select_tag 'member[role_ids]', options_for_select(options), + multiple: false, + no_label: true, + title: l(:label_role_search), + tabIndex: 0, + class: 'form--select' %> +
+
From a720b430daabba317f19709be56f089b61d598bb Mon Sep 17 00:00:00 2001 From: Stefan Botzenhart Date: Mon, 16 Nov 2015 15:55:07 +0100 Subject: [PATCH 2/3] Pass single role id as array This is to not break existing implementation. Otherwise a lot stuff during the process of adding a member to a project (including invitations) need to be changed. Normally one would just pass a single id. --- .../members/_member_form_non_impaired.html.erb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/views/members/_member_form_non_impaired.html.erb b/app/views/members/_member_form_non_impaired.html.erb index 57f5337ef2..2d75ee6c86 100644 --- a/app/views/members/_member_form_non_impaired.html.erb +++ b/app/views/members/_member_form_non_impaired.html.erb @@ -66,12 +66,13 @@ See doc/COPYRIGHT.rdoc for more details.
<% options = roles.collect { |obj| [obj.name, obj.id] } %> - <%= select_tag 'member[role_ids]', options_for_select(options), - multiple: false, - no_label: true, - title: l(:label_role_search), - tabIndex: 0, - class: 'form--select' %> + <%= select_tag 'member[role_ids][]', options_for_select(options), + multiple: false, + no_label: true, + title: l(:label_role_search), + tabIndex: 0, + class: 'form--select', + id: 'member_role_ids' %>
From b7572f141696e6d16b8f727c4c574ea984f0ea61 Mon Sep 17 00:00:00 2001 From: Stefan Botzenhart Date: Mon, 16 Nov 2015 15:56:29 +0100 Subject: [PATCH 3/3] Remove spec for missing role as we always have one Changing the behaviour to a single select without blank option removes the option of not submitting a role. --- spec/features/members/error_messages_spec.rb | 29 ++++++++------------ 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/spec/features/members/error_messages_spec.rb b/spec/features/members/error_messages_spec.rb index 5218afbaab..db4d8bafe2 100644 --- a/spec/features/members/error_messages_spec.rb +++ b/spec/features/members/error_messages_spec.rb @@ -28,7 +28,7 @@ require 'spec_helper' -feature 'group memberships through groups page', type: :feature do +feature 'Group memberships through groups page', type: :feature do let!(:project) { FactoryGirl.create :project, name: 'Project 1', identifier: 'project1' } let(:admin) { FactoryGirl.create :admin } @@ -43,13 +43,6 @@ feature 'group memberships through groups page', type: :feature do end shared_examples 'errors when adding members' do - scenario 'adding a principal without a role, non impaired', js: true do - members_page.visit! - members_page.add_user! 'Peter Pan', as: nil - - expect(page).to have_text 'choose at least one role' - end - scenario 'adding a role without a principal, non impaired', js: true do members_page.visit! members_page.add_user! nil, as: 'Manager' @@ -58,16 +51,18 @@ feature 'group memberships through groups page', type: :feature do end end - context 'with an impaired user' do - before do - admin.impaired = true - admin.save! - end + context 'creating membership' do + context 'with an impaired user' do + before do + admin.impaired = true + admin.save! + end - it_behaves_like 'errors when adding members' - end + it_behaves_like 'errors when adding members' + end - context 'with an un-impaired user' do - it_behaves_like 'errors when adding members' + context 'with an un-impaired user' do + it_behaves_like 'errors when adding members' + end end end