- $scope.deleteImage = function(event) {
- event.preventDefault();
- var force = $scope.dependantPages !== false;
- var url = '/images/' + $scope.selectedImage.id;
- if (force) url += '?force=true';
- $http.delete(url).then((response) => {
- $scope.images.splice($scope.images.indexOf($scope.selectedImage), 1);
- $scope.selectedImage = false;
- $scope.imageDeleteSuccess = true;
- $timeout(() => {
- $scope.imageDeleteSuccess = false;
- }, 3000);
- }, (response) => {
- // Pages failure
- if (response.status === 400) {
- $scope.dependantPages = response.data;
- }
- });
- };
+ $scope.saveImageDetails = function (event) {
+ event.preventDefault();
+ var url = '/images/update/' + $scope.selectedImage.id;
+ $http.put(url, this.selectedImage).then((response) => {
+ $scope.imageUpdateSuccess = true;
+ $timeout(() => {
+ $scope.imageUpdateSuccess = false;
+ }, 3000);
+ }, (response) => {
+ var errors = response.data;
+ var message = '';
+ Object.keys(errors).forEach((key) => {
+ message += errors[key].join('\n');
+ });
+ $scope.imageUpdateFailure = message;
+ $timeout(() => {
+ $scope.imageUpdateFailure = false;
+ }, 5000);
+ });
+ };
+
+ $scope.deleteImage = function (event) {
+ event.preventDefault();
+ var force = $scope.dependantPages !== false;
+ var url = '/images/' + $scope.selectedImage.id;
+ if (force) url += '?force=true';
+ $http.delete(url).then((response) => {
+ $scope.images.splice($scope.images.indexOf($scope.selectedImage), 1);
+ $scope.selectedImage = false;
+ $scope.imageDeleteSuccess = true;
+ $timeout(() => {
+ $scope.imageDeleteSuccess = false;
+ }, 3000);
+ }, (response) => {
+ // Pages failure
+ if (response.status === 400) {
+ $scope.dependantPages = response.data;
+ }
+ });
+ };