@defra/forms-model 3.0.9 → 3.0.11
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.
- package/dist/browser/components/component-types.js +201 -219
- package/dist/browser/components/component-types.js.map +1 -1
- package/dist/browser/components/conditional-component-types.js +9 -27
- package/dist/browser/components/conditional-component-types.js.map +1 -1
- package/dist/browser/components/enums.js +27 -45
- package/dist/browser/components/enums.js.map +1 -1
- package/dist/browser/components/index.js +3 -35
- package/dist/browser/components/index.js.map +1 -1
- package/dist/browser/components/types.js +1 -15
- package/dist/browser/conditions/condition-abstract.js +42 -60
- package/dist/browser/conditions/condition-abstract.js.map +1 -1
- package/dist/browser/conditions/condition-field.js +23 -41
- package/dist/browser/conditions/condition-field.js.map +1 -1
- package/dist/browser/conditions/condition-group-def.js +23 -42
- package/dist/browser/conditions/condition-group-def.js.map +1 -1
- package/dist/browser/conditions/condition-group.js +43 -61
- package/dist/browser/conditions/condition-group.js.map +1 -1
- package/dist/browser/conditions/condition-model.js +185 -196
- package/dist/browser/conditions/condition-model.js.map +1 -1
- package/dist/browser/conditions/condition-operators.js +103 -124
- package/dist/browser/conditions/condition-operators.js.map +1 -1
- package/dist/browser/conditions/condition-ref.js +29 -47
- package/dist/browser/conditions/condition-ref.js.map +1 -1
- package/dist/browser/conditions/condition-value-abstract.js +19 -37
- package/dist/browser/conditions/condition-value-abstract.js.map +1 -1
- package/dist/browser/conditions/condition-value-registration.js +15 -34
- package/dist/browser/conditions/condition-value-registration.js.map +1 -1
- package/dist/browser/conditions/condition-values.js +98 -118
- package/dist/browser/conditions/condition-values.js.map +1 -1
- package/dist/browser/conditions/condition.js +36 -51
- package/dist/browser/conditions/condition.js.map +1 -1
- package/dist/browser/conditions/enums.js +5 -23
- package/dist/browser/conditions/enums.js.map +1 -1
- package/dist/browser/conditions/helpers.js +6 -25
- package/dist/browser/conditions/helpers.js.map +1 -1
- package/dist/browser/conditions/index.js +10 -143
- package/dist/browser/conditions/index.js.map +1 -1
- package/dist/browser/conditions/inline-condition-model.js +372 -394
- package/dist/browser/conditions/inline-condition-model.js.map +1 -1
- package/dist/browser/conditions/inline-condition-operators.js +103 -124
- package/dist/browser/conditions/inline-condition-operators.js.map +1 -1
- package/dist/browser/conditions/inline-condition-values.js +123 -145
- package/dist/browser/conditions/inline-condition-values.js.map +1 -1
- package/dist/browser/conditions/types.js +1 -15
- package/dist/browser/conditions/types.js.map +1 -1
- package/dist/browser/data-model/conditions-wrapper.js +27 -45
- package/dist/browser/data-model/conditions-wrapper.js.map +1 -1
- package/dist/browser/data-model/enums.js +6 -24
- package/dist/browser/data-model/enums.js.map +1 -1
- package/dist/browser/data-model/index.js +3 -35
- package/dist/browser/data-model/index.js.map +1 -1
- package/dist/browser/data-model/input-wrapper.js +28 -46
- package/dist/browser/data-model/input-wrapper.js.map +1 -1
- package/dist/browser/data-model/types.js +7 -25
- package/dist/browser/data-model/types.js.map +1 -1
- package/dist/browser/form/form-configuration.js +16 -35
- package/dist/browser/form/form-configuration.js.map +1 -1
- package/dist/browser/form/index.js +1 -23
- package/dist/browser/form/index.js.map +1 -1
- package/dist/browser/index.js +8 -97
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/migration/index.js +1 -23
- package/dist/browser/migration/index.js.map +1 -1
- package/dist/browser/migration/migration.0-2.js +42 -60
- package/dist/browser/migration/migration.0-2.js.map +1 -1
- package/dist/browser/migration/migration.1-2.js +83 -99
- package/dist/browser/migration/migration.1-2.js.map +1 -1
- package/dist/browser/migration/types.js +1 -15
- package/dist/browser/migration/whichMigrations.js +20 -36
- package/dist/browser/migration/whichMigrations.js.map +1 -1
- package/dist/browser/schema/index.js +1 -29
- package/dist/browser/schema/index.js.map +1 -1
- package/dist/browser/schema/schema.js +231 -249
- package/dist/browser/schema/schema.js.map +1 -1
- package/dist/browser/utils/helpers.js +22 -43
- package/dist/browser/utils/helpers.js.map +1 -1
- package/dist/browser/utils/logger.js +24 -43
- package/dist/browser/utils/logger.js.map +1 -1
- package/dist/module/components/component-types.js +1 -5
- package/dist/module/components/component-types.js.map +1 -1
- package/dist/module/components/conditional-component-types.js +1 -5
- package/dist/module/components/conditional-component-types.js.map +1 -1
- package/dist/module/components/enums.js +1 -5
- package/dist/module/components/enums.js.map +1 -1
- package/dist/module/components/index.js +3 -24
- package/dist/module/components/index.js.map +1 -1
- package/dist/module/components/types.js +2 -1
- package/dist/module/conditions/condition-abstract.js +3 -8
- package/dist/module/conditions/condition-abstract.js.map +1 -1
- package/dist/module/conditions/condition-field.js +3 -8
- package/dist/module/conditions/condition-field.js.map +1 -1
- package/dist/module/conditions/condition-group-def.js +1 -6
- package/dist/module/conditions/condition-group-def.js.map +1 -1
- package/dist/module/conditions/condition-group.js +4 -9
- package/dist/module/conditions/condition-group.js.map +1 -1
- package/dist/module/conditions/condition-model.js +20 -25
- package/dist/module/conditions/condition-model.js.map +1 -1
- package/dist/module/conditions/condition-operators.js +15 -23
- package/dist/module/conditions/condition-operators.js.map +1 -1
- package/dist/module/conditions/condition-ref.js +2 -7
- package/dist/module/conditions/condition-ref.js.map +1 -1
- package/dist/module/conditions/condition-value-abstract.js +3 -8
- package/dist/module/conditions/condition-value-abstract.js.map +1 -1
- package/dist/module/conditions/condition-value-registration.js +1 -6
- package/dist/module/conditions/condition-value-registration.js.map +1 -1
- package/dist/module/conditions/condition-values.js +12 -20
- package/dist/module/conditions/condition-values.js.map +1 -1
- package/dist/module/conditions/condition.js +9 -14
- package/dist/module/conditions/condition.js.map +1 -1
- package/dist/module/conditions/enums.js +1 -5
- package/dist/module/conditions/enums.js.map +1 -1
- package/dist/module/conditions/helpers.js +2 -7
- package/dist/module/conditions/helpers.js.map +1 -1
- package/dist/module/conditions/index.js +10 -139
- package/dist/module/conditions/index.js.map +1 -1
- package/dist/module/conditions/inline-condition-model.js +15 -26
- package/dist/module/conditions/inline-condition-model.js.map +1 -1
- package/dist/module/conditions/inline-condition-operators.js +15 -23
- package/dist/module/conditions/inline-condition-operators.js.map +1 -1
- package/dist/module/conditions/inline-condition-values.js +9 -17
- package/dist/module/conditions/inline-condition-values.js.map +1 -1
- package/dist/module/conditions/types.js +2 -1
- package/dist/module/conditions/types.js.map +1 -1
- package/dist/module/data-model/conditions-wrapper.js +3 -8
- package/dist/module/data-model/conditions-wrapper.js.map +1 -1
- package/dist/module/data-model/enums.js +1 -5
- package/dist/module/data-model/enums.js.map +1 -1
- package/dist/module/data-model/index.js +3 -24
- package/dist/module/data-model/index.js.map +1 -1
- package/dist/module/data-model/input-wrapper.js +3 -8
- package/dist/module/data-model/input-wrapper.js.map +1 -1
- package/dist/module/data-model/types.js +1 -5
- package/dist/module/data-model/types.js.map +1 -1
- package/dist/module/form/form-configuration.js +1 -6
- package/dist/module/form/form-configuration.js.map +1 -1
- package/dist/module/form/index.js +1 -10
- package/dist/module/form/index.js.map +1 -1
- package/dist/module/index.js +8 -91
- package/dist/module/index.js.map +1 -1
- package/dist/module/migration/index.js +1 -10
- package/dist/module/migration/index.js.map +1 -1
- package/dist/module/migration/migration.0-2.js +1 -5
- package/dist/module/migration/migration.0-2.js.map +1 -1
- package/dist/module/migration/migration.1-2.js +3 -6
- package/dist/module/migration/migration.1-2.js.map +1 -1
- package/dist/module/migration/types.js +2 -1
- package/dist/module/migration/whichMigrations.js +5 -9
- package/dist/module/migration/whichMigrations.js.map +1 -1
- package/dist/module/schema/index.js +1 -16
- package/dist/module/schema/index.js.map +1 -1
- package/dist/module/schema/schema.js +163 -167
- package/dist/module/schema/schema.js.map +1 -1
- package/dist/module/utils/helpers.js +5 -13
- package/dist/module/utils/helpers.js.map +1 -1
- package/dist/module/utils/logger.js +1 -6
- package/dist/module/utils/logger.js.map +1 -1
- package/dist/types/components/component-types.d.ts +1 -1
- package/dist/types/components/component-types.d.ts.map +1 -1
- package/dist/types/components/conditional-component-types.d.ts +1 -1
- package/dist/types/components/conditional-component-types.d.ts.map +1 -1
- package/dist/types/components/index.d.ts +3 -3
- package/dist/types/components/index.d.ts.map +1 -1
- package/dist/types/conditions/condition-abstract.d.ts +1 -1
- package/dist/types/conditions/condition-abstract.d.ts.map +1 -1
- package/dist/types/conditions/condition-field.d.ts +1 -1
- package/dist/types/conditions/condition-field.d.ts.map +1 -1
- package/dist/types/conditions/condition-group-def.d.ts +2 -2
- package/dist/types/conditions/condition-group-def.d.ts.map +1 -1
- package/dist/types/conditions/condition-group.d.ts +2 -2
- package/dist/types/conditions/condition-group.d.ts.map +1 -1
- package/dist/types/conditions/condition-model.d.ts +5 -5
- package/dist/types/conditions/condition-model.d.ts.map +1 -1
- package/dist/types/conditions/condition-operators.d.ts +2 -2
- package/dist/types/conditions/condition-operators.d.ts.map +1 -1
- package/dist/types/conditions/condition-ref.d.ts +2 -2
- package/dist/types/conditions/condition-ref.d.ts.map +1 -1
- package/dist/types/conditions/condition-value-abstract.d.ts +1 -1
- package/dist/types/conditions/condition-value-abstract.d.ts.map +1 -1
- package/dist/types/conditions/condition-values.d.ts +3 -3
- package/dist/types/conditions/condition-values.d.ts.map +1 -1
- package/dist/types/conditions/condition.d.ts +4 -4
- package/dist/types/conditions/condition.d.ts.map +1 -1
- package/dist/types/conditions/index.d.ts +10 -10
- package/dist/types/conditions/index.d.ts.map +1 -1
- package/dist/types/conditions/types.d.ts +3 -3
- package/dist/types/conditions/types.d.ts.map +1 -1
- package/dist/types/data-model/conditions-wrapper.d.ts +1 -1
- package/dist/types/data-model/conditions-wrapper.d.ts.map +1 -1
- package/dist/types/data-model/index.d.ts +3 -3
- package/dist/types/data-model/index.d.ts.map +1 -1
- package/dist/types/data-model/input-wrapper.d.ts +2 -2
- package/dist/types/data-model/input-wrapper.d.ts.map +1 -1
- package/dist/types/data-model/types.d.ts +3 -3
- package/dist/types/data-model/types.d.ts.map +1 -1
- package/dist/types/form/index.d.ts +1 -1
- package/dist/types/form/index.d.ts.map +1 -1
- package/dist/types/index.d.ts +11 -11
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/migration/index.d.ts +1 -1
- package/dist/types/migration/index.d.ts.map +1 -1
- package/dist/types/migration/migration.0-2.d.ts +1 -1
- package/dist/types/migration/migration.0-2.d.ts.map +1 -1
- package/dist/types/migration/migration.1-2.d.ts +1 -1
- package/dist/types/migration/migration.1-2.d.ts.map +1 -1
- package/dist/types/migration/whichMigrations.d.ts +1 -1
- package/dist/types/migration/whichMigrations.d.ts.map +1 -1
- package/dist/types/schema/index.d.ts +1 -1
- package/dist/types/schema/index.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/components/component-types.ts +1 -1
- package/src/components/conditional-component-types.ts +1 -1
- package/src/components/index.ts +3 -3
- package/src/conditions/condition-abstract.ts +1 -1
- package/src/conditions/condition-field.ts +2 -2
- package/src/conditions/condition-group-def.ts +1 -1
- package/src/conditions/condition-group.ts +3 -3
- package/src/conditions/condition-model.ts +9 -9
- package/src/conditions/condition-operators.ts +6 -3
- package/src/conditions/condition-ref.ts +2 -2
- package/src/conditions/condition-value-abstract.ts +1 -1
- package/src/conditions/condition-values.ts +3 -3
- package/src/conditions/condition.ts +6 -6
- package/src/conditions/index.ts +10 -10
- package/src/conditions/inline-condition-model.ts +3 -3
- package/src/conditions/inline-condition-operators.ts +1 -1
- package/src/conditions/types.ts +3 -3
- package/src/data-model/conditions-wrapper.ts +2 -2
- package/src/data-model/index.ts +3 -3
- package/src/data-model/input-wrapper.ts +3 -3
- package/src/data-model/types.ts +3 -3
- package/src/form/index.ts +1 -1
- package/src/index.ts +11 -11
- package/src/migration/index.ts +1 -1
- package/src/migration/migration.0-2.ts +1 -1
- package/src/migration/migration.1-2.ts +2 -2
- package/src/migration/whichMigrations.ts +3 -3
- package/src/schema/index.ts +1 -1
@@ -1,418 +1,396 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
}
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
1
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
4
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
5
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
6
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
7
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
8
|
+
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
9
|
+
import { ComponentTypes } from "../components/component-types.js";
|
10
|
+
import { getExpression } from "./inline-condition-operators.js";
|
11
|
+
import { AbstractConditionValue, valueFrom } from "./inline-condition-values.js";
|
12
|
+
export const coordinators = {
|
13
|
+
AND: 'and',
|
14
|
+
OR: 'or'
|
15
|
+
};
|
16
|
+
var _groupedConditions = /*#__PURE__*/new WeakMap();
|
17
|
+
var _userGroupedConditions = /*#__PURE__*/new WeakMap();
|
18
|
+
var _conditionName = /*#__PURE__*/new WeakMap();
|
19
|
+
export class ConditionsModel {
|
20
|
+
constructor() {
|
21
|
+
_classPrivateFieldInitSpec(this, _groupedConditions, void 0);
|
22
|
+
_classPrivateFieldInitSpec(this, _userGroupedConditions, void 0);
|
23
|
+
_classPrivateFieldInitSpec(this, _conditionName, void 0);
|
24
|
+
_classPrivateFieldSet(_groupedConditions, this, []);
|
25
|
+
_classPrivateFieldSet(_userGroupedConditions, this, []);
|
26
|
+
}
|
27
|
+
clone() {
|
28
|
+
const toReturn = new ConditionsModel();
|
29
|
+
_classPrivateFieldSet(_groupedConditions, toReturn, _classPrivateFieldGet(_groupedConditions, this).map(it => it.clone()));
|
30
|
+
_classPrivateFieldSet(_userGroupedConditions, toReturn, _classPrivateFieldGet(_userGroupedConditions, this).map(it => it.clone()));
|
31
|
+
_classPrivateFieldSet(_conditionName, toReturn, _classPrivateFieldGet(_conditionName, this));
|
32
|
+
return toReturn;
|
33
|
+
}
|
34
|
+
clear() {
|
35
|
+
_classPrivateFieldSet(_userGroupedConditions, this, []);
|
36
|
+
_classPrivateFieldSet(_groupedConditions, this, []);
|
37
|
+
_classPrivateFieldSet(_conditionName, this, undefined);
|
38
|
+
return this;
|
39
|
+
}
|
40
|
+
set name(name) {
|
41
|
+
_classPrivateFieldSet(_conditionName, this, name);
|
42
|
+
}
|
43
|
+
get name() {
|
44
|
+
return _classPrivateFieldGet(_conditionName, this);
|
45
|
+
}
|
46
|
+
add(condition) {
|
47
|
+
const coordinatorExpected = _classPrivateFieldGet(_userGroupedConditions, this).length !== 0;
|
48
|
+
if (condition.getCoordinator() && !coordinatorExpected) {
|
49
|
+
throw Error('No coordinator allowed on the first condition');
|
50
|
+
} else if (!condition.getCoordinator() && coordinatorExpected) {
|
51
|
+
throw Error('Coordinator must be present on subsequent conditions');
|
52
|
+
}
|
53
|
+
_classPrivateFieldGet(_userGroupedConditions, this).push(condition);
|
54
|
+
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
55
|
+
return this;
|
56
|
+
}
|
57
|
+
replace(index, condition) {
|
58
|
+
const coordinatorExpected = index !== 0;
|
59
|
+
if (condition.getCoordinator() && !coordinatorExpected) {
|
60
|
+
throw Error('No coordinator allowed on the first condition');
|
61
|
+
} else if (!condition.getCoordinator() && coordinatorExpected) {
|
62
|
+
throw Error('Coordinator must be present on subsequent conditions');
|
63
|
+
} else if (index >= _classPrivateFieldGet(_userGroupedConditions, this).length) {
|
64
|
+
throw Error(`Cannot replace condition ${index} as no such condition exists`);
|
65
|
+
}
|
66
|
+
_classPrivateFieldGet(_userGroupedConditions, this).splice(index, 1, condition);
|
67
|
+
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
68
|
+
return this;
|
69
|
+
}
|
70
|
+
remove(indexes) {
|
71
|
+
_classPrivateFieldSet(_userGroupedConditions, this, _classPrivateFieldGet(_userGroupedConditions, this).filter((_condition, index) => !indexes.includes(index)).map((condition, index) => index === 0 ? condition.asFirstCondition() : condition));
|
72
|
+
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
73
|
+
return this;
|
74
|
+
}
|
75
|
+
addGroups(groupDefs) {
|
76
|
+
_classPrivateFieldSet(_userGroupedConditions, this, this._group(_classPrivateFieldGet(_userGroupedConditions, this), groupDefs));
|
77
|
+
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
78
|
+
return this;
|
79
|
+
}
|
80
|
+
splitGroup(index) {
|
81
|
+
_classPrivateFieldSet(_userGroupedConditions, this, this._ungroup(_classPrivateFieldGet(_userGroupedConditions, this), index));
|
82
|
+
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
83
|
+
return this;
|
84
|
+
}
|
85
|
+
moveEarlier(index) {
|
86
|
+
if (index > 0 && index < _classPrivateFieldGet(_userGroupedConditions, this).length) {
|
87
|
+
_classPrivateFieldGet(_userGroupedConditions, this).splice(index - 1, 0, _classPrivateFieldGet(_userGroupedConditions, this).splice(index, 1)[0]);
|
88
|
+
if (index === 1) {
|
89
|
+
this.switchCoordinators();
|
68
90
|
}
|
69
|
-
_classPrivateFieldGet(_userGroupedConditions, this).push(condition);
|
70
91
|
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
71
|
-
return this;
|
72
92
|
}
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
throw Error(`Cannot replace condition ${index} as no such condition exists`);
|
93
|
+
return this;
|
94
|
+
}
|
95
|
+
moveLater(index) {
|
96
|
+
if (index >= 0 && index < _classPrivateFieldGet(_userGroupedConditions, this).length - 1) {
|
97
|
+
_classPrivateFieldGet(_userGroupedConditions, this).splice(index + 1, 0, _classPrivateFieldGet(_userGroupedConditions, this).splice(index, 1)[0]);
|
98
|
+
if (index === 0) {
|
99
|
+
this.switchCoordinators();
|
81
100
|
}
|
82
|
-
_classPrivateFieldGet(_userGroupedConditions, this).splice(index, 1, condition);
|
83
101
|
_classPrivateFieldSet(_groupedConditions, this, this._applyGroups(_classPrivateFieldGet(_userGroupedConditions, this)));
|
84
|
-
return this;
|
85
102
|
}
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
103
|
+
return this;
|
104
|
+
}
|
105
|
+
switchCoordinators() {
|
106
|
+
_classPrivateFieldGet(_userGroupedConditions, this)[1].setCoordinator(_classPrivateFieldGet(_userGroupedConditions, this)[0].getCoordinator());
|
107
|
+
_classPrivateFieldGet(_userGroupedConditions, this)[0].setCoordinator(undefined);
|
108
|
+
}
|
109
|
+
get asPerUserGroupings() {
|
110
|
+
return [..._classPrivateFieldGet(_userGroupedConditions, this)];
|
111
|
+
}
|
112
|
+
get hasConditions() {
|
113
|
+
return _classPrivateFieldGet(_userGroupedConditions, this).length > 0;
|
114
|
+
}
|
115
|
+
get lastIndex() {
|
116
|
+
return _classPrivateFieldGet(_userGroupedConditions, this).length - 1;
|
117
|
+
}
|
118
|
+
toPresentationString() {
|
119
|
+
return _classPrivateFieldGet(_groupedConditions, this).map(condition => toPresentationString(condition)).join(' ');
|
120
|
+
}
|
121
|
+
toExpression() {
|
122
|
+
return _classPrivateFieldGet(_groupedConditions, this).map(condition => toExpression(condition)).join(' ');
|
123
|
+
}
|
124
|
+
_applyGroups(userGroupedConditions) {
|
125
|
+
const correctedUserGroups = userGroupedConditions.map(condition => condition instanceof ConditionGroup && condition.conditions.length > 2 ? new ConditionGroup(this._group(condition.conditions, this._autoGroupDefs(condition.conditions))) : condition);
|
126
|
+
return this._group(correctedUserGroups, this._autoGroupDefs(correctedUserGroups));
|
127
|
+
}
|
128
|
+
_group(conditions, groupDefs) {
|
129
|
+
return conditions.reduce((groups, condition, index, conditions) => {
|
130
|
+
const groupDef = groupDefs.find(groupDef => groupDef.contains(index));
|
131
|
+
if (groupDef) {
|
132
|
+
if (groupDef.startsWith(index)) {
|
133
|
+
const groupConditions = groupDef.applyTo(conditions);
|
134
|
+
groups.push(new ConditionGroup(groupConditions));
|
106
135
|
}
|
107
|
-
|
136
|
+
} else {
|
137
|
+
groups.push(condition);
|
108
138
|
}
|
109
|
-
return
|
139
|
+
return groups;
|
140
|
+
}, []);
|
141
|
+
}
|
142
|
+
_ungroup(conditions, splitIndex) {
|
143
|
+
if (conditions[splitIndex].isGroup()) {
|
144
|
+
const copy = [...conditions];
|
145
|
+
copy.splice(splitIndex, 1, ...conditions[splitIndex].getGroupedConditions());
|
146
|
+
return copy;
|
110
147
|
}
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
148
|
+
return conditions;
|
149
|
+
}
|
150
|
+
_autoGroupDefs(conditions) {
|
151
|
+
const orPositions = [];
|
152
|
+
conditions.forEach((condition, index) => {
|
153
|
+
if (condition.getCoordinator() === coordinators.OR) {
|
154
|
+
orPositions.push(index);
|
118
155
|
}
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
get hasConditions() {
|
129
|
-
return _classPrivateFieldGet(_userGroupedConditions, this).length > 0;
|
130
|
-
}
|
131
|
-
get lastIndex() {
|
132
|
-
return _classPrivateFieldGet(_userGroupedConditions, this).length - 1;
|
133
|
-
}
|
134
|
-
toPresentationString() {
|
135
|
-
return _classPrivateFieldGet(_groupedConditions, this).map(condition => toPresentationString(condition)).join(' ');
|
136
|
-
}
|
137
|
-
toExpression() {
|
138
|
-
return _classPrivateFieldGet(_groupedConditions, this).map(condition => toExpression(condition)).join(' ');
|
139
|
-
}
|
140
|
-
_applyGroups(userGroupedConditions) {
|
141
|
-
const correctedUserGroups = userGroupedConditions.map(condition => condition instanceof ConditionGroup && condition.conditions.length > 2 ? new ConditionGroup(this._group(condition.conditions, this._autoGroupDefs(condition.conditions))) : condition);
|
142
|
-
return this._group(correctedUserGroups, this._autoGroupDefs(correctedUserGroups));
|
143
|
-
}
|
144
|
-
_group(conditions, groupDefs) {
|
145
|
-
return conditions.reduce((groups, condition, index, conditions) => {
|
146
|
-
const groupDef = groupDefs.find(groupDef => groupDef.contains(index));
|
147
|
-
if (groupDef) {
|
148
|
-
if (groupDef.startsWith(index)) {
|
149
|
-
const groupConditions = groupDef.applyTo(conditions);
|
150
|
-
groups.push(new ConditionGroup(groupConditions));
|
151
|
-
}
|
152
|
-
} else {
|
153
|
-
groups.push(condition);
|
156
|
+
});
|
157
|
+
const hasAnd = !!conditions.find(condition => condition.getCoordinator() === coordinators.AND);
|
158
|
+
const hasOr = orPositions.length > 0;
|
159
|
+
if (hasAnd && hasOr) {
|
160
|
+
let start = 0;
|
161
|
+
const groupDefs = [];
|
162
|
+
orPositions.forEach((position, index) => {
|
163
|
+
if (start < position - 1) {
|
164
|
+
groupDefs.push(new GroupDef(start, position - 1));
|
154
165
|
}
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
if (conditions[splitIndex].isGroup()) {
|
160
|
-
const copy = [...conditions];
|
161
|
-
copy.splice(splitIndex, 1, ...conditions[splitIndex].getGroupedConditions());
|
162
|
-
return copy;
|
163
|
-
}
|
164
|
-
return conditions;
|
165
|
-
}
|
166
|
-
_autoGroupDefs(conditions) {
|
167
|
-
const orPositions = [];
|
168
|
-
conditions.forEach((condition, index) => {
|
169
|
-
if (condition.getCoordinator() === coordinators.OR) {
|
170
|
-
orPositions.push(index);
|
166
|
+
const thisIsTheLastOr = orPositions.length === index + 1;
|
167
|
+
const thereAreMoreConditions = conditions.length - 1 > position;
|
168
|
+
if (thisIsTheLastOr && thereAreMoreConditions) {
|
169
|
+
groupDefs.push(new GroupDef(position, conditions.length - 1));
|
171
170
|
}
|
171
|
+
start = position;
|
172
172
|
});
|
173
|
-
|
174
|
-
const hasOr = orPositions.length > 0;
|
175
|
-
if (hasAnd && hasOr) {
|
176
|
-
let start = 0;
|
177
|
-
const groupDefs = [];
|
178
|
-
orPositions.forEach((position, index) => {
|
179
|
-
if (start < position - 1) {
|
180
|
-
groupDefs.push(new GroupDef(start, position - 1));
|
181
|
-
}
|
182
|
-
const thisIsTheLastOr = orPositions.length === index + 1;
|
183
|
-
const thereAreMoreConditions = conditions.length - 1 > position;
|
184
|
-
if (thisIsTheLastOr && thereAreMoreConditions) {
|
185
|
-
groupDefs.push(new GroupDef(position, conditions.length - 1));
|
186
|
-
}
|
187
|
-
start = position;
|
188
|
-
});
|
189
|
-
return groupDefs;
|
190
|
-
}
|
191
|
-
return [];
|
192
|
-
}
|
193
|
-
toJSON() {
|
194
|
-
const name = _classPrivateFieldGet(_conditionName, this);
|
195
|
-
const conditions = _classPrivateFieldGet(_userGroupedConditions, this);
|
196
|
-
return {
|
197
|
-
name,
|
198
|
-
conditions: conditions.map(it => it.clone())
|
199
|
-
};
|
200
|
-
}
|
201
|
-
static from(obj) {
|
202
|
-
if (obj instanceof ConditionsModel) {
|
203
|
-
return obj;
|
204
|
-
}
|
205
|
-
const toReturn = new ConditionsModel();
|
206
|
-
_classPrivateFieldSet(_conditionName, toReturn, obj.name);
|
207
|
-
_classPrivateFieldSet(_userGroupedConditions, toReturn, obj.conditions.map(it => conditionFrom(it)));
|
208
|
-
_classPrivateFieldSet(_groupedConditions, toReturn, toReturn._applyGroups(_classPrivateFieldGet(_userGroupedConditions, toReturn)));
|
209
|
-
return toReturn;
|
173
|
+
return groupDefs;
|
210
174
|
}
|
175
|
+
return [];
|
211
176
|
}
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
}
|
220
|
-
return new Condition(Field.from(it.field), it.operator, (0, _inlineConditionValues.valueFrom)(it.value), it.coordinator);
|
221
|
-
}
|
222
|
-
class GroupDef {
|
223
|
-
constructor(first, last) {
|
224
|
-
_defineProperty(this, "first", void 0);
|
225
|
-
_defineProperty(this, "last", void 0);
|
226
|
-
if (typeof first !== 'number' || typeof last !== 'number') {
|
227
|
-
throw Error(`Cannot construct a group from ${first} and ${last}`);
|
228
|
-
} else if (first >= last) {
|
229
|
-
throw Error(`Last (${last}) must be greater than first (${first})`);
|
230
|
-
}
|
231
|
-
this.first = first;
|
232
|
-
this.last = last;
|
233
|
-
}
|
234
|
-
contains(index) {
|
235
|
-
return this.first <= index && this.last >= index;
|
236
|
-
}
|
237
|
-
startsWith(index) {
|
238
|
-
return this.first === index;
|
239
|
-
}
|
240
|
-
applyTo(conditions) {
|
241
|
-
return [...conditions].splice(this.first, this.last - this.first + 1);
|
242
|
-
}
|
177
|
+
toJSON() {
|
178
|
+
const name = _classPrivateFieldGet(_conditionName, this);
|
179
|
+
const conditions = _classPrivateFieldGet(_userGroupedConditions, this);
|
180
|
+
return {
|
181
|
+
name,
|
182
|
+
conditions: conditions.map(it => it.clone())
|
183
|
+
};
|
243
184
|
}
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
coordinatorString() {
|
254
|
-
return this.conditions[0].coordinatorString();
|
255
|
-
}
|
256
|
-
conditionString() {
|
257
|
-
const copy = [...this.conditions];
|
258
|
-
copy.splice(0, 1);
|
259
|
-
return `(${this.conditions[0].conditionString()} ${copy.map(condition => toPresentationString(condition)).join(' ')})`;
|
260
|
-
}
|
261
|
-
conditionExpression() {
|
262
|
-
const copy = [...this.conditions];
|
263
|
-
copy.splice(0, 1);
|
264
|
-
return `(${this.conditions[0].conditionExpression()} ${copy.map(condition => toExpression(condition)).join(' ')})`;
|
265
|
-
}
|
266
|
-
asFirstCondition() {
|
267
|
-
this.conditions[0].asFirstCondition();
|
268
|
-
return this;
|
269
|
-
}
|
270
|
-
getCoordinator() {
|
271
|
-
return this.conditions[0].getCoordinator();
|
272
|
-
}
|
273
|
-
setCoordinator(coordinator) {
|
274
|
-
this.conditions[0].setCoordinator(coordinator);
|
275
|
-
}
|
276
|
-
isGroup() {
|
277
|
-
return true;
|
278
|
-
}
|
279
|
-
getGroupedConditions() {
|
280
|
-
return this.conditions.map(condition => condition.clone());
|
281
|
-
}
|
282
|
-
clone() {
|
283
|
-
return new ConditionGroup(this.conditions.map(condition => condition.clone()));
|
284
|
-
}
|
185
|
+
static from(obj) {
|
186
|
+
if (obj instanceof ConditionsModel) {
|
187
|
+
return obj;
|
188
|
+
}
|
189
|
+
const toReturn = new ConditionsModel();
|
190
|
+
_classPrivateFieldSet(_conditionName, toReturn, obj.name);
|
191
|
+
_classPrivateFieldSet(_userGroupedConditions, toReturn, obj.conditions.map(it => conditionFrom(it)));
|
192
|
+
_classPrivateFieldSet(_groupedConditions, toReturn, toReturn._applyGroups(_classPrivateFieldGet(_userGroupedConditions, toReturn)));
|
193
|
+
return toReturn;
|
285
194
|
}
|
286
|
-
|
287
|
-
|
195
|
+
}
|
196
|
+
function conditionFrom(it) {
|
197
|
+
if (it.conditions) {
|
198
|
+
return new ConditionGroup(it.conditions.map(condition => conditionFrom(condition)));
|
288
199
|
}
|
289
|
-
|
290
|
-
return
|
200
|
+
if (it.conditionName) {
|
201
|
+
return new ConditionRef(it.conditionName, it.conditionDisplayName, it.coordinator);
|
291
202
|
}
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
}
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
}
|
306
|
-
this.name = name;
|
307
|
-
this.type = type;
|
308
|
-
this.display = display;
|
309
|
-
}
|
310
|
-
static from(obj) {
|
311
|
-
return new Field(obj.name, obj.type, obj.display);
|
312
|
-
}
|
203
|
+
return new Condition(Field.from(it.field), it.operator, valueFrom(it.value), it.coordinator);
|
204
|
+
}
|
205
|
+
export class GroupDef {
|
206
|
+
constructor(first, last) {
|
207
|
+
_defineProperty(this, "first", void 0);
|
208
|
+
_defineProperty(this, "last", void 0);
|
209
|
+
if (typeof first !== 'number' || typeof last !== 'number') {
|
210
|
+
throw Error(`Cannot construct a group from ${first} and ${last}`);
|
211
|
+
} else if (first >= last) {
|
212
|
+
throw Error(`Last (${last}) must be greater than first (${first})`);
|
213
|
+
}
|
214
|
+
this.first = first;
|
215
|
+
this.last = last;
|
313
216
|
}
|
314
|
-
|
315
|
-
|
316
|
-
constructor(coordinator) {
|
317
|
-
_defineProperty(this, "coordinator", void 0);
|
318
|
-
if (coordinator && !Object.values(coordinators).includes(coordinator)) {
|
319
|
-
throw Error(`coordinator ${coordinator} is not a valid coordinator`);
|
320
|
-
}
|
321
|
-
this.coordinator = coordinator;
|
322
|
-
}
|
323
|
-
coordinatorString() {
|
324
|
-
return this.coordinator ? `${this.coordinator} ` : '';
|
325
|
-
}
|
326
|
-
getCoordinator() {
|
327
|
-
return this.coordinator;
|
328
|
-
}
|
329
|
-
setCoordinator(coordinator) {
|
330
|
-
this.coordinator = coordinator;
|
331
|
-
}
|
332
|
-
isGroup() {
|
333
|
-
return false;
|
334
|
-
}
|
335
|
-
getGroupedConditions() {
|
336
|
-
return [this];
|
337
|
-
}
|
338
|
-
_asFirstCondition() {
|
339
|
-
delete this.coordinator;
|
340
|
-
}
|
341
|
-
asFirstCondition() {
|
342
|
-
throw Error('Implement on the subclass (Why do we have to have this method here at all?!)');
|
343
|
-
}
|
344
|
-
clone() {
|
345
|
-
throw Error('Implement on the subclass (Why do we have to have this method here at all?!)');
|
346
|
-
}
|
347
|
-
conditionString() {
|
348
|
-
throw Error('Implement on the subclass (Why do we have to have this method here at all?!)');
|
349
|
-
}
|
350
|
-
conditionExpression() {
|
351
|
-
throw Error('Implement on the subclass (Why do we have to have this method here at all?!)');
|
352
|
-
}
|
217
|
+
contains(index) {
|
218
|
+
return this.first <= index && this.last >= index;
|
353
219
|
}
|
354
|
-
|
355
|
-
|
356
|
-
super(coordinator);
|
357
|
-
_defineProperty(this, "field", void 0);
|
358
|
-
_defineProperty(this, "operator", void 0);
|
359
|
-
_defineProperty(this, "value", void 0);
|
360
|
-
if (!(field instanceof Field)) {
|
361
|
-
throw Error(`field ${field} is not a valid Field object`);
|
362
|
-
}
|
363
|
-
if (typeof operator !== 'string') {
|
364
|
-
throw Error(`operator ${operator} is not a valid operator`);
|
365
|
-
}
|
366
|
-
if (!(value instanceof _inlineConditionValues.AbstractConditionValue)) {
|
367
|
-
throw Error(`value ${value} is not a valid value type`);
|
368
|
-
}
|
369
|
-
this.field = field;
|
370
|
-
this.operator = operator;
|
371
|
-
this.value = value;
|
372
|
-
}
|
373
|
-
asFirstCondition() {
|
374
|
-
this._asFirstCondition();
|
375
|
-
return this;
|
376
|
-
}
|
377
|
-
conditionString() {
|
378
|
-
return `'${this.field.display}' ${this.operator} '${this.value.toPresentationString()}'`;
|
379
|
-
}
|
380
|
-
conditionExpression() {
|
381
|
-
return (0, _inlineConditionOperators.getExpression)(this.field.type, this.field.name, this.operator, this.value);
|
382
|
-
}
|
383
|
-
clone() {
|
384
|
-
return new Condition(Field.from(this.field), this.operator, this.value.clone(), this.coordinator);
|
385
|
-
}
|
220
|
+
startsWith(index) {
|
221
|
+
return this.first === index;
|
386
222
|
}
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
}
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
223
|
+
applyTo(conditions) {
|
224
|
+
return [...conditions].splice(this.first, this.last - this.first + 1);
|
225
|
+
}
|
226
|
+
}
|
227
|
+
class ConditionGroup {
|
228
|
+
constructor(conditions) {
|
229
|
+
_defineProperty(this, "conditions", void 0);
|
230
|
+
if (!Array.isArray(conditions) || conditions.length < 2) {
|
231
|
+
throw Error('Cannot construct a condition group from a single condition');
|
232
|
+
}
|
233
|
+
this.conditions = conditions;
|
234
|
+
}
|
235
|
+
coordinatorString() {
|
236
|
+
return this.conditions[0].coordinatorString();
|
237
|
+
}
|
238
|
+
conditionString() {
|
239
|
+
const copy = [...this.conditions];
|
240
|
+
copy.splice(0, 1);
|
241
|
+
return `(${this.conditions[0].conditionString()} ${copy.map(condition => toPresentationString(condition)).join(' ')})`;
|
242
|
+
}
|
243
|
+
conditionExpression() {
|
244
|
+
const copy = [...this.conditions];
|
245
|
+
copy.splice(0, 1);
|
246
|
+
return `(${this.conditions[0].conditionExpression()} ${copy.map(condition => toExpression(condition)).join(' ')})`;
|
247
|
+
}
|
248
|
+
asFirstCondition() {
|
249
|
+
this.conditions[0].asFirstCondition();
|
250
|
+
return this;
|
251
|
+
}
|
252
|
+
getCoordinator() {
|
253
|
+
return this.conditions[0].getCoordinator();
|
254
|
+
}
|
255
|
+
setCoordinator(coordinator) {
|
256
|
+
this.conditions[0].setCoordinator(coordinator);
|
257
|
+
}
|
258
|
+
isGroup() {
|
259
|
+
return true;
|
260
|
+
}
|
261
|
+
getGroupedConditions() {
|
262
|
+
return this.conditions.map(condition => condition.clone());
|
263
|
+
}
|
264
|
+
clone() {
|
265
|
+
return new ConditionGroup(this.conditions.map(condition => condition.clone()));
|
266
|
+
}
|
267
|
+
}
|
268
|
+
export function toPresentationString(condition) {
|
269
|
+
return `${condition.coordinatorString()}${condition.conditionString()}`;
|
270
|
+
}
|
271
|
+
export function toExpression(condition) {
|
272
|
+
return `${condition.coordinatorString()}${condition.conditionExpression()}`;
|
273
|
+
}
|
274
|
+
export class Field {
|
275
|
+
constructor(name, type, display) {
|
276
|
+
_defineProperty(this, "name", void 0);
|
277
|
+
_defineProperty(this, "type", void 0);
|
278
|
+
_defineProperty(this, "display", void 0);
|
279
|
+
if (!name || typeof name !== 'string') {
|
280
|
+
throw Error(`name ${name} is not valid`);
|
281
|
+
}
|
282
|
+
if (!ComponentTypes.find(componentType => componentType.name === type)) {
|
283
|
+
throw Error(`type ${type} is not valid`);
|
284
|
+
}
|
285
|
+
if (!display || typeof display !== 'string') {
|
286
|
+
throw Error(`display ${display} is not valid`);
|
287
|
+
}
|
288
|
+
this.name = name;
|
289
|
+
this.type = type;
|
290
|
+
this.display = display;
|
291
|
+
}
|
292
|
+
static from(obj) {
|
293
|
+
return new Field(obj.name, obj.type, obj.display);
|
294
|
+
}
|
295
|
+
}
|
296
|
+
class AbstractCondition {
|
297
|
+
constructor(coordinator) {
|
298
|
+
_defineProperty(this, "coordinator", void 0);
|
299
|
+
if (coordinator && !Object.values(coordinators).includes(coordinator)) {
|
300
|
+
throw Error(`coordinator ${coordinator} is not a valid coordinator`);
|
301
|
+
}
|
302
|
+
this.coordinator = coordinator;
|
303
|
+
}
|
304
|
+
coordinatorString() {
|
305
|
+
return this.coordinator ? `${this.coordinator} ` : '';
|
306
|
+
}
|
307
|
+
getCoordinator() {
|
308
|
+
return this.coordinator;
|
309
|
+
}
|
310
|
+
setCoordinator(coordinator) {
|
311
|
+
this.coordinator = coordinator;
|
312
|
+
}
|
313
|
+
isGroup() {
|
314
|
+
return false;
|
315
|
+
}
|
316
|
+
getGroupedConditions() {
|
317
|
+
return [this];
|
318
|
+
}
|
319
|
+
_asFirstCondition() {
|
320
|
+
delete this.coordinator;
|
321
|
+
}
|
322
|
+
asFirstCondition() {
|
323
|
+
throw Error('Implement on the subclass (Why do we have to have this method here at all?!)');
|
324
|
+
}
|
325
|
+
clone() {
|
326
|
+
throw Error('Implement on the subclass (Why do we have to have this method here at all?!)');
|
327
|
+
}
|
328
|
+
conditionString() {
|
329
|
+
throw Error('Implement on the subclass (Why do we have to have this method here at all?!)');
|
330
|
+
}
|
331
|
+
conditionExpression() {
|
332
|
+
throw Error('Implement on the subclass (Why do we have to have this method here at all?!)');
|
333
|
+
}
|
334
|
+
}
|
335
|
+
export class Condition extends AbstractCondition {
|
336
|
+
constructor(field, operator, value, coordinator) {
|
337
|
+
super(coordinator);
|
338
|
+
_defineProperty(this, "field", void 0);
|
339
|
+
_defineProperty(this, "operator", void 0);
|
340
|
+
_defineProperty(this, "value", void 0);
|
341
|
+
if (!(field instanceof Field)) {
|
342
|
+
throw Error(`field ${field} is not a valid Field object`);
|
343
|
+
}
|
344
|
+
if (typeof operator !== 'string') {
|
345
|
+
throw Error(`operator ${operator} is not a valid operator`);
|
346
|
+
}
|
347
|
+
if (!(value instanceof AbstractConditionValue)) {
|
348
|
+
throw Error(`value ${value} is not a valid value type`);
|
349
|
+
}
|
350
|
+
this.field = field;
|
351
|
+
this.operator = operator;
|
352
|
+
this.value = value;
|
353
|
+
}
|
354
|
+
asFirstCondition() {
|
355
|
+
this._asFirstCondition();
|
356
|
+
return this;
|
357
|
+
}
|
358
|
+
conditionString() {
|
359
|
+
return `'${this.field.display}' ${this.operator} '${this.value.toPresentationString()}'`;
|
360
|
+
}
|
361
|
+
conditionExpression() {
|
362
|
+
return getExpression(this.field.type, this.field.name, this.operator, this.value);
|
363
|
+
}
|
364
|
+
clone() {
|
365
|
+
return new Condition(Field.from(this.field), this.operator, this.value.clone(), this.coordinator);
|
366
|
+
}
|
367
|
+
}
|
368
|
+
export class ConditionRef extends AbstractCondition {
|
369
|
+
constructor(conditionName, conditionDisplayName, coordinator) {
|
370
|
+
super(coordinator);
|
371
|
+
_defineProperty(this, "conditionName", void 0);
|
372
|
+
_defineProperty(this, "conditionDisplayName", void 0);
|
373
|
+
if (typeof conditionName !== 'string') {
|
374
|
+
throw Error(`condition name ${conditionName} is not valid`);
|
375
|
+
}
|
376
|
+
if (typeof conditionDisplayName !== 'string') {
|
377
|
+
throw Error(`condition display name ${conditionDisplayName} is not valid`);
|
378
|
+
}
|
379
|
+
this.conditionName = conditionName;
|
380
|
+
this.conditionDisplayName = conditionDisplayName;
|
381
|
+
}
|
382
|
+
asFirstCondition() {
|
383
|
+
this._asFirstCondition();
|
384
|
+
return this;
|
385
|
+
}
|
386
|
+
conditionString() {
|
387
|
+
return `'${this.conditionDisplayName}'`;
|
388
|
+
}
|
389
|
+
conditionExpression() {
|
390
|
+
return this.conditionName;
|
391
|
+
}
|
392
|
+
clone() {
|
393
|
+
return new ConditionRef(this.conditionName, this.conditionDisplayName, this.coordinator);
|
415
394
|
}
|
416
|
-
|
417
|
-
});
|
395
|
+
}
|
418
396
|
//# sourceMappingURL=inline-condition-model.js.map
|