diff --git a/app/assets/javascripts/app/controllers/_ui_element/user_permission.coffee b/app/assets/javascripts/app/controllers/_ui_element/user_permission.coffee index f6470f98c..877dce2db 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/user_permission.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/user_permission.coffee @@ -46,11 +46,6 @@ class App.UiElement.user_permission if group_id.toString() is group.id.toString() groupsSelected[group.id] = true - # if only one group is selectable, hide all groups - hideGroups = false - if groups.length <= 1 - hideGroups = true - # get roles with group plugin rolesWithGroupPlugin = {} for role in rolesRaw @@ -76,7 +71,6 @@ class App.UiElement.user_permission groups: groups params: params groupsSelected: groupsSelected - hideGroups: hideGroups groupAccesses: App.Group.accesses() ) ) @@ -95,12 +89,12 @@ class App.UiElement.user_permission # if customer, remove admin and agent item.find('[name=role_ids]').bind('change', (e) => - @checkUncheck($(e.currentTarget), rolesWithGroupPlugin, item, hideGroups) + @checkUncheck($(e.currentTarget), rolesWithGroupPlugin, item) ) item.find('[name=role_ids]').trigger('change') item - @checkUncheck: (element, rolesWithGroupPlugin, item, hideGroups) -> + @checkUncheck: (element, rolesWithGroupPlugin, item) -> checked = element.prop('checked') role_id = element.prop('value') return if !role_id @@ -122,33 +116,5 @@ class App.UiElement.user_permission item.localElement.prop('checked', false) triggers.push item.localElement - # if role with groups plugin is deselected, hide group selection - if !checked - selectedRoleIds = [] - item.find('input[name=role_ids]:checked').each( -> - selectedRoleIds.push($(@).val()) - ) - - show = false - for role_id, group of rolesWithGroupPlugin - if _.contains(selectedRoleIds, role_id.toString()) - show = true - break - if !show - item.find('.js-groupList').addClass('hidden') - - # select groups if only one is available - if hideGroups - item.find('.js-groupList .js-groupListItem[value=full]').prop('checked', false) - return - - # if role with groups plugin is selected, show group selection - if rolesWithGroupPlugin[role_id] is 'group' - item.find('.js-groupList:not(.js-groupListHide)').removeClass('hidden') - - # select groups if only one is available - if hideGroups - item.find('.js-groupList .js-groupListItem[value=full]').prop('checked', true) - for trigger in triggers trigger.trigger('change') diff --git a/app/assets/javascripts/app/views/generic/permission.jst.eco b/app/assets/javascripts/app/views/generic/permission.jst.eco index 0a31283fb..cd5954e9e 100644 --- a/app/assets/javascripts/app/views/generic/permission.jst.eco +++ b/app/assets/javascripts/app/views/generic/permission.jst.eco @@ -18,7 +18,7 @@ <%- @T.apply(@, [permission.note].concat(permission.preferences.translations)) %> <% if _.contains(permission.preferences.plugin, 'groups'): %> -
+
<%- @T('Group') %> diff --git a/app/assets/javascripts/app/views/generic/user_permission_group.jst.eco b/app/assets/javascripts/app/views/generic/user_permission_group.jst.eco index 5da89be33..41d6072e5 100644 --- a/app/assets/javascripts/app/views/generic/user_permission_group.jst.eco +++ b/app/assets/javascripts/app/views/generic/user_permission_group.jst.eco @@ -1,4 +1,4 @@ -
+

diff --git a/test/browser/aaa_getting_started_test.rb b/test/browser/aaa_getting_started_test.rb index d2b72391b..760bd0d54 100644 --- a/test/browser/aaa_getting_started_test.rb +++ b/test/browser/aaa_getting_started_test.rb @@ -149,6 +149,7 @@ class AaaGettingStartedTest < TestCase # click( # css: '.js-agent input[name="group_ids"][value="1"]', # ) + check(css: '.js-agent .js-groupListItem[value=full]') click( css: '.js-agent .btn--success', ) diff --git a/test/browser/abb_one_group_test.rb b/test/browser/abb_one_group_test.rb index 9bfb88bbf..60c8ec960 100644 --- a/test/browser/abb_one_group_test.rb +++ b/test/browser/abb_one_group_test.rb @@ -58,13 +58,7 @@ class AgentTicketActionLevel0Test < TestCase css: '.modal [name="email"]', value: "#{agent}@example.com", ) - exists( - displayed: false, - css: '.modal .js-groupList', - ) - exists( - css: '.modal .js-groupListItem[value=full]:checked', - ) + check(css: '.modal .js-groupListItem[value=full]') click( css: '.modal button.btn.btn--primary', fast: true, @@ -99,31 +93,7 @@ class AgentTicketActionLevel0Test < TestCase value: "#{agent}2@example.com", ) - # disable agent role - uncheck( - css: '.modal [name="role_ids"][value=2]', - ) - - exists( - displayed: false, - css: '.modal .js-groupList', - ) - exists_not( - css: '.modal .js-groupListItem[value=full]:checked', - ) - - # enable agent role - check( - css: '.modal [name="role_ids"][value=2]', - ) - - exists( - displayed: false, - css: '.modal .js-groupList', - ) - exists( - css: '.modal .js-groupListItem[value=full]:checked', - ) + check(css: '.modal .js-groupListItem[value=full]') click( css: '.modal button.btn.btn--primary',