Commit 99918be7 authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

Added variable button fix

parent 18e2388d
...@@ -31,8 +31,7 @@ class CommentTypeToggle { ...@@ -31,8 +31,7 @@ class CommentTypeToggle {
}], }],
}; };
if (!this.closeButton || !this.reopenButton) return config; if (this.closeButton) {
config.InputSetter.push({ config.InputSetter.push({
input: this.closeButton, input: this.closeButton,
valueAttribute: 'data-close-text', valueAttribute: 'data-close-text',
...@@ -40,7 +39,11 @@ class CommentTypeToggle { ...@@ -40,7 +39,11 @@ class CommentTypeToggle {
input: this.closeButton, input: this.closeButton,
valueAttribute: 'data-close-text', valueAttribute: 'data-close-text',
inputAttribute: 'data-alternative-text', inputAttribute: 'data-alternative-text',
}, { });
}
if (this.reopenButton) {
config.InputSetter.push({
input: this.reopenButton, input: this.reopenButton,
valueAttribute: 'data-reopen-text', valueAttribute: 'data-reopen-text',
}, { }, {
...@@ -48,6 +51,7 @@ class CommentTypeToggle { ...@@ -48,6 +51,7 @@ class CommentTypeToggle {
valueAttribute: 'data-reopen-text', valueAttribute: 'data-reopen-text',
inputAttribute: 'data-alternative-text', inputAttribute: 'data-alternative-text',
}); });
}
return config; return config;
} }
......
...@@ -143,7 +143,7 @@ require('./task_list'); ...@@ -143,7 +143,7 @@ require('./task_list');
const noteTypeInput = form.querySelector('#note_type'); const noteTypeInput = form.querySelector('#note_type');
const submitButton = form.querySelector('.js-comment-type-dropdown .js-comment-submit-button'); const submitButton = form.querySelector('.js-comment-type-dropdown .js-comment-submit-button');
const closeButton = form.querySelector('.js-note-target-close'); const closeButton = form.querySelector('.js-note-target-close');
const reopenButton = form.querySelector('.js-note-target-reopen'); const reopenButton = form.querySelector('.reopen-mr-link') || form.querySelector('.js-note-target-reopen');
const commentTypeToggle = new CommentTypeToggle({ const commentTypeToggle = new CommentTypeToggle({
dropdownTrigger, dropdownTrigger,
......
...@@ -101,7 +101,7 @@ describe('CommentTypeToggle', function () { ...@@ -101,7 +101,7 @@ describe('CommentTypeToggle', function () {
this.setConfig = CommentTypeToggle.prototype.setConfig.call(this.commentTypeToggle); this.setConfig = CommentTypeToggle.prototype.setConfig.call(this.commentTypeToggle);
}); });
it('should not add .closeButton or .reopenButton related InputSetter config', function () { it('should not add .closeButton related InputSetter config', function () {
expect(this.setConfig).toEqual({ expect(this.setConfig).toEqual({
InputSetter: [{ InputSetter: [{
input: this.commentTypeToggle.noteTypeInput, input: this.commentTypeToggle.noteTypeInput,
...@@ -109,6 +109,13 @@ describe('CommentTypeToggle', function () { ...@@ -109,6 +109,13 @@ describe('CommentTypeToggle', function () {
}, { }, {
input: this.commentTypeToggle.submitButton, input: this.commentTypeToggle.submitButton,
valueAttribute: 'data-submit-text', valueAttribute: 'data-submit-text',
}, {
input: this.commentTypeToggle.reopenButton,
valueAttribute: 'data-reopen-text',
}, {
input: this.commentTypeToggle.reopenButton,
valueAttribute: 'data-reopen-text',
inputAttribute: 'data-alternative-text',
}], }],
}); });
}); });
...@@ -127,7 +134,7 @@ describe('CommentTypeToggle', function () { ...@@ -127,7 +134,7 @@ describe('CommentTypeToggle', function () {
this.setConfig = CommentTypeToggle.prototype.setConfig.call(this.commentTypeToggle); this.setConfig = CommentTypeToggle.prototype.setConfig.call(this.commentTypeToggle);
}); });
it('should not add .closeButton or .reopenButton related InputSetter config', function () { it('should not add .reopenButton related InputSetter config', function () {
expect(this.setConfig).toEqual({ expect(this.setConfig).toEqual({
InputSetter: [{ InputSetter: [{
input: this.commentTypeToggle.noteTypeInput, input: this.commentTypeToggle.noteTypeInput,
...@@ -135,6 +142,13 @@ describe('CommentTypeToggle', function () { ...@@ -135,6 +142,13 @@ describe('CommentTypeToggle', function () {
}, { }, {
input: this.commentTypeToggle.submitButton, input: this.commentTypeToggle.submitButton,
valueAttribute: 'data-submit-text', valueAttribute: 'data-submit-text',
}, {
input: this.commentTypeToggle.closeButton,
valueAttribute: 'data-close-text',
}, {
input: this.commentTypeToggle.closeButton,
valueAttribute: 'data-close-text',
inputAttribute: 'data-alternative-text',
}], }],
}); });
}); });
......
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