diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-07-08 10:30:38 +0300 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-07-29 12:50:39 +0300 |
commit | 12387b4d2c6abbe1de2fc6b0776207d9135c29f0 (patch) | |
tree | d8966a8f149e75e24842b4ae85ba7e7c048e0ce0 /app/assets/javascripts | |
parent | 828f6eb6e50e6193fad9dbdd95d9dd56506e4064 (diff) |
Allow setting "Allowed To Push/Merge" while creating a protected branch.
1. Reuse the same dropdown component that we used for updating these
settings (`ProtectedBranchesAccessSelect`). Have it accept options
for the parent container (so we can control the elements it sees) and
whether or not to save changes via AJAX (we need this for update, but
not create).
2. Change the "Developers" option to "Developers + Masters", which is
clearer.
3. Remove `developers_can_push` and `developers_can_merge` from the
model, since they're not needed anymore.
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r-- | app/assets/javascripts/protected_branches_access_select.js.coffee | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/app/assets/javascripts/protected_branches_access_select.js.coffee b/app/assets/javascripts/protected_branches_access_select.js.coffee index b472ff7ec27..7c6f2f9f38e 100644 --- a/app/assets/javascripts/protected_branches_access_select.js.coffee +++ b/app/assets/javascripts/protected_branches_access_select.js.coffee @@ -1,18 +1,18 @@ class @ProtectedBranchesAccessSelect - constructor: () -> - $(".allowed-to-merge").each (i, element) => + constructor: (@container, @saveOnSelect) -> + @container.find(".allowed-to-merge").each (i, element) => fieldName = $(element).data('field-name') $(element).glDropdown - data: [{id: 'developers', text: 'Developers'}, {id: 'masters', text: 'Masters'}] + data: [{id: 'developers', text: 'Developers + Masters'}, {id: 'masters', text: 'Masters'}] selectable: true fieldName: fieldName clicked: _.partial(@onSelect, element) - $(".allowed-to-push").each (i, element) => + @container.find(".allowed-to-push").each (i, element) => fieldName = $(element).data('field-name') $(element).glDropdown data: [{id: 'no_one', text: 'No one'}, - {id: 'developers', text: 'Developers'}, + {id: 'developers', text: 'Developers + Masters'}, {id: 'masters', text: 'Masters'}] selectable: true fieldName: fieldName @@ -21,19 +21,20 @@ class @ProtectedBranchesAccessSelect onSelect: (dropdown, selected, element, e) => $(dropdown).find('.dropdown-toggle-text').text(selected.text) - $.ajax - type: "PATCH" - url: $(dropdown).data('url') - dataType: "json" - data: - id: $(dropdown).data('id') - protected_branch: - "#{$(dropdown).data('type')}": selected.id + if @saveOnSelect + $.ajax + type: "PATCH" + url: $(dropdown).data('url') + dataType: "json" + data: + id: $(dropdown).data('id') + protected_branch: + "#{$(dropdown).data('type')}": selected.id - success: -> - row = $(e.target) - row.closest('tr').effect('highlight') + success: -> + row = $(e.target) + row.closest('tr').effect('highlight') - error: -> - new Flash("Failed to update branch!", "alert") + error: -> + new Flash("Failed to update branch!", "alert") |