Added missing permission checkboxes and improved image AJAX permission responses

This commit is contained in:
Dan Brown
2016-02-27 20:52:46 +00:00
parent 473261be35
commit a14b5c33fd
4 changed files with 28 additions and 13 deletions

View File

@ -118,6 +118,7 @@ module.exports = function (ngApp, events) {
page++;
});
}
$scope.fetchData = fetchData;
/**
@ -130,12 +131,16 @@ module.exports = function (ngApp, events) {
$http.put(url, this.selectedImage).then((response) => {
events.emit('success', 'Image details updated');
}, (response) => {
var errors = response.data;
var message = '';
Object.keys(errors).forEach((key) => {
message += errors[key].join('\n');
});
events.emit('error', message);
if (response.status === 422) {
var errors = response.data;
var message = '';
Object.keys(errors).forEach((key) => {
message += errors[key].join('\n');
});
events.emit('error', message);
} else if (response.status === 403) {
events.emit('error', response.data.error);
}
});
};
@ -158,6 +163,8 @@ module.exports = function (ngApp, events) {
// Pages failure
if (response.status === 400) {
$scope.dependantPages = response.data;
} else if (response.status === 403) {
events.emit('error', response.data.error);
}
});
};
@ -167,7 +174,7 @@ module.exports = function (ngApp, events) {
* @param stringDate
* @returns {Date}
*/
$scope.getDate = function(stringDate) {
$scope.getDate = function (stringDate) {
return new Date(stringDate);
};