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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. angular.module('app')
  2. .controller('PkGuidController', ['$scope', 'pkGuidBusiness', 'AppUtilsBusiness', '$mdDialog', 'luBusyBusiness',
  3. function($scope, pkGuidBusiness, AppUtilsBusiness, $mdDialog, luBusyBusiness) {
  4. $scope.selected = [];
  5. $scope.query = {
  6. order: 'someText',
  7. filter: '',
  8. limit: 5,
  9. page: 1
  10. };
  11. $scope.busy = luBusyBusiness.reset();
  12. $scope.appUtils = AppUtilsBusiness;
  13. $scope.isFilterShown = false;
  14. $scope.pkGuids = null;
  15. $scope.showFilter = function(show) {
  16. $scope.isFilterShown = show;
  17. if (!$scope.isFilterShown) {
  18. if ($scope.query.filter != '') {
  19. $scope.query.filter = '';
  20. $scope.getPkGuids();
  21. }
  22. }
  23. };
  24. $scope.askRemoveOne = function (pkguid) {
  25. var confirm = $mdDialog.confirm()
  26. .title(AppUtilsBusiness.tr('common.confirmDelete'))
  27. .textContent(AppUtilsBusiness.tr('pkguid.deleteOne', {text: pkguid.someText}))
  28. .ok(AppUtilsBusiness.tr('common.delete'))
  29. .cancel(AppUtilsBusiness.tr('common.cancel'));
  30. $mdDialog.show(confirm).then(function() {
  31. pkGuidBusiness.deleteDbo(pkguid.id, 'pkguid.table').then(function(data)
  32. {
  33. $scope.getPkGuids();
  34. }, function(error) {});
  35. }, function () {});
  36. };
  37. $scope.askRemoveSelected = function () {
  38. var confirm = $mdDialog.confirm()
  39. .title(AppUtilsBusiness.tr('common.confirmDelete'))
  40. .textContent(AppUtilsBusiness.tr('pkguid.deleteMultiple', {count: $scope.selected.length}))
  41. .ok(AppUtilsBusiness.tr('common.delete'))
  42. .cancel(AppUtilsBusiness.tr('common.cancel'));
  43. $mdDialog.show(confirm).then(function() {
  44. $scope.removeFirstSelected();
  45. }, function () {});
  46. };
  47. $scope.removeFirstSelected = function() {
  48. if ($scope.selected.length == 0) {
  49. $scope.getPkGuids();
  50. }
  51. else {
  52. pkGuidBusiness.deleteDbo($scope.selected[0].id, 'pkguid.table')
  53. .then(function(data)
  54. {
  55. $scope.selected = $scope.selected.splice(1);
  56. $scope.removeFirstSelected();
  57. }, function(error) {});
  58. }
  59. };
  60. $scope.getPkGuids = function()
  61. {
  62. $scope.selected = [];
  63. var orderBy = AppUtilsBusiness.convertOrderBy($scope.query.order);
  64. pkGuidBusiness.getMultiple(orderBy, $scope.query.filter, $scope.query.page - 1, $scope.query.limit, 'pkguid.table').then(function(data)
  65. {
  66. $scope.pkGuids = data;
  67. }, function(error)
  68. {
  69. $scope.pkGuids = null;
  70. });
  71. };
  72. $scope.getPkGuids();
  73. }]);