@sapui5/sap.rules.ui 1.107.0 → 1.108.0

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 +7 -4
  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,433 +1,436 @@
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
- "./library",
12
- "sap/ui/core/Control",
13
- "sap/m/Select",
14
- "sap/ui/core/Item",
15
- "sap/rules/ui/DecisionTable",
16
- "sap/rules/ui/DecisionTableConfiguration",
17
- "sap/rules/ui/TextRuleConfiguration",
18
- "sap/rules/ui/RuleType",
19
- "sap/rules/ui/RuleFormat",
20
- "sap/rules/ui/TextRule"
21
- ], function(jQuery, library, Control, Select, Item, DecisionTable, DecisionTableConfiguration, TextRuleConfiguration, RuleType,
22
- RuleFormat, TextRule) {
23
- "use strict";
24
-
25
- /**
26
- * Constructor for a new RuleBuilder control.
27
- *
28
- * @param {string} [sId] ID for the new control, generated automatically if no ID is given.
29
- * @param {object} [mSettings] Initial settings for the new control.
30
- *
31
- * @class
32
- * The <code>sap.rules.ui.RuleBuilder</code> control allows business users to create rules using a business language.
33
- * @extends sap.ui.core.Control
34
- *
35
- * @author SAP SE
36
- * @version 1.107.0
37
- *
38
- * @constructor
39
- * @public
40
- * @alias sap.rules.ui.RuleBuilder
41
- * @ui5-metamodel This control/element also will be described in the UI5 (legacy) designtime metamodel
42
- *
43
- */
44
- var oRuleBuilder = Control.extend("sap.rules.ui.RuleBuilder", {
45
- metadata: {
46
- library: "sap.rules.ui",
47
- properties: {
48
- /**
49
- * Available types that can be created using the <code>sap.rules.ui.RuleBuilder</code> control.
50
- * If empty, all rule types will be available for selection.
51
- * If only one type exists, the Rule Builder will open it automatically.
52
- */
53
- types: {
54
- type: "sap.rules.ui.RuleType[]",
55
- defaultValue: [sap.rules.ui.RuleType.DecisionTable, sap.rules.ui.RuleType.TextRule]
56
- },
57
- /**
58
- * Name of the rule's ODataModel (optional).
59
- * The ODataModel object belongs to the application and should be set by the application.
60
- * Example:
61
- * <pre class="javascript">
62
- * var oModel = new sap.ui.model.v2.oDataModel();
63
- * var ruleBuilder = new RuleBuilder({
64
- * modelName: "rulesModel"
65
- * });
66
- * ruleBuilder.setModel(oModel, "rulesModel")
67
- * </pre>
68
- */
69
- // modelName: {
70
- // type: "string",
71
- // group: "Misc",
72
- // },
73
- /**
74
- * Path to a Rule object in the model data, which is used for the definition of relative context bindings inside the RuleBuilder control (mandatory).
75
- * Example: "/Rules(Id='0050569181751ED683EFEEC6AA2B73C5',Version='000001')"
76
- */
77
- bindingContextPath: {
78
- type: "string",
79
- group: "Misc"
80
- },
81
- /**
82
- * Indicates whether or not the controls of the RuleBuilder are editable.
83
- */
84
- editable: {
85
- type: "boolean",
86
- defaultValue: true
87
- }
88
- },
89
- aggregations: {
90
- /**
91
- * Provides a combo box from which the user selects the rule type for the new rule. Only relevant if <b>types</b> contains more than one value.
92
- * @private
93
- */
94
- _ruleTypeSelector: {
95
- type: "sap.m.ComboBox",
96
- multiple: false,
97
- singularName: "_ruleTypeSelector",
98
- visibility: "hidden"
99
- },
100
- /**
101
- * Rule created by the Rule Builder.
102
- * @private
103
- */
104
- _rule: {
105
- type: "sap.rules.ui.RuleBase",
106
- multiple: false,
107
- singularName: "_rule",
108
- visibility: "hidden"
109
- },
110
- /**
111
- * Configuration for rule of type 'decision table'.
112
- */
113
- decisionTableConfiguration: {
114
- type: "sap.rules.ui.DecisionTableConfiguration",
115
- multiple: false,
116
- singularName: "decisionTableConfiguration"
117
- },
118
- /**
119
- * Configuration for rule of type 'Text Rule'.
120
- */
121
- textRuleConfiguration: {
122
- type: "sap.rules.ui.TextRuleConfiguration",
123
- multiple: false,
124
- singularName: "textRuleConfiguration"
125
- }
126
-
127
- },
128
- /**
129
- * Association to the expression language element.
130
- */
131
- associations: {
132
- /**
133
- Expression language to model English like expressions. Should not be used when sap.rules.ui.services.AstExpressionLanguage is used.
134
- */
135
- "expressionLanguage": {
136
- type: "sap.rules.ui.services.ExpressionLanguage",
137
- multiple: false,
138
- singularName: "expressionLanguage"
139
- },
140
- /**
141
- Expression language to use DMN SFEEL for modelling expressions. Should not be used when sap.rules.ui.services.ExpressionLanguage is used.
142
- */
143
- "astExpressionLanguage": {
144
- type: "sap.rules.ui.services.AstExpressionLanguage",
145
- multiple: false,
146
- singularName: "astExpressionLanguage"
147
- }
148
- },
149
-
150
- events: {
151
- // "controlReady": {},
152
- // "ruleBodyChange": {},
153
- // "ruleBodyLiveChange": {},
154
- // "displayModeSelected": {}
155
- }
156
- },
157
-
158
- init: function() {
159
- this.oBundle = sap.ui.getCore().getLibraryResourceBundle("sap.rules.ui.i18n");
160
- this.needCreateDisplayedControl = true;
161
-
162
- this.needRebind = true;
163
-
164
- this._internalModel = this._initInternalModel();
165
- this.setModel(this._internalModel, "ruleBuilderInternalModel");
166
- },
167
-
168
- validate: function() {
169
- var oRule = this.getAggregation("_rule");
170
- if (oRule) {
171
- oRule.validate();
172
- }
173
- },
174
-
175
- _initInternalModel: function() {
176
- var data = {
177
- types: this.getTypes(),
178
- //modelName: this.getModelName(),
179
- bindingContextPath: this.getBindingContextPath(),
180
- editable: this.getEditable(),
181
- decisionTableConfiguration: {},
182
- textRuleConfiguration: {}
183
- };
184
- var oModel = new sap.ui.model.json.JSONModel();
185
- oModel.setData(data);
186
- return oModel;
187
- },
188
-
189
- _getModel: function() {
190
- // var modelName = this.getModelName();
191
- // if (modelName) {
192
- // return this.getModel(modelName);
193
- // }
194
- return this.getModel();
195
- },
196
-
197
- _setBindingContext: function() {
198
- var bindingContextPath = this.getBindingContextPath();
199
- var model = this._getModel();
200
-
201
- var oContext = new sap.ui.model.Context(model, bindingContextPath);
202
- this.setBindingContext(oContext);
203
- },
204
-
205
- _createRuleset: function() {
206
- return null;
207
- },
208
-
209
- _createTextRule: function() {
210
- // get DT configuration object, or create it if it doesn't exists
211
- var oTextRuleConfiguration = this.getTextRuleConfiguration();
212
- if (!oTextRuleConfiguration) {
213
- oTextRuleConfiguration = new sap.rules.ui.TextRuleConfiguration();
214
- this.setTextRuleConfiguration(oTextRuleConfiguration);
215
- };
216
-
217
- var oTextRule = new sap.rules.ui.TextRule({
218
- bindingContextPath: {
219
- path: "ruleBuilderInternalModel>/bindingContextPath"
220
- },
221
- modelName: {
222
- path: "ruleBuilderInternalModel>/modelName"
223
- },
224
- editable: {
225
- path: "ruleBuilderInternalModel>/editable"
226
- },
227
- enableSettings: {
228
- path: "ruleBuilderInternalModel>/textRuleConfiguration/enableSettings"
229
- },
230
- enableSettingResult: {
231
- path: "ruleBuilderInternalModel>/textRuleConfiguration/enableSettingResult"
232
- },
233
- expressionLanguage: this.getExpressionLanguage(),
234
- astExpressionLanguage: this.getAstExpressionLanguage()
235
- });
236
- return oTextRule;
237
- },
238
-
239
- _createDecisionTable: function() {
240
- // get DT configuration object, or create it if it doesn't exists
241
- var oDecisionTableConfiguration = this.getDecisionTableConfiguration();
242
- if (!oDecisionTableConfiguration) {
243
- oDecisionTableConfiguration = new sap.rules.ui.DecisionTableConfiguration();
244
- this.setDecisionTableConfiguration(oDecisionTableConfiguration);
245
- };
246
-
247
- sap.rules.ui.DecisionTable.prototype.VISIBLEROWCOUNT = this.getDecisionTableConfiguration().getVisibleRowCount();
248
- sap.rules.ui.DecisionTable.prototype.THRESHOLD = this.getDecisionTableConfiguration().getThreshold();
249
- // create DT
250
- var oDT = new sap.rules.ui.DecisionTable({
251
- bindingContextPath: {
252
- path: "ruleBuilderInternalModel>/bindingContextPath"
253
- },
254
- modelName: {
255
- path: "ruleBuilderInternalModel>/modelName"
256
- },
257
- editable: {
258
- path: "ruleBuilderInternalModel>/editable"
259
- },
260
- cellFormat: {
261
- path: "ruleBuilderInternalModel>/decisionTableConfiguration/cellFormat"
262
- },
263
- enableSettings: {
264
- path: "ruleBuilderInternalModel>/decisionTableConfiguration/enableSettings"
265
- },
266
- enableSettingResult: {
267
- path: "ruleBuilderInternalModel>/decisionTableConfiguration/enableSettingResult"
268
- },
269
- hitPolicies: {
270
- path: "ruleBuilderInternalModel>/decisionTableConfiguration/hitPolicies"
271
- },
272
- decisionTableFormat: {
273
- path: "ruleBuilderInternalModel>/decisionTableConfiguration/decisionTableFormat"
274
- },
275
- expressionLanguage: this.getExpressionLanguage(),
276
- astExpressionLanguage: this.getAstExpressionLanguage()
277
-
278
- });
279
- return oDT;
280
- },
281
-
282
- _createDisplayedControl: function(sDisplayedControlType) {
283
- var oDisplayedControl;
284
- switch (sDisplayedControlType) {
285
- case sap.rules.ui.RuleType.DecisionTable:
286
- oDisplayedControl = this._createDecisionTable();
287
- break;
288
- case "sap.rules.ui.RuleType.Ruleset":
289
- oDisplayedControl = this._createRuleset();
290
- break;
291
- case sap.rules.ui.RuleType.TextRule:
292
- oDisplayedControl = this._createTextRule();
293
- break;
294
- default:
295
- break;
296
- };
297
- this.setAggregation("_rule", oDisplayedControl, true);
298
- },
299
-
300
- _createRuleTypeSelector: function() {
301
- /*eslint consistent-this: ["error", "me"]*/
302
- var me = this;
303
-
304
- this.oBundle.getText('decisionTable');
305
-
306
- var oRuleTypesModel = new sap.ui.model.json.JSONModel({
307
- items: [{
308
- key: sap.rules.ui.RuleType.DecisionTable,
309
- text: this.oBundle.getText('decisionTable')
310
- }]
311
- });
312
-
313
- var oRuleTypeSelector = new sap.m.ComboBox({
314
- width: "25%",
315
- items: {
316
- path: 'ruleTypes>/items',
317
- template: new sap.ui.core.Item({
318
- text: "{ruleTypes>text}",
319
- key: "{ruleTypes>key}"
320
- })
321
- },
322
- change: function(oEvent) {
323
- var sRuleType = oEvent.getSource().getSelectedKey();
324
- me._createDisplayedControl.call(me, sRuleType);
325
- }
326
- }).setModel(oRuleTypesModel, "ruleTypes");
327
-
328
- this.setAggregation("_ruleTypeSelector", oRuleTypeSelector, true);
329
- },
330
-
331
- setEditable: function(value) {
332
- this._internalModel.setProperty("/editable", value);
333
- return this.setProperty("editable", value, true);
334
- },
335
- setBindingContextPath: function(value, reload) {
336
- var oldValue = this.getBindingContextPath();
337
- if (reload || (value && (oldValue !== value))) {
338
- this.needRebind = true;
339
- this._internalModel.setProperty("/bindingContextPath", value);
340
- this._needReBind();
341
- return this.setProperty("bindingContextPath", value);
342
- }
343
- },
344
- setModelName: function(value) {
345
- this.needRebind = true;
346
- this._internalModel.setProperty("/modelName", value);
347
- return this.setProperty("modelName", value);
348
- },
349
-
350
- _setTextRuleConfigurationProperty: function(propertyName, value) {
351
- var sPath = "/textRuleConfiguration/" + propertyName;
352
- this._internalModel.setProperty(sPath, value);
353
- },
354
-
355
- setTextRuleConfiguration: function(oTextRuleConfiguration) {
356
- oTextRuleConfiguration.attachChange(function(oEvent) {
357
- this.getParent()._setTextRuleConfigurationProperty.call(this.getParent(), oEvent.getParameter("name"), oEvent.getParameter(
358
- "value"))
359
- });
360
-
361
- this._setTextRuleConfigurationProperty("enableSettings", oTextRuleConfiguration.getEnableSettings());
362
- this._setTextRuleConfigurationProperty("enableSettingResult", oTextRuleConfiguration.getEnableSettingResult());
363
-
364
- return this.setAggregation("textRuleConfiguration", oTextRuleConfiguration, true)
365
- },
366
-
367
- _setDecisionTableConfigurationProperty: function(propertyName, value) {
368
- var sPath = "/decisionTableConfiguration/" + propertyName;
369
- this._internalModel.setProperty(sPath, value);
370
- },
371
-
372
- setDecisionTableConfiguration: function(oDecisionTableConfiguration) {
373
- oDecisionTableConfiguration.attachChange(function(oEvent) {
374
- this.getParent()._setDecisionTableConfigurationProperty.call(this.getParent(), oEvent.getParameter("name"), oEvent.getParameter(
375
- "value"))
376
- });
377
-
378
- this._setDecisionTableConfigurationProperty("enableSettings", oDecisionTableConfiguration.getEnableSettings());
379
- this._setDecisionTableConfigurationProperty("enableSettingResult", oDecisionTableConfiguration.getEnableSettingResult());
380
- this._setDecisionTableConfigurationProperty("hitPolicies", oDecisionTableConfiguration.getHitPolicies());
381
- this._setDecisionTableConfigurationProperty("cellFormat", oDecisionTableConfiguration.getCellFormat());
382
- this._setDecisionTableConfigurationProperty("decisionTableFormat", oDecisionTableConfiguration.getDecisionTableFormat());
383
- this._setDecisionTableConfigurationProperty("visibleRowCount", oDecisionTableConfiguration.getVisibleRowCount());
384
- this._setDecisionTableConfigurationProperty("threshold", oDecisionTableConfiguration.getThreshold());
385
-
386
- return this.setAggregation("decisionTableConfiguration", oDecisionTableConfiguration, true)
387
- },
388
-
389
- setExpressionLanguage: function(oExpressionLanguage) {
390
- var oRule = this.getAggregation("_rule");
391
- if (oRule) {
392
- oRule.setExpressionLanguage(oExpressionLanguage);
393
- }
394
- return this.setAssociation("expressionLanguage", oExpressionLanguage, true);
395
- },
396
-
397
- setAstExpressionLanguage: function(oAstExpressionLanguage) {
398
- var oRule = this.getAggregation("_rule");
399
- if (oRule) {
400
- oRule.setAstExpressionLanguage(oAstExpressionLanguage);
401
- }
402
- return this.setAssociation("astExpressionLanguage", oAstExpressionLanguage, true);
403
- },
404
-
405
- resetControl: function () {     // Destroy the content
406
-     
407
- var  oRuleAggregation  = this.getAggregation("_rule");
408
- if (oRuleAggregation) { 
409
- oRuleAggregation.destroy();
410
- }
411
- },
412
-
413
- _needReBind: function() {
414
- if (this.needRebind) {
415
- this.resetControl();
416
- var oRuleTypes = this.getTypes();
417
- if (oRuleTypes && oRuleTypes.length === 1) {
418
- this._createDisplayedControl(oRuleTypes[0]);
419
- this.needCreateDisplayedControl = false;
420
- }
421
- this.needRebind = false;
422
- }
423
- },
424
-
425
- onBeforeRendering: function() {
426
- this._needReBind();
427
- }
428
-
429
- });
430
-
431
- return oRuleBuilder;
432
-
433
- }, /* bExport= */ true);
5
+
6
+ */
7
+
8
+ // Provides control sap.rules.ui.
9
+ sap.ui.define([
10
+ "jquery.sap.global",
11
+ "./library",
12
+ "sap/ui/core/Control",
13
+ "sap/m/Select",
14
+ "sap/ui/core/Item",
15
+ "sap/rules/ui/DecisionTable",
16
+ "sap/rules/ui/DecisionTableConfiguration",
17
+ "sap/rules/ui/TextRuleConfiguration",
18
+ "sap/rules/ui/RuleType",
19
+ "sap/rules/ui/RuleFormat",
20
+ "sap/rules/ui/TextRule",
21
+ "./RuleBuilderRenderer"
22
+ ], function(jQuery, library, Control, Select, Item, DecisionTable, DecisionTableConfiguration, TextRuleConfiguration, RuleType,
23
+ RuleFormat, TextRule, RuleBuilderRenderer) {
24
+ "use strict";
25
+
26
+ /**
27
+ * Constructor for a new RuleBuilder control.
28
+ *
29
+ * @param {string} [sId] ID for the new control, generated automatically if no ID is given.
30
+ * @param {object} [mSettings] Initial settings for the new control.
31
+ *
32
+ * @class
33
+ * The <code>sap.rules.ui.RuleBuilder</code> control allows business users to create rules using a business language.
34
+ * @extends sap.ui.core.Control
35
+ *
36
+ * @author SAP SE
37
+ * @version 1.108.0
38
+ *
39
+ * @constructor
40
+ * @public
41
+ * @alias sap.rules.ui.RuleBuilder
42
+ * @ui5-metamodel This control/element also will be described in the UI5 (legacy) designtime metamodel
43
+ *
44
+ */
45
+ var oRuleBuilder = Control.extend("sap.rules.ui.RuleBuilder", {
46
+ metadata: {
47
+ library: "sap.rules.ui",
48
+ properties: {
49
+ /**
50
+ * Available types that can be created using the <code>sap.rules.ui.RuleBuilder</code> control.
51
+ * If empty, all rule types will be available for selection.
52
+ * If only one type exists, the Rule Builder will open it automatically.
53
+ */
54
+ types: {
55
+ type: "sap.rules.ui.RuleType[]",
56
+ defaultValue: [sap.rules.ui.RuleType.DecisionTable, sap.rules.ui.RuleType.TextRule]
57
+ },
58
+ /**
59
+ * Name of the rule's ODataModel (optional).
60
+ * The ODataModel object belongs to the application and should be set by the application.
61
+ * Example:
62
+ * <pre class="javascript">
63
+ * var oModel = new sap.ui.model.v2.oDataModel();
64
+ * var ruleBuilder = new RuleBuilder({
65
+ * modelName: "rulesModel"
66
+ * });
67
+ * ruleBuilder.setModel(oModel, "rulesModel")
68
+ * </pre>
69
+ */
70
+ // modelName: {
71
+ // type: "string",
72
+ // group: "Misc",
73
+ // },
74
+ /**
75
+ * Path to a Rule object in the model data, which is used for the definition of relative context bindings inside the RuleBuilder control (mandatory).
76
+ * Example: "/Rules(Id='0050569181751ED683EFEEC6AA2B73C5',Version='000001')"
77
+ */
78
+ bindingContextPath: {
79
+ type: "string",
80
+ group: "Misc"
81
+ },
82
+ /**
83
+ * Indicates whether or not the controls of the RuleBuilder are editable.
84
+ */
85
+ editable: {
86
+ type: "boolean",
87
+ defaultValue: true
88
+ }
89
+ },
90
+ aggregations: {
91
+ /**
92
+ * Provides a combo box from which the user selects the rule type for the new rule. Only relevant if <b>types</b> contains more than one value.
93
+ * @private
94
+ */
95
+ _ruleTypeSelector: {
96
+ type: "sap.m.ComboBox",
97
+ multiple: false,
98
+ singularName: "_ruleTypeSelector",
99
+ visibility: "hidden"
100
+ },
101
+ /**
102
+ * Rule created by the Rule Builder.
103
+ * @private
104
+ */
105
+ _rule: {
106
+ type: "sap.rules.ui.RuleBase",
107
+ multiple: false,
108
+ singularName: "_rule",
109
+ visibility: "hidden"
110
+ },
111
+ /**
112
+ * Configuration for rule of type 'decision table'.
113
+ */
114
+ decisionTableConfiguration: {
115
+ type: "sap.rules.ui.DecisionTableConfiguration",
116
+ multiple: false,
117
+ singularName: "decisionTableConfiguration"
118
+ },
119
+ /**
120
+ * Configuration for rule of type 'Text Rule'.
121
+ */
122
+ textRuleConfiguration: {
123
+ type: "sap.rules.ui.TextRuleConfiguration",
124
+ multiple: false,
125
+ singularName: "textRuleConfiguration"
126
+ }
127
+
128
+ },
129
+ /**
130
+ * Association to the expression language element.
131
+ */
132
+ associations: {
133
+ /**
134
+ Expression language to model English like expressions. Should not be used when sap.rules.ui.services.AstExpressionLanguage is used.
135
+ */
136
+ "expressionLanguage": {
137
+ type: "sap.rules.ui.services.ExpressionLanguage",
138
+ multiple: false,
139
+ singularName: "expressionLanguage"
140
+ },
141
+ /**
142
+ Expression language to use DMN SFEEL for modelling expressions. Should not be used when sap.rules.ui.services.ExpressionLanguage is used.
143
+ */
144
+ "astExpressionLanguage": {
145
+ type: "sap.rules.ui.services.AstExpressionLanguage",
146
+ multiple: false,
147
+ singularName: "astExpressionLanguage"
148
+ }
149
+ },
150
+
151
+ events: {
152
+ // "controlReady": {},
153
+ // "ruleBodyChange": {},
154
+ // "ruleBodyLiveChange": {},
155
+ // "displayModeSelected": {}
156
+ }
157
+ },
158
+
159
+ init: function() {
160
+ this.oBundle = sap.ui.getCore().getLibraryResourceBundle("sap.rules.ui.i18n");
161
+ this.needCreateDisplayedControl = true;
162
+
163
+ this.needRebind = true;
164
+
165
+ this._internalModel = this._initInternalModel();
166
+ this.setModel(this._internalModel, "ruleBuilderInternalModel");
167
+ },
168
+
169
+ validate: function() {
170
+ var oRule = this.getAggregation("_rule");
171
+ if (oRule) {
172
+ oRule.validate();
173
+ }
174
+ },
175
+
176
+ _initInternalModel: function() {
177
+ var data = {
178
+ types: this.getTypes(),
179
+ //modelName: this.getModelName(),
180
+ bindingContextPath: this.getBindingContextPath(),
181
+ editable: this.getEditable(),
182
+ decisionTableConfiguration: {},
183
+ textRuleConfiguration: {}
184
+ };
185
+ var oModel = new sap.ui.model.json.JSONModel();
186
+ oModel.setData(data);
187
+ return oModel;
188
+ },
189
+
190
+ _getModel: function() {
191
+ // var modelName = this.getModelName();
192
+ // if (modelName) {
193
+ // return this.getModel(modelName);
194
+ // }
195
+ return this.getModel();
196
+ },
197
+
198
+ _setBindingContext: function() {
199
+ var bindingContextPath = this.getBindingContextPath();
200
+ var model = this._getModel();
201
+
202
+ var oContext = new sap.ui.model.Context(model, bindingContextPath);
203
+ this.setBindingContext(oContext);
204
+ },
205
+
206
+ _createRuleset: function() {
207
+ return null;
208
+ },
209
+
210
+ _createTextRule: function() {
211
+ // get DT configuration object, or create it if it doesn't exists
212
+ var oTextRuleConfiguration = this.getTextRuleConfiguration();
213
+ if (!oTextRuleConfiguration) {
214
+ oTextRuleConfiguration = new sap.rules.ui.TextRuleConfiguration();
215
+ this.setTextRuleConfiguration(oTextRuleConfiguration);
216
+ };
217
+
218
+ var oTextRule = new sap.rules.ui.TextRule({
219
+ bindingContextPath: {
220
+ path: "ruleBuilderInternalModel>/bindingContextPath"
221
+ },
222
+ modelName: {
223
+ path: "ruleBuilderInternalModel>/modelName"
224
+ },
225
+ editable: {
226
+ path: "ruleBuilderInternalModel>/editable"
227
+ },
228
+ enableSettings: {
229
+ path: "ruleBuilderInternalModel>/textRuleConfiguration/enableSettings"
230
+ },
231
+ enableSettingResult: {
232
+ path: "ruleBuilderInternalModel>/textRuleConfiguration/enableSettingResult"
233
+ },
234
+ expressionLanguage: this.getExpressionLanguage(),
235
+ astExpressionLanguage: this.getAstExpressionLanguage()
236
+ });
237
+ return oTextRule;
238
+ },
239
+
240
+ _createDecisionTable: function() {
241
+ // get DT configuration object, or create it if it doesn't exists
242
+ var oDecisionTableConfiguration = this.getDecisionTableConfiguration();
243
+ if (!oDecisionTableConfiguration) {
244
+ oDecisionTableConfiguration = new sap.rules.ui.DecisionTableConfiguration();
245
+ this.setDecisionTableConfiguration(oDecisionTableConfiguration);
246
+ };
247
+
248
+ sap.rules.ui.DecisionTable.prototype.VISIBLEROWCOUNT = this.getDecisionTableConfiguration().getVisibleRowCount();
249
+ sap.rules.ui.DecisionTable.prototype.THRESHOLD = this.getDecisionTableConfiguration().getThreshold();
250
+ // create DT
251
+ var oDT = new sap.rules.ui.DecisionTable({
252
+ bindingContextPath: {
253
+ path: "ruleBuilderInternalModel>/bindingContextPath"
254
+ },
255
+ modelName: {
256
+ path: "ruleBuilderInternalModel>/modelName"
257
+ },
258
+ editable: {
259
+ path: "ruleBuilderInternalModel>/editable"
260
+ },
261
+ cellFormat: {
262
+ path: "ruleBuilderInternalModel>/decisionTableConfiguration/cellFormat"
263
+ },
264
+ enableSettings: {
265
+ path: "ruleBuilderInternalModel>/decisionTableConfiguration/enableSettings"
266
+ },
267
+ enableSettingResult: {
268
+ path: "ruleBuilderInternalModel>/decisionTableConfiguration/enableSettingResult"
269
+ },
270
+ hitPolicies: {
271
+ path: "ruleBuilderInternalModel>/decisionTableConfiguration/hitPolicies"
272
+ },
273
+ decisionTableFormat: {
274
+ path: "ruleBuilderInternalModel>/decisionTableConfiguration/decisionTableFormat"
275
+ },
276
+ expressionLanguage: this.getExpressionLanguage(),
277
+ astExpressionLanguage: this.getAstExpressionLanguage()
278
+
279
+ });
280
+ return oDT;
281
+ },
282
+
283
+ _createDisplayedControl: function(sDisplayedControlType) {
284
+ var oDisplayedControl;
285
+ switch (sDisplayedControlType) {
286
+ case sap.rules.ui.RuleType.DecisionTable:
287
+ oDisplayedControl = this._createDecisionTable();
288
+ break;
289
+ case "sap.rules.ui.RuleType.Ruleset":
290
+ oDisplayedControl = this._createRuleset();
291
+ break;
292
+ case sap.rules.ui.RuleType.TextRule:
293
+ oDisplayedControl = this._createTextRule();
294
+ break;
295
+ default:
296
+ break;
297
+ };
298
+ this.setAggregation("_rule", oDisplayedControl, true);
299
+ },
300
+
301
+ _createRuleTypeSelector: function() {
302
+ /*eslint consistent-this: ["error", "me"]*/
303
+ var me = this;
304
+
305
+ this.oBundle.getText('decisionTable');
306
+
307
+ var oRuleTypesModel = new sap.ui.model.json.JSONModel({
308
+ items: [{
309
+ key: sap.rules.ui.RuleType.DecisionTable,
310
+ text: this.oBundle.getText('decisionTable')
311
+ }]
312
+ });
313
+
314
+ var oRuleTypeSelector = new sap.m.ComboBox({
315
+ width: "25%",
316
+ items: {
317
+ path: 'ruleTypes>/items',
318
+ template: new sap.ui.core.Item({
319
+ text: "{ruleTypes>text}",
320
+ key: "{ruleTypes>key}"
321
+ })
322
+ },
323
+ change: function(oEvent) {
324
+ var sRuleType = oEvent.getSource().getSelectedKey();
325
+ me._createDisplayedControl.call(me, sRuleType);
326
+ }
327
+ }).setModel(oRuleTypesModel, "ruleTypes");
328
+
329
+ this.setAggregation("_ruleTypeSelector", oRuleTypeSelector, true);
330
+ },
331
+
332
+ setEditable: function(value) {
333
+ this._internalModel.setProperty("/editable", value);
334
+ return this.setProperty("editable", value, true);
335
+ },
336
+ setBindingContextPath: function(value, reload) {
337
+ var oldValue = this.getBindingContextPath();
338
+ if (reload || (value && (oldValue !== value))) {
339
+ this.needRebind = true;
340
+ this._internalModel.setProperty("/bindingContextPath", value);
341
+ this._needReBind();
342
+ return this.setProperty("bindingContextPath", value);
343
+ }
344
+ },
345
+ setModelName: function(value) {
346
+ this.needRebind = true;
347
+ this._internalModel.setProperty("/modelName", value);
348
+ return this.setProperty("modelName", value);
349
+ },
350
+
351
+ _setTextRuleConfigurationProperty: function(propertyName, value) {
352
+ var sPath = "/textRuleConfiguration/" + propertyName;
353
+ this._internalModel.setProperty(sPath, value);
354
+ },
355
+
356
+ setTextRuleConfiguration: function(oTextRuleConfiguration) {
357
+ oTextRuleConfiguration.attachChange(function(oEvent) {
358
+ this.getParent()._setTextRuleConfigurationProperty.call(this.getParent(), oEvent.getParameter("name"), oEvent.getParameter(
359
+ "value"))
360
+ });
361
+
362
+ this._setTextRuleConfigurationProperty("enableSettings", oTextRuleConfiguration.getEnableSettings());
363
+ this._setTextRuleConfigurationProperty("enableSettingResult", oTextRuleConfiguration.getEnableSettingResult());
364
+
365
+ return this.setAggregation("textRuleConfiguration", oTextRuleConfiguration, true)
366
+ },
367
+
368
+ _setDecisionTableConfigurationProperty: function(propertyName, value) {
369
+ var sPath = "/decisionTableConfiguration/" + propertyName;
370
+ this._internalModel.setProperty(sPath, value);
371
+ },
372
+
373
+ setDecisionTableConfiguration: function(oDecisionTableConfiguration) {
374
+ oDecisionTableConfiguration.attachChange(function(oEvent) {
375
+ this.getParent()._setDecisionTableConfigurationProperty.call(this.getParent(), oEvent.getParameter("name"), oEvent.getParameter(
376
+ "value"))
377
+ });
378
+
379
+ this._setDecisionTableConfigurationProperty("enableSettings", oDecisionTableConfiguration.getEnableSettings());
380
+ this._setDecisionTableConfigurationProperty("enableSettingResult", oDecisionTableConfiguration.getEnableSettingResult());
381
+ this._setDecisionTableConfigurationProperty("hitPolicies", oDecisionTableConfiguration.getHitPolicies());
382
+ this._setDecisionTableConfigurationProperty("cellFormat", oDecisionTableConfiguration.getCellFormat());
383
+ this._setDecisionTableConfigurationProperty("decisionTableFormat", oDecisionTableConfiguration.getDecisionTableFormat());
384
+ this._setDecisionTableConfigurationProperty("visibleRowCount", oDecisionTableConfiguration.getVisibleRowCount());
385
+ this._setDecisionTableConfigurationProperty("threshold", oDecisionTableConfiguration.getThreshold());
386
+
387
+ return this.setAggregation("decisionTableConfiguration", oDecisionTableConfiguration, true)
388
+ },
389
+
390
+ setExpressionLanguage: function(oExpressionLanguage) {
391
+ var oRule = this.getAggregation("_rule");
392
+ if (oRule) {
393
+ oRule.setExpressionLanguage(oExpressionLanguage);
394
+ }
395
+ return this.setAssociation("expressionLanguage", oExpressionLanguage, true);
396
+ },
397
+
398
+ setAstExpressionLanguage: function(oAstExpressionLanguage) {
399
+ var oRule = this.getAggregation("_rule");
400
+ if (oRule) {
401
+ oRule.setAstExpressionLanguage(oAstExpressionLanguage);
402
+ }
403
+ return this.setAssociation("astExpressionLanguage", oAstExpressionLanguage, true);
404
+ },
405
+
406
+ resetControl: function () {     // Destroy the content
407
+     
408
+ var  oRuleAggregation  = this.getAggregation("_rule");
409
+ if (oRuleAggregation) { 
410
+ oRuleAggregation.destroy();
411
+ }
412
+ },
413
+
414
+ _needReBind: function() {
415
+ if (this.needRebind) {
416
+ this.resetControl();
417
+ var oRuleTypes = this.getTypes();
418
+ if (oRuleTypes && oRuleTypes.length === 1) {
419
+ this._createDisplayedControl(oRuleTypes[0]);
420
+ this.needCreateDisplayedControl = false;
421
+ }
422
+ this.needRebind = false;
423
+ }
424
+ },
425
+
426
+ onBeforeRendering: function() {
427
+ this._needReBind();
428
+ },
429
+
430
+ renderer: RuleBuilderRenderer
431
+
432
+ });
433
+
434
+ return oRuleBuilder;
435
+
436
+ }, /* bExport= */ true);