summaryrefslogtreecommitdiff
path: root/app/assets/javascripts
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r--app/assets/javascripts/protected_branches_access_select.js.es618
1 files changed, 14 insertions, 4 deletions
diff --git a/app/assets/javascripts/protected_branches_access_select.js.es6 b/app/assets/javascripts/protected_branches_access_select.js.es6
index 93b7d7755a7..e98312bbf37 100644
--- a/app/assets/javascripts/protected_branches_access_select.js.es6
+++ b/app/assets/javascripts/protected_branches_access_select.js.es6
@@ -1,27 +1,35 @@
class ProtectedBranchesAccessSelect {
- constructor(container, saveOnSelect) {
+ constructor(container, saveOnSelect, selectDefault) {
this.container = container;
this.saveOnSelect = saveOnSelect;
this.container.find(".allowed-to-merge").each((i, element) => {
var fieldName = $(element).data('field-name');
- return $(element).glDropdown({
+ var dropdown = $(element).glDropdown({
data: gon.merge_access_levels,
selectable: true,
fieldName: fieldName,
clicked: _.chain(this.onSelect).partial(element).bind(this).value()
});
+
+ if (selectDefault) {
+ dropdown.data('glDropdown').selectRowAtIndex(document.createEvent("Event"), 0);
+ }
});
this.container.find(".allowed-to-push").each((i, element) => {
var fieldName = $(element).data('field-name');
- return $(element).glDropdown({
+ var dropdown = $(element).glDropdown({
data: gon.push_access_levels,
selectable: true,
fieldName: fieldName,
clicked: _.chain(this.onSelect).partial(element).bind(this).value()
});
+
+ if (selectDefault) {
+ dropdown.data('glDropdown').selectRowAtIndex(document.createEvent("Event"), 0);
+ }
});
}
@@ -36,7 +44,9 @@ class ProtectedBranchesAccessSelect {
_method: 'PATCH',
id: $(dropdown).data('id'),
protected_branch: {
- ["" + ($(dropdown).data('type'))]: selected.id
+ ["" + ($(dropdown).data('type')) + "_attributes"]: {
+ "access_level": selected.id
+ }
}
},
success: function() {