BigW Consortium Gitlab

Commit 725a4fef by Jacob Schatz Committed by Mike Greiling

Add thenable ajax calls.

parent 91d3e6d9
......@@ -99,15 +99,13 @@ const Api = {
commitMultiple(id, data, callback) {
const url = Api.buildUrl(Api.commitPath)
.replace(':id', id);
return $.ajax({
return this.wrapAjaxCall({
url,
type: 'POST',
contentType: 'application/json; charset=utf-8',
data: JSON.stringify(data),
dataType: 'json',
})
.done(commitData => callback(commitData))
.fail(message => callback(message.responseJSON));
});
},
// Return text for a specific license
......
......@@ -42,10 +42,11 @@ export default {
actions,
};
Store.submitCommitsLoading = true;
Service.commitFiles(payload, this.resetCommitState);
Service.commitFiles(payload)
.then(this.resetCommitState);
},
resetCommitState() {
resetCommitState(data) {
this.submitCommitsLoading = false;
this.changedFiles = [];
this.commitMessage = '';
......
......@@ -65,14 +65,14 @@ const RepoService = {
return urlArray.join('/');
},
commitFiles(payload, cb) {
Api.commitMultiple(Store.projectId, payload, (data) => {
commitFiles(payload) {
return Api.commitMultiple(Store.projectId, payload)
.then((data) => {
if (data.short_id && data.stats) {
Flash(`Your changes have been committed. Commit ${data.short_id} with ${data.stats.additions} additions, ${data.stats.deletions} deletions.`, 'notice');
} else {
Flash(data.message);
}
cb();
});
},
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment