forked from mirrors/easyappointments
Display error message (if any) when saving appointments or unavailable time periods.
This commit is contained in:
parent
dbc45f6b27
commit
f122d1ea20
1 changed files with 29 additions and 6 deletions
|
@ -27,8 +27,8 @@ window.BackendCalendarApi = window.BackendCalendarApi || {};
|
||||||
*
|
*
|
||||||
* This method stores the changes of an already registered appointment into the database, via an ajax call.
|
* This method stores the changes of an already registered appointment into the database, via an ajax call.
|
||||||
*
|
*
|
||||||
* @param {Object} appointment Contain the new appointment data. The ID of the appointment MUST be
|
* @param {Object} appointment Contain the new appointment data. The ID of the appointment MUST be already included.
|
||||||
* already included. The rest values must follow the database structure.
|
* The rest values must follow the database structure.
|
||||||
* @param {Object} [customer] Optional, contains the customer data.
|
* @param {Object} [customer] Optional, contains the customer data.
|
||||||
* @param {Function} [successCallback] Optional, if defined, this function is going to be executed on post success.
|
* @param {Function} [successCallback] Optional, if defined, this function is going to be executed on post success.
|
||||||
* @param {Function} [errorCallback] Optional, if defined, this function is going to be executed on post failure.
|
* @param {Function} [errorCallback] Optional, if defined, this function is going to be executed on post failure.
|
||||||
|
@ -52,6 +52,8 @@ window.BackendCalendarApi = window.BackendCalendarApi || {};
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail(function (jqXHR, textStatus, errorThrown) {
|
.fail(function (jqXHR, textStatus, errorThrown) {
|
||||||
|
GeneralFunctions.ajaxFailureHandler(jqXHR, textStatus, errorThrown);
|
||||||
|
|
||||||
if (errorCallback) {
|
if (errorCallback) {
|
||||||
errorCallback();
|
errorCallback();
|
||||||
}
|
}
|
||||||
|
@ -74,12 +76,23 @@ window.BackendCalendarApi = window.BackendCalendarApi || {};
|
||||||
};
|
};
|
||||||
|
|
||||||
$.post(url, data)
|
$.post(url, data)
|
||||||
.done(successCallback)
|
.done(function (response) {
|
||||||
.fail(errorCallback);
|
if (successCallback) {
|
||||||
|
successCallback(response);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.fail(function (jqXHR, textStatus, errorThrown) {
|
||||||
|
GeneralFunctions.ajaxFailureHandler(jqXHR, textStatus, errorThrown);
|
||||||
|
|
||||||
|
if (errorCallback) {
|
||||||
|
errorCallback();
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save extra period of work to database.
|
* Save extra period of work to database.
|
||||||
|
*
|
||||||
* @param {Object} extra_periods Contains the extra period data.
|
* @param {Object} extra_periods Contains the extra period data.
|
||||||
* @param {Function} successCallback The ajax success callback function.
|
* @param {Function} successCallback The ajax success callback function.
|
||||||
* @param {Function} errorCallback The ajax failure callback function.
|
* @param {Function} errorCallback The ajax failure callback function.
|
||||||
|
@ -93,8 +106,18 @@ window.BackendCalendarApi = window.BackendCalendarApi || {};
|
||||||
};
|
};
|
||||||
|
|
||||||
$.post(url, data)
|
$.post(url, data)
|
||||||
.done(successCallback)
|
.done(function (response) {
|
||||||
.fail(errorCallback);
|
if (successCallback) {
|
||||||
|
successCallback(response);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.fail(function (jqXHR, textStatus, errorThrown) {
|
||||||
|
GeneralFunctions.ajaxFailureHandler(jqXHR, textStatus, errorThrown);
|
||||||
|
|
||||||
|
if (errorCallback) {
|
||||||
|
errorCallback();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
})(window.BackendCalendarApi);
|
})(window.BackendCalendarApi);
|
||||||
|
|
Loading…
Reference in a new issue