summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/comment_type_toggle.js
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-07 14:09:15 +0100
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-07 14:09:15 +0100
commit18e2388de19f47093cb3192f4b8dbabdd9c3bfad (patch)
treed7960767b781d5a50da2a0bfbf889bcc8ef35644 /app/assets/javascripts/comment_type_toggle.js
parent2f22890d4223c0b524ee1f27e222a24a8f0c9a87 (diff)
downloadgitlab-ce-18e2388de19f47093cb3192f4b8dbabdd9c3bfad.tar.gz
Fixed issue button state bug
Diffstat (limited to 'app/assets/javascripts/comment_type_toggle.js')
-rw-r--r--app/assets/javascripts/comment_type_toggle.js69
1 files changed, 42 insertions, 27 deletions
diff --git a/app/assets/javascripts/comment_type_toggle.js b/app/assets/javascripts/comment_type_toggle.js
index 34878f90050..ba3b43b201d 100644
--- a/app/assets/javascripts/comment_type_toggle.js
+++ b/app/assets/javascripts/comment_type_toggle.js
@@ -2,39 +2,54 @@ import DropLab from '~/droplab/drop_lab';
import InputSetter from '~/droplab/plugins/input_setter';
class CommentTypeToggle {
- constructor(dropdownTrigger, dropdownList, noteTypeInput, submitButton, closeButton) {
- this.dropdownTrigger = dropdownTrigger;
- this.dropdownList = dropdownList;
- this.noteTypeInput = noteTypeInput;
- this.submitButton = submitButton;
- this.closeButton = closeButton;
+ constructor(opts = {}) {
+ this.dropdownTrigger = opts.dropdownTrigger;
+ this.dropdownList = opts.dropdownList;
+ this.noteTypeInput = opts.noteTypeInput;
+ this.submitButton = opts.submitButton;
+ this.closeButton = opts.closeButton;
+ this.reopenButton = opts.reopenButton;
}
initDroplab() {
this.droplab = new DropLab();
- const inputSetterConfig = [{
- input: this.noteTypeInput,
- valueAttribute: 'data-value',
- },
- {
- input: this.submitButton,
- valueAttribute: 'data-button-text',
- }];
- if (this.closeButton) {
- inputSetterConfig.push({
- input: this.closeButton,
- valueAttribute: 'data-secondary-button-text',
- }, {
- input: this.closeButton,
- valueAttribute: 'data-secondary-button-text',
- inputAttribute: 'data-alternative-text',
- });
- }
-
- this.droplab.init(this.dropdownTrigger, this.dropdownList, [InputSetter], {
- InputSetter: inputSetterConfig,
+ const config = this.setConfig();
+
+ this.droplab.init(this.dropdownTrigger, this.dropdownList, [InputSetter], config);
+ }
+
+ setConfig() {
+ const config = {
+ InputSetter: [{
+ input: this.noteTypeInput,
+ valueAttribute: 'data-value',
+ },
+ {
+ input: this.submitButton,
+ valueAttribute: 'data-submit-text',
+ }],
+ };
+
+ if (!this.closeButton || !this.reopenButton) return config;
+
+ config.InputSetter.push({
+ input: this.closeButton,
+ valueAttribute: 'data-close-text',
+ }, {
+ input: this.closeButton,
+ valueAttribute: 'data-close-text',
+ inputAttribute: 'data-alternative-text',
+ }, {
+ input: this.reopenButton,
+ valueAttribute: 'data-reopen-text',
+ }, {
+ input: this.reopenButton,
+ valueAttribute: 'data-reopen-text',
+ inputAttribute: 'data-alternative-text',
});
+
+ return config;
}
}