properties-default-controllers.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. * String controller
  20. */
  21. var KisBpmStringPropertyCtrl = [ '$scope', function ($scope) {
  22. $scope.shapeId = $scope.selectedShape.id;
  23. $scope.valueFlushed = false;
  24. /** Handler called when input field is blurred */
  25. $scope.inputBlurred = function() {
  26. $scope.valueFlushed = true;
  27. if ($scope.property.value) {
  28. $scope.property.value = $scope.property.value.replace(/(<([^>]+)>)/ig,"");
  29. }
  30. $scope.updatePropertyInModel($scope.property);
  31. };
  32. $scope.enterPressed = function(keyEvent) {
  33. if (keyEvent && keyEvent.which === 13) {
  34. keyEvent.preventDefault();
  35. $scope.inputBlurred(); // we want to do the same as if the user would blur the input field
  36. }
  37. };
  38. $scope.$on('$destroy', function controllerDestroyed() {
  39. if(!$scope.valueFlushed) {
  40. if ($scope.property.value) {
  41. $scope.property.value = $scope.property.value.replace(/(<([^>]+)>)/ig,"");
  42. }
  43. $scope.updatePropertyInModel($scope.property, $scope.shapeId);
  44. }
  45. });
  46. }];
  47. /*
  48. * Boolean controller
  49. */
  50. var KisBpmBooleanPropertyCtrl = ['$scope', function ($scope) {
  51. $scope.changeValue = function() {
  52. if ($scope.property.key === 'oryx-defaultflow' && $scope.property.value) {
  53. var selectedShape = $scope.selectedShape;
  54. if (selectedShape) {
  55. var incomingNodes = selectedShape.getIncomingShapes();
  56. if (incomingNodes && incomingNodes.length > 0) {
  57. // get first node, since there can be only one for a sequence flow
  58. var rootNode = incomingNodes[0];
  59. var flows = rootNode.getOutgoingShapes();
  60. if (flows && flows.length > 1) {
  61. // in case there are more flows, check if another flow is already defined as default
  62. for (var i = 0; i < flows.length; i++) {
  63. if (flows[i].resourceId != selectedShape.resourceId) {
  64. var defaultFlowProp = flows[i].properties['oryx-defaultflow'];
  65. if (defaultFlowProp) {
  66. flows[i].setProperty('oryx-defaultflow', false, true);
  67. }
  68. }
  69. }
  70. }
  71. }
  72. }
  73. }
  74. $scope.updatePropertyInModel($scope.property);
  75. };
  76. }];
  77. /*
  78. * Text controller
  79. */
  80. var KisBpmTextPropertyCtrl = [ '$scope', '$modal', function($scope, $modal) {
  81. var opts = {
  82. template: 'editor-app/configuration/properties/text-popup.html?version=' + Date.now(),
  83. scope: $scope
  84. };
  85. // Open the dialog
  86. $modal(opts);
  87. }];
  88. var KisBpmTextPropertyPopupCtrl = ['$scope', function($scope) {
  89. $scope.save = function() {
  90. $scope.updatePropertyInModel($scope.property);
  91. $scope.close();
  92. };
  93. $scope.close = function() {
  94. $scope.property.mode = 'read';
  95. $scope.$hide();
  96. };
  97. }];