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

325 lines
13 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. angular.module('flowableModeler')
  14. .controller('AppDefinitionBuilderController', ['$rootScope', '$scope', '$translate', '$http', '$location', '$routeParams', '$modal', '$popover', '$timeout',
  15. function ($rootScope, $scope, $translate, $http, $location, $routeParams, $modal, $popover, $timeout) {
  16. // Main page (needed for visual indicator of current page)
  17. $rootScope.setMainPageById('apps');
  18. // Initialize model
  19. $scope.model = {
  20. // Store the main model id, this points to the current version of a model,
  21. // even when we're showing history
  22. latestModelId: $routeParams.modelId
  23. };
  24. $scope.appBuilder = {
  25. activeTab: 'bpmn'
  26. };
  27. $scope.tabs = [
  28. {
  29. id: 'bpmn',
  30. title: 'BPMN models'
  31. },
  32. {
  33. id: 'cmmn',
  34. title: 'CMMN models'
  35. }
  36. ];
  37. $scope.loadApp = function() {
  38. $http({method: 'GET', url: FLOWABLE.APP_URL.getAppDefinitionUrl($routeParams.modelId)}).
  39. success(function(data, status, headers, config) {
  40. $rootScope.currentAppDefinition = data;
  41. if (!$rootScope.currentAppDefinition.definition.theme) {
  42. $rootScope.currentAppDefinition.definition.theme = 'theme-1';
  43. }
  44. if (!$rootScope.currentAppDefinition.definition.icon) {
  45. $rootScope.currentAppDefinition.definition.icon = 'glyphicon-asterisk';
  46. }
  47. }).error(function(data, status, headers, config) {
  48. console.log("Error loading model");
  49. });
  50. };
  51. // Cleanup app definition on rootscope when scope is destroyed
  52. $scope.$on('$destroy', function() {
  53. $rootScope.currentAppDefinition = undefined;
  54. });
  55. $scope.editIncludedModels = function() {
  56. _internalCreateModal({
  57. template: 'views/popup/app-definition-models-included.html?version=' + Date.now(),
  58. scope: $scope
  59. }, $modal, $scope);
  60. };
  61. $scope.availableIcons = [
  62. 'glyphicon-asterisk', 'glyphicon-plus',
  63. 'glyphicon-euro', 'glyphicon-cloud', 'glyphicon-envelope',
  64. 'glyphicon-pencil', 'glyphicon-glass', 'glyphicon-music',
  65. 'glyphicon-search', 'glyphicon-heart', 'glyphicon-star',
  66. 'glyphicon-star-empty', 'glyphicon-user', 'glyphicon-film',
  67. 'glyphicon-th-large', 'glyphicon-th', 'glyphicon-th-list',
  68. 'glyphicon-ok', 'glyphicon-remove', 'glyphicon-zoom-in',
  69. 'glyphicon-zoom-out', 'glyphicon-off', 'glyphicon-signal',
  70. 'glyphicon-cog', 'glyphicon-trash', 'glyphicon-home',
  71. 'glyphicon-file', 'glyphicon-time', 'glyphicon-road',
  72. 'glyphicon-download-alt', 'glyphicon-download',
  73. 'glyphicon-upload', 'glyphicon-inbox', 'glyphicon-play-circle',
  74. 'glyphicon-repeat', 'glyphicon-refresh', 'glyphicon-list-alt',
  75. 'glyphicon-lock', 'glyphicon-flag', 'glyphicon-headphones',
  76. 'glyphicon-volume-up', 'glyphicon-tag', 'glyphicon-tags',
  77. 'glyphicon-book', 'glyphicon-bookmark', 'glyphicon-print',
  78. 'glyphicon-camera', 'glyphicon-list', 'glyphicon-facetime-video',
  79. 'glyphicon-picture', 'glyphicon-map-marker', 'glyphicon-adjust',
  80. 'glyphicon-tint', 'glyphicon-edit', 'glyphicon-share',
  81. 'glyphicon-check', 'glyphicon-move', 'glyphicon-play',
  82. 'glyphicon-eject', 'glyphicon-plus-sign', 'glyphicon-minus-sign',
  83. 'glyphicon-remove-sign', 'glyphicon-ok-sign',
  84. 'glyphicon-question-sign', 'glyphicon-info-sign',
  85. 'glyphicon-screenshot', 'glyphicon-remove-circle',
  86. 'glyphicon-ok-circle', 'glyphicon-ban-circle',
  87. 'glyphicon-share-alt', 'glyphicon-exclamation-sign',
  88. 'glyphicon-gift', 'glyphicon-leaf', 'glyphicon-fire',
  89. 'glyphicon-eye-open', 'glyphicon-eye-close',
  90. 'glyphicon-warning-sign', 'glyphicon-plane',
  91. 'glyphicon-calendar', 'glyphicon-random', 'glyphicon-comment',
  92. 'glyphicon-magnet', 'glyphicon-retweet',
  93. 'glyphicon-shopping-cart', 'glyphicon-folder-close',
  94. 'glyphicon-folder-open', 'glyphicon-hdd', 'glyphicon-bullhorn',
  95. 'glyphicon-bell', 'glyphicon-certificate', 'glyphicon-thumbs-up',
  96. 'glyphicon-thumbs-down', 'glyphicon-hand-left',
  97. 'glyphicon-globe', 'glyphicon-wrench', 'glyphicon-tasks',
  98. 'glyphicon-filter', 'glyphicon-briefcase', 'glyphicon-dashboard',
  99. 'glyphicon-paperclip', 'glyphicon-heart-empty', 'glyphicon-link',
  100. 'glyphicon-phone', 'glyphicon-pushpin', 'glyphicon-usd',
  101. 'glyphicon-gbp', 'glyphicon-sort', 'glyphicon-flash',
  102. 'glyphicon-record', 'glyphicon-save', 'glyphicon-open',
  103. 'glyphicon-saved', 'glyphicon-send', 'glyphicon-floppy-disk',
  104. 'glyphicon-credit-card', 'glyphicon-cutlery',
  105. 'glyphicon-earphone', 'glyphicon-phone-alt', 'glyphicon-tower',
  106. 'glyphicon-stats', 'glyphicon-cloud-download',
  107. 'glyphicon-cloud-upload', 'glyphicon-tree-conifer',
  108. 'glyphicon-tree-deciduous'
  109. ];
  110. // TODO: add themes and perhaps have colors inside JS instead of different css-classes for each theme
  111. $scope.availableThemes = [
  112. 'theme-1', 'theme-2', 'theme-3',
  113. 'theme-4', 'theme-5', 'theme-6',
  114. 'theme-7', 'theme-8', 'theme-9',
  115. 'theme-10'
  116. ];
  117. $scope.changeIcon = function($event) {
  118. if (!$scope.changeIconState) {
  119. var state = {};
  120. $scope.changeIconState = state;
  121. // Create popover
  122. state.popover = $popover(angular.element($event.currentTarget), {
  123. template: 'views/popover/select-app-icon.html',
  124. placement: 'bottom-left',
  125. show: true,
  126. scope: $scope
  127. });
  128. var destroy = function() {
  129. state.popover.destroy();
  130. delete $scope.changeIconState;
  131. };
  132. // When popup is hidden or scope is destroyed, hide popup
  133. state.popover.$scope.$on('tooltip.hide', destroy);
  134. $scope.$on('$destroy', destroy);
  135. }
  136. };
  137. $scope.selectIcon = function(icon) {
  138. $rootScope.currentAppDefinition.definition.icon = icon;
  139. };
  140. $scope.changeTheme = function($event) {
  141. if(!$scope.changeThemeState) {
  142. var state = {};
  143. $scope.changeThemeState = state;
  144. // Create popover
  145. state.popover = $popover(angular.element($event.currentTarget), {
  146. template: 'views/popover/select-app-theme.html',
  147. placement: 'bottom-left',
  148. show: true,
  149. scope: $scope
  150. });
  151. var destroy = function() {
  152. state.popover.destroy();
  153. delete $scope.changeThemeState;
  154. };
  155. // When popup is hidden or scope is destroyed, hide popup
  156. state.popover.$scope.$on('tooltip.hide', destroy);
  157. $scope.$on('$destroy', destroy);
  158. }
  159. };
  160. $scope.selectTheme = function(theme) {
  161. $rootScope.currentAppDefinition.definition.theme = theme;
  162. };
  163. $scope.loadApp();
  164. }]);
  165. angular.module('flowableModeler')
  166. .controller('ModelsIncludedPopupCtrl', ['$rootScope', '$scope', '$translate', '$http', '$timeout', '$location', function ($rootScope, $scope, $translate, $http, $timeout, $location) {
  167. $scope.popup = {
  168. loading: false,
  169. selectedModels: [],
  170. selectedCmmnModels: [],
  171. activeTab: 'bpmn'
  172. };
  173. if ($rootScope.currentAppDefinition.definition.models) {
  174. for (var i = 0; i < $rootScope.currentAppDefinition.definition.models.length; i++) {
  175. $scope.popup.selectedModels.push($rootScope.currentAppDefinition.definition.models[i].id);
  176. }
  177. }
  178. if ($rootScope.currentAppDefinition.definition.cmmnModels) {
  179. for (var i = 0; i < $rootScope.currentAppDefinition.definition.cmmnModels.length; i++) {
  180. $scope.popup.selectedCmmnModels.push($rootScope.currentAppDefinition.definition.cmmnModels[i].id);
  181. }
  182. }
  183. $scope.tabs = [
  184. {
  185. id: 'bpmn',
  186. title: 'BPMN models'
  187. },
  188. {
  189. id: 'cmmn',
  190. title: 'CMMN models'
  191. }
  192. ];
  193. $scope.loadModels = function() {
  194. $scope.popup.loading = true;
  195. $http({method: 'GET', url: FLOWABLE.APP_URL.getModelsForAppDefinitionUrl()}).
  196. success(function(data, status, headers, config) {
  197. $scope.popup.models = data;
  198. $scope.popup.loading = false;
  199. }).
  200. error(function(data, status, headers, config) {
  201. $scope.popup.loading = false;
  202. });
  203. $http({method: 'GET', url: FLOWABLE.APP_URL.getCmmnModelsForAppDefinitionUrl()}).
  204. success(function(data, status, headers, config) {
  205. $scope.popup.cmmnModels = data;
  206. $scope.popup.loading = false;
  207. }).
  208. error(function(data, status, headers, config) {
  209. $scope.popup.loading = false;
  210. });
  211. };
  212. $scope.selectModel = function(model) {
  213. var index = $scope.popup.selectedModels.indexOf(model.id);
  214. if (index >= 0) {
  215. $scope.popup.selectedModels.splice(index, 1);
  216. } else {
  217. $scope.popup.selectedModels.push(model.id);
  218. }
  219. var modelArray = [];
  220. for (var i = 0; i < $scope.popup.models.data.length; i++) {
  221. if ($scope.popup.selectedModels.indexOf($scope.popup.models.data[i].id) >= 0) {
  222. var selectedModel = $scope.popup.models.data[i];
  223. var summaryModel = {
  224. id: selectedModel.id,
  225. name: selectedModel.name,
  226. version: selectedModel.version,
  227. modelType: selectedModel.modelType,
  228. description: selectedModel.description,
  229. stencilSetId: selectedModel.stencilSet,
  230. createdByFullName: selectedModel.createdByFullName,
  231. createdBy: selectedModel.createdBy,
  232. lastUpdatedByFullName: selectedModel.lastUpdatedByFullName,
  233. lastUpdatedBy: selectedModel.lastUpdatedBy,
  234. lastUpdated: selectedModel.lastUpdated
  235. };
  236. modelArray.push(summaryModel);
  237. }
  238. }
  239. $rootScope.currentAppDefinition.definition.models = modelArray;
  240. };
  241. $scope.selectCmmnModel = function(model) {
  242. var index = $scope.popup.selectedCmmnModels.indexOf(model.id);
  243. if (index >= 0) {
  244. $scope.popup.selectedCmmnModels.splice(index, 1);
  245. } else {
  246. $scope.popup.selectedCmmnModels.push(model.id);
  247. }
  248. var modelArray = [];
  249. for (var i = 0; i < $scope.popup.cmmnModels.data.length; i++) {
  250. if ($scope.popup.selectedCmmnModels.indexOf($scope.popup.cmmnModels.data[i].id) >= 0) {
  251. var selectedModel = $scope.popup.cmmnModels.data[i];
  252. var summaryModel = {
  253. id: selectedModel.id,
  254. name: selectedModel.name,
  255. version: selectedModel.version,
  256. modelType: selectedModel.modelType,
  257. description: selectedModel.description,
  258. stencilSetId: selectedModel.stencilSet,
  259. createdByFullName: selectedModel.createdByFullName,
  260. createdBy: selectedModel.createdBy,
  261. lastUpdatedByFullName: selectedModel.lastUpdatedByFullName,
  262. lastUpdatedBy: selectedModel.lastUpdatedBy,
  263. lastUpdated: selectedModel.lastUpdated
  264. };
  265. modelArray.push(summaryModel);
  266. }
  267. }
  268. $rootScope.currentAppDefinition.definition.cmmnModels = modelArray;
  269. };
  270. $scope.isModelSelected = function(model) {
  271. if ($scope.popup.selectedModels.indexOf(model.id) >= 0) {
  272. return true;
  273. } else {
  274. return false;
  275. }
  276. };
  277. $scope.isCmmnModelSelected = function(model) {
  278. if ($scope.popup.selectedCmmnModels.indexOf(model.id) >= 0) {
  279. return true;
  280. } else {
  281. return false;
  282. }
  283. };
  284. $scope.close = function() {
  285. $scope.$hide();
  286. };
  287. $scope.loadModels();
  288. }]);