summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlfredo Sumaran <alfredo@gitlab.com>2016-08-05 02:18:20 -0500
committerAlfredo Sumaran <alfredo@gitlab.com>2016-08-05 17:19:01 -0500
commit0e730a14a108dac05b25783427e8f299b0db4adc (patch)
tree6d84b94d57a53302c27abafee9b93b0192132679 /app
parentcd086eba79378465d820733b38d5e92fc1c8689d (diff)
downloadgitlab-ce-0e730a14a108dac05b25783427e8f299b0db4adc.tar.gz
Cache onSelect callback before passing to each dropdown instance
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/protected_branch_create.js.es616
1 files changed, 9 insertions, 7 deletions
diff --git a/app/assets/javascripts/protected_branch_create.js.es6 b/app/assets/javascripts/protected_branch_create.js.es6
index d112be2d08a..6942b6c36d6 100644
--- a/app/assets/javascripts/protected_branch_create.js.es6
+++ b/app/assets/javascripts/protected_branch_create.js.es6
@@ -8,38 +8,40 @@
}
buildDropdowns() {
- // Allowed to Merge dropdown
const $allowedToMergeDropdown = this.$wrap.find('.js-allowed-to-merge');
const $allowedToPushDropdown = this.$wrap.find('.js-allowed-to-push');
+ // Cache callback
+ this.onSelectCallback = this.onSelect.bind(this);
+
+ // Allowed to Merge dropdown
new gl.ProtectedBranchAccessDropdown({
$dropdown: $allowedToMergeDropdown,
data: gon.merge_access_levels,
- onSelect: this.onSelect.bind(this)
+ onSelect: this.onSelectCallback
});
- // Select default
- $allowedToMergeDropdown.data('glDropdown').selectRowAtIndex(0);
-
// Allowed to Push dropdown
new gl.ProtectedBranchAccessDropdown({
$dropdown: $allowedToPushDropdown,
data: gon.push_access_levels,
- onSelect: this.onSelect.bind(this)
+ onSelect: this.onSelectCallback
});
// Select default
$allowedToPushDropdown.data('glDropdown').selectRowAtIndex(0);
+ $allowedToMergeDropdown.data('glDropdown').selectRowAtIndex(0);
// Protected branch dropdown
new ProtectedBranchDropdown({
$dropdown: this.$wrap.find('.js-protected-branch-select'),
- onSelect: this.onSelect.bind(this)
+ onSelect: this.onSelectCallback
});
}
// This will run after clicked callback
onSelect() {
+
// Enable submit button
const $branchInput = this.$wrap.find('input[name="protected_branch[name]"]');
const $allowedToMergeInput = this.$wrap.find('input[name="protected_branch[merge_access_level_attributes][access_level]"]');