Digital Office Automation System Backend
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

properties-assignment-controller.js 4.6KB

il y a 1 jour
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * Activiti Modeler component part of the Activiti project
  3. * Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. /*
  19. * Assignment
  20. */
  21. var KisBpmAssignmentCtrl = [ '$scope', '$modal', function($scope, $modal) {
  22. // Config for the modal window
  23. var opts = {
  24. template: 'editor-app/configuration/properties/assignment-popup.html?version=' + Date.now(),
  25. scope: $scope
  26. };
  27. // Open the dialog
  28. $modal(opts);
  29. }];
  30. var KisBpmAssignmentPopupCtrl = [ '$scope', function($scope) {
  31. // Put json representing assignment on scope
  32. if ($scope.property.value !== undefined && $scope.property.value !== null
  33. && $scope.property.value.assignment !== undefined
  34. && $scope.property.value.assignment !== null)
  35. {
  36. $scope.assignment = $scope.property.value.assignment;
  37. } else {
  38. $scope.assignment = {};
  39. }
  40. if ($scope.assignment.candidateUsers == undefined || $scope.assignment.candidateUsers.length == 0)
  41. {
  42. $scope.assignment.candidateUsers = [{value: ''}];
  43. }
  44. // Click handler for + button after enum value
  45. var userValueIndex = 1;
  46. $scope.addCandidateUserValue = function(index) {
  47. $scope.assignment.candidateUsers.splice(index + 1, 0, {value: 'value ' + userValueIndex++});
  48. };
  49. // Click handler for - button after enum value
  50. $scope.removeCandidateUserValue = function(index) {
  51. $scope.assignment.candidateUsers.splice(index, 1);
  52. };
  53. if ($scope.assignment.candidateGroups == undefined || $scope.assignment.candidateGroups.length == 0)
  54. {
  55. $scope.assignment.candidateGroups = [{value: ''}];
  56. }
  57. var groupValueIndex = 1;
  58. $scope.addCandidateGroupValue = function(index) {
  59. $scope.assignment.candidateGroups.splice(index + 1, 0, {value: 'value ' + groupValueIndex++});
  60. };
  61. // Click handler for - button after enum value
  62. $scope.removeCandidateGroupValue = function(index) {
  63. $scope.assignment.candidateGroups.splice(index, 1);
  64. };
  65. $scope.save = function() {
  66. $scope.property.value = {};
  67. handleAssignmentInput($scope);
  68. $scope.property.value.assignment = $scope.assignment;
  69. $scope.updatePropertyInModel($scope.property);
  70. $scope.close();
  71. };
  72. // Close button handler
  73. $scope.close = function() {
  74. handleAssignmentInput($scope);
  75. $scope.property.mode = 'read';
  76. $scope.$hide();
  77. };
  78. var handleAssignmentInput = function($scope) {
  79. if ($scope.assignment.candidateUsers)
  80. {
  81. var emptyUsers = true;
  82. var toRemoveIndexes = [];
  83. for (var i = 0; i < $scope.assignment.candidateUsers.length; i++)
  84. {
  85. if ($scope.assignment.candidateUsers[i].value != '')
  86. {
  87. emptyUsers = false;
  88. }
  89. else
  90. {
  91. toRemoveIndexes[toRemoveIndexes.length] = i;
  92. }
  93. }
  94. for (var i = 0; i < toRemoveIndexes.length; i++)
  95. {
  96. $scope.assignment.candidateUsers.splice(toRemoveIndexes[i], 1);
  97. }
  98. if (emptyUsers)
  99. {
  100. $scope.assignment.candidateUsers = undefined;
  101. }
  102. }
  103. if ($scope.assignment.candidateGroups)
  104. {
  105. var emptyGroups = true;
  106. var toRemoveIndexes = [];
  107. for (var i = 0; i < $scope.assignment.candidateGroups.length; i++)
  108. {
  109. if ($scope.assignment.candidateGroups[i].value != '')
  110. {
  111. emptyGroups = false;
  112. }
  113. else
  114. {
  115. toRemoveIndexes[toRemoveIndexes.length] = i;
  116. }
  117. }
  118. for (var i = 0; i < toRemoveIndexes.length; i++)
  119. {
  120. $scope.assignment.candidateGroups.splice(toRemoveIndexes[i], 1);
  121. }
  122. if (emptyGroups)
  123. {
  124. $scope.assignment.candidateGroups = undefined;
  125. }
  126. }
  127. };
  128. }];