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 3.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. filter: '',
  8. limit: 5,
  9. page: 1
  10. };
  11. $scope.isFilterShown = false;
  12. $scope.pkGuids = null;
  13. $scope.error = null;
  14. $scope.showFilter = function(show) {
  15. $scope.isFilterShown = show;
  16. if (!$scope.isFilterShown) {
  17. if ($scope.query.filter != '') {
  18. $scope.query.filter = '';
  19. $scope.getPkGuids();
  20. }
  21. }
  22. };
  23. $scope.askRemoveOne = function (pkguid) {
  24. var confirm = $mdDialog.confirm()
  25. .title('Confirm deletion')
  26. .textContent('Do you really want to delete PkGuid \'' + pkguid.someText + '\'?')
  27. .ok('Delete')
  28. .cancel('Cancel');
  29. $mdDialog.show(confirm).then(function() {
  30. $scope.error = null;
  31. $scope.promise = pkGuidBusiness.deleteDbo(pkguid.id).then(function(data)
  32. {
  33. $scope.getPkGuids();
  34. }, function(error)
  35. {
  36. $scope.error = error;
  37. });
  38. }, function () {});
  39. };
  40. $scope.askRemoveSelected = function () {
  41. var confirm = $mdDialog.confirm()
  42. .title('Confirm deletion')
  43. .textContent('Do you really want to delete ' + $scope.selected.length + ' PkGuid?')
  44. .ok('Delete')
  45. .cancel('Cancel');
  46. $mdDialog.show(confirm).then(function() {
  47. $scope.error = null;
  48. $scope.removeFirstSelected();
  49. }, function () {});
  50. };
  51. $scope.removeFirstSelected = function() {
  52. if ($scope.selected.length == 0) {
  53. $scope.getPkGuids();
  54. }
  55. else {
  56. $scope.promise = pkGuidBusiness.deleteDbo($scope.selected[0].id)
  57. .then(function(data)
  58. {
  59. $scope.selected = $scope.selected.splice(1);
  60. $scope.removeFirstSelected();
  61. }, function(error)
  62. {
  63. $scope.error = error;
  64. });
  65. }
  66. };
  67. $scope.getPkGuids = function()
  68. {
  69. $scope.error = null;
  70. $scope.selected = [];
  71. var orderBy = AppUtilsBusiness.convertOrderBy($scope.query.order);
  72. $scope.promise = pkGuidBusiness.getMultiple(orderBy, $scope.query.filter, $scope.query.page - 1, $scope.query.limit).then(function(data)
  73. {
  74. $scope.pkGuids = data;
  75. }, function(error)
  76. {
  77. $scope.pkGuids = null;
  78. $scope.error = error;
  79. });
  80. };
  81. $scope.getPkGuids();
  82. }]);