提交 | 用户 | 时间
|
1ac2bc
|
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 |
|
|
15 |
* You should have received a copy of the GNU Lesser General Public |
|
16 |
* License along with this library; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
18 |
*/ |
|
19 |
|
|
20 |
/* |
|
21 |
* Input parameters for call activity |
|
22 |
*/ |
|
23 |
|
|
24 |
var KisBpmOutParametersCtrl = [ '$scope' , '$modal', '$timeout', '$translate', function($scope, $modal, $timeout, $translate) { |
|
25 |
|
|
26 |
// Config for the modal window |
|
27 |
var opts = { |
|
28 |
template: 'editor-app/configuration/properties/out-parameters-popup.html?version=' + Date.now(), |
|
29 |
scope: $scope |
|
30 |
}; |
|
31 |
|
|
32 |
// Open the dialog |
|
33 |
$modal(opts); |
|
34 |
}]; |
|
35 |
|
|
36 |
var KisBpmOutParametersPopupCtrl = [ '$scope', '$q', '$translate', function($scope, $q, $translate) { |
|
37 |
|
|
38 |
// Put json representing form properties on scope |
|
39 |
if ($scope.property.value !== undefined && $scope.property.value !== null |
|
40 |
&& $scope.property.value.outParameters !== undefined |
|
41 |
&& $scope.property.value.outParameters !== null) { |
|
42 |
// Note that we clone the json object rather then setting it directly, |
|
43 |
// this to cope with the fact that the user can click the cancel button and no changes should have happened |
|
44 |
$scope.parameters = angular.copy($scope.property.value.outParameters); |
|
45 |
} else { |
|
46 |
$scope.parameters = []; |
|
47 |
} |
|
48 |
|
|
49 |
// Array to contain selected properties (yes - we only can select one, but ng-grid isn't smart enough) |
|
50 |
$scope.selectedParameters = []; |
|
51 |
$scope.translationsRetrieved = false; |
|
52 |
|
|
53 |
$scope.labels = {}; |
|
54 |
|
|
55 |
var sourcePromise = $translate('PROPERTY.PARAMETER.SOURCE'); |
|
56 |
var sourceExpressionPromise = $translate('PROPERTY.PARAMETER.SOURCEEXPRESSION'); |
|
57 |
var targetPromise = $translate('PROPERTY.PARAMETER.TARGET'); |
|
58 |
|
|
59 |
$q.all([sourcePromise, sourceExpressionPromise, targetPromise]).then(function(results) { |
|
60 |
$scope.labels.sourceLabel = results[0]; |
|
61 |
$scope.labels.sourceExpressionLabel = results[1]; |
|
62 |
$scope.labels.targetLabel = results[2]; |
|
63 |
$scope.translationsRetrieved = true; |
|
64 |
|
|
65 |
// Config for grid |
|
66 |
$scope.gridOptions = { |
|
67 |
data: 'parameters', |
|
68 |
enableRowReordering: true, |
|
69 |
headerRowHeight: 28, |
|
70 |
multiSelect: false, |
|
71 |
keepLastSelected : false, |
|
72 |
selectedItems: $scope.selectedParameters, |
|
73 |
columnDefs: [{ field: 'source', displayName: $scope.labels.sourceLabel }, |
|
74 |
{ field: 'sourceExpression', displayName: $scope.labels.sourceExpressionLabel }, |
|
75 |
{ field: 'target', displayName: $scope.labels.targetLabel }] |
|
76 |
}; |
|
77 |
}); |
|
78 |
|
|
79 |
// Click handler for add button |
|
80 |
$scope.addNewParameter = function() { |
|
81 |
$scope.parameters.push({ source : '', |
|
82 |
sourceExpression : '', |
|
83 |
target : ''}); |
|
84 |
}; |
|
85 |
|
|
86 |
// Click handler for remove button |
|
87 |
$scope.removeParameter = function() { |
|
88 |
if ($scope.selectedParameters.length > 0) { |
|
89 |
var index = $scope.parameters.indexOf($scope.selectedParameters[0]); |
|
90 |
$scope.gridOptions.selectItem(index, false); |
|
91 |
$scope.parameters.splice(index, 1); |
|
92 |
|
|
93 |
$scope.selectedParameters.length = 0; |
|
94 |
if (index < $scope.parameters.length) { |
|
95 |
$scope.gridOptions.selectItem(index + 1, true); |
|
96 |
} else if ($scope.parameters.length > 0) { |
|
97 |
$scope.gridOptions.selectItem(index - 1, true); |
|
98 |
} |
|
99 |
} |
|
100 |
}; |
|
101 |
|
|
102 |
// Click handler for up button |
|
103 |
$scope.moveParameterUp = function() { |
|
104 |
if ($scope.selectedParameters.length > 0) { |
|
105 |
var index = $scope.parameters.indexOf($scope.selectedParameters[0]); |
|
106 |
if (index != 0) { // If it's the first, no moving up of course |
|
107 |
// Reason for funny way of swapping, see https://github.com/angular-ui/ng-grid/issues/272 |
|
108 |
var temp = $scope.parameters[index]; |
|
109 |
$scope.parameters.splice(index, 1); |
|
110 |
$timeout(function(){ |
|
111 |
$scope.parameters.splice(index + -1, 0, temp); |
|
112 |
}, 100); |
|
113 |
|
|
114 |
} |
|
115 |
} |
|
116 |
}; |
|
117 |
|
|
118 |
// Click handler for down button |
|
119 |
$scope.moveParameterDown = function() { |
|
120 |
if ($scope.selectedParameters.length > 0) { |
|
121 |
var index = $scope.parameters.indexOf($scope.selectedParameters[0]); |
|
122 |
if (index != $scope.parameters.length - 1) { // If it's the last element, no moving down of course |
|
123 |
// Reason for funny way of swapping, see https://github.com/angular-ui/ng-grid/issues/272 |
|
124 |
var temp = $scope.parameters[index]; |
|
125 |
$scope.parameters.splice(index, 1); |
|
126 |
$timeout(function(){ |
|
127 |
$scope.parameters.splice(index + 1, 0, temp); |
|
128 |
}, 100); |
|
129 |
|
|
130 |
} |
|
131 |
} |
|
132 |
}; |
|
133 |
|
|
134 |
// Click handler for save button |
|
135 |
$scope.save = function() { |
|
136 |
|
|
137 |
if ($scope.parameters.length > 0) { |
|
138 |
$scope.property.value = {}; |
|
139 |
$scope.property.value.outParameters = $scope.parameters; |
|
140 |
} else { |
|
141 |
$scope.property.value = null; |
|
142 |
} |
|
143 |
|
|
144 |
$scope.updatePropertyInModel($scope.property); |
|
145 |
$scope.close(); |
|
146 |
}; |
|
147 |
|
|
148 |
$scope.cancel = function() { |
|
149 |
$scope.close(); |
|
150 |
}; |
|
151 |
|
|
152 |
// Close button handler |
|
153 |
$scope.close = function() { |
|
154 |
$scope.property.mode = 'read'; |
|
155 |
$scope.$hide(); |
|
156 |
}; |
|
157 |
|
|
158 |
}]; |