Skip to content

Commit

Permalink
FIX "Save" button state
Browse files Browse the repository at this point in the history
Previously, Save button remains as it is after clicking on it with api call
in background. Now, we enabled loading UI on button when start processing
  • Loading branch information
hitaishi19 committed Dec 9, 2024
1 parent 1229d0f commit 6f1e8a2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

28 changes: 23 additions & 5 deletions client/src/legacy/LeftAndMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,24 @@ $.entwine('ss', function($) {
// default to first button if none given - simulates browser behaviour
if(!button) button = this.find('.btn-toolbar :submit:first');

if ($(button).is("button")) {
$(button).append(
$(
'<div class="btn__loading-icon">' +
'<span class="btn__circle btn__circle--1"></span>' +
'<span class="btn__circle btn__circle--2"></span>' +
'<span class="btn__circle btn__circle--3"></span>' +
"</div>"
)
);

$(button).css($(button).outerWidth() + "px");
}

// set button to "submitting" state
$(button).addClass('btn--loading loading');
$(button).prop('disabled', true);

var beforeSubmitFormEventData = {
// array of promises that must resolve({success:true}) before the form is submitted
// result of each promise must be an object of
Expand Down Expand Up @@ -499,15 +517,12 @@ $.entwine('ss', function($) {
}
});
}
clearButton();
return false;
}

self.trigger('submitform', {form: form, button: button});

// set button to "submitting" state
$(button).addClass('btn--loading loading');
$(button).prop('disabled', true);

if($(button).is('button')) {

$(button).append($(
Expand Down Expand Up @@ -572,7 +587,10 @@ $.entwine('ss', function($) {
newContentEls.filter('form').trigger('aftersubmitform', {status: status, xhr: xhr, formData: formData});
}
}, ajaxOptions));
});
}).catch(function() {
// Handle errors from the promises
clearButton();
});;

return false;
},
Expand Down

0 comments on commit 6f1e8a2

Please sign in to comment.