电子档案
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.

288 lines
10 KiB

  1. /* Licensed under the Apache License, Version 2.0 (the "License");
  2. * you may not use this file except in compliance with the License.
  3. * You may obtain a copy of the License at
  4. *
  5. * http://www.apache.org/licenses/LICENSE-2.0
  6. *
  7. * Unless required by applicable law or agreed to in writing, software
  8. * distributed under the License is distributed on an "AS IS" BASIS,
  9. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. * See the License for the specific language governing permissions and
  11. * limitations under the License.
  12. */
  13. 'use strict';
  14. angular.module('flowableModeler')
  15. .controller('EditModelPopupCtrl', ['$rootScope', '$scope', '$http', '$translate', '$location',
  16. function ($rootScope, $scope, $http, $translate, $location) {
  17. var model;
  18. var popupType;
  19. if ($scope.model.process) {
  20. model = $scope.model.process;
  21. popupType = 'PROCESS';
  22. } else if ($scope.model.caseModel) {
  23. model = $scope.model.caseModel;
  24. popupType = 'CASE';
  25. } else if ($scope.model.form) {
  26. model = $scope.model.form;
  27. popupType = 'FORM';
  28. } else if ($scope.model.decisionTable) {
  29. model = $scope.model.decisionTable;
  30. popupType = 'DECISION-TABLE';
  31. } else if ($scope.model.decisionService) {
  32. model = $scope.model.decisionService;
  33. popupType = 'DECISION-SERVICE';
  34. } else {
  35. model = $scope.model.app;
  36. popupType = 'APP';
  37. }
  38. $scope.popup = {
  39. loading: false,
  40. popupType: popupType,
  41. modelName: model.name,
  42. modelKey: model.key,
  43. modelDescription: model.description,
  44. id: model.id
  45. };
  46. $scope.ok = function () {
  47. if (!$scope.popup.modelName || $scope.popup.modelName.length == 0 ||
  48. !$scope.popup.modelKey || $scope.popup.modelKey.length == 0) {
  49. return;
  50. }
  51. $scope.model.name = $scope.popup.modelName;
  52. $scope.model.key = $scope.popup.modelKey;
  53. $scope.model.description = $scope.popup.modelDescription;
  54. $scope.popup.loading = true;
  55. var updateData = {
  56. name: $scope.model.name,
  57. key: $scope.model.key, description:
  58. $scope.model.description
  59. };
  60. $http({method: 'PUT', url: FLOWABLE.APP_URL.getModelUrl($scope.popup.id), data: updateData}).
  61. success(function(data, status, headers, config) {
  62. if ($scope.model.process) {
  63. $scope.model.process = data;
  64. } else if ($scope.model.caseModel) {
  65. $scope.model.caseModel = data;
  66. } else if ($scope.model.form) {
  67. $scope.model.form = data;
  68. } else if ($scope.model.decisionTable) {
  69. $scope.model.decisionTable = data;
  70. } else if ($scope.model.decisionService) {
  71. $scope.model.decisionService = data;
  72. } else {
  73. $scope.model.app = data;
  74. }
  75. $scope.addAlertPromise($translate('PROCESS.ALERT.EDIT-CONFIRM'), 'info');
  76. $scope.$hide();
  77. $scope.popup.loading = false;
  78. if (popupType === 'FORM') {
  79. $location.path("/forms/" + $scope.popup.id);
  80. } else if (popupType === 'APP') {
  81. $location.path("/apps/" + $scope.popup.id);
  82. } else if (popupType === 'DECISION-TABLE') {
  83. $location.path("/decision-tables/" + $scope.popup.id);
  84. } else if (popupType === 'CASE') {
  85. $location.path("/casemodels/" + $scope.popup.id);
  86. } else if (popupType === 'DECISION-SERVICE') {
  87. $location.path("/decision-services/" + $scope.popup.id);
  88. } else {
  89. $location.path("/processes/" + $scope.popup.id);
  90. }
  91. }).
  92. error(function(data, status, headers, config) {
  93. $scope.popup.loading = false;
  94. $scope.popup.errorMessage = data.message;
  95. });
  96. };
  97. $scope.cancel = function () {
  98. if (!$scope.popup.loading) {
  99. $scope.$hide();
  100. }
  101. };
  102. }]);
  103. angular.module('flowableModeler')
  104. .controller('DeleteModelPopupCtrl', ['$rootScope', '$scope', '$http', '$translate', function ($rootScope, $scope, $http, $translate) {
  105. var model;
  106. var popupType;
  107. if ($scope.model.process) {
  108. model = $scope.model.process;
  109. popupType = 'PROCESS';
  110. } else if ($scope.model.caseModel) {
  111. model = $scope.model.caseModel;
  112. popupType = 'CASE';
  113. } else if ($scope.model.form) {
  114. model = $scope.model.form;
  115. popupType = 'FORM';
  116. } else if ($scope.model.decisionTable) {
  117. model = $scope.model.decisionTable;
  118. popupType = 'DECISION-TABLE';
  119. } else if ($scope.model.decisionService) {
  120. model = $scope.model.decisionService;
  121. popupType = 'DECISION-SERVICE';
  122. } else {
  123. model = $scope.model.app;
  124. popupType = 'APP';
  125. }
  126. $scope.popup = {
  127. loading: true,
  128. loadingRelations: true,
  129. cascade: 'false',
  130. popupType: popupType,
  131. model: model
  132. };
  133. // Loading relations when opening
  134. $http({method: 'GET', url: FLOWABLE.APP_URL.getModelParentRelationsUrl($scope.popup.model.id)}).
  135. success(function (data, status, headers, config) {
  136. $scope.popup.loading = false;
  137. $scope.popup.loadingRelations = false;
  138. $scope.popup.relations = data;
  139. }).
  140. error(function (data, status, headers, config) {
  141. $scope.$hide();
  142. $scope.popup.loading = false;
  143. });
  144. $scope.ok = function () {
  145. $scope.popup.loading = true;
  146. var params = {
  147. // Explicit string-check because radio-values cannot be js-booleans
  148. cascade: $scope.popup.cascade === 'true'
  149. };
  150. $http({method: 'DELETE', url: FLOWABLE.APP_URL.getModelUrl($scope.popup.model.id), params: params}).
  151. success(function (data, status, headers, config) {
  152. $scope.$hide();
  153. $scope.popup.loading = false;
  154. $scope.addAlertPromise($translate(popupType + '.ALERT.DELETE-CONFIRM'), 'info');
  155. $scope.returnToList();
  156. }).
  157. error(function (data, status, headers, config) {
  158. $scope.$hide();
  159. $scope.popup.loading = false;
  160. });
  161. };
  162. $scope.cancel = function () {
  163. if (!$scope.popup.loading) {
  164. $scope.$hide();
  165. }
  166. };
  167. }]);
  168. angular.module('flowableModeler')
  169. .controller('UseAsNewVersionPopupCtrl', ['$rootScope', '$scope', '$http', '$translate', '$location', function ($rootScope, $scope, $http, $translate, $location) {
  170. var model;
  171. var popupType;
  172. if ($scope.model.process) {
  173. model = $scope.model.process;
  174. popupType = 'PROCESS';
  175. } else if ($scope.model.caseModel) {
  176. model = $scope.model.caseModel;
  177. popupType = 'CASE';
  178. } else if ($scope.model.form) {
  179. model = $scope.model.form;
  180. popupType = 'FORM';
  181. } else if ($scope.model.decisionTable) {
  182. model = $scope.model.decisionTable;
  183. popupType = 'DECISION-TABLE';
  184. } else if ($scope.model.decisionService) {
  185. model = $scope.model.decisionService;
  186. popupType = 'DECISION-SERVICE';
  187. } else {
  188. model = $scope.model.app;
  189. popupType = 'APP';
  190. }
  191. $scope.popup = {
  192. loading: false,
  193. model: model,
  194. popupType: popupType,
  195. latestModelId: $scope.model.latestModelId,
  196. comment: ''
  197. };
  198. $scope.ok = function () {
  199. $scope.popup.loading = true;
  200. var actionData = {
  201. action: 'useAsNewVersion',
  202. comment: $scope.popup.comment
  203. };
  204. $http({method: 'POST', url: FLOWABLE.APP_URL.getModelHistoryUrl($scope.popup.latestModelId, $scope.popup.model.id), data: actionData}).
  205. success(function(data, status, headers, config) {
  206. var backToOverview = function() {
  207. if (popupType === 'FORM') {
  208. $location.path("/forms/" + $scope.popup.latestModelId);
  209. } else if (popupType === 'APP') {
  210. $location.path("/apps/" + $scope.popup.latestModelId);
  211. } else if (popupType === 'DECISION-TABLE') {
  212. $location.path("/decision-tables/" + $scope.popup.latestModelId);
  213. } else if (popupType === 'DECISION-SERVICE') {
  214. $location.path("/decision-services/" + $scope.popup.latestModelId);
  215. } else if (popupType === 'CASE') {
  216. $location.path("/casemodels/" + $scope.popup.latestModelId);
  217. } else {
  218. $location.path("/processes/" + $scope.popup.latestModelId);
  219. }
  220. };
  221. if (data && data.unresolvedModels && data.unresolvedModels.length > 0) {
  222. // There were unresolved models
  223. $scope.popup.loading = false;
  224. $scope.popup.foundUnresolvedModels = true;
  225. $scope.popup.unresolvedModels = data.unresolvedModels;
  226. $scope.close = function() {
  227. $scope.$hide();
  228. backToOverview();
  229. };
  230. } else {
  231. // All models working resolved perfectly
  232. $scope.popup.loading = false;
  233. $scope.$hide();
  234. $scope.addAlertPromise($translate(popupType + '.ALERT.NEW-VERSION-CONFIRM'), 'info');
  235. backToOverview();
  236. }
  237. }).
  238. error(function(data, status, headers, config) {
  239. $scope.$hide();
  240. $scope.popup.loading = false;
  241. });
  242. };
  243. $scope.cancel = function () {
  244. if (!$scope.popup.loading) {
  245. $scope.$hide();
  246. }
  247. };
  248. }]);