|
@@ -572,6 +572,38 @@
|
|
|
addMCHook('refreshDashboardAppointments', function() {
|
|
|
onDateChange(selectedDate);
|
|
|
});
|
|
|
+
|
|
|
+ $('form[discardable]')
|
|
|
+ .off('submit.discardable')
|
|
|
+ .on('submit.discardable', function() {
|
|
|
+ let form = $(this),
|
|
|
+ submitButton = form.find('[submit]'),
|
|
|
+ spinner = form.find('.spinner');
|
|
|
+ submitButton.hide();
|
|
|
+ if(!spinner.length) {
|
|
|
+ spinner = $('<img/>').addClass('spinner icon-16').attr('src', '/vanillaspin.gif').insertAfter(submitButton);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ spinner.show();
|
|
|
+ }
|
|
|
+ $.post(form.attr('url'), form.serialize(), _data => {
|
|
|
+ if(!hasResponseError(_data)) {
|
|
|
+ let container = form.closest('[discardable-container]');
|
|
|
+ if(!container.siblings('[discardable-container]').length) {
|
|
|
+ container.remove();
|
|
|
+ fastReload();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ container.remove();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ spinner.hide();
|
|
|
+ submitButton.show();
|
|
|
+ }
|
|
|
+ }, 'json');
|
|
|
+ return false;
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
addMCInitializer('pro-dashboard', init, '#pro-dashboard-container');
|