summaryrefslogtreecommitdiff
path: root/assets/js/components
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2017-02-18 15:53:48 -0500
committerFrederic Guillot <fred@kanboard.net>2017-02-18 15:53:48 -0500
commit76f73eebea0fa875487611cf9e01d8167e84a142 (patch)
tree0358d008cb291c9fc481eec5560516e0b1ca0116 /assets/js/components
parentfb8c3352004c255de66848cd97644298a8ea452a (diff)
Upload files button stay disabled when there are other submit buttons on the same page
Diffstat (limited to 'assets/js/components')
-rw-r--r--assets/js/components/submit-buttons.js22
1 files changed, 15 insertions, 7 deletions
diff --git a/assets/js/components/submit-buttons.js b/assets/js/components/submit-buttons.js
index 2745841a..9e8ec1ca 100644
--- a/assets/js/components/submit-buttons.js
+++ b/assets/js/components/submit-buttons.js
@@ -3,10 +3,11 @@ KB.component('submit-buttons', function (containerElement, options) {
var isDisabled = options.disabled || false;
var submitLabel = options.submitLabel;
var formActionElement = null;
+ var submitButtonElement = null;
function onSubmit() {
isLoading = true;
- KB.find('#modal-submit-button').replace(buildButton());
+ replaceButton();
KB.trigger('modal.submit');
}
@@ -16,19 +17,19 @@ KB.component('submit-buttons', function (containerElement, options) {
function onStop() {
isLoading = false;
- KB.find('#modal-submit-button').replace(buildButton());
+ replaceButton();
}
function onDisable() {
isLoading = false;
isDisabled = true;
- KB.find('#modal-submit-button').replace(buildButton());
+ replaceButton();
}
function onEnable() {
isLoading = false;
isDisabled = false;
- KB.find('#modal-submit-button').replace(buildButton());
+ replaceButton();
}
function onHide() {
@@ -37,12 +38,11 @@ KB.component('submit-buttons', function (containerElement, options) {
function onUpdateSubmitLabel(eventData) {
submitLabel = eventData.submitLabel;
- KB.find('#modal-submit-button').replace(buildButton());
+ replaceButton();
}
function buildButton() {
var button = KB.dom('button')
- .attr('id', 'modal-submit-button')
.attr('type', 'submit')
.attr('class', 'btn btn-' + (options.color || 'blue'));
@@ -71,6 +71,12 @@ KB.component('submit-buttons', function (containerElement, options) {
.build();
}
+ function replaceButton() {
+ var buttonElement = buildButton();
+ KB.dom(submitButtonElement).replace(buttonElement);
+ submitButtonElement = buttonElement;
+ }
+
this.render = function () {
KB.on('modal.stop', onStop);
KB.on('modal.disable', onDisable);
@@ -86,9 +92,11 @@ KB.component('submit-buttons', function (containerElement, options) {
KB.removeListener('modal.submit.label', onUpdateSubmitLabel);
});
+ submitButtonElement = buildButton();
+
var formActionElementBuilder = KB.dom('div')
.attr('class', 'form-actions')
- .add(buildButton());
+ .add(submitButtonElement);
if (KB.modal.isOpen()) {
formActionElementBuilder