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 @@ ...@@ -28,10 +28,6 @@
onSelect: this.onSelectCallback onSelect: this.onSelectCallback
}); });
// Select default
$allowedToPushDropdown.data('glDropdown').selectRowAtIndex(0);
$allowedToMergeDropdown.data('glDropdown').selectRowAtIndex(0);
// Protected branch dropdown // Protected branch dropdown
new gl.ProtectedBranchDropdown({ new gl.ProtectedBranchDropdown({
$dropdown: this.$wrap.find('.js-protected-branch-select'), $dropdown: this.$wrap.find('.js-protected-branch-select'),
...@@ -39,16 +35,13 @@ ...@@ -39,16 +35,13 @@
}); });
} }
// This will run after clicked callback // Enable submit button after selecting an option
onSelect() { onSelect() {
// Enable submit button
const $branchInput = this.$wrap.find('input[name="protected_branch[name]"]'); 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 $allowedToMergeInputs = this.$wrap.find('input[name^="protected_branch[merge_access_levels_attributes]"]');
const $allowedToPushInput = this.$wrap.find('input[name="protected_branch[push_access_levels_attributes][][access_level]"]'); const $allowedToPushInputs = this.$wrap.find('input[name^="protected_branch[push_access_levels_attributes]"]');
console.log('x');
console.log('onSelect'); if ($branchInput.length && $allowedToMergeInputs.length && $allowedToPushInputs.length){
if ($branchInput.val() && $allowedToMergeInput.val() && $allowedToPushInput.val()){
console.log('onSelect'); console.log('onSelect');
this.$form.find('input[type="submit"]').removeAttr('disabled'); this.$form.find('input[type="submit"]').removeAttr('disabled');
} }
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
Allowed to merge: Allowed to merge:
.col-md-10 .col-md-10
= dropdown_tag('Select', = 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' }}) data: { input_id: 'merge_access_levels_attributes' }})
.form-group .form-group
%label.col-md-2.text-right{ for: 'push_access_levels_attributes' } %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