@sapui5/sap.rules.ui 1.107.0 → 1.108.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/package.json +1 -1
  2. package/src/sap/rules/ui/.library +1 -1
  3. package/src/sap/rules/ui/AstExpressionBasic.js +27 -6
  4. package/src/sap/rules/ui/AstExpressionBasicRenderer.js +71 -55
  5. package/src/sap/rules/ui/AutoCompleteSuggestionContent.js +5 -3
  6. package/src/sap/rules/ui/AutoCompleteSuggestionContentRenderer.js +39 -40
  7. package/src/sap/rules/ui/BindingSpy.js +1 -1
  8. package/src/sap/rules/ui/DecisionTable.js +2157 -2154
  9. package/src/sap/rules/ui/DecisionTableCell.js +7 -4
  10. package/src/sap/rules/ui/DecisionTableCellAstExpressionBasic.js +7 -4
  11. package/src/sap/rules/ui/DecisionTableCellAstExpressionBasicRenderer.js +5 -3
  12. package/src/sap/rules/ui/DecisionTableCellExpressionAdvanced.js +238 -236
  13. package/src/sap/rules/ui/DecisionTableCellExpressionAdvancedRenderer.js +6 -4
  14. package/src/sap/rules/ui/DecisionTableCellExpressionBasic.js +29 -22
  15. package/src/sap/rules/ui/DecisionTableCellExpressionBasicRenderer.js +6 -4
  16. package/src/sap/rules/ui/DecisionTableCellRenderer.js +10 -10
  17. package/src/sap/rules/ui/DecisionTableConfiguration.js +1 -1
  18. package/src/sap/rules/ui/DecisionTableRenderer.js +163 -161
  19. package/src/sap/rules/ui/DecisionTableSettings.js +6 -4
  20. package/src/sap/rules/ui/DecisionTableSettingsOld.js +963 -961
  21. package/src/sap/rules/ui/DecisionTableSettingsOldRenderer.js +9 -10
  22. package/src/sap/rules/ui/DecisionTableSettingsRenderer.js +9 -10
  23. package/src/sap/rules/ui/ExpressionAdvanced.js +1726 -1724
  24. package/src/sap/rules/ui/ExpressionAdvancedRenderer.js +8 -8
  25. package/src/sap/rules/ui/ExpressionBase.js +1 -1
  26. package/src/sap/rules/ui/ExpressionBasic.js +7 -4
  27. package/src/sap/rules/ui/ExpressionBasicRenderer.js +8 -7
  28. package/src/sap/rules/ui/InstructionRenderer.js +73 -33
  29. package/src/sap/rules/ui/RuleBase.js +1 -1
  30. package/src/sap/rules/ui/RuleBuilder.js +433 -430
  31. package/src/sap/rules/ui/RuleBuilderRenderer.js +8 -9
  32. package/src/sap/rules/ui/TextRule.js +7 -4
  33. package/src/sap/rules/ui/TextRuleConfiguration.js +1 -1
  34. package/src/sap/rules/ui/TextRuleRenderer.js +45 -44
  35. package/src/sap/rules/ui/TextRuleSettings.js +6 -4
  36. package/src/sap/rules/ui/TextRuleSettingsRenderer.js +9 -9
  37. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionAdvancedFunctionPanel.js +4 -3
  38. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionAdvancedFunctionPanelRenderer.js +10 -11
  39. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionAggregateFunctionPanel.js +100 -98
  40. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionAggregateFunctionPanelRenderer.js +9 -10
  41. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionArrayOperatorPanel.js +4 -3
  42. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionArrayOperatorPanelRenderer.js +10 -10
  43. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionComparisionOperatorPanel.js +109 -107
  44. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionComparisionOperatorPanelRenderer.js +39 -40
  45. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionDateAndTimePanel.js +5 -3
  46. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionDateAndTimePanelRenderer.js +10 -10
  47. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionFixedValuePanel.js +840 -838
  48. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionFixedValuePanelRenderer.js +40 -40
  49. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionFunctionalOperatorPanel.js +4 -3
  50. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionFunctionalOperatorPanelRenderer.js +10 -11
  51. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionLogicalOperatorPanel.js +112 -110
  52. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionLogicalOperatorPanelRenderer.js +39 -40
  53. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionLoopFunctionPanel.js +100 -98
  54. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionLoopFunctionPanelRenderer.js +9 -10
  55. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionMathematicalOperatorPanel.js +122 -119
  56. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionMathematicalOperatorPanelRenderer.js +39 -40
  57. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionMiscellaneousOperatorPanel.js +5 -2
  58. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionMiscellaneousOperatorPanelRenderer.js +10 -11
  59. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionOperationsPanel.js +4 -3
  60. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionOperationsPanelRenderer.js +10 -11
  61. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionRangeOperatorPanel.js +4 -3
  62. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionRangeOperatorPanelRenderer.js +10 -11
  63. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionSelectFunctionPanel.js +108 -106
  64. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionSelectFunctionPanelRenderer.js +40 -40
  65. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionTimeAndDurationFunctionPanel.js +254 -252
  66. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionTimeAndDurationFunctionPanelRenderer.js +40 -40
  67. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionVocabularyPanel.js +631 -629
  68. package/src/sap/rules/ui/ast/autoCompleteContent/AutoSuggestionVocabularyPanelRenderer.js +40 -40
  69. package/src/sap/rules/ui/library.js +31 -10
  70. package/src/sap/rules/ui/type/ExpressionAbs.js +1 -1
@@ -1,965 +1,967 @@
1
- /*!
1
+ /*!
2
2
  * SAP UI development toolkit for HTML5 (SAPUI5)
3
3
 
4
4
  (c) Copyright 2009-2016 SAP SE. All rights reserved
5
-
6
- */
7
-
8
- // Provides control sap.rules.ui.
9
- sap.ui.define([
10
- "jquery.sap.global",
11
- "sap/rules/ui/library",
12
- "sap/ui/core/Control",
13
- "sap/ui/layout/form/SimpleForm",
14
- "sap/m/Label",
15
- "sap/m/Switch",
16
- "sap/m/Select",
17
- "sap/m/Table",
18
- "sap/m/Text",
19
- "sap/m/CheckBox",
20
- "sap/m/Input",
21
- "sap/m/Button",
22
- "sap/rules/ui/ExpressionAdvanced",
23
- "sap/ui/layout/VerticalLayout",
24
- "sap/rules/ui/type/Expression"
25
- ],
26
- function(jQuery, library, Control, SimpleForm, Label, Switch, Select, Table, Text, CheckBox, Input, Button, ExpressionAdvanced, VerticalLayout, ExpressionType) {
27
- "use strict";
28
-
29
- /**
30
- * Constructor for a new DecisionTableSettingsOld Control.
31
- *
32
- * @param {string} [sId] id for the new control, generated automatically if no id is given
33
- * @param {object} [mSettings] initial settings for the new control
34
- *
35
- * @class
36
- * Some class description goes here.
37
- * @extends Control
38
- *
39
- * @author SAP SE
40
- * @version 1.107.0
41
- *
42
- * @constructor
43
- * @private
44
- * @alias sap.rules.ui.DecisionTableSettingsOld
45
- * @ui5-metamodel This control/element also will be described in the UI5 (legacy) designtime metamodel
46
- */
47
- var oDecisionTableSettingsOld = Control.extend("sap.rules.ui.DecisionTableSettingsOld", {
48
- metadata: {
49
- library: "sap.rules.ui",
50
- properties: {
51
- // ruleFormat: {
52
- // type: "string",
53
- // defaultValue: sap.rules.ui.RuleFormat.Advanced
54
- // },
55
- hitPolicies: {
56
- type: "sap.rules.ui.RuleHitPolicy[]",
57
- defaultValue: [sap.rules.ui.RuleHitPolicy.FirstMatch, sap.rules.ui.RuleHitPolicy.AllMatch]
58
- },
59
- modelName: {
60
- type: "string",
61
- defaultValue: ""
62
- },
63
- newDecisionTable: {
64
- type: "boolean",
65
- defaultValue: false
66
- }
67
- },
68
- aggregations: {
69
- mainLayout:{
70
- type: "sap.ui.layout.form.SimpleForm",
71
- multiple: false
72
- }
73
- },
74
- defaultAggregation: "mainLayout",
75
- associations: {
76
- expressionLanguage: {
77
- type: "sap.rules.ui.services.ExpressionLanguage",
78
- multiple: false,
79
- singularName: "expressionLanguage"
80
- }
81
- },
82
- events: {},
83
- publicMethods: []
84
- }
85
- });
86
-
87
- sap.rules.ui.DecisionTableSettingsOld.prototype.init = function() {
88
-
89
- this.oBundle = sap.ui.getCore().getLibraryResourceBundle("sap.rules.ui.i18n");
90
- this.needCreateLayout = true;
91
- this.firstLoad = true;
92
-
93
- this.onsapescape = function(oEvent) {
94
- // oEvent.preventDefault();
95
- oEvent.stopPropagation();
96
- };
97
- this._decisionTableHeaderSettingFormatter = new ExpressionType();
98
- this.setBusyIndicatorDelay(0);
99
- };
100
-
101
- sap.rules.ui.DecisionTableSettingsOld.prototype.onBeforeRendering = function() {
102
-
103
- if (this.firstLoad) {
104
- this._initSettingsModel();
105
-
106
- if (this.getProperty("newDecisionTable") === true) {
107
- this._prepareNewRuleWorkaround();
108
- }
109
-
110
- this.firstLoad = false;
111
- }
112
-
113
- if (this.needCreateLayout) {
114
- var layout = this.getAggregation("mainLayout");
115
- if (layout) {
116
- layout.destroy();
117
- }
118
-
119
- layout = this._createLayout();
120
- this.setAggregation("mainLayout", layout, true);
121
- this.needCreateLayout = false;
122
-
123
- this.conditionsTable.getBinding("items").attachDataRequested(function() {
124
- this.setBusy(true);
125
- }.bind(this));
126
-
127
- this.conditionsTable.getBinding("items").attachDataReceived(function() {
128
- this.setBusy(false);
129
- }.bind(this));
130
- }
131
- };
132
-
133
- // sap.rules.ui.DecisionTableSettingsOld.prototype.exit = function() {
134
-
135
- // };
136
-
137
- /**
138
- * Create DecisionTable structure for new rule
139
- * @private
140
- */
141
- sap.rules.ui.DecisionTableSettingsOld.prototype._prepareNewRule = function() {
142
-
143
- var oModel = this._getModel();
144
- var oContext = this.getBindingContext();
145
-
146
- // rule's data
147
- var ruleFormat = sap.rules.ui.RuleFormat.Advanced; // TODO: take from configuration
148
- oModel.setProperty("Type", sap.rules.ui.RuleType.DecisionTable, oContext, true);
149
- oModel.setProperty("RuleFormat", ruleFormat, oContext, true);
150
- var oExpressionLanguage = sap.ui.getCore().byId(this.getExpressionLanguage());
151
- var sExpressionLanguageVersion = oExpressionLanguage.getExpressionLanguageVersion();
152
- oModel.setProperty("ExpressionLanguageVersion", sExpressionLanguageVersion, oContext, true);
153
-
154
- // NOTE: "oData" and "params" objects are changed during execution by _createXYZ functions
155
- var oData = {
156
- ruleId: oContext.getProperty("Id"),
157
- version: oContext.getProperty("Version")
158
- };
159
-
160
- var params = {
161
- //groupId: sap.rules.ui.ChangeId.DecisionTableColumns
162
- };
163
-
164
- // create DecisionTable
165
- this._createDecisionTable(oData, params);
166
-
167
- // create Condition Column
168
- oData.colId = 1;
169
- oData.expression = "";
170
- this._createCondition(oData, params);
171
-
172
- // create Result Parameters Columns
173
- oData.colId = 2;
174
- var addedColumns = this._createResult(oData, params);
175
-
176
- // create Decision Table Row
177
- oData.rowId = 1;
178
- oData.columnsNumber = 1 + addedColumns;
179
- this._createRow(oData, params);
180
- };
181
-
182
- /**
183
- * Add Decision Table to Rule if doesn't exist.
184
- * @param {object} oData - data for new DecisionTable
185
- * @param {string} oData.ruleId - rule's Id
186
- * @param {map} mParameters? - Optional parameter map containing any of the following properties:
187
- * @param {string} mParameters.groupId? - groupId for changes on oDataModel
188
- * @param {function} mParameters.success? - success handler
189
- * @param {function} mParameters.error? - error handler
190
- * @private
191
- */
192
- sap.rules.ui.DecisionTableSettingsOld.prototype._createDecisionTable = function(oData, mParameters) {
193
- var oModel = this._getModel();
194
- var oContext = this.getBindingContext();
195
-
196
- var hitPolicy = this.getHitPolicies()[0];
197
-
198
- // if "DecisionTable" exists - update HitPolicy, otherwise create new DT entry
199
- if (oContext.getProperty("DecisionTable")) {
200
- oModel.setProperty("DecisionTable/HitPolicy", hitPolicy, oContext, true);
201
- } else {
202
- var oDecisionTableData = {
203
- RuleId: oData.ruleId,
204
- Version: oData.version,
205
- HitPolicy: hitPolicy
206
- };
207
-
208
- mParameters = mParameters ? mParameters : {};
209
- mParameters.properties = oDecisionTableData;
210
- oModel.createEntry("/DecisionTables", mParameters);
211
- }
212
- };
213
-
214
- /**
215
- * Add new Row to Decision Table
216
- * @param {object} oData - data for new row
217
- * @param {string} oData.ruleId - rule's Id
218
- * @param {string} oData.rowId - row's Id
219
- * @param {map} mParameters? - Optional parameter map containing any of the following properties:
220
- * @param {string} mParameters.groupId? - groupId for changes on oDataModel
221
- * @param {function} mParameters.success? - success handler
222
- * @param {function} mParameters.error? - error handler
223
- * @private
224
- */
225
- sap.rules.ui.DecisionTableSettingsOld.prototype._createRow = function(oData, mParameters) {
226
-
227
- mParameters = mParameters ? mParameters : {};
228
-
229
- var oModel = this._getModel();
230
- var oRowData = {
231
- RuleId: oData.ruleId,
232
- Version: oData.version,
233
- Id: oData.rowId
234
- };
235
-
236
- mParameters.properties = oRowData;
237
- oModel.createEntry("/DecisionTableRows", mParameters);
238
-
239
- this._createCellsForNewRow(oData, mParameters);
240
- };
241
-
242
- /**
243
- * Add new condition to Decision Table
244
- * @param {object} oData - data for new column
245
- * @param {string} oData.ruleId - rule's Id
246
- * @param {int} oData.colId - column Id for new column
247
- * @param {string} oData.expression - expression part for new column
248
- * @param {map} mParameters? - Optional parameter map containing any of the following properties:
249
- * @param {string} mParameters.groupId? - groupId for changes on oDataModel
250
- * @param {function} mParameters.success? - success handler
251
- * @param {function} mParameters.error? - error handler
252
- * @private
253
- */
254
- sap.rules.ui.DecisionTableSettingsOld.prototype._createCondition = function(oData, mParameters) {
255
-
256
- mParameters = mParameters ? mParameters : {};
257
-
258
- var oModel = this._getModel();
259
-
260
- var oColumnData = {
261
- RuleId: oData.ruleId,
262
- Version: oData.version,
263
- Id: oData.colId,
264
- Type: sap.rules.ui.DecisionTableColumn.Condition
265
- };
266
-
267
- mParameters.properties = oColumnData;
268
- oModel.createEntry("/DecisionTableColumns", mParameters);
269
-
270
- var oConditionColumnData = {
271
- RuleId: oData.ruleId,
272
- Version: oData.version,
273
- Id: oData.colId,
274
- Expression: oData.expression,
275
- ValueOnly: false, // TODO: take from configuration
276
- FixedOperator: "",
277
- Description: ""
278
- };
279
-
280
- mParameters.properties = oConditionColumnData;
281
- oModel.createEntry("/DecisionTableColumnConditions", mParameters);
282
- };
283
-
284
- /**
285
- * Add cells to existing rows for new Column
286
- * @param {object} oData - data for new column
287
- * @param {string} oData.ruleId - rule's Id
288
- * @param {int} oData.colId - column Id for new column
289
- * @param {map} mParameters? - Optional parameter map containing any of the following properties:
290
- * @param {string} mParameters.groupId? - groupId for changes on oDataModel
291
- * @param {function} mParameters.success? - success handler
292
- * @param {function} mParameters.error? - error handler
293
- * @private
294
- */
295
- sap.rules.ui.DecisionTableSettingsOld.prototype._createCellsForNewColumn = function(oData, mParameters) {
296
-
297
- mParameters = mParameters ? mParameters : {};
298
-
299
- var oModel = this._getModel();
300
- var oContext = this.getBindingContext();
301
- var rowKeys = oModel.getProperty("DecisionTable/DecisionTableRows", oContext);
302
-
303
- for (var i = 0; i < rowKeys.length; i++) {
304
-
305
- var rowId = oModel.getProperty("/" + rowKeys[i]).Id;
306
-
307
- var oCellData = {
308
- RuleId: oData.ruleId,
309
- Version: oData.version,
310
- RowId: rowId,
311
- ColId: oData.colId,
312
- Content: ""
313
- };
314
-
315
- mParameters.properties = oCellData;
316
- oModel.createEntry("/DecisionTableRowCells", mParameters);
317
- }
318
- };
319
-
320
- /**
321
- * Add cells for existing columns for new Row
322
- * @param {object} oData - data for new column
323
- * @param {string} oData.ruleId - rule's Id
324
- * @param {int} oData.rowId - row Id of new row
325
- * @param {int} oData.columnsNumber - number of columns in DecisionTable
326
- * @param {map} mParameters? - Optional parameter map containing any of the following properties:
327
- * @param {string} mParameters.groupId? - groupId for changes on oDataModel
328
- * @param {function} mParameters.success? - success handler
329
- * @param {function} mParameters.error? - error handler
330
- * @private
331
- */
332
- sap.rules.ui.DecisionTableSettingsOld.prototype._createCellsForNewRow = function(oData, mParameters) {
333
-
334
- mParameters = mParameters ? mParameters : {};
335
-
336
- var oModel = this._getModel();
337
-
338
- for (var colId = 1; colId <= oData.columnsNumber; colId++) {
339
- var oCellData = {
340
- RuleId: oData.ruleId,
341
- Version: oData.version,
342
- RowId: oData.rowId,
343
- ColId: colId,
344
- Content: ""
345
- };
346
-
347
- mParameters.properties = oCellData;
348
- oModel.createEntry("/DecisionTableRowCells", mParameters);
349
- }
350
- };
351
-
352
- /**
353
- * Add new Result columns to Decision Table
354
- * @param {object} oData - data for new column
355
- * @param {string} oData.ruleId - rule's Id
356
- * @param {int} oData.colId - column Id for new column
357
- * @param {map} mParameters? - Optional parameter map containing any of the following properties:
358
- * @param {string} mParameters.groupId? - groupId for changes on oDataModel
359
- * @param {function} mParameters.success? - success handler
360
- * @param {function} mParameters.error? - error handler
361
- * @returns {int} number of added columns
362
- * @private
363
- */
364
- sap.rules.ui.DecisionTableSettingsOld.prototype._createResult = function(oData, mParameters) {
365
-
366
- var oContext = this.getBindingContext();
367
-
368
- // TODO: use ResultDataObjectId instead
369
- var resultName = oContext.getProperty("ResultDataObjectName");
370
- var oExpressionLanguage = sap.ui.getCore().byId(this.getExpressionLanguage());
371
- var resultInfo = oExpressionLanguage.getResultInfo(resultName);
372
- var resultParams = resultInfo ? resultInfo.requiredParams : [];
373
- var resultLength = resultParams.length;
374
-
375
- var colId = oData.colId;
376
- for (var i = 0; i < resultLength; i++) {
377
- oData.colId = colId + i;
378
- oData.resultParameterData = resultParams[i];
379
- this._createResultParameter(oData, mParameters);
380
- }
381
-
382
- return resultLength;
383
- };
384
-
385
- /**
386
- * Add new Result Parameter column to Decision Table
387
- * @param {object} oData - data for new column
388
- * @param {string} oData.ruleId - rule's Id
389
- * @param {int} oData.colId - column Id for new column
390
- * @param {object} oData.resultParameterData - data for result parameter column
391
- * @param {map} mParameters? - Optional parameter map containing any of the following properties:
392
- * @param {string} mParameters.groupId? - groupId for changes on oDataModel
393
- * @param {function} mParameters.success? - success handler
394
- * @param {function} mParameters.error? - error handler
395
- * @private
396
- */
397
- sap.rules.ui.DecisionTableSettingsOld.prototype._createResultParameter = function(oData, mParameters) {
398
-
399
- mParameters = mParameters ? mParameters : {};
400
-
401
- var oModel = this._getModel();
402
-
403
- var oColumnData = {
404
- RuleId: oData.ruleId,
405
- Version: oData.version,
406
- Id: oData.colId,
407
- Type: sap.rules.ui.DecisionTableColumn.Result
408
- };
409
-
410
- mParameters.properties = oColumnData;
411
- oModel.createEntry("/DecisionTableColumns", mParameters);
412
-
413
- var oResultColumnData = {
414
- RuleId: oData.ruleId,
415
- Version: oData.version,
416
- Id: oData.colId,
417
- DataObjectAttributeName: oData.resultParameterData.name,
418
- // DataObjectAttributeId: oData.resultParameterData.id,
419
- DataObjectAttributeId: oData.resultParameterData.paramId,
420
- BusinessDataType: oData.resultParameterData.businessDataType
421
- };
422
-
423
- mParameters.properties = oResultColumnData;
424
- oModel.createEntry("/DecisionTableColumnResults", mParameters);
425
-
426
- //this._createCellsForNewColumn(ruleId, iColId, sChangeId);
427
- };
428
-
429
- /**
430
- * Remove column
431
- * @param {object} oColumnContext - context of column to remove
432
- * @param {map} mParameters? - Optional parameter map containing any of the following properties:
433
- * @param {string} mParameters.groupId? - groupId for changes on oDataModel
434
- * @param {function} mParameters.success? - success handler
435
- * @param {function} mParameters.error? - error handler
436
- * @private
437
- */
438
- sap.rules.ui.DecisionTableSettingsOld.prototype._removeColumn = function(oColumnContext, mParameters) {
439
- var oModel = this._getModel();
440
-
441
- var columnPath = oColumnContext.getPath();
442
- oModel.remove(columnPath, mParameters);
443
-
444
- //var colId = oColumnContext.getProperty("Id");
445
- // this._removeCellsForColumn(colId, sChangeId);
446
-
447
- // remove fixedOperator data for deleted row (internal model)
448
- //var tableData = this._internalModel.setProperty("/tableData", {}, true);
449
- //delete tableData[colId];
450
- //this._updateRemoveRowEnabled();
451
-
452
- this._internalModel.setProperty("/tableData", {}, true);
453
- };
454
-
455
- /**
456
- * Remove cells from existing rows for deleted Column
457
- * @param {object} oData - data for new column
458
- * @param {string} oData.ruleId - rule's Id
459
- * @param {int} oData.colId - column Id for new column
460
- * @param {map} mParameters? - Optional parameter map containing any of the following properties:
461
- * @param {string} mParameters.groupId? - groupId for changes on oDataModel
462
- * @param {function} mParameters.success? - success handler
463
- * @param {function} mParameters.error? - error handler
464
- * @private
465
- */
466
- sap.rules.ui.DecisionTableSettingsOld.prototype._removeCellsForColumn = function(oData, mParameters) {
467
- var oModel = this._getModel();
468
- var oContext = this.getBindingContext();
469
- var rowKeys = oModel.getProperty("DecisionTable/DecisionTableRows", oContext);
470
-
471
- var columnIndex = oData.colId - 1;
472
- for (var i = 0; i < rowKeys.length; i++) {
473
-
474
- var rowCells = oModel.getProperty("/" + rowKeys[i] + "/Cells");
475
- var cellPath = "/" + rowCells[columnIndex];
476
-
477
- oModel.remove(cellPath, mParameters);
478
- }
479
- };
480
-
481
- sap.rules.ui.DecisionTableSettingsOld.prototype._createTable = function() {
482
-
483
- this.conditionsTable = new Table({
484
- backgroundDesign: sap.m.BackgroundDesign.Solid,
485
- showSeparators: sap.m.ListSeparators.None,
486
- fixedLayout: true,
487
- layoutData: new sap.ui.layout.form.GridContainerData({
488
- halfGrid: false
489
- }),
490
- columns: [
491
- new sap.m.Column({
492
- width: "50%",
493
- header: new sap.m.Label({
494
- text: this.oBundle.getText("colOfDecisionTable"),
495
- design: sap.m.LabelDesign.Bold
496
- }).setTooltip(this.oBundle.getText("colOfDecisionTable"))
497
- }),
498
- // new sap.m.Column({
499
- // width: "25%",
500
- // header: new sap.m.Label({
501
- // text: this.oBundle.getText("displayName")
502
- // }).setTooltip(this.oBundle.getText("displayName"))
503
- // }),
504
- new sap.m.Column({
505
- width: "30%",
506
- header: new sap.m.Label({
507
- text: this.oBundle.getText("fixedOperator"),
508
- design: sap.m.LabelDesign.Bold
509
- }).setTooltip(this.oBundle.getText("fixedOperator"))
510
- }),
511
- // new sap.m.Column({
512
- // width: "15%",
513
- // header: new sap.m.Label({
514
- // text: this.oBundle.getText("valueOnly"),
515
- // design: sap.m.LabelDesign.Bold
516
- // }).setTooltip(this.oBundle.getText("valueOnly"))
517
- // }),
518
- new sap.m.Column({
519
- width: "20%"
520
- })
521
- ]
522
- }).data("hrf-id", "columnsTable", true);
523
-
524
-
525
- this.conditionsTable.bindItems({
526
- path: "DecisionTable/DecisionTableColumnsCondition",
527
- factory: this._tableColumnsFactory.bind(this),
528
- parameters: {
529
- expand: "Condition"
530
- }
531
- });
532
-
533
- this.conditionsTable.setBusyIndicatorDelay(0);
534
-
535
- return this.conditionsTable;
536
- };
537
-
538
- sap.rules.ui.DecisionTableSettingsOld.prototype._createLayout = function() {
539
- var oForm = new SimpleForm({
540
- editable: true,
541
- layout: "ResponsiveGridLayout",
542
- maxContainerCols: 1,
543
- columnsL: 1,
544
- columnsM: 1,
545
- labelSpanM: 1,
546
- content: [
547
- // new Label({
548
- // text: this.oBundle.getText("advancedMode")
549
- // }).setTooltip(this.oBundle.getText("advancedMode")),
550
- // new CheckBox({
551
- // selected: {
552
- // path: "RuleFormat",
553
- // formatter: Formatter.ruleFormatAsBoolean
554
- // },
555
- // enabled: "{maModel>/advancedMode/enabled}",
556
- // visible: "{settingsModel>/advancedMode/visible}",
557
- // select: this._setAdvancedMode.bind(this)
558
- // }),
559
-
560
- new Label({
561
- text: this.oBundle.getText("hitPolicy")
562
- }).setTooltip(this.oBundle.getText("hitPolicy")),
563
- new Select({
564
- width: "25%",
565
- enabled: "{settingsModel>/hitPolicy/enabled}",
566
- items: {
567
- path: "settingsModel>/hitPolicy/hitPolicyEnumration",
568
- template: new sap.ui.core.Item({
569
- key: "{settingsModel>key}",
570
- text: "{settingsModel>text}"
571
- })
572
- },
573
- selectedKey: "{DecisionTable/HitPolicy}"
574
- }),
575
-
576
- new Label(),
577
- this._createTable(),
578
-
579
- new Label({
580
- text: this.oBundle.getText("ouput")
581
- }).setTooltip(this.oBundle.getText("ouput")),
582
- new Text({
583
- width: "25%",
584
- text: "{ResultDataObjectName}"
585
- })
586
- ]
587
- });
588
-
589
- return oForm;
590
- };
591
-
592
- sap.rules.ui.DecisionTableSettingsOld.prototype._setFixedOperatorOnExpressionChange = function(displayExpression, colId) {
593
- var oFixedOperatorData = this._getFixedOperatorDataForExpression(displayExpression);
594
- this._internalModel.setProperty("/tableData/" + colId, oFixedOperatorData, true);
595
- this._updateRemoveRowEnabled();
596
- };
597
-
598
- sap.rules.ui.DecisionTableSettingsOld.prototype.setExpressionLanguage = function (oExpressionLanguage){
599
- this.setAssociation("expressionLanguage", oExpressionLanguage, true);
600
- this._decisionTableHeaderSettingFormatter.setExpressionLanguage(oExpressionLanguage);
601
- };
602
- sap.rules.ui.DecisionTableSettingsOld.prototype._getColumnControlObject = function(oBindingContext) {
603
- var mode = this._internalModel.getProperty("/advancedMode/current");
604
- if (mode === sap.rules.ui.RuleFormat.Advanced) {
605
- var oExpressionLanguage = sap.ui.getCore().byId(this.getExpressionLanguage());
606
-
607
- return new ExpressionAdvanced({
608
- expressionLanguage: oExpressionLanguage,
609
- placeholder: this.oBundle.getText("expressionPlaceHolder"),
610
- validateOnLoad: true,
611
- type : sap.rules.ui.ExpressionType.NonComparison,
612
- value: {
613
- path: "Condition/Expression",
614
- type: this._decisionTableHeaderSettingFormatter,
615
- events: {
616
- change: function(oEvent) {
617
- var oSource = oEvent.getSource();
618
- var oContext = oSource.getContext();
619
- var colId = oContext.getProperty("Id");
620
-
621
- //Workaround to fix RULES-4723
622
- var result = oExpressionLanguage.convertDecisionTableExpressionToDisplayValue(oSource.getValue(), "", "", sap.rules.ui.ExpressionType.All);
623
- var value;
624
- if (result.output.status === "Success" && result.output.converted) {
625
- value = result.output.converted.header;
626
- } else {
627
- value = oSource.getValue();
628
- }
629
-
630
- this._setFixedOperatorOnExpressionChange(value, colId);
631
- }.bind(this)
632
- }
633
- },
634
- enabled: true,
635
- change: function(oEvent) {
636
- var oSource = oEvent.getSource();
637
- var oContext = oSource.getBindingContext();
638
- var colId = oContext.getProperty("Id");
639
- this._setFixedOperatorOnExpressionChange(oSource.getValue(), colId);
640
-
641
- // clear previous fixed operator if expression is empty
642
- var expression = oContext.getProperty("Condition/Expression");
643
- if (!expression) {
644
- var model = oContext.getModel();
645
- model.setProperty(oContext.getPath() + "/Condition/FixedOperator", "");
646
- }
647
- }.bind(this)
648
- });
649
- } else {
650
- return new Select({
651
- width: "100%",
652
- items: {
653
- path: "",
654
- template: new sap.ui.core.Item({
655
- key: "",
656
- text: ""
657
- })
658
- },
659
- selectedKey: "{Condition/Expression}",
660
- enabled: true,
661
- change: function(oControlEvent) {
662
-
663
- }
664
- });
665
- }
666
- };
667
-
668
- sap.rules.ui.DecisionTableSettingsOld.prototype._tableColumnsFactory = function(sId, oContext) {
669
- var ruleId = oContext.getProperty("RuleId");
670
- var version = oContext.getProperty("Version");
671
- var colId = oContext.getProperty("Id");
672
-
673
- return new sap.m.ColumnListItem({
674
- cells: [
675
- this._getColumnControlObject(oContext),
676
- // new sap.m.Input({
677
- // value: "{Condition/Description}",
678
- // placeholder: this.oBundle.getText("displayNamePlaceHolder")
679
- // }),
680
- new sap.m.Select({
681
- width: "100%",
682
- items: {
683
- path: "settingsModel>/tableData/" + colId + "/fixOperatorEnumration",
684
- template: new sap.ui.core.Item({
685
- key: "{settingsModel>key}",
686
- text: "{settingsModel>value}"
687
- })
688
- },
689
- selectedKey: "{Condition/FixedOperator}",
690
- enabled: "{settingsModel>/tableData/" + colId + "/fixOperatorEnabled}"
691
- }),
692
- // new sap.m.Switch({
693
- // state: "{Condition/ValueOnly}",
694
- // enabled: false
695
- // }),
696
- new sap.ui.layout.HorizontalLayout({
697
- content: [
698
- new sap.m.Button({
699
- type: sap.m.ButtonType.Transparent,
700
- icon: sap.ui.core.IconPool.getIconURI("sys-cancel"),
701
- visible: "{settingsModel>/removeRowEnabled}",
702
- press: function(oEvent) {
703
- var oColumnContext = oEvent.getSource().getBindingContext();
704
- var params = {
705
- //groupId: sap.rules.ui.ChangeId.DecisionTableColumns
706
- };
707
- this._removeColumnWorkaround(oColumnContext, params);
708
- }.bind(this)
709
- }).setTooltip(this.oBundle.getText("removeColumn")),
710
- new sap.m.Button({
711
- type: sap.m.ButtonType.Transparent,
712
- icon: sap.ui.core.IconPool.getIconURI("add"),
713
- press: function(oEvent) {
714
- var oData = {
715
- ruleId: ruleId,
716
- version: version,
717
- colId: colId + 1,
718
- expression: ""
719
- };
720
- var params = {
721
- //groupId: sap.rules.ui.ChangeId.DecisionTableColumns
722
- };
723
- this._addConditionWorkaround(oData, params);
724
- }.bind(this)
725
- }).setTooltip(this.oBundle.getText("addColumn"))
726
- ],
727
- height: "1em"
728
- })
729
- ]
730
- });
731
- };
732
-
733
- /**
734
- * Create DecisionTable structure for new rule
735
- * @private
736
- */
737
- sap.rules.ui.DecisionTableSettingsOld.prototype._prepareNewRuleWorkaround = function() {
738
- this._prepareNewRule();
739
- this._saveWorkaround();
740
- };
741
-
742
- /**
743
- * Add new condition to Decision Table
744
- * @param {object} oData - data for new column
745
- * @param {map} mParameters? - Optional parameter map containing any of the following properties:
746
- * @private
747
- */
748
- sap.rules.ui.DecisionTableSettingsOld.prototype._addConditionWorkaround = function(oData, mParameters) {
749
-
750
- this._createCondition(oData, mParameters);
751
- this._saveWorkaround();
752
- };
753
-
754
- /**
755
- * Remove column
756
- * @param {object} oColumnContext - context of column to remove
757
- * @param {map} mParameters? - Optional parameter map containing any of the following properties:
758
- * @private
759
- */
760
- sap.rules.ui.DecisionTableSettingsOld.prototype._removeColumnWorkaround = function(oColumnContext, mParameters) {
761
- var oModel = this._getModel();
762
-
763
- if (oModel.hasPendingChanges()) {
764
- // save all model's changes before row removal
765
- this._saveWorkaround({
766
- success: function() {
767
- this._removeColumn(oColumnContext, mParameters);
768
- }.bind(this)
769
- });
770
- } else {
771
- this._removeColumn(oColumnContext, mParameters);
772
- }
773
- };
774
-
775
- /**
776
- * @private
777
- * @param {map} mParameters? - Optional parameter map containing any of the following properties:
778
- */
779
- sap.rules.ui.DecisionTableSettingsOld.prototype._saveWorkaround = function(mParameters) {
780
- var oModel = this._getModel();
781
- oModel.submitChanges(mParameters);
782
- };
783
-
784
-
785
- sap.rules.ui.DecisionTableSettingsOld.prototype._getModel = function() {
786
- var modelName = this.getModelName();
787
- if (modelName) {
788
- return this.getModel(modelName);
789
- }
790
- return this.getModel();
791
- };
792
-
793
- sap.rules.ui.DecisionTableSettingsOld.prototype._getBindModelName = function() {
794
- var path = "";
795
- var modelName = this.getModelName();
796
-
797
- if (modelName) {
798
- path = modelName + ">";
799
- }
800
-
801
- return path;
802
- };
803
-
804
- sap.rules.ui.DecisionTableSettingsOld.prototype._initSettingsModel = function() {
805
- var initialData = {};
806
-
807
- initialData.advancedMode = this._getAdvancedModeData();
808
- initialData.hitPolicy = this._getHitPoliciesData();
809
- initialData.tableData = {};
810
- initialData.removeRowEnabled = false;
811
-
812
- this._internalModel = new sap.ui.model.json.JSONModel(initialData);
813
- this.setModel(this._internalModel, "settingsModel");
814
- };
815
-
816
- sap.rules.ui.DecisionTableSettingsOld.prototype._getAdvancedModeData = function() {
817
- var mode;
818
- var advancedModeData = {};
819
-
820
- // Check rule's Format from rule's data - it is stronger then configuration property
821
- var oContext = this.getBindingContext();
822
- var ruleFormat = oContext.getProperty("RuleFormat");
823
-
824
- if (ruleFormat === sap.rules.ui.RuleFormat.Advanced) {
825
- mode = sap.rules.ui.RuleFormat.Advanced;
826
- } else {
827
- mode = sap.rules.ui.RuleFormat.Advanced; // TODO: should be: this.getRuleFormat();
828
- }
829
-
830
- switch (mode) {
831
- case sap.rules.ui.RuleFormat.All:
832
- advancedModeData = {
833
- current: sap.rules.ui.RuleFormat.Basic,
834
- enabled: true,
835
- visible: true
836
- };
837
- break;
838
-
839
- case sap.rules.ui.RuleFormat.Basic:
840
- advancedModeData = {
841
- current: sap.rules.ui.RuleFormat.Basic,
842
- enabled: false,
843
- visible: false
844
- };
845
- break;
846
-
847
- case sap.rules.ui.RuleFormat.Advanced:
848
- advancedModeData = {
849
- current: sap.rules.ui.RuleFormat.Advanced,
850
- enabled: false,
851
- visible: true
852
- };
853
-
854
- break;
855
-
856
- default:
857
- }
858
- return advancedModeData;
859
- };
860
-
861
- sap.rules.ui.DecisionTableSettingsOld.prototype._getHitPoliciesData = function() {
862
- var hitPolicy = this.getProperty("hitPolicies");
863
- var length = hitPolicy.length;
864
- var oHitPolicyData = {
865
- hitPolicyEnumration: []
866
- };
867
-
868
- for (var i = 0; i < length; i++) {
869
- oHitPolicyData.hitPolicyEnumration.push({
870
- key: hitPolicy[i],
871
- text: this.oBundle.getText(hitPolicy[i])
872
- });
873
- }
874
-
875
- oHitPolicyData.enabled = length > 1 ? true : false;
876
-
877
- return oHitPolicyData;
878
- };
879
-
880
- sap.rules.ui.DecisionTableSettingsOld.prototype._getFixedOperatorDataForExpression = function(sExpression) {
881
- var fixOperatorEnabled = sExpression ? true : false;
882
- var fixedOperatiorData = {
883
- fixOperatorEnumration: [{
884
- key: "",
885
- value: this.oBundle.getText("fixOperatorDefaultValue")
886
- }],
887
- fixOperatorEnabled: fixOperatorEnabled
888
- };
889
-
890
- if (fixOperatorEnabled) {
891
- var oSuggestions = [];
892
- var oExpressionLanguage = sap.ui.getCore().byId(this.getExpressionLanguage());
893
- var oFilter = [{
894
- tokenType: sap.rules.ui.ExpressionTokenType.reservedWord,
895
- tokenCategory: sap.rules.ui.ExpressionCategory.comparisonOp
896
- }, {
897
- tokenType: sap.rules.ui.ExpressionTokenType.reservedWord,
898
- tokenCategory: sap.rules.ui.ExpressionCategory.comparisonBetweenOp
899
- }, {
900
- tokenType: sap.rules.ui.ExpressionTokenType.reservedWord,
901
- tokenCategory: sap.rules.ui.ExpressionCategory.comparisonExistOp
902
- }];
903
- oSuggestions = oExpressionLanguage.getSuggestionsByCategories(sExpression, oFilter);
904
- for (var i = 0; i < oSuggestions.length; i++) {
905
- fixedOperatiorData.fixOperatorEnumration.push({
906
- key: oSuggestions[i].text,
907
- value: oSuggestions[i].text
908
- });
909
- }
910
- }
911
- return fixedOperatiorData;
912
- };
913
-
914
- sap.rules.ui.DecisionTableSettingsOld.prototype._setAdvancedMode = function(oControlEvent) {
915
- var bAdvancedModeStatus = oControlEvent.getParameter("selected");
916
- var ruleFormat = bAdvancedModeStatus ? sap.rules.ui.RuleFormat.Advanced : sap.rules.ui.RuleFormat.Basic;
917
-
918
- var oRuleModel = this._getModel();
919
- var oContextPath = this.getBindingContext().getPath();
920
- oRuleModel.setProperty(oContextPath + "/RuleFormat", ruleFormat);
921
-
922
- this.needCreateLayout = true;
923
- this.invalidate();
924
- };
925
-
926
- sap.rules.ui.DecisionTableSettingsOld.prototype._updateRemoveRowEnabled = function() {
927
- var tableData = this._internalModel.getProperty("/tableData");
928
- var len = Object.keys(tableData).length;
929
- var enabled = len > 1;
930
- this._internalModel.setProperty("/removeRowEnabled", enabled, null, true);
931
- };
932
-
933
- sap.rules.ui.DecisionTableSettingsOld.prototype.getButtons = function(oDialog) {
934
-
935
- var aButtons = [];
936
-
937
- //Add apply button
938
- var oApplyButton = new Button({
939
- text: this.oBundle.getText("applyChangesBtn")
940
- }).setTooltip(this.oBundle.getText("applyChangesBtn"));
941
-
942
- oApplyButton.attachPress(function() {
943
-
944
- //flag for calculate only once header span for multi header in columnFactory function
945
- this.multiHeaderFlag = false;
946
-
947
- // Workaround: we submit changes, because if we change a cell and then open this dialog and close it,
948
- // the cell display value will not be the same as the cell value when in-focus
949
- this.getModel().submitChanges();
950
-
951
- //For attachBeforeClose in decisionTable file
952
- oDialog.setState(sap.ui.core.ValueState.Success);
953
-
954
- oDialog.close();
955
-
956
- }, this);
957
-
958
- aButtons.push(oApplyButton);
959
-
960
- return aButtons;
961
- };
962
-
963
- return oDecisionTableSettingsOld;
964
-
5
+
6
+ */
7
+
8
+ // Provides control sap.rules.ui.
9
+ sap.ui.define([
10
+ "jquery.sap.global",
11
+ "sap/rules/ui/library",
12
+ "sap/ui/core/Control",
13
+ "sap/ui/layout/form/SimpleForm",
14
+ "sap/m/Label",
15
+ "sap/m/Switch",
16
+ "sap/m/Select",
17
+ "sap/m/Table",
18
+ "sap/m/Text",
19
+ "sap/m/CheckBox",
20
+ "sap/m/Input",
21
+ "sap/m/Button",
22
+ "sap/rules/ui/ExpressionAdvanced",
23
+ "sap/ui/layout/VerticalLayout",
24
+ "sap/rules/ui/type/Expression",
25
+ "./DecisionTableSettingsOldRenderer"
26
+ ],
27
+ function(jQuery, library, Control, SimpleForm, Label, Switch, Select, Table, Text, CheckBox, Input, Button, ExpressionAdvanced, VerticalLayout, ExpressionType, DecisionTableSettingsOldRenderer) {
28
+ "use strict";
29
+
30
+ /**
31
+ * Constructor for a new DecisionTableSettingsOld Control.
32
+ *
33
+ * @param {string} [sId] id for the new control, generated automatically if no id is given
34
+ * @param {object} [mSettings] initial settings for the new control
35
+ *
36
+ * @class
37
+ * Some class description goes here.
38
+ * @extends Control
39
+ *
40
+ * @author SAP SE
41
+ * @version 1.108.1
42
+ *
43
+ * @constructor
44
+ * @private
45
+ * @alias sap.rules.ui.DecisionTableSettingsOld
46
+ * @ui5-metamodel This control/element also will be described in the UI5 (legacy) designtime metamodel
47
+ */
48
+ var oDecisionTableSettingsOld = Control.extend("sap.rules.ui.DecisionTableSettingsOld", {
49
+ metadata: {
50
+ library: "sap.rules.ui",
51
+ properties: {
52
+ // ruleFormat: {
53
+ // type: "string",
54
+ // defaultValue: sap.rules.ui.RuleFormat.Advanced
55
+ // },
56
+ hitPolicies: {
57
+ type: "sap.rules.ui.RuleHitPolicy[]",
58
+ defaultValue: [sap.rules.ui.RuleHitPolicy.FirstMatch, sap.rules.ui.RuleHitPolicy.AllMatch]
59
+ },
60
+ modelName: {
61
+ type: "string",
62
+ defaultValue: ""
63
+ },
64
+ newDecisionTable: {
65
+ type: "boolean",
66
+ defaultValue: false
67
+ }
68
+ },
69
+ aggregations: {
70
+ mainLayout:{
71
+ type: "sap.ui.layout.form.SimpleForm",
72
+ multiple: false
73
+ }
74
+ },
75
+ defaultAggregation: "mainLayout",
76
+ associations: {
77
+ expressionLanguage: {
78
+ type: "sap.rules.ui.services.ExpressionLanguage",
79
+ multiple: false,
80
+ singularName: "expressionLanguage"
81
+ }
82
+ },
83
+ events: {},
84
+ publicMethods: []
85
+ },
86
+ renderer: DecisionTableSettingsOldRenderer
87
+ });
88
+
89
+ sap.rules.ui.DecisionTableSettingsOld.prototype.init = function() {
90
+
91
+ this.oBundle = sap.ui.getCore().getLibraryResourceBundle("sap.rules.ui.i18n");
92
+ this.needCreateLayout = true;
93
+ this.firstLoad = true;
94
+
95
+ this.onsapescape = function(oEvent) {
96
+ // oEvent.preventDefault();
97
+ oEvent.stopPropagation();
98
+ };
99
+ this._decisionTableHeaderSettingFormatter = new ExpressionType();
100
+ this.setBusyIndicatorDelay(0);
101
+ };
102
+
103
+ sap.rules.ui.DecisionTableSettingsOld.prototype.onBeforeRendering = function() {
104
+
105
+ if (this.firstLoad) {
106
+ this._initSettingsModel();
107
+
108
+ if (this.getProperty("newDecisionTable") === true) {
109
+ this._prepareNewRuleWorkaround();
110
+ }
111
+
112
+ this.firstLoad = false;
113
+ }
114
+
115
+ if (this.needCreateLayout) {
116
+ var layout = this.getAggregation("mainLayout");
117
+ if (layout) {
118
+ layout.destroy();
119
+ }
120
+
121
+ layout = this._createLayout();
122
+ this.setAggregation("mainLayout", layout, true);
123
+ this.needCreateLayout = false;
124
+
125
+ this.conditionsTable.getBinding("items").attachDataRequested(function() {
126
+ this.setBusy(true);
127
+ }.bind(this));
128
+
129
+ this.conditionsTable.getBinding("items").attachDataReceived(function() {
130
+ this.setBusy(false);
131
+ }.bind(this));
132
+ }
133
+ };
134
+
135
+ // sap.rules.ui.DecisionTableSettingsOld.prototype.exit = function() {
136
+
137
+ // };
138
+
139
+ /**
140
+ * Create DecisionTable structure for new rule
141
+ * @private
142
+ */
143
+ sap.rules.ui.DecisionTableSettingsOld.prototype._prepareNewRule = function() {
144
+
145
+ var oModel = this._getModel();
146
+ var oContext = this.getBindingContext();
147
+
148
+ // rule's data
149
+ var ruleFormat = sap.rules.ui.RuleFormat.Advanced; // TODO: take from configuration
150
+ oModel.setProperty("Type", sap.rules.ui.RuleType.DecisionTable, oContext, true);
151
+ oModel.setProperty("RuleFormat", ruleFormat, oContext, true);
152
+ var oExpressionLanguage = sap.ui.getCore().byId(this.getExpressionLanguage());
153
+ var sExpressionLanguageVersion = oExpressionLanguage.getExpressionLanguageVersion();
154
+ oModel.setProperty("ExpressionLanguageVersion", sExpressionLanguageVersion, oContext, true);
155
+
156
+ // NOTE: "oData" and "params" objects are changed during execution by _createXYZ functions
157
+ var oData = {
158
+ ruleId: oContext.getProperty("Id"),
159
+ version: oContext.getProperty("Version")
160
+ };
161
+
162
+ var params = {
163
+ //groupId: sap.rules.ui.ChangeId.DecisionTableColumns
164
+ };
165
+
166
+ // create DecisionTable
167
+ this._createDecisionTable(oData, params);
168
+
169
+ // create Condition Column
170
+ oData.colId = 1;
171
+ oData.expression = "";
172
+ this._createCondition(oData, params);
173
+
174
+ // create Result Parameters Columns
175
+ oData.colId = 2;
176
+ var addedColumns = this._createResult(oData, params);
177
+
178
+ // create Decision Table Row
179
+ oData.rowId = 1;
180
+ oData.columnsNumber = 1 + addedColumns;
181
+ this._createRow(oData, params);
182
+ };
183
+
184
+ /**
185
+ * Add Decision Table to Rule if doesn't exist.
186
+ * @param {object} oData - data for new DecisionTable
187
+ * @param {string} oData.ruleId - rule's Id
188
+ * @param {map} mParameters? - Optional parameter map containing any of the following properties:
189
+ * @param {string} mParameters.groupId? - groupId for changes on oDataModel
190
+ * @param {function} mParameters.success? - success handler
191
+ * @param {function} mParameters.error? - error handler
192
+ * @private
193
+ */
194
+ sap.rules.ui.DecisionTableSettingsOld.prototype._createDecisionTable = function(oData, mParameters) {
195
+ var oModel = this._getModel();
196
+ var oContext = this.getBindingContext();
197
+
198
+ var hitPolicy = this.getHitPolicies()[0];
199
+
200
+ // if "DecisionTable" exists - update HitPolicy, otherwise create new DT entry
201
+ if (oContext.getProperty("DecisionTable")) {
202
+ oModel.setProperty("DecisionTable/HitPolicy", hitPolicy, oContext, true);
203
+ } else {
204
+ var oDecisionTableData = {
205
+ RuleId: oData.ruleId,
206
+ Version: oData.version,
207
+ HitPolicy: hitPolicy
208
+ };
209
+
210
+ mParameters = mParameters ? mParameters : {};
211
+ mParameters.properties = oDecisionTableData;
212
+ oModel.createEntry("/DecisionTables", mParameters);
213
+ }
214
+ };
215
+
216
+ /**
217
+ * Add new Row to Decision Table
218
+ * @param {object} oData - data for new row
219
+ * @param {string} oData.ruleId - rule's Id
220
+ * @param {string} oData.rowId - row's Id
221
+ * @param {map} mParameters? - Optional parameter map containing any of the following properties:
222
+ * @param {string} mParameters.groupId? - groupId for changes on oDataModel
223
+ * @param {function} mParameters.success? - success handler
224
+ * @param {function} mParameters.error? - error handler
225
+ * @private
226
+ */
227
+ sap.rules.ui.DecisionTableSettingsOld.prototype._createRow = function(oData, mParameters) {
228
+
229
+ mParameters = mParameters ? mParameters : {};
230
+
231
+ var oModel = this._getModel();
232
+ var oRowData = {
233
+ RuleId: oData.ruleId,
234
+ Version: oData.version,
235
+ Id: oData.rowId
236
+ };
237
+
238
+ mParameters.properties = oRowData;
239
+ oModel.createEntry("/DecisionTableRows", mParameters);
240
+
241
+ this._createCellsForNewRow(oData, mParameters);
242
+ };
243
+
244
+ /**
245
+ * Add new condition to Decision Table
246
+ * @param {object} oData - data for new column
247
+ * @param {string} oData.ruleId - rule's Id
248
+ * @param {int} oData.colId - column Id for new column
249
+ * @param {string} oData.expression - expression part for new column
250
+ * @param {map} mParameters? - Optional parameter map containing any of the following properties:
251
+ * @param {string} mParameters.groupId? - groupId for changes on oDataModel
252
+ * @param {function} mParameters.success? - success handler
253
+ * @param {function} mParameters.error? - error handler
254
+ * @private
255
+ */
256
+ sap.rules.ui.DecisionTableSettingsOld.prototype._createCondition = function(oData, mParameters) {
257
+
258
+ mParameters = mParameters ? mParameters : {};
259
+
260
+ var oModel = this._getModel();
261
+
262
+ var oColumnData = {
263
+ RuleId: oData.ruleId,
264
+ Version: oData.version,
265
+ Id: oData.colId,
266
+ Type: sap.rules.ui.DecisionTableColumn.Condition
267
+ };
268
+
269
+ mParameters.properties = oColumnData;
270
+ oModel.createEntry("/DecisionTableColumns", mParameters);
271
+
272
+ var oConditionColumnData = {
273
+ RuleId: oData.ruleId,
274
+ Version: oData.version,
275
+ Id: oData.colId,
276
+ Expression: oData.expression,
277
+ ValueOnly: false, // TODO: take from configuration
278
+ FixedOperator: "",
279
+ Description: ""
280
+ };
281
+
282
+ mParameters.properties = oConditionColumnData;
283
+ oModel.createEntry("/DecisionTableColumnConditions", mParameters);
284
+ };
285
+
286
+ /**
287
+ * Add cells to existing rows for new Column
288
+ * @param {object} oData - data for new column
289
+ * @param {string} oData.ruleId - rule's Id
290
+ * @param {int} oData.colId - column Id for new column
291
+ * @param {map} mParameters? - Optional parameter map containing any of the following properties:
292
+ * @param {string} mParameters.groupId? - groupId for changes on oDataModel
293
+ * @param {function} mParameters.success? - success handler
294
+ * @param {function} mParameters.error? - error handler
295
+ * @private
296
+ */
297
+ sap.rules.ui.DecisionTableSettingsOld.prototype._createCellsForNewColumn = function(oData, mParameters) {
298
+
299
+ mParameters = mParameters ? mParameters : {};
300
+
301
+ var oModel = this._getModel();
302
+ var oContext = this.getBindingContext();
303
+ var rowKeys = oModel.getProperty("DecisionTable/DecisionTableRows", oContext);
304
+
305
+ for (var i = 0; i < rowKeys.length; i++) {
306
+
307
+ var rowId = oModel.getProperty("/" + rowKeys[i]).Id;
308
+
309
+ var oCellData = {
310
+ RuleId: oData.ruleId,
311
+ Version: oData.version,
312
+ RowId: rowId,
313
+ ColId: oData.colId,
314
+ Content: ""
315
+ };
316
+
317
+ mParameters.properties = oCellData;
318
+ oModel.createEntry("/DecisionTableRowCells", mParameters);
319
+ }
320
+ };
321
+
322
+ /**
323
+ * Add cells for existing columns for new Row
324
+ * @param {object} oData - data for new column
325
+ * @param {string} oData.ruleId - rule's Id
326
+ * @param {int} oData.rowId - row Id of new row
327
+ * @param {int} oData.columnsNumber - number of columns in DecisionTable
328
+ * @param {map} mParameters? - Optional parameter map containing any of the following properties:
329
+ * @param {string} mParameters.groupId? - groupId for changes on oDataModel
330
+ * @param {function} mParameters.success? - success handler
331
+ * @param {function} mParameters.error? - error handler
332
+ * @private
333
+ */
334
+ sap.rules.ui.DecisionTableSettingsOld.prototype._createCellsForNewRow = function(oData, mParameters) {
335
+
336
+ mParameters = mParameters ? mParameters : {};
337
+
338
+ var oModel = this._getModel();
339
+
340
+ for (var colId = 1; colId <= oData.columnsNumber; colId++) {
341
+ var oCellData = {
342
+ RuleId: oData.ruleId,
343
+ Version: oData.version,
344
+ RowId: oData.rowId,
345
+ ColId: colId,
346
+ Content: ""
347
+ };
348
+
349
+ mParameters.properties = oCellData;
350
+ oModel.createEntry("/DecisionTableRowCells", mParameters);
351
+ }
352
+ };
353
+
354
+ /**
355
+ * Add new Result columns to Decision Table
356
+ * @param {object} oData - data for new column
357
+ * @param {string} oData.ruleId - rule's Id
358
+ * @param {int} oData.colId - column Id for new column
359
+ * @param {map} mParameters? - Optional parameter map containing any of the following properties:
360
+ * @param {string} mParameters.groupId? - groupId for changes on oDataModel
361
+ * @param {function} mParameters.success? - success handler
362
+ * @param {function} mParameters.error? - error handler
363
+ * @returns {int} number of added columns
364
+ * @private
365
+ */
366
+ sap.rules.ui.DecisionTableSettingsOld.prototype._createResult = function(oData, mParameters) {
367
+
368
+ var oContext = this.getBindingContext();
369
+
370
+ // TODO: use ResultDataObjectId instead
371
+ var resultName = oContext.getProperty("ResultDataObjectName");
372
+ var oExpressionLanguage = sap.ui.getCore().byId(this.getExpressionLanguage());
373
+ var resultInfo = oExpressionLanguage.getResultInfo(resultName);
374
+ var resultParams = resultInfo ? resultInfo.requiredParams : [];
375
+ var resultLength = resultParams.length;
376
+
377
+ var colId = oData.colId;
378
+ for (var i = 0; i < resultLength; i++) {
379
+ oData.colId = colId + i;
380
+ oData.resultParameterData = resultParams[i];
381
+ this._createResultParameter(oData, mParameters);
382
+ }
383
+
384
+ return resultLength;
385
+ };
386
+
387
+ /**
388
+ * Add new Result Parameter column to Decision Table
389
+ * @param {object} oData - data for new column
390
+ * @param {string} oData.ruleId - rule's Id
391
+ * @param {int} oData.colId - column Id for new column
392
+ * @param {object} oData.resultParameterData - data for result parameter column
393
+ * @param {map} mParameters? - Optional parameter map containing any of the following properties:
394
+ * @param {string} mParameters.groupId? - groupId for changes on oDataModel
395
+ * @param {function} mParameters.success? - success handler
396
+ * @param {function} mParameters.error? - error handler
397
+ * @private
398
+ */
399
+ sap.rules.ui.DecisionTableSettingsOld.prototype._createResultParameter = function(oData, mParameters) {
400
+
401
+ mParameters = mParameters ? mParameters : {};
402
+
403
+ var oModel = this._getModel();
404
+
405
+ var oColumnData = {
406
+ RuleId: oData.ruleId,
407
+ Version: oData.version,
408
+ Id: oData.colId,
409
+ Type: sap.rules.ui.DecisionTableColumn.Result
410
+ };
411
+
412
+ mParameters.properties = oColumnData;
413
+ oModel.createEntry("/DecisionTableColumns", mParameters);
414
+
415
+ var oResultColumnData = {
416
+ RuleId: oData.ruleId,
417
+ Version: oData.version,
418
+ Id: oData.colId,
419
+ DataObjectAttributeName: oData.resultParameterData.name,
420
+ // DataObjectAttributeId: oData.resultParameterData.id,
421
+ DataObjectAttributeId: oData.resultParameterData.paramId,
422
+ BusinessDataType: oData.resultParameterData.businessDataType
423
+ };
424
+
425
+ mParameters.properties = oResultColumnData;
426
+ oModel.createEntry("/DecisionTableColumnResults", mParameters);
427
+
428
+ //this._createCellsForNewColumn(ruleId, iColId, sChangeId);
429
+ };
430
+
431
+ /**
432
+ * Remove column
433
+ * @param {object} oColumnContext - context of column to remove
434
+ * @param {map} mParameters? - Optional parameter map containing any of the following properties:
435
+ * @param {string} mParameters.groupId? - groupId for changes on oDataModel
436
+ * @param {function} mParameters.success? - success handler
437
+ * @param {function} mParameters.error? - error handler
438
+ * @private
439
+ */
440
+ sap.rules.ui.DecisionTableSettingsOld.prototype._removeColumn = function(oColumnContext, mParameters) {
441
+ var oModel = this._getModel();
442
+
443
+ var columnPath = oColumnContext.getPath();
444
+ oModel.remove(columnPath, mParameters);
445
+
446
+ //var colId = oColumnContext.getProperty("Id");
447
+ // this._removeCellsForColumn(colId, sChangeId);
448
+
449
+ // remove fixedOperator data for deleted row (internal model)
450
+ //var tableData = this._internalModel.setProperty("/tableData", {}, true);
451
+ //delete tableData[colId];
452
+ //this._updateRemoveRowEnabled();
453
+
454
+ this._internalModel.setProperty("/tableData", {}, true);
455
+ };
456
+
457
+ /**
458
+ * Remove cells from existing rows for deleted Column
459
+ * @param {object} oData - data for new column
460
+ * @param {string} oData.ruleId - rule's Id
461
+ * @param {int} oData.colId - column Id for new column
462
+ * @param {map} mParameters? - Optional parameter map containing any of the following properties:
463
+ * @param {string} mParameters.groupId? - groupId for changes on oDataModel
464
+ * @param {function} mParameters.success? - success handler
465
+ * @param {function} mParameters.error? - error handler
466
+ * @private
467
+ */
468
+ sap.rules.ui.DecisionTableSettingsOld.prototype._removeCellsForColumn = function(oData, mParameters) {
469
+ var oModel = this._getModel();
470
+ var oContext = this.getBindingContext();
471
+ var rowKeys = oModel.getProperty("DecisionTable/DecisionTableRows", oContext);
472
+
473
+ var columnIndex = oData.colId - 1;
474
+ for (var i = 0; i < rowKeys.length; i++) {
475
+
476
+ var rowCells = oModel.getProperty("/" + rowKeys[i] + "/Cells");
477
+ var cellPath = "/" + rowCells[columnIndex];
478
+
479
+ oModel.remove(cellPath, mParameters);
480
+ }
481
+ };
482
+
483
+ sap.rules.ui.DecisionTableSettingsOld.prototype._createTable = function() {
484
+
485
+ this.conditionsTable = new Table({
486
+ backgroundDesign: sap.m.BackgroundDesign.Solid,
487
+ showSeparators: sap.m.ListSeparators.None,
488
+ fixedLayout: true,
489
+ layoutData: new sap.ui.layout.form.GridContainerData({
490
+ halfGrid: false
491
+ }),
492
+ columns: [
493
+ new sap.m.Column({
494
+ width: "50%",
495
+ header: new sap.m.Label({
496
+ text: this.oBundle.getText("colOfDecisionTable"),
497
+ design: sap.m.LabelDesign.Bold
498
+ }).setTooltip(this.oBundle.getText("colOfDecisionTable"))
499
+ }),
500
+ // new sap.m.Column({
501
+ // width: "25%",
502
+ // header: new sap.m.Label({
503
+ // text: this.oBundle.getText("displayName")
504
+ // }).setTooltip(this.oBundle.getText("displayName"))
505
+ // }),
506
+ new sap.m.Column({
507
+ width: "30%",
508
+ header: new sap.m.Label({
509
+ text: this.oBundle.getText("fixedOperator"),
510
+ design: sap.m.LabelDesign.Bold
511
+ }).setTooltip(this.oBundle.getText("fixedOperator"))
512
+ }),
513
+ // new sap.m.Column({
514
+ // width: "15%",
515
+ // header: new sap.m.Label({
516
+ // text: this.oBundle.getText("valueOnly"),
517
+ // design: sap.m.LabelDesign.Bold
518
+ // }).setTooltip(this.oBundle.getText("valueOnly"))
519
+ // }),
520
+ new sap.m.Column({
521
+ width: "20%"
522
+ })
523
+ ]
524
+ }).data("hrf-id", "columnsTable", true);
525
+
526
+
527
+ this.conditionsTable.bindItems({
528
+ path: "DecisionTable/DecisionTableColumnsCondition",
529
+ factory: this._tableColumnsFactory.bind(this),
530
+ parameters: {
531
+ expand: "Condition"
532
+ }
533
+ });
534
+
535
+ this.conditionsTable.setBusyIndicatorDelay(0);
536
+
537
+ return this.conditionsTable;
538
+ };
539
+
540
+ sap.rules.ui.DecisionTableSettingsOld.prototype._createLayout = function() {
541
+ var oForm = new SimpleForm({
542
+ editable: true,
543
+ layout: "ResponsiveGridLayout",
544
+ maxContainerCols: 1,
545
+ columnsL: 1,
546
+ columnsM: 1,
547
+ labelSpanM: 1,
548
+ content: [
549
+ // new Label({
550
+ // text: this.oBundle.getText("advancedMode")
551
+ // }).setTooltip(this.oBundle.getText("advancedMode")),
552
+ // new CheckBox({
553
+ // selected: {
554
+ // path: "RuleFormat",
555
+ // formatter: Formatter.ruleFormatAsBoolean
556
+ // },
557
+ // enabled: "{maModel>/advancedMode/enabled}",
558
+ // visible: "{settingsModel>/advancedMode/visible}",
559
+ // select: this._setAdvancedMode.bind(this)
560
+ // }),
561
+
562
+ new Label({
563
+ text: this.oBundle.getText("hitPolicy")
564
+ }).setTooltip(this.oBundle.getText("hitPolicy")),
565
+ new Select({
566
+ width: "25%",
567
+ enabled: "{settingsModel>/hitPolicy/enabled}",
568
+ items: {
569
+ path: "settingsModel>/hitPolicy/hitPolicyEnumration",
570
+ template: new sap.ui.core.Item({
571
+ key: "{settingsModel>key}",
572
+ text: "{settingsModel>text}"
573
+ })
574
+ },
575
+ selectedKey: "{DecisionTable/HitPolicy}"
576
+ }),
577
+
578
+ new Label(),
579
+ this._createTable(),
580
+
581
+ new Label({
582
+ text: this.oBundle.getText("ouput")
583
+ }).setTooltip(this.oBundle.getText("ouput")),
584
+ new Text({
585
+ width: "25%",
586
+ text: "{ResultDataObjectName}"
587
+ })
588
+ ]
589
+ });
590
+
591
+ return oForm;
592
+ };
593
+
594
+ sap.rules.ui.DecisionTableSettingsOld.prototype._setFixedOperatorOnExpressionChange = function(displayExpression, colId) {
595
+ var oFixedOperatorData = this._getFixedOperatorDataForExpression(displayExpression);
596
+ this._internalModel.setProperty("/tableData/" + colId, oFixedOperatorData, true);
597
+ this._updateRemoveRowEnabled();
598
+ };
599
+
600
+ sap.rules.ui.DecisionTableSettingsOld.prototype.setExpressionLanguage = function (oExpressionLanguage){
601
+ this.setAssociation("expressionLanguage", oExpressionLanguage, true);
602
+ this._decisionTableHeaderSettingFormatter.setExpressionLanguage(oExpressionLanguage);
603
+ };
604
+ sap.rules.ui.DecisionTableSettingsOld.prototype._getColumnControlObject = function(oBindingContext) {
605
+ var mode = this._internalModel.getProperty("/advancedMode/current");
606
+ if (mode === sap.rules.ui.RuleFormat.Advanced) {
607
+ var oExpressionLanguage = sap.ui.getCore().byId(this.getExpressionLanguage());
608
+
609
+ return new ExpressionAdvanced({
610
+ expressionLanguage: oExpressionLanguage,
611
+ placeholder: this.oBundle.getText("expressionPlaceHolder"),
612
+ validateOnLoad: true,
613
+ type : sap.rules.ui.ExpressionType.NonComparison,
614
+ value: {
615
+ path: "Condition/Expression",
616
+ type: this._decisionTableHeaderSettingFormatter,
617
+ events: {
618
+ change: function(oEvent) {
619
+ var oSource = oEvent.getSource();
620
+ var oContext = oSource.getContext();
621
+ var colId = oContext.getProperty("Id");
622
+
623
+ //Workaround to fix RULES-4723
624
+ var result = oExpressionLanguage.convertDecisionTableExpressionToDisplayValue(oSource.getValue(), "", "", sap.rules.ui.ExpressionType.All);
625
+ var value;
626
+ if (result.output.status === "Success" && result.output.converted) {
627
+ value = result.output.converted.header;
628
+ } else {
629
+ value = oSource.getValue();
630
+ }
631
+
632
+ this._setFixedOperatorOnExpressionChange(value, colId);
633
+ }.bind(this)
634
+ }
635
+ },
636
+ enabled: true,
637
+ change: function(oEvent) {
638
+ var oSource = oEvent.getSource();
639
+ var oContext = oSource.getBindingContext();
640
+ var colId = oContext.getProperty("Id");
641
+ this._setFixedOperatorOnExpressionChange(oSource.getValue(), colId);
642
+
643
+ // clear previous fixed operator if expression is empty
644
+ var expression = oContext.getProperty("Condition/Expression");
645
+ if (!expression) {
646
+ var model = oContext.getModel();
647
+ model.setProperty(oContext.getPath() + "/Condition/FixedOperator", "");
648
+ }
649
+ }.bind(this)
650
+ });
651
+ } else {
652
+ return new Select({
653
+ width: "100%",
654
+ items: {
655
+ path: "",
656
+ template: new sap.ui.core.Item({
657
+ key: "",
658
+ text: ""
659
+ })
660
+ },
661
+ selectedKey: "{Condition/Expression}",
662
+ enabled: true,
663
+ change: function(oControlEvent) {
664
+
665
+ }
666
+ });
667
+ }
668
+ };
669
+
670
+ sap.rules.ui.DecisionTableSettingsOld.prototype._tableColumnsFactory = function(sId, oContext) {
671
+ var ruleId = oContext.getProperty("RuleId");
672
+ var version = oContext.getProperty("Version");
673
+ var colId = oContext.getProperty("Id");
674
+
675
+ return new sap.m.ColumnListItem({
676
+ cells: [
677
+ this._getColumnControlObject(oContext),
678
+ // new sap.m.Input({
679
+ // value: "{Condition/Description}",
680
+ // placeholder: this.oBundle.getText("displayNamePlaceHolder")
681
+ // }),
682
+ new sap.m.Select({
683
+ width: "100%",
684
+ items: {
685
+ path: "settingsModel>/tableData/" + colId + "/fixOperatorEnumration",
686
+ template: new sap.ui.core.Item({
687
+ key: "{settingsModel>key}",
688
+ text: "{settingsModel>value}"
689
+ })
690
+ },
691
+ selectedKey: "{Condition/FixedOperator}",
692
+ enabled: "{settingsModel>/tableData/" + colId + "/fixOperatorEnabled}"
693
+ }),
694
+ // new sap.m.Switch({
695
+ // state: "{Condition/ValueOnly}",
696
+ // enabled: false
697
+ // }),
698
+ new sap.ui.layout.HorizontalLayout({
699
+ content: [
700
+ new sap.m.Button({
701
+ type: sap.m.ButtonType.Transparent,
702
+ icon: sap.ui.core.IconPool.getIconURI("sys-cancel"),
703
+ visible: "{settingsModel>/removeRowEnabled}",
704
+ press: function(oEvent) {
705
+ var oColumnContext = oEvent.getSource().getBindingContext();
706
+ var params = {
707
+ //groupId: sap.rules.ui.ChangeId.DecisionTableColumns
708
+ };
709
+ this._removeColumnWorkaround(oColumnContext, params);
710
+ }.bind(this)
711
+ }).setTooltip(this.oBundle.getText("removeColumn")),
712
+ new sap.m.Button({
713
+ type: sap.m.ButtonType.Transparent,
714
+ icon: sap.ui.core.IconPool.getIconURI("add"),
715
+ press: function(oEvent) {
716
+ var oData = {
717
+ ruleId: ruleId,
718
+ version: version,
719
+ colId: colId + 1,
720
+ expression: ""
721
+ };
722
+ var params = {
723
+ //groupId: sap.rules.ui.ChangeId.DecisionTableColumns
724
+ };
725
+ this._addConditionWorkaround(oData, params);
726
+ }.bind(this)
727
+ }).setTooltip(this.oBundle.getText("addColumn"))
728
+ ],
729
+ height: "1em"
730
+ })
731
+ ]
732
+ });
733
+ };
734
+
735
+ /**
736
+ * Create DecisionTable structure for new rule
737
+ * @private
738
+ */
739
+ sap.rules.ui.DecisionTableSettingsOld.prototype._prepareNewRuleWorkaround = function() {
740
+ this._prepareNewRule();
741
+ this._saveWorkaround();
742
+ };
743
+
744
+ /**
745
+ * Add new condition to Decision Table
746
+ * @param {object} oData - data for new column
747
+ * @param {map} mParameters? - Optional parameter map containing any of the following properties:
748
+ * @private
749
+ */
750
+ sap.rules.ui.DecisionTableSettingsOld.prototype._addConditionWorkaround = function(oData, mParameters) {
751
+
752
+ this._createCondition(oData, mParameters);
753
+ this._saveWorkaround();
754
+ };
755
+
756
+ /**
757
+ * Remove column
758
+ * @param {object} oColumnContext - context of column to remove
759
+ * @param {map} mParameters? - Optional parameter map containing any of the following properties:
760
+ * @private
761
+ */
762
+ sap.rules.ui.DecisionTableSettingsOld.prototype._removeColumnWorkaround = function(oColumnContext, mParameters) {
763
+ var oModel = this._getModel();
764
+
765
+ if (oModel.hasPendingChanges()) {
766
+ // save all model's changes before row removal
767
+ this._saveWorkaround({
768
+ success: function() {
769
+ this._removeColumn(oColumnContext, mParameters);
770
+ }.bind(this)
771
+ });
772
+ } else {
773
+ this._removeColumn(oColumnContext, mParameters);
774
+ }
775
+ };
776
+
777
+ /**
778
+ * @private
779
+ * @param {map} mParameters? - Optional parameter map containing any of the following properties:
780
+ */
781
+ sap.rules.ui.DecisionTableSettingsOld.prototype._saveWorkaround = function(mParameters) {
782
+ var oModel = this._getModel();
783
+ oModel.submitChanges(mParameters);
784
+ };
785
+
786
+
787
+ sap.rules.ui.DecisionTableSettingsOld.prototype._getModel = function() {
788
+ var modelName = this.getModelName();
789
+ if (modelName) {
790
+ return this.getModel(modelName);
791
+ }
792
+ return this.getModel();
793
+ };
794
+
795
+ sap.rules.ui.DecisionTableSettingsOld.prototype._getBindModelName = function() {
796
+ var path = "";
797
+ var modelName = this.getModelName();
798
+
799
+ if (modelName) {
800
+ path = modelName + ">";
801
+ }
802
+
803
+ return path;
804
+ };
805
+
806
+ sap.rules.ui.DecisionTableSettingsOld.prototype._initSettingsModel = function() {
807
+ var initialData = {};
808
+
809
+ initialData.advancedMode = this._getAdvancedModeData();
810
+ initialData.hitPolicy = this._getHitPoliciesData();
811
+ initialData.tableData = {};
812
+ initialData.removeRowEnabled = false;
813
+
814
+ this._internalModel = new sap.ui.model.json.JSONModel(initialData);
815
+ this.setModel(this._internalModel, "settingsModel");
816
+ };
817
+
818
+ sap.rules.ui.DecisionTableSettingsOld.prototype._getAdvancedModeData = function() {
819
+ var mode;
820
+ var advancedModeData = {};
821
+
822
+ // Check rule's Format from rule's data - it is stronger then configuration property
823
+ var oContext = this.getBindingContext();
824
+ var ruleFormat = oContext.getProperty("RuleFormat");
825
+
826
+ if (ruleFormat === sap.rules.ui.RuleFormat.Advanced) {
827
+ mode = sap.rules.ui.RuleFormat.Advanced;
828
+ } else {
829
+ mode = sap.rules.ui.RuleFormat.Advanced; // TODO: should be: this.getRuleFormat();
830
+ }
831
+
832
+ switch (mode) {
833
+ case sap.rules.ui.RuleFormat.All:
834
+ advancedModeData = {
835
+ current: sap.rules.ui.RuleFormat.Basic,
836
+ enabled: true,
837
+ visible: true
838
+ };
839
+ break;
840
+
841
+ case sap.rules.ui.RuleFormat.Basic:
842
+ advancedModeData = {
843
+ current: sap.rules.ui.RuleFormat.Basic,
844
+ enabled: false,
845
+ visible: false
846
+ };
847
+ break;
848
+
849
+ case sap.rules.ui.RuleFormat.Advanced:
850
+ advancedModeData = {
851
+ current: sap.rules.ui.RuleFormat.Advanced,
852
+ enabled: false,
853
+ visible: true
854
+ };
855
+
856
+ break;
857
+
858
+ default:
859
+ }
860
+ return advancedModeData;
861
+ };
862
+
863
+ sap.rules.ui.DecisionTableSettingsOld.prototype._getHitPoliciesData = function() {
864
+ var hitPolicy = this.getProperty("hitPolicies");
865
+ var length = hitPolicy.length;
866
+ var oHitPolicyData = {
867
+ hitPolicyEnumration: []
868
+ };
869
+
870
+ for (var i = 0; i < length; i++) {
871
+ oHitPolicyData.hitPolicyEnumration.push({
872
+ key: hitPolicy[i],
873
+ text: this.oBundle.getText(hitPolicy[i])
874
+ });
875
+ }
876
+
877
+ oHitPolicyData.enabled = length > 1 ? true : false;
878
+
879
+ return oHitPolicyData;
880
+ };
881
+
882
+ sap.rules.ui.DecisionTableSettingsOld.prototype._getFixedOperatorDataForExpression = function(sExpression) {
883
+ var fixOperatorEnabled = sExpression ? true : false;
884
+ var fixedOperatiorData = {
885
+ fixOperatorEnumration: [{
886
+ key: "",
887
+ value: this.oBundle.getText("fixOperatorDefaultValue")
888
+ }],
889
+ fixOperatorEnabled: fixOperatorEnabled
890
+ };
891
+
892
+ if (fixOperatorEnabled) {
893
+ var oSuggestions = [];
894
+ var oExpressionLanguage = sap.ui.getCore().byId(this.getExpressionLanguage());
895
+ var oFilter = [{
896
+ tokenType: sap.rules.ui.ExpressionTokenType.reservedWord,
897
+ tokenCategory: sap.rules.ui.ExpressionCategory.comparisonOp
898
+ }, {
899
+ tokenType: sap.rules.ui.ExpressionTokenType.reservedWord,
900
+ tokenCategory: sap.rules.ui.ExpressionCategory.comparisonBetweenOp
901
+ }, {
902
+ tokenType: sap.rules.ui.ExpressionTokenType.reservedWord,
903
+ tokenCategory: sap.rules.ui.ExpressionCategory.comparisonExistOp
904
+ }];
905
+ oSuggestions = oExpressionLanguage.getSuggestionsByCategories(sExpression, oFilter);
906
+ for (var i = 0; i < oSuggestions.length; i++) {
907
+ fixedOperatiorData.fixOperatorEnumration.push({
908
+ key: oSuggestions[i].text,
909
+ value: oSuggestions[i].text
910
+ });
911
+ }
912
+ }
913
+ return fixedOperatiorData;
914
+ };
915
+
916
+ sap.rules.ui.DecisionTableSettingsOld.prototype._setAdvancedMode = function(oControlEvent) {
917
+ var bAdvancedModeStatus = oControlEvent.getParameter("selected");
918
+ var ruleFormat = bAdvancedModeStatus ? sap.rules.ui.RuleFormat.Advanced : sap.rules.ui.RuleFormat.Basic;
919
+
920
+ var oRuleModel = this._getModel();
921
+ var oContextPath = this.getBindingContext().getPath();
922
+ oRuleModel.setProperty(oContextPath + "/RuleFormat", ruleFormat);
923
+
924
+ this.needCreateLayout = true;
925
+ this.invalidate();
926
+ };
927
+
928
+ sap.rules.ui.DecisionTableSettingsOld.prototype._updateRemoveRowEnabled = function() {
929
+ var tableData = this._internalModel.getProperty("/tableData");
930
+ var len = Object.keys(tableData).length;
931
+ var enabled = len > 1;
932
+ this._internalModel.setProperty("/removeRowEnabled", enabled, null, true);
933
+ };
934
+
935
+ sap.rules.ui.DecisionTableSettingsOld.prototype.getButtons = function(oDialog) {
936
+
937
+ var aButtons = [];
938
+
939
+ //Add apply button
940
+ var oApplyButton = new Button({
941
+ text: this.oBundle.getText("applyChangesBtn")
942
+ }).setTooltip(this.oBundle.getText("applyChangesBtn"));
943
+
944
+ oApplyButton.attachPress(function() {
945
+
946
+ //flag for calculate only once header span for multi header in columnFactory function
947
+ this.multiHeaderFlag = false;
948
+
949
+ // Workaround: we submit changes, because if we change a cell and then open this dialog and close it,
950
+ // the cell display value will not be the same as the cell value when in-focus
951
+ this.getModel().submitChanges();
952
+
953
+ //For attachBeforeClose in decisionTable file
954
+ oDialog.setState(sap.ui.core.ValueState.Success);
955
+
956
+ oDialog.close();
957
+
958
+ }, this);
959
+
960
+ aButtons.push(oApplyButton);
961
+
962
+ return aButtons;
963
+ };
964
+
965
+ return oDecisionTableSettingsOld;
966
+
965
967
  }, /* bExport= */ true);