1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- angular.module('app')
- .controller('PkGuidController', ['$scope', 'pkGuidBusiness', 'AppUtilsBusiness', '$mdDialog',
- function($scope, pkGuidBusiness, AppUtilsBusiness, $mdDialog) {
-
- $scope.selected = [];
-
- $scope.query = {
- order: 'someText',
- filter: '',
- limit: 5,
- page: 1
- };
-
- $scope.isFilterShown = false;
- $scope.pkGuids = null;
- $scope.error = null;
-
- $scope.showFilter = function(show) {
- $scope.isFilterShown = show;
- if (!$scope.isFilterShown) {
- if ($scope.query.filter != '') {
- $scope.query.filter = '';
- $scope.getPkGuids();
- }
- }
- };
-
- $scope.askRemoveOne = function (pkguid) {
- var confirm = $mdDialog.confirm()
- .title('Confirm deletion')
- .textContent('Do you really want to delete PkGuid \'' + pkguid.someText + '\'?')
- .ok('Delete')
- .cancel('Cancel');
- $mdDialog.show(confirm).then(function() {
- $scope.error = null;
- $scope.promise = pkGuidBusiness.deleteDbo(pkguid.id).then(function(data)
- {
- $scope.getPkGuids();
- }, function(error)
- {
- $scope.error = error;
- });
- }, function () {});
- };
-
- $scope.askRemoveSelected = function () {
- var confirm = $mdDialog.confirm()
- .title('Confirm deletion')
- .textContent('Do you really want to delete ' + $scope.selected.length + ' PkGuid?')
- .ok('Delete')
- .cancel('Cancel');
- $mdDialog.show(confirm).then(function() {
- $scope.error = null;
- $scope.removeFirstSelected();
-
- }, function () {});
- };
-
- $scope.removeFirstSelected = function() {
- if ($scope.selected.length == 0) {
- $scope.getPkGuids();
- }
- else {
- $scope.promise = pkGuidBusiness.deleteDbo($scope.selected[0].id)
- .then(function(data)
- {
- $scope.selected = $scope.selected.splice(1);
- $scope.removeFirstSelected();
- }, function(error)
- {
- $scope.error = error;
- });
- }
- };
-
- $scope.getPkGuids = function()
- {
- $scope.error = null;
- $scope.selected = [];
- var orderBy = AppUtilsBusiness.convertOrderBy($scope.query.order);
- $scope.promise = pkGuidBusiness.getMultiple(orderBy, $scope.query.filter, $scope.query.page - 1, $scope.query.limit).then(function(data)
- {
- $scope.pkGuids = data;
- }, function(error)
- {
- $scope.pkGuids = null;
- $scope.error = error;
- });
- };
-
- $scope.getPkGuids();
- }]);
|