Upload files button stay disabled when there are other submit buttons on the same page

This commit is contained in:
Frederic Guillot
2017-02-18 15:53:48 -05:00
parent fb8c335200
commit 76f73eebea
3 changed files with 18 additions and 9 deletions

View File

@@ -24,6 +24,7 @@ Breaking changes:
Bug fixes: Bug fixes:
* Upload files button stay disabled when there are other submit buttons on the same page
* Hiding subtasks from hidden tasks in dashboard * Hiding subtasks from hidden tasks in dashboard
Version 1.0.39 (Feb 12, 2017) Version 1.0.39 (Feb 12, 2017)

File diff suppressed because one or more lines are too long

View File

@@ -3,10 +3,11 @@ KB.component('submit-buttons', function (containerElement, options) {
var isDisabled = options.disabled || false; var isDisabled = options.disabled || false;
var submitLabel = options.submitLabel; var submitLabel = options.submitLabel;
var formActionElement = null; var formActionElement = null;
var submitButtonElement = null;
function onSubmit() { function onSubmit() {
isLoading = true; isLoading = true;
KB.find('#modal-submit-button').replace(buildButton()); replaceButton();
KB.trigger('modal.submit'); KB.trigger('modal.submit');
} }
@@ -16,19 +17,19 @@ KB.component('submit-buttons', function (containerElement, options) {
function onStop() { function onStop() {
isLoading = false; isLoading = false;
KB.find('#modal-submit-button').replace(buildButton()); replaceButton();
} }
function onDisable() { function onDisable() {
isLoading = false; isLoading = false;
isDisabled = true; isDisabled = true;
KB.find('#modal-submit-button').replace(buildButton()); replaceButton();
} }
function onEnable() { function onEnable() {
isLoading = false; isLoading = false;
isDisabled = false; isDisabled = false;
KB.find('#modal-submit-button').replace(buildButton()); replaceButton();
} }
function onHide() { function onHide() {
@@ -37,12 +38,11 @@ KB.component('submit-buttons', function (containerElement, options) {
function onUpdateSubmitLabel(eventData) { function onUpdateSubmitLabel(eventData) {
submitLabel = eventData.submitLabel; submitLabel = eventData.submitLabel;
KB.find('#modal-submit-button').replace(buildButton()); replaceButton();
} }
function buildButton() { function buildButton() {
var button = KB.dom('button') var button = KB.dom('button')
.attr('id', 'modal-submit-button')
.attr('type', 'submit') .attr('type', 'submit')
.attr('class', 'btn btn-' + (options.color || 'blue')); .attr('class', 'btn btn-' + (options.color || 'blue'));
@@ -71,6 +71,12 @@ KB.component('submit-buttons', function (containerElement, options) {
.build(); .build();
} }
function replaceButton() {
var buttonElement = buildButton();
KB.dom(submitButtonElement).replace(buttonElement);
submitButtonElement = buttonElement;
}
this.render = function () { this.render = function () {
KB.on('modal.stop', onStop); KB.on('modal.stop', onStop);
KB.on('modal.disable', onDisable); KB.on('modal.disable', onDisable);
@@ -86,9 +92,11 @@ KB.component('submit-buttons', function (containerElement, options) {
KB.removeListener('modal.submit.label', onUpdateSubmitLabel); KB.removeListener('modal.submit.label', onUpdateSubmitLabel);
}); });
submitButtonElement = buildButton();
var formActionElementBuilder = KB.dom('div') var formActionElementBuilder = KB.dom('div')
.attr('class', 'form-actions') .attr('class', 'form-actions')
.add(buildButton()); .add(submitButtonElement);
if (KB.modal.isOpen()) { if (KB.modal.isOpen()) {
formActionElementBuilder formActionElementBuilder