Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

pkguid.controller.js 3.5KB

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(AppUtilsBusiness.tr('common.confirmDelete'))
  26. .textContent(AppUtilsBusiness.tr('pkguid.deleteOne', {text: pkguid.someText}))
  27. .ok(AppUtilsBusiness.tr('common.delete'))
  28. .cancel(AppUtilsBusiness.tr('common.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(AppUtilsBusiness.tr('common.confirmDelete'))
  43. .textContent(AppUtilsBusiness.tr('pkguid.deleteMultiple', {count: $scope.selected.length}))
  44. .ok(AppUtilsBusiness.tr('common.delete'))
  45. .cancel(AppUtilsBusiness.tr('common.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. }]);