@media-quest/builder 0.0.2 → 0.0.3
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/public-api.d.mts +24 -6
- package/dist/public-api.d.ts +24 -6
- package/dist/public-api.js +58 -32
- package/dist/public-api.mjs +39 -32
- package/package.json +3 -4
- package/src/public-api.ts +3 -0
- package/src/rulebuilder/Builder-rule.spec.ts +182 -182
- package/src/rulebuilder/Builder-rule.ts +34 -65
- package/src/rulebuilder/RuleBuilder-test-utils.ts +228 -228
- package/src/rulebuilder/SingleSelectItem.ts +118 -118
- package/src/rulebuilder/{Builder-condition-group.ts → condition/Builder-condition-group.ts} +15 -33
- package/src/rulebuilder/condition/Builder-condition.spec.ts +169 -0
- package/src/rulebuilder/condition/Builder-condition.ts +186 -0
- package/src/rulebuilder/index.ts +11 -11
- package/src/rulebuilder/Builder-condition.spec.ts +0 -169
- package/src/rulebuilder/Builder-condition.ts +0 -186
- /package/src/rulebuilder/{Builder-condition-group.spec.ts → condition/Builder-condition-group.spec.ts} +0 -0
- /package/src/rulebuilder/{Builder-operator.spec.ts → condition/Builder-operator.spec.ts} +0 -0
- /package/src/rulebuilder/{Builder-operator.ts → condition/Builder-operator.ts} +0 -0
|
@@ -1,74 +1,74 @@
|
|
|
1
1
|
import { BuilderRule, type BuilderRuleDto } from "./Builder-rule";
|
|
2
2
|
import { RuleBuilderTestUtils as U } from "./RuleBuilder-test-utils";
|
|
3
3
|
import { RuleInput } from "./RuleInput";
|
|
4
|
-
import type { BuilderConditionGroupDto } from "./Builder-condition-group";
|
|
4
|
+
import type { BuilderConditionGroupDto } from "./condition/Builder-condition-group";
|
|
5
5
|
|
|
6
6
|
const { createBuilderVariables_A_H } = U;
|
|
7
7
|
let questionVariables = createBuilderVariables_A_H();
|
|
8
8
|
const createDto = (): {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
ruleInput: RuleInput;
|
|
10
|
+
builderRuleDto: BuilderRuleDto;
|
|
11
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
|
-
|
|
12
|
+
const v1 = U.createRuleVariable("v1", 2);
|
|
13
|
+
const v2 = U.createRuleVariable("v2", 2);
|
|
14
|
+
const v3 = U.createRuleVariable("v3", 2);
|
|
15
|
+
const v4 = U.createRuleVariable("v4", 2);
|
|
16
|
+
const vg1 = U.createRuleVariable("vg1", 2);
|
|
17
|
+
const vg2 = U.createRuleVariable("vg2", 2);
|
|
18
|
+
const vg3 = U.createRuleVariable("vg3", 2);
|
|
19
|
+
const vg4 = U.createRuleVariable("vg4", 2);
|
|
20
|
+
const variableList = [v1, v2, v3, v4, vg1, vg2, vg3, vg4];
|
|
21
|
+
const tagAction1 = U.excludeByTagAction("tag1");
|
|
22
|
+
const tagAction2 = U.excludeByTagAction("tag2");
|
|
23
|
+
const tagAction3 = U.excludeByTagAction("tag3");
|
|
24
|
+
const tagAction4 = U.excludeByTagAction("tag4");
|
|
25
|
+
const pageAction1 = U.excludeByPageIdAction(v1.varId);
|
|
26
|
+
const pageAction2 = U.excludeByPageIdAction(v2.varId);
|
|
27
|
+
const pageAction3 = U.excludeByPageIdAction(v3.varId);
|
|
28
|
+
const pageAction4 = U.excludeByPageIdAction(v4.varId);
|
|
29
|
+
|
|
30
|
+
// const pageAction =
|
|
31
|
+
// const excludeByTagList = [];
|
|
32
|
+
const ruleInput = new RuleInput(
|
|
33
|
+
variableList,
|
|
34
|
+
[],
|
|
35
|
+
[pageAction1, pageAction2, pageAction3, pageAction4],
|
|
36
|
+
[tagAction1, tagAction2, tagAction3, tagAction4],
|
|
37
|
+
[],
|
|
38
|
+
);
|
|
39
|
+
const c1 = U.createConditionDto(v1);
|
|
40
|
+
const c2 = U.createConditionDto(v2);
|
|
41
|
+
const c3 = U.createConditionDto(v3);
|
|
42
|
+
const c4 = U.createConditionDto(v4);
|
|
43
|
+
const cg1 = U.createConditionDto(vg1);
|
|
44
|
+
const cg2 = U.createConditionDto(vg2);
|
|
45
|
+
const cg3 = U.createConditionDto(vg3);
|
|
46
|
+
const cg4 = U.createConditionDto(vg4);
|
|
47
|
+
const group3: BuilderConditionGroupDto = {
|
|
48
|
+
kind: "condition-group",
|
|
49
|
+
name: "group3",
|
|
50
|
+
type: "all",
|
|
51
|
+
conditions: [cg1, cg2, cg3, cg4],
|
|
52
|
+
};
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
const builderRuleDto1: BuilderRuleDto = {
|
|
55
|
+
type: "any",
|
|
56
|
+
jumpToPage: false,
|
|
57
|
+
excludePages: [v1.varId, v3.varId],
|
|
58
|
+
excludeTags: [tagAction1.tag, tagAction2.tag],
|
|
59
|
+
name: "kitchen-sink",
|
|
60
|
+
conditions: [c1, c2, group3, c3, c4],
|
|
61
|
+
};
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
return { ruleInput, builderRuleDto: builderRuleDto1 };
|
|
64
64
|
};
|
|
65
65
|
let dto: BuilderRuleDto = {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
name: "test-rule",
|
|
67
|
+
conditions: [],
|
|
68
|
+
type: "all",
|
|
69
|
+
excludePages: [],
|
|
70
|
+
excludeTags: [],
|
|
71
|
+
jumpToPage: false,
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
const excludeByTagActionList = U.excludeByTagActionList();
|
|
@@ -78,130 +78,130 @@ let ruleInput = new RuleInput(questionVariables, [], [...pageActions], excludeBy
|
|
|
78
78
|
let rule: BuilderRule = BuilderRule.fromDto(dto, ruleInput);
|
|
79
79
|
|
|
80
80
|
beforeEach(() => {
|
|
81
|
-
|
|
81
|
+
rule = BuilderRule.fromDto(dto, ruleInput);
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
describe("Builder Rule", () => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
85
|
+
test("Can create rule", () => {
|
|
86
|
+
expect(rule).toBeInstanceOf(BuilderRule);
|
|
87
|
+
});
|
|
88
|
+
test("Can add condition", () => {
|
|
89
|
+
rule.addCondition();
|
|
90
|
+
expect(rule.conditions.length).toBe(1);
|
|
91
|
+
});
|
|
92
|
+
test("Can delete condition", () => {
|
|
93
|
+
const r1 = rule.addCondition();
|
|
94
|
+
const r2 = rule.addCondition();
|
|
95
|
+
const r3 = rule.addCondition();
|
|
96
|
+
const r4 = rule.addCondition();
|
|
97
|
+
const r5 = rule.addCondition();
|
|
98
|
+
expect(rule.conditionCount).toBe(5);
|
|
99
|
+
const result = rule.deleteCondition(r3);
|
|
100
|
+
expect(result).toBeTruthy();
|
|
101
|
+
expect(rule.conditionCount).toBe(4);
|
|
102
|
+
expect(rule.conditions[0]).toBe(r1);
|
|
103
|
+
expect(rule.conditions[1]).toBe(r2);
|
|
104
|
+
expect(rule.conditions[2]).toBe(r4);
|
|
105
|
+
expect(rule.conditions[3]).toBe(r5);
|
|
106
|
+
expect(rule.deleteCondition(r3)).toBeFalsy();
|
|
107
|
+
// expect(rule.conditions[0]).toBe(r1);
|
|
108
|
+
});
|
|
109
|
+
test("Can delete condition-group", () => {
|
|
110
|
+
const r1 = rule.addCondition();
|
|
111
|
+
const r2 = rule.addConditionGroup();
|
|
112
|
+
const r3 = rule.addConditionGroup();
|
|
113
|
+
const r4 = rule.addCondition();
|
|
114
|
+
const r5 = rule.addConditionGroup();
|
|
115
|
+
expect(rule.conditionCount).toBe(5);
|
|
116
|
+
const result = rule.deleteCondition(r2);
|
|
117
|
+
expect(result).toBeTruthy();
|
|
118
|
+
expect(rule.conditionCount).toBe(4);
|
|
119
|
+
expect(rule.conditions[0]).toBe(r1);
|
|
120
|
+
expect(rule.conditions[1]).toBe(r3);
|
|
121
|
+
expect(rule.conditions[2]).toBe(r4);
|
|
122
|
+
expect(rule.conditions[3]).toBe(r5);
|
|
123
|
+
expect(rule.deleteCondition(r2)).toBeFalsy();
|
|
124
|
+
expect(rule.deleteCondition(r1)).toBeTruthy();
|
|
125
|
+
expect(rule.deleteCondition(r5)).toBeTruthy();
|
|
126
|
+
expect(rule.conditionCount).toBe(2);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test("Conditions have no operators available before variable is set.", () => {
|
|
130
|
+
const c1 = rule.addCondition();
|
|
131
|
+
expect(c1.operatorsSelectItems.length).toBe(0);
|
|
132
|
+
|
|
133
|
+
const a = c1.variableSelectItemsInUniverse[0]?.data ?? false;
|
|
134
|
+
c1.variable = a;
|
|
135
|
+
expect(c1.operatorsSelectItems.length).toBe(2);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test("Conditions and actions in dto will exist: ", () => {
|
|
139
|
+
const v1 = ruleInput.questionVars[0];
|
|
140
|
+
const v2 = ruleInput.questionVars[1];
|
|
141
|
+
const tag1 = ruleInput.excludeByTagActions[0];
|
|
142
|
+
const pageAction1 = ruleInput.excludeByPageIdActions[0];
|
|
143
|
+
|
|
144
|
+
const dtoWithOneCondition: BuilderRuleDto = {
|
|
145
|
+
...dto,
|
|
146
|
+
excludePages: [pageAction1.pageId],
|
|
147
|
+
excludeTags: [tag1.tag],
|
|
148
|
+
jumpToPage: v1.varId,
|
|
149
|
+
conditions: [
|
|
150
|
+
{
|
|
151
|
+
kind: "condition",
|
|
152
|
+
name: "condition 1",
|
|
153
|
+
variableId: v1.varId,
|
|
154
|
+
operator: "equal",
|
|
155
|
+
value: v1.options[0].value,
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
kind: "condition-group",
|
|
159
|
+
type: "all",
|
|
160
|
+
name: "condtion-grup-from-testing.",
|
|
161
|
+
conditions: [
|
|
162
|
+
{
|
|
163
|
+
name: "nested-condition",
|
|
164
|
+
kind: "condition",
|
|
165
|
+
value: v2.options[0].value,
|
|
166
|
+
operator: "equal",
|
|
167
|
+
variableId: v2.varId,
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const rule = BuilderRule.fromDto(dtoWithOneCondition, ruleInput);
|
|
175
|
+
// console.log(rule);
|
|
176
|
+
expect(rule.conditions.length).toBe(2);
|
|
177
|
+
const excludeTags = rule.toJson().excludeTags;
|
|
178
|
+
expect(excludeTags.length).toBe(1);
|
|
179
|
+
expect(rule.jumpToActionManager).toBeTruthy();
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
test("fromJSON -> toJSON -> are equal.", () => {
|
|
183
|
+
const data = createDto();
|
|
184
|
+
|
|
185
|
+
const localRule = BuilderRule.fromDto(data.builderRuleDto, data.ruleInput);
|
|
186
|
+
|
|
187
|
+
const json = localRule.toJson();
|
|
188
|
+
expect(data.builderRuleDto).toStrictEqual(json);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test("invalid tags will be removed.", () => {
|
|
192
|
+
const ruleInput = new RuleInput([], [], [], U.excludeByTagActionList(), []);
|
|
193
|
+
const dto: BuilderRuleDto = {
|
|
194
|
+
conditions: [],
|
|
195
|
+
excludePages: [],
|
|
196
|
+
excludeTags: ["tag3", "tag1"],
|
|
197
|
+
jumpToPage: false,
|
|
198
|
+
name: "Rule-name-in-test",
|
|
199
|
+
type: "all",
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const localRule = BuilderRule.fromDto(dto, ruleInput);
|
|
203
|
+
|
|
204
|
+
expect(ruleInput.excludeByTagActions.length).toStrictEqual(10);
|
|
205
|
+
expect(ruleInput.excludeByTagActions.length).toStrictEqual(10);
|
|
206
|
+
});
|
|
207
207
|
});
|
|
@@ -1,86 +1,62 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BuilderCondition,
|
|
3
|
-
type BuilderConditionDto
|
|
4
|
-
} from './Builder-condition';
|
|
1
|
+
import { BuilderCondition, type BuilderConditionDto } from "./condition/Builder-condition";
|
|
5
2
|
import {
|
|
6
3
|
BuilderConditionGroup,
|
|
7
4
|
type BuilderConditionGroupDto,
|
|
8
|
-
type ConditionGroupType
|
|
9
|
-
} from
|
|
10
|
-
import type { RuleInput } from
|
|
11
|
-
import { BuilderObject } from
|
|
12
|
-
import { TagActionManager } from
|
|
13
|
-
import { PageActionManager } from
|
|
14
|
-
import { JumpToActionManager } from
|
|
5
|
+
type ConditionGroupType,
|
|
6
|
+
} from "./condition/Builder-condition-group";
|
|
7
|
+
import type { RuleInput } from "./RuleInput";
|
|
8
|
+
import { BuilderObject } from "../BuilderObject";
|
|
9
|
+
import { TagActionManager } from "./tag-action-manager";
|
|
10
|
+
import { PageActionManager } from "./page-action-manager";
|
|
11
|
+
import { JumpToActionManager } from "./jump-to-action-manager";
|
|
15
12
|
|
|
16
13
|
export interface BuilderRuleDto {
|
|
17
14
|
readonly type: ConditionGroupType;
|
|
18
15
|
readonly name: string;
|
|
19
|
-
readonly conditions: ReadonlyArray<
|
|
20
|
-
BuilderConditionDto | BuilderConditionGroupDto
|
|
21
|
-
>;
|
|
16
|
+
readonly conditions: ReadonlyArray<BuilderConditionDto | BuilderConditionGroupDto>;
|
|
22
17
|
readonly excludeTags: ReadonlyArray<string>;
|
|
23
18
|
readonly excludePages: ReadonlyArray<string>;
|
|
24
19
|
readonly jumpToPage: string | false;
|
|
25
20
|
}
|
|
26
|
-
export class BuilderRule extends BuilderObject<
|
|
27
|
-
readonly objectType:
|
|
28
|
-
private _type: ConditionGroupType =
|
|
29
|
-
public name =
|
|
21
|
+
export class BuilderRule extends BuilderObject<"builder-rule", BuilderRuleDto> {
|
|
22
|
+
readonly objectType: "builder-rule" = "builder-rule";
|
|
23
|
+
private _type: ConditionGroupType = "all";
|
|
24
|
+
public name = "Rule name";
|
|
30
25
|
// public countNumber = 1;
|
|
31
|
-
private readonly _conditions: Array<
|
|
32
|
-
BuilderCondition | BuilderConditionGroup
|
|
33
|
-
> = [];
|
|
26
|
+
private readonly _conditions: Array<BuilderCondition | BuilderConditionGroup> = [];
|
|
34
27
|
|
|
35
28
|
private _tagActionManager: TagActionManager;
|
|
36
29
|
private _pageActionManager: PageActionManager;
|
|
37
30
|
readonly jumpToActionManager: JumpToActionManager;
|
|
38
|
-
public static readonly fromDto = (
|
|
39
|
-
dto: BuilderRuleDto,
|
|
40
|
-
input: RuleInput
|
|
41
|
-
): BuilderRule => {
|
|
31
|
+
public static readonly fromDto = (dto: BuilderRuleDto, input: RuleInput): BuilderRule => {
|
|
42
32
|
return new BuilderRule(dto, input);
|
|
43
33
|
};
|
|
44
34
|
|
|
45
35
|
protected constructor(
|
|
46
36
|
private readonly dto: BuilderRuleDto,
|
|
47
|
-
private readonly _ruleInput: RuleInput
|
|
37
|
+
private readonly _ruleInput: RuleInput,
|
|
48
38
|
) {
|
|
49
39
|
super(dto);
|
|
50
40
|
const conditionInput = this._ruleInput.getConditionInput();
|
|
51
|
-
this.name = dto.name ??
|
|
52
|
-
this._type = dto.type ??
|
|
53
|
-
this._conditions = dto.conditions.reduce<
|
|
54
|
-
|
|
55
|
-
>((acc, curr) => {
|
|
56
|
-
if (curr.kind === 'condition') {
|
|
41
|
+
this.name = dto.name ?? "";
|
|
42
|
+
this._type = dto.type ?? "any";
|
|
43
|
+
this._conditions = dto.conditions.reduce<Array<BuilderCondition | BuilderConditionGroup>>((acc, curr) => {
|
|
44
|
+
if (curr.kind === "condition") {
|
|
57
45
|
const condition = BuilderCondition.fromDto(curr, conditionInput);
|
|
58
46
|
acc.push(condition);
|
|
59
47
|
}
|
|
60
|
-
if (curr.kind ===
|
|
61
|
-
const conditionGroup = BuilderConditionGroup.fromDto(
|
|
62
|
-
curr,
|
|
63
|
-
conditionInput
|
|
64
|
-
);
|
|
48
|
+
if (curr.kind === "condition-group") {
|
|
49
|
+
const conditionGroup = BuilderConditionGroup.fromDto(curr, conditionInput);
|
|
65
50
|
acc.push(conditionGroup);
|
|
66
51
|
}
|
|
67
52
|
return acc;
|
|
68
53
|
}, []);
|
|
69
54
|
// TODO CHECK WITH CURRENT OPTIONS.
|
|
70
|
-
this._pageActionManager = new PageActionManager(
|
|
71
|
-
_ruleInput.excludeByPageIdActions,
|
|
72
|
-
dto.excludePages
|
|
73
|
-
);
|
|
55
|
+
this._pageActionManager = new PageActionManager(_ruleInput.excludeByPageIdActions, dto.excludePages);
|
|
74
56
|
// this.excludeByPageIdDtoList.push(...dto.excludePages);
|
|
75
|
-
this._tagActionManager = new TagActionManager(
|
|
76
|
-
_ruleInput.excludeByTagActions,
|
|
77
|
-
dto.excludeTags
|
|
78
|
-
);
|
|
57
|
+
this._tagActionManager = new TagActionManager(_ruleInput.excludeByTagActions, dto.excludeTags);
|
|
79
58
|
|
|
80
|
-
this.jumpToActionManager = new JumpToActionManager(
|
|
81
|
-
_ruleInput.jumpToPageActions,
|
|
82
|
-
dto.jumpToPage
|
|
83
|
-
);
|
|
59
|
+
this.jumpToActionManager = new JumpToActionManager(_ruleInput.jumpToPageActions, dto.jumpToPage);
|
|
84
60
|
}
|
|
85
61
|
|
|
86
62
|
get conditions(): ReadonlyArray<BuilderConditionGroup | BuilderCondition> {
|
|
@@ -109,9 +85,7 @@ export class BuilderRule extends BuilderObject<'builder-rule', BuilderRuleDto> {
|
|
|
109
85
|
return this._type;
|
|
110
86
|
}
|
|
111
87
|
|
|
112
|
-
deleteCondition(
|
|
113
|
-
condition: BuilderCondition | BuilderConditionGroup
|
|
114
|
-
): boolean {
|
|
88
|
+
deleteCondition(condition: BuilderCondition | BuilderConditionGroup): boolean {
|
|
115
89
|
const index = this._conditions.indexOf(condition);
|
|
116
90
|
if (index < 0) {
|
|
117
91
|
return false;
|
|
@@ -121,24 +95,19 @@ export class BuilderRule extends BuilderObject<'builder-rule', BuilderRuleDto> {
|
|
|
121
95
|
}
|
|
122
96
|
|
|
123
97
|
addCondition(): BuilderCondition {
|
|
124
|
-
const condition = BuilderCondition.create(
|
|
125
|
-
this._ruleInput.getConditionInput()
|
|
126
|
-
);
|
|
98
|
+
const condition = BuilderCondition.create(this._ruleInput.getConditionInput());
|
|
127
99
|
this._conditions.push(condition);
|
|
128
100
|
return condition;
|
|
129
101
|
}
|
|
130
102
|
|
|
131
103
|
addConditionGroup(): BuilderConditionGroup {
|
|
132
104
|
const dto: BuilderConditionGroupDto = {
|
|
133
|
-
kind:
|
|
134
|
-
name:
|
|
135
|
-
type:
|
|
136
|
-
conditions: []
|
|
105
|
+
kind: "condition-group",
|
|
106
|
+
name: "",
|
|
107
|
+
type: "all",
|
|
108
|
+
conditions: [],
|
|
137
109
|
};
|
|
138
|
-
const newGroup = BuilderConditionGroup.fromDto(
|
|
139
|
-
dto,
|
|
140
|
-
this._ruleInput.questionVars
|
|
141
|
-
);
|
|
110
|
+
const newGroup = BuilderConditionGroup.fromDto(dto, this._ruleInput.questionVars);
|
|
142
111
|
this._conditions.push(newGroup);
|
|
143
112
|
return newGroup;
|
|
144
113
|
}
|
|
@@ -148,7 +117,7 @@ export class BuilderRule extends BuilderObject<'builder-rule', BuilderRuleDto> {
|
|
|
148
117
|
}
|
|
149
118
|
|
|
150
119
|
toJson(): BuilderRuleDto {
|
|
151
|
-
const conditions = this._conditions.map(c => c.toJson());
|
|
120
|
+
const conditions = this._conditions.map((c) => c.toJson());
|
|
152
121
|
const excludePages = this._pageActionManager.getCurrentSelection();
|
|
153
122
|
const excludeTags = this._tagActionManager.getCurrentSelection();
|
|
154
123
|
const jumpToPage = this.jumpToActionManager.getSelectedPageId();
|
|
@@ -158,7 +127,7 @@ export class BuilderRule extends BuilderObject<'builder-rule', BuilderRuleDto> {
|
|
|
158
127
|
conditions,
|
|
159
128
|
excludePages,
|
|
160
129
|
jumpToPage,
|
|
161
|
-
excludeTags
|
|
130
|
+
excludeTags,
|
|
162
131
|
};
|
|
163
132
|
return dto;
|
|
164
133
|
}
|