32 lines
972 B
JavaScript
32 lines
972 B
JavaScript
angular.module("mediaModal")
|
|
.controller('FileDestroyController', [
|
|
'$scope', '$http', 'upload_url',
|
|
function ($scope, $http, upload_url) {
|
|
var file = $scope.file,
|
|
state;
|
|
if (file.url) {
|
|
file.$state = function () {
|
|
return state;
|
|
};
|
|
file.$destroy = function () {
|
|
state = 'pending';
|
|
return $http({
|
|
url: file.deleteUrl,
|
|
method: file.deleteType
|
|
}).then(
|
|
function () {
|
|
state = 'resolved';
|
|
$scope.clear(file);
|
|
},
|
|
function () {
|
|
state = 'rejected';
|
|
}
|
|
);
|
|
};
|
|
} else if (!file.$cancel && !file._index) {
|
|
file.$cancel = function () {
|
|
$scope.clear(file);
|
|
};
|
|
}
|
|
}
|
|
]); |