You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pkguid.controller.js 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. angular.module('app')
  2. .controller('PkGuidController', ['$scope', 'pkGuidBusiness', 'AppUtilsBusiness', '$mdDialog',
  3. function($scope, pkGuidBusiness, AppUtilsBusiness, $mdDialog) {
  4. $scope.selected = [];
  5. $scope.query = {
  6. order: 'someText',
  7. limit: 5,
  8. page: 1
  9. };
  10. $scope.pkGuids = null;
  11. $scope.error = null;
  12. $scope.askRemoveOne = function (pkguid) {
  13. var confirm = $mdDialog.confirm()
  14. .title('Confirm deletion')
  15. .textContent('Do you really want to delete PkGuid \'' + pkguid.someText + '\'?')
  16. .ok('Delete')
  17. .cancel('Cancel');
  18. $mdDialog.show(confirm).then(function() {
  19. $scope.error = null;
  20. $scope.promise = pkGuidBusiness.deleteDbo(pkguid.id).then(function(data)
  21. {
  22. $scope.getPkGuids();
  23. }, function(error)
  24. {
  25. $scope.error = error;
  26. });
  27. }, function () {});
  28. };
  29. $scope.askRemoveSelected = function () {
  30. var confirm = $mdDialog.confirm()
  31. .title('Confirm deletion')
  32. .textContent('Do you really want to delete ' + $scope.selected.length + ' PkGuids?')
  33. .ok('Delete')
  34. .cancel('Cancel');
  35. $mdDialog.show(confirm).then(function() {
  36. $scope.error = null;
  37. $scope.removeFirstSelected();
  38. }, function () {});
  39. };
  40. $scope.removeFirstSelected = function() {
  41. if ($scope.selected.length == 0) {
  42. $scope.getPkGuids();
  43. }
  44. else {
  45. pkGuidBusiness.deleteDbo($scope.selected[0].id)
  46. .then(function(data)
  47. {
  48. $scope.selected = $scope.selected.splice(1);
  49. $scope.removeFirstSelected();
  50. }, function(error)
  51. {
  52. $scope.error = error;
  53. });
  54. }
  55. };
  56. $scope.getPkGuids = function()
  57. {
  58. $scope.error = null;
  59. $scope.selected = [];
  60. var orderBy = AppUtilsBusiness.convertOrderBy($scope.query.order);
  61. $scope.promise = pkGuidBusiness.getMultiple(orderBy, $scope.query.page - 1, $scope.query.limit).then(function(data)
  62. {
  63. $scope.pkGuids = data;
  64. }, function(error)
  65. {
  66. $scope.pkGuids = null;
  67. $scope.error = error;
  68. });
  69. };
  70. $scope.getPkGuids();
  71. }]);