@media-quest/builder 0.0.22 → 0.0.24
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/package.json +1 -1
- package/src/Builder-option.ts +66 -66
- package/src/Builder-page.spec.ts +320 -320
- package/src/Builder-page.ts +257 -257
- package/src/Builder-question.spec.ts +68 -68
- package/src/Builder-question.ts +101 -101
- package/src/Builder-schema.spec.ts +51 -0
- package/src/Builder-schema.ts +47 -15
- package/src/Builder-text.spec.ts +24 -24
- package/src/Builder-text.ts +57 -57
- package/src/BuilderMainImageDto.ts +7 -7
- package/src/BuilderMainText.ts +81 -81
- package/src/BuilderMainVideoDto.ts +10 -10
- package/src/BuilderObject.ts +61 -61
- package/src/BuilderTag.ts +97 -97
- package/src/builder-compiler.ts +14 -0
- package/src/codebook.ts +72 -72
- package/src/media-files.ts +28 -28
- package/src/primitives/page-prefix.ts +58 -58
- package/src/primitives/prefix.spec.ts +5 -5
- package/src/primitives/schema-prefix.ts +52 -52
- package/src/primitives/varID.ts +11 -11
- package/src/public-api.ts +3 -1
- package/src/rulebuilder/Builder-rule.spec.ts +322 -322
- package/src/rulebuilder/Builder-rule.ts +190 -190
- package/src/rulebuilder/RuleAction.ts +106 -106
- package/src/rulebuilder/RuleBuilder-test-utils.ts +316 -316
- package/src/rulebuilder/RuleInput.ts +44 -44
- package/src/rulebuilder/RuleVariable.ts +49 -49
- package/src/rulebuilder/SingleSelectItem.ts +135 -135
- package/src/rulebuilder/condition/Builder-condition-group.spec.ts +47 -47
- package/src/rulebuilder/condition/Builder-condition-group.ts +118 -118
- package/src/rulebuilder/condition/Builder-condition.spec.ts +195 -195
- package/src/rulebuilder/condition/Builder-condition.ts +208 -208
- package/src/rulebuilder/condition/Builder-operator.spec.ts +9 -9
- package/src/rulebuilder/condition/Builder-operator.ts +31 -31
- package/src/rulebuilder/index.ts +22 -22
- package/src/rulebuilder/jump-to-action-manager.ts +33 -33
- package/src/rulebuilder/multi-select-item.ts +73 -73
- package/src/rulebuilder/page-action-manager.ts +31 -31
- package/src/rulebuilder/rule2/Rule2.ts +211 -211
- package/src/rulebuilder/tag-action-manager.spec.ts +44 -44
- package/src/rulebuilder/tag-action-manager.ts +28 -28
- package/src/schema-config.ts +25 -25
- package/src/theme/AbstractThemeCompiler.ts +7 -7
- package/src/theme/IDefaultTheme.ts +226 -226
- package/src/theme/css-theme.ts +7 -7
- package/src/theme/default-theme-compiler.ts +358 -358
- package/src/theme/icon-urls.ts +29 -29
- package/src/theme/theme-utils.ts +57 -57
- package/src/theme/theme1.spec.ts +52 -52
- package/src/variable/mq-variable.spec.ts +146 -0
- package/src/{mq-variable.ts → variable/mq-variable.ts} +8 -1
- package/src/variable/sum-score.ts +138 -0
- package/tsconfig.json +15 -15
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,190 +1,190 @@
|
|
|
1
|
-
import { BuilderCondition, type BuilderConditionDto } from "./condition/Builder-condition";
|
|
2
|
-
import {
|
|
3
|
-
BuilderConditionGroup,
|
|
4
|
-
type BuilderConditionGroupDto,
|
|
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";
|
|
12
|
-
import { Condition, PageID, RuleActionPageQue, PageQueRules } from "@media-quest/engine";
|
|
13
|
-
|
|
14
|
-
export interface BuilderRuleDto {
|
|
15
|
-
readonly type: ConditionGroupType;
|
|
16
|
-
readonly name: string;
|
|
17
|
-
readonly conditions: ReadonlyArray<BuilderConditionDto | BuilderConditionGroupDto>;
|
|
18
|
-
readonly excludeTags: ReadonlyArray<string>;
|
|
19
|
-
readonly excludePages: ReadonlyArray<PageID>;
|
|
20
|
-
readonly jumpToPage: string | false;
|
|
21
|
-
}
|
|
22
|
-
export class BuilderRule extends BuilderObject<"builder-rule", BuilderRuleDto> {
|
|
23
|
-
readonly objectType: "builder-rule" = "builder-rule";
|
|
24
|
-
private _type: ConditionGroupType = "all";
|
|
25
|
-
public name = "Rule name";
|
|
26
|
-
// public countNumber = 1;
|
|
27
|
-
private readonly _conditions: Array<BuilderCondition | BuilderConditionGroup> = [];
|
|
28
|
-
|
|
29
|
-
private readonly _tagActionManager: TagActionManager;
|
|
30
|
-
private _pageActionManager: PageActionManager;
|
|
31
|
-
readonly jumpToActionManager: JumpToActionManager;
|
|
32
|
-
public static readonly fromDto = (dto: BuilderRuleDto, input: RuleInput): BuilderRule => {
|
|
33
|
-
return new BuilderRule(dto, input);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
protected constructor(
|
|
37
|
-
private readonly dto: BuilderRuleDto,
|
|
38
|
-
private readonly _ruleInput: RuleInput,
|
|
39
|
-
) {
|
|
40
|
-
super(dto);
|
|
41
|
-
const conditionInput = this._ruleInput.getConditionInput();
|
|
42
|
-
this.name = dto.name ?? "";
|
|
43
|
-
this._type = dto.type ?? "any";
|
|
44
|
-
this._conditions = dto.conditions.reduce<Array<BuilderCondition | BuilderConditionGroup>>(
|
|
45
|
-
(acc, curr) => {
|
|
46
|
-
if (curr.kind === "condition") {
|
|
47
|
-
const condition = BuilderCondition.fromDto(curr, conditionInput);
|
|
48
|
-
acc.push(condition);
|
|
49
|
-
}
|
|
50
|
-
if (curr.kind === "condition-group") {
|
|
51
|
-
const conditionGroup = BuilderConditionGroup.fromDto(curr, conditionInput);
|
|
52
|
-
acc.push(conditionGroup);
|
|
53
|
-
}
|
|
54
|
-
return acc;
|
|
55
|
-
},
|
|
56
|
-
[],
|
|
57
|
-
);
|
|
58
|
-
// TODO CHECK WITH CURRENT OPTIONS.
|
|
59
|
-
this._pageActionManager = new PageActionManager(
|
|
60
|
-
_ruleInput.excludeByPageIdActions,
|
|
61
|
-
dto.excludePages,
|
|
62
|
-
);
|
|
63
|
-
// this.excludeByPageIdDtoList.push(...dto.excludePages);
|
|
64
|
-
this._tagActionManager = new TagActionManager(_ruleInput.excludeByTagActions, dto.excludeTags);
|
|
65
|
-
|
|
66
|
-
this.jumpToActionManager = new JumpToActionManager(
|
|
67
|
-
_ruleInput.jumpToPageActions,
|
|
68
|
-
dto.jumpToPage,
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
get conditions(): ReadonlyArray<BuilderConditionGroup | BuilderCondition> {
|
|
73
|
-
return this._conditions;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
getTagActions() {
|
|
77
|
-
return this._tagActionManager.selectItems;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
getValidPageActions() {
|
|
81
|
-
return this._pageActionManager.selectItems;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
get conditionCount() {
|
|
85
|
-
return this._conditions.length;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
set type(type: ConditionGroupType) {
|
|
89
|
-
if (BuilderConditionGroup.isConditionGroupType(type)) {
|
|
90
|
-
this._type = type;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
get type() {
|
|
95
|
-
return this._type;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
deleteCondition(condition: BuilderCondition | BuilderConditionGroup): boolean {
|
|
99
|
-
const index = this._conditions.indexOf(condition);
|
|
100
|
-
if (index < 0) {
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
this._conditions.splice(index, 1);
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
addCondition(): BuilderCondition {
|
|
108
|
-
const condition = BuilderCondition.create(this._ruleInput.getConditionInput());
|
|
109
|
-
this._conditions.push(condition);
|
|
110
|
-
return condition;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
addConditionGroup(): BuilderConditionGroup {
|
|
114
|
-
const dto: BuilderConditionGroupDto = {
|
|
115
|
-
kind: "condition-group",
|
|
116
|
-
name: "",
|
|
117
|
-
type: "all",
|
|
118
|
-
conditions: [],
|
|
119
|
-
};
|
|
120
|
-
const newGroup = BuilderConditionGroup.fromDto(dto, this._ruleInput.questionVars);
|
|
121
|
-
this._conditions.push(newGroup);
|
|
122
|
-
return newGroup;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
clone(): BuilderRuleDto {
|
|
126
|
-
return this.toJson();
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
toJson(): BuilderRuleDto {
|
|
130
|
-
const conditions = this._conditions.map((c) => c.toJson());
|
|
131
|
-
const excludePages = this._pageActionManager.getCurrentSelection();
|
|
132
|
-
const excludeTags = this._tagActionManager.getCurrentSelection();
|
|
133
|
-
const jumpToPage = this.jumpToActionManager.getSelectedPageId();
|
|
134
|
-
const dto: BuilderRuleDto = {
|
|
135
|
-
type: this._type,
|
|
136
|
-
name: this.name,
|
|
137
|
-
conditions,
|
|
138
|
-
excludePages,
|
|
139
|
-
jumpToPage,
|
|
140
|
-
excludeTags,
|
|
141
|
-
};
|
|
142
|
-
return dto;
|
|
143
|
-
}
|
|
144
|
-
toEngineRule(): PageQueRules {
|
|
145
|
-
const conditions: Condition[] = [];
|
|
146
|
-
this._conditions.forEach((c) => {
|
|
147
|
-
if (c) {
|
|
148
|
-
if (c instanceof BuilderCondition) {
|
|
149
|
-
const simpleCondition = c.toEngineCondition();
|
|
150
|
-
if (simpleCondition) {
|
|
151
|
-
conditions.push(simpleCondition);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
if (c instanceof BuilderConditionGroup) {
|
|
155
|
-
const complexCondition = c.toEngineConditionComplex();
|
|
156
|
-
if (complexCondition) conditions.push(complexCondition);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
let all: Condition[] = [];
|
|
161
|
-
let some: Condition[] = [];
|
|
162
|
-
|
|
163
|
-
if (this.type === "all") {
|
|
164
|
-
all = [...conditions];
|
|
165
|
-
}
|
|
166
|
-
const ruleActionList: Array<RuleActionPageQue> = [];
|
|
167
|
-
const maybeJumpToPage = this.jumpToActionManager.selected;
|
|
168
|
-
if (maybeJumpToPage) {
|
|
169
|
-
ruleActionList.push({ kind: "jumpToPage", pageId: maybeJumpToPage.data.pageId });
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const excludePageByIdList = this._pageActionManager.getEngineAction().map((a) => a.pageId);
|
|
173
|
-
if (excludePageByIdList.length) {
|
|
174
|
-
ruleActionList.push({ kind: "excludeByPageId", pageIds: [...excludePageByIdList] });
|
|
175
|
-
}
|
|
176
|
-
const excludeTags = this._tagActionManager.getEngineActions().map((tagA) => tagA.tag);
|
|
177
|
-
if (excludeTags.length) {
|
|
178
|
-
ruleActionList.push({ kind: "excludeByTag", tagIds: [...excludeTags] });
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const rule: PageQueRules = {
|
|
182
|
-
description: this.name,
|
|
183
|
-
all,
|
|
184
|
-
some,
|
|
185
|
-
onFailure: [],
|
|
186
|
-
onSuccess: ruleActionList,
|
|
187
|
-
};
|
|
188
|
-
return rule;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
1
|
+
import { BuilderCondition, type BuilderConditionDto } from "./condition/Builder-condition";
|
|
2
|
+
import {
|
|
3
|
+
BuilderConditionGroup,
|
|
4
|
+
type BuilderConditionGroupDto,
|
|
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";
|
|
12
|
+
import { Condition, PageID, RuleActionPageQue, PageQueRules } from "@media-quest/engine";
|
|
13
|
+
|
|
14
|
+
export interface BuilderRuleDto {
|
|
15
|
+
readonly type: ConditionGroupType;
|
|
16
|
+
readonly name: string;
|
|
17
|
+
readonly conditions: ReadonlyArray<BuilderConditionDto | BuilderConditionGroupDto>;
|
|
18
|
+
readonly excludeTags: ReadonlyArray<string>;
|
|
19
|
+
readonly excludePages: ReadonlyArray<PageID>;
|
|
20
|
+
readonly jumpToPage: string | false;
|
|
21
|
+
}
|
|
22
|
+
export class BuilderRule extends BuilderObject<"builder-rule", BuilderRuleDto> {
|
|
23
|
+
readonly objectType: "builder-rule" = "builder-rule";
|
|
24
|
+
private _type: ConditionGroupType = "all";
|
|
25
|
+
public name = "Rule name";
|
|
26
|
+
// public countNumber = 1;
|
|
27
|
+
private readonly _conditions: Array<BuilderCondition | BuilderConditionGroup> = [];
|
|
28
|
+
|
|
29
|
+
private readonly _tagActionManager: TagActionManager;
|
|
30
|
+
private _pageActionManager: PageActionManager;
|
|
31
|
+
readonly jumpToActionManager: JumpToActionManager;
|
|
32
|
+
public static readonly fromDto = (dto: BuilderRuleDto, input: RuleInput): BuilderRule => {
|
|
33
|
+
return new BuilderRule(dto, input);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
protected constructor(
|
|
37
|
+
private readonly dto: BuilderRuleDto,
|
|
38
|
+
private readonly _ruleInput: RuleInput,
|
|
39
|
+
) {
|
|
40
|
+
super(dto);
|
|
41
|
+
const conditionInput = this._ruleInput.getConditionInput();
|
|
42
|
+
this.name = dto.name ?? "";
|
|
43
|
+
this._type = dto.type ?? "any";
|
|
44
|
+
this._conditions = dto.conditions.reduce<Array<BuilderCondition | BuilderConditionGroup>>(
|
|
45
|
+
(acc, curr) => {
|
|
46
|
+
if (curr.kind === "condition") {
|
|
47
|
+
const condition = BuilderCondition.fromDto(curr, conditionInput);
|
|
48
|
+
acc.push(condition);
|
|
49
|
+
}
|
|
50
|
+
if (curr.kind === "condition-group") {
|
|
51
|
+
const conditionGroup = BuilderConditionGroup.fromDto(curr, conditionInput);
|
|
52
|
+
acc.push(conditionGroup);
|
|
53
|
+
}
|
|
54
|
+
return acc;
|
|
55
|
+
},
|
|
56
|
+
[],
|
|
57
|
+
);
|
|
58
|
+
// TODO CHECK WITH CURRENT OPTIONS.
|
|
59
|
+
this._pageActionManager = new PageActionManager(
|
|
60
|
+
_ruleInput.excludeByPageIdActions,
|
|
61
|
+
dto.excludePages,
|
|
62
|
+
);
|
|
63
|
+
// this.excludeByPageIdDtoList.push(...dto.excludePages);
|
|
64
|
+
this._tagActionManager = new TagActionManager(_ruleInput.excludeByTagActions, dto.excludeTags);
|
|
65
|
+
|
|
66
|
+
this.jumpToActionManager = new JumpToActionManager(
|
|
67
|
+
_ruleInput.jumpToPageActions,
|
|
68
|
+
dto.jumpToPage,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
get conditions(): ReadonlyArray<BuilderConditionGroup | BuilderCondition> {
|
|
73
|
+
return this._conditions;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
getTagActions() {
|
|
77
|
+
return this._tagActionManager.selectItems;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
getValidPageActions() {
|
|
81
|
+
return this._pageActionManager.selectItems;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
get conditionCount() {
|
|
85
|
+
return this._conditions.length;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
set type(type: ConditionGroupType) {
|
|
89
|
+
if (BuilderConditionGroup.isConditionGroupType(type)) {
|
|
90
|
+
this._type = type;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
get type() {
|
|
95
|
+
return this._type;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
deleteCondition(condition: BuilderCondition | BuilderConditionGroup): boolean {
|
|
99
|
+
const index = this._conditions.indexOf(condition);
|
|
100
|
+
if (index < 0) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
this._conditions.splice(index, 1);
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
addCondition(): BuilderCondition {
|
|
108
|
+
const condition = BuilderCondition.create(this._ruleInput.getConditionInput());
|
|
109
|
+
this._conditions.push(condition);
|
|
110
|
+
return condition;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
addConditionGroup(): BuilderConditionGroup {
|
|
114
|
+
const dto: BuilderConditionGroupDto = {
|
|
115
|
+
kind: "condition-group",
|
|
116
|
+
name: "",
|
|
117
|
+
type: "all",
|
|
118
|
+
conditions: [],
|
|
119
|
+
};
|
|
120
|
+
const newGroup = BuilderConditionGroup.fromDto(dto, this._ruleInput.questionVars);
|
|
121
|
+
this._conditions.push(newGroup);
|
|
122
|
+
return newGroup;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
clone(): BuilderRuleDto {
|
|
126
|
+
return this.toJson();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
toJson(): BuilderRuleDto {
|
|
130
|
+
const conditions = this._conditions.map((c) => c.toJson());
|
|
131
|
+
const excludePages = this._pageActionManager.getCurrentSelection();
|
|
132
|
+
const excludeTags = this._tagActionManager.getCurrentSelection();
|
|
133
|
+
const jumpToPage = this.jumpToActionManager.getSelectedPageId();
|
|
134
|
+
const dto: BuilderRuleDto = {
|
|
135
|
+
type: this._type,
|
|
136
|
+
name: this.name,
|
|
137
|
+
conditions,
|
|
138
|
+
excludePages,
|
|
139
|
+
jumpToPage,
|
|
140
|
+
excludeTags,
|
|
141
|
+
};
|
|
142
|
+
return dto;
|
|
143
|
+
}
|
|
144
|
+
toEngineRule(): PageQueRules {
|
|
145
|
+
const conditions: Condition[] = [];
|
|
146
|
+
this._conditions.forEach((c) => {
|
|
147
|
+
if (c) {
|
|
148
|
+
if (c instanceof BuilderCondition) {
|
|
149
|
+
const simpleCondition = c.toEngineCondition();
|
|
150
|
+
if (simpleCondition) {
|
|
151
|
+
conditions.push(simpleCondition);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (c instanceof BuilderConditionGroup) {
|
|
155
|
+
const complexCondition = c.toEngineConditionComplex();
|
|
156
|
+
if (complexCondition) conditions.push(complexCondition);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
let all: Condition[] = [];
|
|
161
|
+
let some: Condition[] = [];
|
|
162
|
+
|
|
163
|
+
if (this.type === "all") {
|
|
164
|
+
all = [...conditions];
|
|
165
|
+
}
|
|
166
|
+
const ruleActionList: Array<RuleActionPageQue> = [];
|
|
167
|
+
const maybeJumpToPage = this.jumpToActionManager.selected;
|
|
168
|
+
if (maybeJumpToPage) {
|
|
169
|
+
ruleActionList.push({ kind: "jumpToPage", pageId: maybeJumpToPage.data.pageId });
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const excludePageByIdList = this._pageActionManager.getEngineAction().map((a) => a.pageId);
|
|
173
|
+
if (excludePageByIdList.length) {
|
|
174
|
+
ruleActionList.push({ kind: "excludeByPageId", pageIds: [...excludePageByIdList] });
|
|
175
|
+
}
|
|
176
|
+
const excludeTags = this._tagActionManager.getEngineActions().map((tagA) => tagA.tag);
|
|
177
|
+
if (excludeTags.length) {
|
|
178
|
+
ruleActionList.push({ kind: "excludeByTag", tagIds: [...excludeTags] });
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const rule: PageQueRules = {
|
|
182
|
+
description: this.name,
|
|
183
|
+
all,
|
|
184
|
+
some,
|
|
185
|
+
onFailure: [],
|
|
186
|
+
onSuccess: ruleActionList,
|
|
187
|
+
};
|
|
188
|
+
return rule;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
import { PageID } from "@media-quest/engine";
|
|
2
|
-
|
|
3
|
-
import { PagePrefixValue } from "../primitives/page-prefix";
|
|
4
|
-
|
|
5
|
-
export interface ExcludeByPageAction {
|
|
6
|
-
readonly kind: "exclude-by-pageId";
|
|
7
|
-
readonly pageId: PageID;
|
|
8
|
-
readonly pagePrefix: PagePrefixValue;
|
|
9
|
-
readonly mainText: string;
|
|
10
|
-
readonly pageNumber: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface JumpToPageAction {
|
|
14
|
-
readonly kind: "jump-to-page";
|
|
15
|
-
readonly pageId: PageID;
|
|
16
|
-
readonly pagePrefix: PagePrefixValue;
|
|
17
|
-
readonly mainText: string;
|
|
18
|
-
readonly pageNumber: number;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface ExcludeByTagAction {
|
|
22
|
-
readonly kind: "exclude-by-tag";
|
|
23
|
-
readonly tag: string;
|
|
24
|
-
readonly description: string;
|
|
25
|
-
readonly pageCount: number;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// interface ISearchable {
|
|
29
|
-
// getLabel(): string;
|
|
30
|
-
// getTooltip(): string;
|
|
31
|
-
// getSearchString(): string;
|
|
32
|
-
// }
|
|
33
|
-
// interface ISelectable {
|
|
34
|
-
// isSelected: boolean;
|
|
35
|
-
// }
|
|
36
|
-
//
|
|
37
|
-
// export class PageAction implements ISearchable, ISelectable {
|
|
38
|
-
// public readonly description = "Will exclude this page from the survey.";
|
|
39
|
-
// private _isSelected: boolean = false;
|
|
40
|
-
// get isSelected(): boolean {
|
|
41
|
-
// return this._isSelected;
|
|
42
|
-
// }
|
|
43
|
-
// set isSelected(value: boolean) {
|
|
44
|
-
// const casted = value as unknown;
|
|
45
|
-
// if (typeof casted === "boolean") {
|
|
46
|
-
// this._isSelected = casted;
|
|
47
|
-
// }
|
|
48
|
-
// }
|
|
49
|
-
// get pageId(): PageID {
|
|
50
|
-
// return this.data.pageId;
|
|
51
|
-
// }
|
|
52
|
-
// get pagePrefix(): PagePrefixValue {
|
|
53
|
-
// return this.data.pagePrefix;
|
|
54
|
-
// }
|
|
55
|
-
// get mainText(): string {
|
|
56
|
-
// return this.data.mainText;
|
|
57
|
-
// }
|
|
58
|
-
// get pageNumber(): number {
|
|
59
|
-
// return this.data.pageNumber;
|
|
60
|
-
// }
|
|
61
|
-
// constructor(
|
|
62
|
-
// private readonly data: {
|
|
63
|
-
// pageId: PageID;
|
|
64
|
-
// pagePrefix: PagePrefixValue;
|
|
65
|
-
// mainText: string;
|
|
66
|
-
// pageNumber: number;
|
|
67
|
-
// isSelected: boolean;
|
|
68
|
-
// },
|
|
69
|
-
// ) {
|
|
70
|
-
// this.isSelected = this.data.isSelected;
|
|
71
|
-
// }
|
|
72
|
-
//
|
|
73
|
-
// getLabel(): string {
|
|
74
|
-
// return this.data.pagePrefix + " (" + this.data.pageNumber + ")";
|
|
75
|
-
// }
|
|
76
|
-
// getTooltip(): string {
|
|
77
|
-
// return this.data.mainText;
|
|
78
|
-
// }
|
|
79
|
-
// getSearchString(): string {
|
|
80
|
-
// return this.data.pagePrefix + this.data.mainText;
|
|
81
|
-
// }
|
|
82
|
-
// }
|
|
83
|
-
// export class TagAction implements ISearchable {
|
|
84
|
-
// constructor(
|
|
85
|
-
// readonly tag: string,
|
|
86
|
-
// readonly description: string,
|
|
87
|
-
// readonly usedInPages: { pageNumber: number; pagePrefix: PagePrefixValue }[],
|
|
88
|
-
// ) {}
|
|
89
|
-
// getLabel(): string {
|
|
90
|
-
// return this.tag + " (" + this.usedInPages.length + ")";
|
|
91
|
-
// }
|
|
92
|
-
// getTooltip(): string {
|
|
93
|
-
// return this.description;
|
|
94
|
-
// }
|
|
95
|
-
// getSearchString(): string {
|
|
96
|
-
// return this.tag;
|
|
97
|
-
// }
|
|
98
|
-
// }
|
|
99
|
-
|
|
100
|
-
// class SelectableCollection<T> {
|
|
101
|
-
// private readonly _items: Array<T>;
|
|
102
|
-
// private selected: T | false = false;
|
|
103
|
-
// constructor(items: ReadonlyArray<T>) {
|
|
104
|
-
// this._items = [...items];
|
|
105
|
-
// }
|
|
106
|
-
// }
|
|
1
|
+
import { PageID } from "@media-quest/engine";
|
|
2
|
+
|
|
3
|
+
import { PagePrefixValue } from "../primitives/page-prefix";
|
|
4
|
+
|
|
5
|
+
export interface ExcludeByPageAction {
|
|
6
|
+
readonly kind: "exclude-by-pageId";
|
|
7
|
+
readonly pageId: PageID;
|
|
8
|
+
readonly pagePrefix: PagePrefixValue;
|
|
9
|
+
readonly mainText: string;
|
|
10
|
+
readonly pageNumber: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface JumpToPageAction {
|
|
14
|
+
readonly kind: "jump-to-page";
|
|
15
|
+
readonly pageId: PageID;
|
|
16
|
+
readonly pagePrefix: PagePrefixValue;
|
|
17
|
+
readonly mainText: string;
|
|
18
|
+
readonly pageNumber: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ExcludeByTagAction {
|
|
22
|
+
readonly kind: "exclude-by-tag";
|
|
23
|
+
readonly tag: string;
|
|
24
|
+
readonly description: string;
|
|
25
|
+
readonly pageCount: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// interface ISearchable {
|
|
29
|
+
// getLabel(): string;
|
|
30
|
+
// getTooltip(): string;
|
|
31
|
+
// getSearchString(): string;
|
|
32
|
+
// }
|
|
33
|
+
// interface ISelectable {
|
|
34
|
+
// isSelected: boolean;
|
|
35
|
+
// }
|
|
36
|
+
//
|
|
37
|
+
// export class PageAction implements ISearchable, ISelectable {
|
|
38
|
+
// public readonly description = "Will exclude this page from the survey.";
|
|
39
|
+
// private _isSelected: boolean = false;
|
|
40
|
+
// get isSelected(): boolean {
|
|
41
|
+
// return this._isSelected;
|
|
42
|
+
// }
|
|
43
|
+
// set isSelected(value: boolean) {
|
|
44
|
+
// const casted = value as unknown;
|
|
45
|
+
// if (typeof casted === "boolean") {
|
|
46
|
+
// this._isSelected = casted;
|
|
47
|
+
// }
|
|
48
|
+
// }
|
|
49
|
+
// get pageId(): PageID {
|
|
50
|
+
// return this.data.pageId;
|
|
51
|
+
// }
|
|
52
|
+
// get pagePrefix(): PagePrefixValue {
|
|
53
|
+
// return this.data.pagePrefix;
|
|
54
|
+
// }
|
|
55
|
+
// get mainText(): string {
|
|
56
|
+
// return this.data.mainText;
|
|
57
|
+
// }
|
|
58
|
+
// get pageNumber(): number {
|
|
59
|
+
// return this.data.pageNumber;
|
|
60
|
+
// }
|
|
61
|
+
// constructor(
|
|
62
|
+
// private readonly data: {
|
|
63
|
+
// pageId: PageID;
|
|
64
|
+
// pagePrefix: PagePrefixValue;
|
|
65
|
+
// mainText: string;
|
|
66
|
+
// pageNumber: number;
|
|
67
|
+
// isSelected: boolean;
|
|
68
|
+
// },
|
|
69
|
+
// ) {
|
|
70
|
+
// this.isSelected = this.data.isSelected;
|
|
71
|
+
// }
|
|
72
|
+
//
|
|
73
|
+
// getLabel(): string {
|
|
74
|
+
// return this.data.pagePrefix + " (" + this.data.pageNumber + ")";
|
|
75
|
+
// }
|
|
76
|
+
// getTooltip(): string {
|
|
77
|
+
// return this.data.mainText;
|
|
78
|
+
// }
|
|
79
|
+
// getSearchString(): string {
|
|
80
|
+
// return this.data.pagePrefix + this.data.mainText;
|
|
81
|
+
// }
|
|
82
|
+
// }
|
|
83
|
+
// export class TagAction implements ISearchable {
|
|
84
|
+
// constructor(
|
|
85
|
+
// readonly tag: string,
|
|
86
|
+
// readonly description: string,
|
|
87
|
+
// readonly usedInPages: { pageNumber: number; pagePrefix: PagePrefixValue }[],
|
|
88
|
+
// ) {}
|
|
89
|
+
// getLabel(): string {
|
|
90
|
+
// return this.tag + " (" + this.usedInPages.length + ")";
|
|
91
|
+
// }
|
|
92
|
+
// getTooltip(): string {
|
|
93
|
+
// return this.description;
|
|
94
|
+
// }
|
|
95
|
+
// getSearchString(): string {
|
|
96
|
+
// return this.tag;
|
|
97
|
+
// }
|
|
98
|
+
// }
|
|
99
|
+
|
|
100
|
+
// class SelectableCollection<T> {
|
|
101
|
+
// private readonly _items: Array<T>;
|
|
102
|
+
// private selected: T | false = false;
|
|
103
|
+
// constructor(items: ReadonlyArray<T>) {
|
|
104
|
+
// this._items = [...items];
|
|
105
|
+
// }
|
|
106
|
+
// }
|