@media-quest/builder 0.0.9 → 0.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/public-api.d.mts +31 -26
- package/dist/public-api.d.ts +31 -26
- package/dist/public-api.js +49 -42
- package/dist/public-api.mjs +47 -40
- package/package.json +2 -2
- package/src/Builder-page.spec.ts +2 -1
- package/src/Builder-page.ts +3 -1
- package/src/Builder-schema.spec.ts +3 -2
- package/src/Builder-schema.ts +13 -19
- package/src/primitives/page-prefix.ts +58 -0
- package/src/primitives/prefix.ts +0 -0
- package/src/primitives/schema-prefix.ts +52 -0
- package/src/primitives/varID.ts +11 -0
- package/src/public-api.ts +4 -1
- package/src/rulebuilder/Builder-rule.spec.ts +3 -1
- package/src/rulebuilder/Builder-rule.ts +2 -2
- package/src/rulebuilder/RuleAction.ts +84 -0
- package/src/rulebuilder/RuleBuilder-test-utils.ts +32 -12
- package/src/rulebuilder/RuleVariable.ts +3 -1
- package/src/rulebuilder/SingleSelectItem.ts +2 -2
- package/src/rulebuilder/condition/Builder-condition.spec.ts +2 -1
- package/src/rulebuilder/multi-select-item.ts +57 -54
- package/src/rulebuilder/page-action-manager.ts +2 -1
- package/src/prefix.ts +0 -107
- /package/src/{prefix.spec.ts → primitives/prefix.spec.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@media-quest/builder",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "Builder library for Media-quest schemas",
|
|
5
5
|
"main": "dist/public-api.js",
|
|
6
6
|
"module": "dist/public-api.mjs",
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
"prepublishOnly": "npm run build"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@media-quest/engine": "0.0.
|
|
16
|
+
"@media-quest/engine": "0.0.11"
|
|
17
17
|
}
|
|
18
18
|
}
|
package/src/Builder-page.spec.ts
CHANGED
|
@@ -4,7 +4,8 @@ import type { BuilderQuestionDto } from "./Builder-question";
|
|
|
4
4
|
import { BuilderQuestion } from "./Builder-question";
|
|
5
5
|
import type { BuilderObjectId } from "./BuilderObject";
|
|
6
6
|
import { DUtil, PageID } from "@media-quest/engine";
|
|
7
|
-
import { PagePrefix
|
|
7
|
+
import { PagePrefix } from "./primitives/page-prefix";
|
|
8
|
+
import { SchemaPrefix } from "./primitives/schema-prefix";
|
|
8
9
|
|
|
9
10
|
const U = DUtil;
|
|
10
11
|
const deleteIdsFromPage = (page: BuilderPageDto) => {
|
package/src/Builder-page.ts
CHANGED
|
@@ -9,7 +9,9 @@ import type { BuilderMainTextDto } from "./BuilderMainText";
|
|
|
9
9
|
import { BuilderMainText } from "./BuilderMainText";
|
|
10
10
|
import { BuilderVariableOption, QuestionVariable } from "./rulebuilder/RuleVariable";
|
|
11
11
|
import { DUtil, PageID } from "@media-quest/engine";
|
|
12
|
-
import { PagePrefix, PagePrefixValue
|
|
12
|
+
import { PagePrefix, PagePrefixValue } from "./primitives/page-prefix";
|
|
13
|
+
import { VarID } from "./primitives/varID";
|
|
14
|
+
import { SchemaPrefix, SchemaPrefixValue } from "./primitives/schema-prefix";
|
|
13
15
|
|
|
14
16
|
const U = DUtil;
|
|
15
17
|
export type BuilderPageType = "info-page" | "question" | "multi-select" | "form";
|
|
@@ -5,7 +5,8 @@ import type { BuilderTagDto } from "./BuilderTag";
|
|
|
5
5
|
import { BuilderTag } from "./BuilderTag";
|
|
6
6
|
import type { BuilderObjectId } from "./BuilderObject";
|
|
7
7
|
import { PageID, SchemaID } from "@media-quest/engine";
|
|
8
|
-
import { PagePrefix
|
|
8
|
+
import { PagePrefix } from "./primitives/page-prefix";
|
|
9
|
+
import { SchemaPrefix } from "./primitives/schema-prefix";
|
|
9
10
|
|
|
10
11
|
const tag1: BuilderTagDto = BuilderTag.create("tag1", "This tag is defined in schemaDto1").toJson();
|
|
11
12
|
|
|
@@ -166,7 +167,7 @@ describe("Builder schema", () => {
|
|
|
166
167
|
test("Can create Schema from dto", () => {
|
|
167
168
|
const s = BuilderSchema.fromJson(schemaDto1);
|
|
168
169
|
expect(s.id).toBe(schemaDto1.id);
|
|
169
|
-
expect(s.prefix).toBe(schemaDto1.prefix);
|
|
170
|
+
expect(s.prefix.value).toBe(schemaDto1.prefix);
|
|
170
171
|
expect(s.baseHeight).toBe(schemaDto1.baseHeight);
|
|
171
172
|
expect(s.baseWidth).toBe(schemaDto1.baseWidth);
|
|
172
173
|
expect(s.backgroundColor).toBe(schemaDto1.backgroundColor);
|
package/src/Builder-schema.ts
CHANGED
|
@@ -11,18 +11,10 @@ import { BuilderRule } from "./rulebuilder";
|
|
|
11
11
|
import { DefaultThemeCompiler } from "./theme/default-theme-compiler";
|
|
12
12
|
import { ImageFile } from "./media-files";
|
|
13
13
|
import { SchemaDto, DUtil, PageID, SchemaID } from "@media-quest/engine";
|
|
14
|
-
import { PagePrefix
|
|
14
|
+
import { PagePrefix } from "./primitives/page-prefix";
|
|
15
|
+
import { SchemaPrefix, SchemaPrefixValue } from "./primitives/schema-prefix";
|
|
15
16
|
const U = DUtil;
|
|
16
17
|
|
|
17
|
-
class PrimitiveWrapper<T> {
|
|
18
|
-
constructor(private readonly _value: T) {}
|
|
19
|
-
|
|
20
|
-
get value(): T {
|
|
21
|
-
return this._value;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// type SchemaHash = string & { __MD5__HASH: true };
|
|
26
18
|
export interface BuilderSchemaDto {
|
|
27
19
|
readonly id: SchemaID;
|
|
28
20
|
readonly prefix: SchemaPrefixValue;
|
|
@@ -43,7 +35,7 @@ export interface SchemaBuildOutput {
|
|
|
43
35
|
}
|
|
44
36
|
|
|
45
37
|
export class BuilderSchema {
|
|
46
|
-
|
|
38
|
+
readonly prefix: SchemaPrefix;
|
|
47
39
|
baseHeight = 1300;
|
|
48
40
|
baseWidth = 1024;
|
|
49
41
|
backgroundColor = "#000000";
|
|
@@ -54,9 +46,9 @@ export class BuilderSchema {
|
|
|
54
46
|
return [...this._rules];
|
|
55
47
|
}
|
|
56
48
|
|
|
57
|
-
get prefix(): SchemaPrefixValue {
|
|
58
|
-
|
|
59
|
-
}
|
|
49
|
+
// get prefix(): SchemaPrefixValue {
|
|
50
|
+
// return this._prefix.value;
|
|
51
|
+
// }
|
|
60
52
|
|
|
61
53
|
private readonly _tagCollection: TagCollection = TagCollection.create();
|
|
62
54
|
get tags(): ReadonlyArray<BuilderTag> {
|
|
@@ -99,16 +91,16 @@ export class BuilderSchema {
|
|
|
99
91
|
rules,
|
|
100
92
|
tags,
|
|
101
93
|
mainImage: this.mainImage,
|
|
102
|
-
prefix: this.prefix,
|
|
94
|
+
prefix: this.prefix.value,
|
|
103
95
|
};
|
|
104
96
|
return dto;
|
|
105
97
|
}
|
|
106
98
|
private constructor(
|
|
107
99
|
public readonly id: SchemaID,
|
|
108
100
|
public name: string,
|
|
109
|
-
|
|
101
|
+
prefix: SchemaPrefix,
|
|
110
102
|
) {
|
|
111
|
-
this.
|
|
103
|
+
this.prefix = prefix;
|
|
112
104
|
}
|
|
113
105
|
|
|
114
106
|
addPage(type: BuilderPageType, atIndex = -1): BuilderPage {
|
|
@@ -208,20 +200,22 @@ export class BuilderSchema {
|
|
|
208
200
|
return excludeByTagDto;
|
|
209
201
|
});
|
|
210
202
|
const jumpActions: JumpToPageAction[] = [];
|
|
211
|
-
const prefix = this.prefix;
|
|
212
203
|
this.pages.forEach((page, index) => {
|
|
213
|
-
const pageVariables = page.getQuestionVariables(this.
|
|
204
|
+
const pageVariables = page.getQuestionVariables(this.prefix, index);
|
|
214
205
|
qVars.push(...pageVariables);
|
|
215
206
|
const mainText = page.mainText.text;
|
|
207
|
+
const pagePrefix = page.prefix;
|
|
216
208
|
const jumpAction: JumpToPageAction = {
|
|
217
209
|
kind: "jump-to-page",
|
|
218
210
|
pageId: page.id,
|
|
211
|
+
pagePrefix,
|
|
219
212
|
pageNumber: index,
|
|
220
213
|
mainText: page.mainText.text,
|
|
221
214
|
};
|
|
222
215
|
const excludePageAction: ExcludeByPageAction = {
|
|
223
216
|
kind: "exclude-by-pageId",
|
|
224
217
|
pageId: page.id,
|
|
218
|
+
pagePrefix,
|
|
225
219
|
pageNumber: index,
|
|
226
220
|
mainText,
|
|
227
221
|
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { SchemaPrefix } from "./schema-prefix";
|
|
2
|
+
|
|
3
|
+
export type PagePrefixValue = string & { __PAGE_PREFIX__: true };
|
|
4
|
+
export const createRandomPrefix = <const P extends string>(length: number): P => {
|
|
5
|
+
const letters = "abcdefghijklmnopqrstuvyz";
|
|
6
|
+
const all = letters + letters.toUpperCase();
|
|
7
|
+
let result = "";
|
|
8
|
+
for (let i = 0; i < length; i++) {
|
|
9
|
+
const char = all.charAt(Math.floor(Math.random() * all.length));
|
|
10
|
+
result += char;
|
|
11
|
+
}
|
|
12
|
+
return result as P;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export class PagePrefix {
|
|
16
|
+
public static readonly MIN_LENGTH = 1;
|
|
17
|
+
private static randomLen = 5;
|
|
18
|
+
public static readonly MAX_LENGTH = 16;
|
|
19
|
+
|
|
20
|
+
public static create = (): PagePrefix => {
|
|
21
|
+
const v = createRandomPrefix<PagePrefixValue>(PagePrefix.randomLen);
|
|
22
|
+
return new PagePrefix(v);
|
|
23
|
+
};
|
|
24
|
+
public static fromString = (value: string): PagePrefix | false => {
|
|
25
|
+
if (!PagePrefix.isValid(value)) return false;
|
|
26
|
+
return new PagePrefix(value);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
public static fromStringOrThrow = (value: string): PagePrefixValue => {
|
|
30
|
+
if (!PagePrefix.isValid(value)) throw new Error("Invalid prefix");
|
|
31
|
+
return value;
|
|
32
|
+
};
|
|
33
|
+
public static castOrCreateRandom = (value: string): PagePrefix => {
|
|
34
|
+
const v = PagePrefix.isValid(value) ? value : createRandomPrefix<PagePrefixValue>(PagePrefix.randomLen);
|
|
35
|
+
return new PagePrefix(v);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
public static isValid = (prefix: string | 999): prefix is PagePrefixValue => {
|
|
39
|
+
if (typeof prefix !== "string") return false;
|
|
40
|
+
if (prefix.length < SchemaPrefix.MIN_LENGTH) return false;
|
|
41
|
+
if (prefix.length > SchemaPrefix.MAX_LENGTH) return false;
|
|
42
|
+
return true;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
get value(): PagePrefixValue {
|
|
46
|
+
return this._value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
set value(value: string) {
|
|
50
|
+
if (!PagePrefix.isValid(value)) {
|
|
51
|
+
console.log("INVALID PREFIX", value);
|
|
52
|
+
} else {
|
|
53
|
+
this._value = value;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private constructor(private _value: PagePrefixValue) {}
|
|
58
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createRandomPrefix } from "./page-prefix";
|
|
2
|
+
|
|
3
|
+
export type SchemaPrefixValue = string & { __SCHEMA_PREFIX__: true };
|
|
4
|
+
|
|
5
|
+
export class SchemaPrefix {
|
|
6
|
+
public static readonly MIN_LENGTH = 1;
|
|
7
|
+
private static randomLen = 5;
|
|
8
|
+
public static readonly MAX_LENGTH = 16;
|
|
9
|
+
|
|
10
|
+
public static fromValue = (value: SchemaPrefixValue): SchemaPrefix => {
|
|
11
|
+
return new SchemaPrefix(value);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
public static fromValueOrThrow = (value: string): SchemaPrefix => {
|
|
15
|
+
if (!SchemaPrefix.isValid(value)) throw new Error("Invalid prefix");
|
|
16
|
+
return new SchemaPrefix(value);
|
|
17
|
+
};
|
|
18
|
+
public static fromString = (value: string): SchemaPrefix | false => {
|
|
19
|
+
if (!SchemaPrefix.isValid(value)) return false;
|
|
20
|
+
return new SchemaPrefix(value);
|
|
21
|
+
};
|
|
22
|
+
public static castOrCreateRandom = (value: string): SchemaPrefix => {
|
|
23
|
+
const v = SchemaPrefix.isValid(value) ? value : createRandomPrefix<SchemaPrefixValue>(SchemaPrefix.randomLen);
|
|
24
|
+
return new SchemaPrefix(v);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
public static isValid = (prefix: string | 999): prefix is SchemaPrefixValue => {
|
|
28
|
+
if (typeof prefix !== "string") return false;
|
|
29
|
+
if (prefix.length < SchemaPrefix.MIN_LENGTH) return false;
|
|
30
|
+
if (prefix.length > SchemaPrefix.MAX_LENGTH) return false;
|
|
31
|
+
return true;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
toJSON() {}
|
|
35
|
+
|
|
36
|
+
get value(): SchemaPrefixValue {
|
|
37
|
+
return this._value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
get isValid() {
|
|
41
|
+
return SchemaPrefix.isValid(this._value);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
set value(value: string) {
|
|
45
|
+
const casted = value as unknown;
|
|
46
|
+
if (typeof casted === "string") {
|
|
47
|
+
this._value = casted as SchemaPrefixValue;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private constructor(private _value: SchemaPrefixValue) {}
|
|
52
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PagePrefixValue } from "./page-prefix";
|
|
2
|
+
|
|
3
|
+
import { SchemaPrefixValue } from "./schema-prefix";
|
|
4
|
+
|
|
5
|
+
export type VarID = `${SchemaPrefixValue}_${PagePrefixValue}`;
|
|
6
|
+
export const VarID = {
|
|
7
|
+
create: (schemaPrefix: SchemaPrefixValue, pagePrefix: PagePrefixValue): VarID => {
|
|
8
|
+
const varId = schemaPrefix + "_" + pagePrefix;
|
|
9
|
+
return varId as VarID;
|
|
10
|
+
},
|
|
11
|
+
};
|
package/src/public-api.ts
CHANGED
|
@@ -8,6 +8,9 @@ export { BuilderMainText, type BuilderMainTextDto } from "./BuilderMainText";
|
|
|
8
8
|
export { type BuilderMainVideoDto } from "./BuilderMainVideoDto";
|
|
9
9
|
export { type BuilderTagDto, BuilderTag, TagCollection } from "./BuilderTag";
|
|
10
10
|
export { type AudioFile, type ImageFile, type VideoFile } from "./media-files";
|
|
11
|
-
export * from "./prefix";
|
|
12
11
|
// Public Api of rule-builder
|
|
13
12
|
export * from "./rulebuilder";
|
|
13
|
+
export { PagePrefix } from "./primitives/page-prefix";
|
|
14
|
+
export { createRandomPrefix } from "./primitives/page-prefix";
|
|
15
|
+
export { PagePrefixValue } from "./primitives/page-prefix";
|
|
16
|
+
export { VarID } from "./primitives/varID";
|
|
@@ -4,7 +4,9 @@ import { RuleInput } from "./RuleInput";
|
|
|
4
4
|
import type { BuilderConditionGroupDto } from "./condition/Builder-condition-group";
|
|
5
5
|
import { BuilderConditionDto } from "./condition/Builder-condition";
|
|
6
6
|
import { Condition, PageID } from "@media-quest/engine";
|
|
7
|
-
import { PagePrefix
|
|
7
|
+
import { PagePrefix } from "../primitives/page-prefix";
|
|
8
|
+
import { VarID } from "../primitives/varID";
|
|
9
|
+
import { SchemaPrefix } from "../primitives/schema-prefix";
|
|
8
10
|
|
|
9
11
|
const { createPagesAndVars_A_H } = U;
|
|
10
12
|
|
|
@@ -9,14 +9,14 @@ import { BuilderObject } from "../BuilderObject";
|
|
|
9
9
|
import { TagActionManager } from "./tag-action-manager";
|
|
10
10
|
import { PageActionManager } from "./page-action-manager";
|
|
11
11
|
import { JumpToActionManager } from "./jump-to-action-manager";
|
|
12
|
-
import { Condition, PageQueCommand, PageQueRules } from "@media-quest/engine";
|
|
12
|
+
import { Condition, PageID, PageQueCommand, PageQueRules } from "@media-quest/engine";
|
|
13
13
|
|
|
14
14
|
export interface BuilderRuleDto {
|
|
15
15
|
readonly type: ConditionGroupType;
|
|
16
16
|
readonly name: string;
|
|
17
17
|
readonly conditions: ReadonlyArray<BuilderConditionDto | BuilderConditionGroupDto>;
|
|
18
18
|
readonly excludeTags: ReadonlyArray<string>;
|
|
19
|
-
readonly excludePages: ReadonlyArray<
|
|
19
|
+
readonly excludePages: ReadonlyArray<PageID>;
|
|
20
20
|
readonly jumpToPage: string | false;
|
|
21
21
|
}
|
|
22
22
|
export class BuilderRule extends BuilderObject<"builder-rule", BuilderRuleDto> {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { PageID } from "@media-quest/engine";
|
|
2
2
|
|
|
3
|
+
import { PagePrefixValue } from "../primitives/page-prefix";
|
|
4
|
+
|
|
3
5
|
export interface ExcludeByPageAction {
|
|
4
6
|
readonly kind: "exclude-by-pageId";
|
|
5
7
|
readonly pageId: PageID;
|
|
8
|
+
readonly pagePrefix: PagePrefixValue;
|
|
6
9
|
readonly mainText: string;
|
|
7
10
|
readonly pageNumber: number;
|
|
8
11
|
}
|
|
@@ -10,6 +13,7 @@ export interface ExcludeByPageAction {
|
|
|
10
13
|
export interface JumpToPageAction {
|
|
11
14
|
readonly kind: "jump-to-page";
|
|
12
15
|
readonly pageId: PageID;
|
|
16
|
+
readonly pagePrefix: PagePrefixValue;
|
|
13
17
|
readonly mainText: string;
|
|
14
18
|
readonly pageNumber: number;
|
|
15
19
|
}
|
|
@@ -20,3 +24,83 @@ export interface ExcludeByTagAction {
|
|
|
20
24
|
readonly description: string;
|
|
21
25
|
readonly pageCount: number;
|
|
22
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
|
+
// }
|
|
@@ -7,9 +7,15 @@ import type { BuilderOperator } from "./condition/Builder-operator";
|
|
|
7
7
|
import type { ExcludeByPageAction, ExcludeByTagAction, JumpToPageAction } from "./RuleAction";
|
|
8
8
|
import { ExcludeByPageIdSelectItem, ExcludeByTagSelectItem } from "./multi-select-item";
|
|
9
9
|
import { PageID } from "@media-quest/engine";
|
|
10
|
-
import { PagePrefix,
|
|
10
|
+
import { PagePrefix, PagePrefixValue } from "../primitives/page-prefix";
|
|
11
|
+
import { VarID } from "../primitives/varID";
|
|
12
|
+
import { SchemaPrefix } from "../primitives/schema-prefix";
|
|
11
13
|
|
|
12
|
-
const
|
|
14
|
+
const idPxx = () => {
|
|
15
|
+
const id = PageID.create();
|
|
16
|
+
const prefix = PagePrefix.fromStringOrThrow("pxx");
|
|
17
|
+
return { id, prefix: prefix };
|
|
18
|
+
};
|
|
13
19
|
export namespace RuleBuilderTestUtils {
|
|
14
20
|
export const createOptions = () => [
|
|
15
21
|
BuilderOption.create(0, "Nei"),
|
|
@@ -29,18 +35,22 @@ export namespace RuleBuilderTestUtils {
|
|
|
29
35
|
};
|
|
30
36
|
|
|
31
37
|
export const excludeByPageIdAction = (pageId: PageID, pageNumber: number) => {
|
|
38
|
+
const pagePrefix = PagePrefix.castOrCreateRandom("").value;
|
|
32
39
|
const action: ExcludeByPageAction = {
|
|
33
40
|
kind: "exclude-by-pageId",
|
|
34
41
|
mainText: "",
|
|
35
42
|
pageId,
|
|
43
|
+
pagePrefix,
|
|
36
44
|
pageNumber,
|
|
37
45
|
};
|
|
38
46
|
return action;
|
|
39
47
|
};
|
|
40
48
|
export const jumpToPageAction = (pageId: PageID, pageNumber: number) => {
|
|
49
|
+
const pagePrefix = PagePrefix.castOrCreateRandom("").value;
|
|
41
50
|
const action: JumpToPageAction = {
|
|
42
51
|
kind: "jump-to-page",
|
|
43
52
|
mainText: "TEXT: " + pageId,
|
|
53
|
+
pagePrefix,
|
|
44
54
|
pageId,
|
|
45
55
|
pageNumber,
|
|
46
56
|
};
|
|
@@ -150,7 +160,8 @@ export namespace RuleBuilderTestUtils {
|
|
|
150
160
|
ExcludeByPageIdSelectItem.create(
|
|
151
161
|
{
|
|
152
162
|
kind: "exclude-by-pageId",
|
|
153
|
-
pageId:
|
|
163
|
+
pageId: idPxx().id,
|
|
164
|
+
pagePrefix: idPxx().prefix,
|
|
154
165
|
pageNumber: 5,
|
|
155
166
|
mainText: "Har du noen gang vært deprimeri?? ",
|
|
156
167
|
},
|
|
@@ -160,7 +171,8 @@ export namespace RuleBuilderTestUtils {
|
|
|
160
171
|
ExcludeByPageIdSelectItem.create(
|
|
161
172
|
{
|
|
162
173
|
kind: "exclude-by-pageId",
|
|
163
|
-
pageId:
|
|
174
|
+
pageId: idPxx().id,
|
|
175
|
+
pagePrefix: idPxx().prefix,
|
|
164
176
|
pageNumber: 5,
|
|
165
177
|
mainText: "Har du noen gang vært deprimeri?? ",
|
|
166
178
|
},
|
|
@@ -170,7 +182,8 @@ export namespace RuleBuilderTestUtils {
|
|
|
170
182
|
ExcludeByPageIdSelectItem.create(
|
|
171
183
|
{
|
|
172
184
|
kind: "exclude-by-pageId",
|
|
173
|
-
pageId:
|
|
185
|
+
pageId: idPxx().id,
|
|
186
|
+
pagePrefix: idPxx().prefix,
|
|
174
187
|
pageNumber: 5,
|
|
175
188
|
mainText: "Har du noen gang vært deprimeri?? ",
|
|
176
189
|
},
|
|
@@ -180,7 +193,8 @@ export namespace RuleBuilderTestUtils {
|
|
|
180
193
|
ExcludeByPageIdSelectItem.create(
|
|
181
194
|
{
|
|
182
195
|
kind: "exclude-by-pageId",
|
|
183
|
-
pageId:
|
|
196
|
+
pageId: idPxx().id,
|
|
197
|
+
pagePrefix: idPxx().prefix,
|
|
184
198
|
pageNumber: 5,
|
|
185
199
|
mainText: "Har du noen gang vært deprimeri?? ",
|
|
186
200
|
},
|
|
@@ -190,7 +204,8 @@ export namespace RuleBuilderTestUtils {
|
|
|
190
204
|
ExcludeByPageIdSelectItem.create(
|
|
191
205
|
{
|
|
192
206
|
kind: "exclude-by-pageId",
|
|
193
|
-
pageId:
|
|
207
|
+
pageId: idPxx().id,
|
|
208
|
+
pagePrefix: idPxx().prefix,
|
|
194
209
|
pageNumber: 5,
|
|
195
210
|
mainText: "Har du noen gang vært deprimeri?? ",
|
|
196
211
|
},
|
|
@@ -199,7 +214,8 @@ export namespace RuleBuilderTestUtils {
|
|
|
199
214
|
ExcludeByPageIdSelectItem.create(
|
|
200
215
|
{
|
|
201
216
|
kind: "exclude-by-pageId",
|
|
202
|
-
pageId:
|
|
217
|
+
pageId: idPxx().id,
|
|
218
|
+
pagePrefix: idPxx().prefix,
|
|
203
219
|
pageNumber: 5,
|
|
204
220
|
mainText: "Har du noen gang vært deprimeri?? ",
|
|
205
221
|
},
|
|
@@ -209,7 +225,8 @@ export namespace RuleBuilderTestUtils {
|
|
|
209
225
|
ExcludeByPageIdSelectItem.create(
|
|
210
226
|
{
|
|
211
227
|
kind: "exclude-by-pageId",
|
|
212
|
-
pageId:
|
|
228
|
+
pageId: idPxx().id,
|
|
229
|
+
pagePrefix: idPxx().prefix,
|
|
213
230
|
pageNumber: 5,
|
|
214
231
|
mainText: "Har du noen gang vært deprimeri?? ",
|
|
215
232
|
},
|
|
@@ -219,7 +236,8 @@ export namespace RuleBuilderTestUtils {
|
|
|
219
236
|
ExcludeByPageIdSelectItem.create(
|
|
220
237
|
{
|
|
221
238
|
kind: "exclude-by-pageId",
|
|
222
|
-
pageId:
|
|
239
|
+
pageId: idPxx().id,
|
|
240
|
+
pagePrefix: idPxx().prefix,
|
|
223
241
|
pageNumber: 5,
|
|
224
242
|
mainText: "Har du noen gang vært deprimeri?? ",
|
|
225
243
|
},
|
|
@@ -229,7 +247,8 @@ export namespace RuleBuilderTestUtils {
|
|
|
229
247
|
ExcludeByPageIdSelectItem.create(
|
|
230
248
|
{
|
|
231
249
|
kind: "exclude-by-pageId",
|
|
232
|
-
pageId:
|
|
250
|
+
pageId: idPxx().id,
|
|
251
|
+
pagePrefix: idPxx().prefix,
|
|
233
252
|
pageNumber: 5,
|
|
234
253
|
mainText: "Har du noen gang vært deprimeri?? ",
|
|
235
254
|
},
|
|
@@ -239,7 +258,8 @@ export namespace RuleBuilderTestUtils {
|
|
|
239
258
|
ExcludeByPageIdSelectItem.create(
|
|
240
259
|
{
|
|
241
260
|
kind: "exclude-by-pageId",
|
|
242
|
-
pageId:
|
|
261
|
+
pageId: idPxx().id,
|
|
262
|
+
pagePrefix: idPxx().prefix,
|
|
243
263
|
pageNumber: 5,
|
|
244
264
|
mainText: "Har du noen gang vært deprimeri?? ",
|
|
245
265
|
},
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { PagePrefix
|
|
1
|
+
import { PagePrefix } from "../primitives/page-prefix";
|
|
2
|
+
import { VarID } from "../primitives/varID";
|
|
3
|
+
import { SchemaPrefix } from "../primitives/schema-prefix";
|
|
2
4
|
|
|
3
5
|
const BuilderVariableType = {
|
|
4
6
|
numericWithOptions: true,
|
|
@@ -122,11 +122,11 @@ export class JumpToPageSelectItem extends SingleSelectItem<JumpToPageAction> {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
protected getSearchString(): string {
|
|
125
|
-
return this.data.
|
|
125
|
+
return this.data.pagePrefix + this.data.mainText;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
protected getSelectLabel(): string {
|
|
129
|
-
return this.data.
|
|
129
|
+
return this.data.pagePrefix + " (" + this.data.pageNumber + ")";
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
protected getTooltip(): string {
|
|
@@ -2,7 +2,8 @@ import { BuilderCondition, type BuilderConditionDto } from "./Builder-condition"
|
|
|
2
2
|
import { RuleBuilderTestUtils } from "../RuleBuilder-test-utils";
|
|
3
3
|
import type { BuilderVariable, BuilderVariableOption } from "../RuleVariable";
|
|
4
4
|
import { QuestionVariable } from "../RuleVariable";
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
import { SchemaPrefix } from "../../primitives/schema-prefix";
|
|
6
7
|
|
|
7
8
|
let condition = BuilderCondition.create([]);
|
|
8
9
|
|