From deb8f578bddf30e3e4f00784aff05b1ffddb5f9e Mon Sep 17 00:00:00 2001 From: ThieryMichel Date: Mon, 30 Mar 2015 11:47:09 +0200 Subject: [PATCH] add batchDelete view --- src/javascripts/ng-admin/Crud/CrudModule.js | 2 ++ .../Crud/batchDelete/BatchDeleteController.js | 33 +++++++++++++++++++ .../Crud/batchDelete/batchDelete.html | 32 ++++++++++++++++++ .../Crud/button/maBatchDeleteButton.js | 30 +++++++++++++++++ src/javascripts/ng-admin/Crud/list/list.html | 2 +- .../Crud/misc/view-batch-actions.html | 2 +- src/javascripts/ng-admin/Crud/routing.js | 22 ++++++++++++- .../ng-admin/es6/lib/Entity/Entity.js | 10 ++++++ .../ng-admin/es6/lib/View/BatchDeleteView.js | 11 +++++++ 9 files changed, 141 insertions(+), 3 deletions(-) create mode 100644 src/javascripts/ng-admin/Crud/batchDelete/BatchDeleteController.js create mode 100644 src/javascripts/ng-admin/Crud/batchDelete/batchDelete.html create mode 100644 src/javascripts/ng-admin/Crud/button/maBatchDeleteButton.js create mode 100644 src/javascripts/ng-admin/es6/lib/View/BatchDeleteView.js diff --git a/src/javascripts/ng-admin/Crud/CrudModule.js b/src/javascripts/ng-admin/Crud/CrudModule.js index fd7ce3d8..e41a7775 100644 --- a/src/javascripts/ng-admin/Crud/CrudModule.js +++ b/src/javascripts/ng-admin/Crud/CrudModule.js @@ -24,6 +24,7 @@ define(function (require) { CrudModule.controller('ShowController', require('ng-admin/Crud/show/ShowController')); CrudModule.controller('FormController', require('ng-admin/Crud/form/FormController')); CrudModule.controller('DeleteController', require('ng-admin/Crud/delete/DeleteController')); + CrudModule.controller('BatchDeleteController', require('ng-admin/Crud/batchDelete/BatchDeleteController')); CrudModule.service('RetrieveQueries', require('ng-admin/Crud/repository/RetrieveQueries')); CrudModule.service('CreateQueries', require('ng-admin/Crud/repository/CreateQueries')); @@ -74,6 +75,7 @@ define(function (require) { CrudModule.directive('maShowButton', require('ng-admin/Crud/button/maShowButton')); CrudModule.directive('maListButton', require('ng-admin/Crud/button/maListButton')); CrudModule.directive('maDeleteButton', require('ng-admin/Crud/button/maDeleteButton')); + CrudModule.directive('maBatchDeleteButton', require('ng-admin/Crud/button/maBatchDeleteButton')); CrudModule.directive('maViewActions', require('ng-admin/Crud/misc/ViewActions')); CrudModule.directive('maViewBatchActions', require('ng-admin/Crud/misc/ViewBatchActions')); diff --git a/src/javascripts/ng-admin/Crud/batchDelete/BatchDeleteController.js b/src/javascripts/ng-admin/Crud/batchDelete/BatchDeleteController.js new file mode 100644 index 00000000..0d265722 --- /dev/null +++ b/src/javascripts/ng-admin/Crud/batchDelete/BatchDeleteController.js @@ -0,0 +1,33 @@ +/*global define*/ + +define(function () { + 'use strict'; + + var BatchDeleteController = function ($scope, $stateParams, $filter, $anchorScroll, progression, view) { + this.$scope = $scope; + this.$stateParams = $stateParams; + this.$filter = $filter; + this.progression = progression; + this.view = view; + this.entity = view.getEntity(); + this.selection = $stateParams.selection; + this.title = view.title(); + this.description = view.description(); + this.actions = view.actions(); + this.loadingPage = false; + this.fields = this.$filter('orderElement')(view.fields()); + + $scope.$on('$destroy', this.destroy.bind(this)); + }; + + BatchDeleteController.prototype.destroy = function () { + this.$scope = undefined; + this.$stateParams = undefined; + this.$filter = undefined; + this.$anchorScroll = undefined; + }; + + BatchDeleteController.$inject = ['$scope', '$stateParams', '$filter', '$anchorScroll', 'progression', 'view']; + + return BatchDeleteController; +}); diff --git a/src/javascripts/ng-admin/Crud/batchDelete/batchDelete.html b/src/javascripts/ng-admin/Crud/batchDelete/batchDelete.html new file mode 100644 index 00000000..97b24ba8 --- /dev/null +++ b/src/javascripts/ng-admin/Crud/batchDelete/batchDelete.html @@ -0,0 +1,32 @@ +
+
+ + + + + + +
+
+ +
+
+

Are you sure ?

+ + +
+
+ +
+
+ + +
+
diff --git a/src/javascripts/ng-admin/Crud/button/maBatchDeleteButton.js b/src/javascripts/ng-admin/Crud/button/maBatchDeleteButton.js new file mode 100644 index 00000000..605348e3 --- /dev/null +++ b/src/javascripts/ng-admin/Crud/button/maBatchDeleteButton.js @@ -0,0 +1,30 @@ +/*global define*/ + +define(function () { + 'use strict'; + + function maBatchDeleteButtonDirective($state) { + return { + restrict: 'E', + scope: { + 'entity': '&', + 'selection': '&', + }, + link: function ($scope) { + $scope.gotoBatchDelete = function () { + var entity = $scope.entity(); + $state.go('batchDelete', {selection: $scope.selection(), entity: entity.name()}); + }; + }, + template: +'' + + ' Delete' + +'' + + }; + } + + maBatchDeleteButtonDirective.$inject = ['$state']; + + return maBatchDeleteButtonDirective; +}); diff --git a/src/javascripts/ng-admin/Crud/list/list.html b/src/javascripts/ng-admin/Crud/list/list.html index a83e12c7..b4bfde06 100644 --- a/src/javascripts/ng-admin/Crud/list/list.html +++ b/src/javascripts/ng-admin/Crud/list/list.html @@ -4,7 +4,7 @@ - +