From 54412dac15203b9208ca3ab56617262e7968050b Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Sun, 21 Aug 2016 00:18:28 -0500 Subject: Make dropdown selectables This makes dropdown to look according the dropdowns on the edit form. This options add a tick mark next to the selected option. --- .../projects/protected_branches/_create_protected_branch.html.haml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app') diff --git a/app/views/projects/protected_branches/_create_protected_branch.html.haml b/app/views/projects/protected_branches/_create_protected_branch.html.haml index 95d8743f546..226f8311a90 100644 --- a/app/views/projects/protected_branches/_create_protected_branch.html.haml +++ b/app/views/projects/protected_branches/_create_protected_branch.html.haml @@ -25,6 +25,7 @@ .js-allowed-to-merge-container = dropdown_tag('Select', options: { toggle_class: 'js-allowed-to-merge wide', + dropdown_class: 'dropdown-menu-selectable', data: { field_name: 'protected_branch[merge_access_levels_attributes][0][access_level]', input_id: 'merge_access_levels_attributes' }}) .form-group %label.col-md-2.text-right{ for: 'push_access_levels_attributes' } @@ -33,6 +34,7 @@ .js-allowed-to-push-container = dropdown_tag('Select', options: { toggle_class: 'js-allowed-to-push wide', + dropdown_class: 'dropdown-menu-selectable', data: { field_name: 'protected_branch[push_access_levels_attributes][0][access_level]', input_id: 'push_access_levels_attributes' }}) .panel-footer -- cgit v1.2.1 From 18e98a364388e53786c7fe01eaff75efa496bb4c Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Sun, 21 Aug 2016 00:19:22 -0500 Subject: Do not update if one dropdown has not selected any option No need to update the branch permission if no option is marked on the dropdown --- app/assets/javascripts/protected_branch_edit.js.es6 | 3 +++ 1 file changed, 3 insertions(+) (limited to 'app') diff --git a/app/assets/javascripts/protected_branch_edit.js.es6 b/app/assets/javascripts/protected_branch_edit.js.es6 index a59fcbfa082..40bc4adb71b 100644 --- a/app/assets/javascripts/protected_branch_edit.js.es6 +++ b/app/assets/javascripts/protected_branch_edit.js.es6 @@ -31,6 +31,9 @@ const $allowedToMergeInput = this.$wrap.find(`input[name="${this.$allowedToMergeDropdown.data('fieldName')}"]`); const $allowedToPushInput = this.$wrap.find(`input[name="${this.$allowedToPushDropdown.data('fieldName')}"]`); + // Do not update if one dropdown has not selected any option + if (!($allowedToMergeInput.length && $allowedToPushInput.length)) return; + $.ajax({ type: 'POST', url: this.$wrap.data('url'), -- cgit v1.2.1 From 4a4d8608e8a09e0c55f690aeefc05f742bc67011 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Sun, 21 Aug 2016 00:20:57 -0500 Subject: Toggle dropdown disabled attribute Before this the dropdowns were not being disabled if the user unselected an option from the allowed to merge/push dropdowns. --- app/assets/javascripts/protected_branch_create.js.es6 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'app') diff --git a/app/assets/javascripts/protected_branch_create.js.es6 b/app/assets/javascripts/protected_branch_create.js.es6 index 2efca2414dc..46beca469b9 100644 --- a/app/assets/javascripts/protected_branch_create.js.es6 +++ b/app/assets/javascripts/protected_branch_create.js.es6 @@ -47,9 +47,7 @@ const $allowedToMergeInput = this.$wrap.find('input[name="protected_branch[merge_access_levels_attributes][0][access_level]"]'); const $allowedToPushInput = this.$wrap.find('input[name="protected_branch[push_access_levels_attributes][0][access_level]"]'); - if ($branchInput.val() && $allowedToMergeInput.val() && $allowedToPushInput.val()){ - this.$form.find('input[type="submit"]').removeAttr('disabled'); - } + this.$form.find('input[type="submit"]').attr('disabled', !($branchInput.val() && $allowedToMergeInput.length && $allowedToPushInput.length)); } } -- cgit v1.2.1 From a7d7e9a51889a276f2d057207fba8d095fa8fc8d Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Sun, 21 Aug 2016 00:21:32 -0500 Subject: Set default label if user unselects the option from dropdown --- app/assets/javascripts/protected_branch_access_dropdown.js.es6 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/assets/javascripts/protected_branch_access_dropdown.js.es6 b/app/assets/javascripts/protected_branch_access_dropdown.js.es6 index 2fbb088fa04..7aeb5f92514 100644 --- a/app/assets/javascripts/protected_branch_access_dropdown.js.es6 +++ b/app/assets/javascripts/protected_branch_access_dropdown.js.es6 @@ -10,8 +10,12 @@ selectable: true, inputId: $dropdown.data('input-id'), fieldName: $dropdown.data('field-name'), - toggleLabel(item) { - return item.text; + toggleLabel(item, el) { + if (el.is('.is-active')) { + return item.text; + } else { + return 'Select'; + } }, clicked(item, $el, e) { e.preventDefault(); -- cgit v1.2.1