zettapi_client
Version:
Admin panel and client-side CRUD operations in angular to use with zettapi_server rest api to get started quickly in any CMS project.
31 lines (30 loc) • 903 B
JavaScript
app.directive('entityRemove', function () {
return {
restrict: 'E',
scope: {
entity: "@",
item: "="
},
transclude: true,
templateUrl: 'directives/entity/entity.remove.html',
controller: function ($scope, $rootScope, $entity, zapi) {
var entityObj = zapi.entityMap[$scope.entity];
if (!entityObj) return;
$scope.remove = function (entity, item) {
swal({
title: "Esta ação é irreversível",
type: "info",
text: "Está prestes a apanhar um registo, deseja continuar?",
showCancelButton: true,
cancelButtonText: "Cancelar",
confirmButtonText: "OK"
}).then(function (result) {
if (result && result.dismiss) return;
$entity.remove(entity, item, $scope);
}).catch(function (err) {
console.error(err);
});
};
}
};
});