Commit a8e4fe1e authored by Alfredo Sumaran's avatar Alfredo Sumaran

Enable submit button by checking if all required inputs are present

[ci skip]
parent 74c2fe9e
......@@ -28,10 +28,6 @@
onSelect: this.onSelectCallback
});
// Select default
$allowedToPushDropdown.data('glDropdown').selectRowAtIndex(0);
$allowedToMergeDropdown.data('glDropdown').selectRowAtIndex(0);
// Protected branch dropdown
new gl.ProtectedBranchDropdown({
$dropdown: this.$wrap.find('.js-protected-branch-select'),
......@@ -39,16 +35,13 @@
});
}
// This will run after clicked callback
// Enable submit button after selecting an option
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_levels_attributes][][access_level]"]');
const $allowedToPushInput = this.$wrap.find('input[name="protected_branch[push_access_levels_attributes][][access_level]"]');
console.log('onSelect');
if ($branchInput.val() && $allowedToMergeInput.val() && $allowedToPushInput.val()){
const $allowedToMergeInputs = this.$wrap.find('input[name^="protected_branch[merge_access_levels_attributes]"]');
const $allowedToPushInputs = this.$wrap.find('input[name^="protected_branch[push_access_levels_attributes]"]');
console.log('x');
if ($branchInput.length && $allowedToMergeInputs.length && $allowedToPushInputs.length){
console.log('onSelect');
this.$form.find('input[type="submit"]').removeAttr('disabled');
}
......
......@@ -23,7 +23,7 @@
Allowed to merge:
.col-md-10
= dropdown_tag('Select',
options: { toggle_class: 'js-allowed-to-merge wide js-multiselect js-multiselect', dropdown_class: 'dropdown-menu-user dropdown-menu-selectable', filter: true,
options: { toggle_class: 'js-allowed-to-merge wide js-multiselectjs-multiselect', dropdown_class: 'dropdown-menu-user dropdown-menu-selectable', filter: true,
data: { input_id: 'merge_access_levels_attributes' }})
.form-group
%label.col-md-2.text-right{ for: 'push_access_levels_attributes' }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment