@legalplace/prerenderx 2.4.0 → 2.4.2
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.
|
@@ -19,6 +19,8 @@ declare class DataPopulator {
|
|
|
19
19
|
constructor(conditionsRunner: ConditionsRunner, references: Types.ReferencesType, ovc: OVC_TYPE, dataMap: ConditionDataMap, id?: number, index?: number);
|
|
20
20
|
getData(): Readonly<ConditionData>;
|
|
21
21
|
private populateConditions;
|
|
22
|
+
private getOptionConditions;
|
|
23
|
+
private getVariablesConditions;
|
|
22
24
|
private populateVariables;
|
|
23
25
|
private getVariableValues;
|
|
24
26
|
private getVariableRootParent;
|
|
@@ -35,19 +35,53 @@ var DataPopulator = (function () {
|
|
|
35
35
|
for (var i = 0; i < this.dataMap.c.s.length; i += 1) {
|
|
36
36
|
var sectionId = this.dataMap.c.s[i];
|
|
37
37
|
var sectionCondition = this.sectionConditionValue(sectionId);
|
|
38
|
-
this.data.c.s[sectionId] = [sectionCondition
|
|
38
|
+
this.data.c.s[sectionId] = [sectionCondition !== false];
|
|
39
39
|
}
|
|
40
40
|
for (var i = 0; i < this.dataMap.c.o.length; i += 1) {
|
|
41
41
|
var optionId = this.dataMap.c.o[i];
|
|
42
|
-
var optionCondition = this.
|
|
42
|
+
var optionCondition = __spreadArrays(this.getOptionConditions(optionId));
|
|
43
43
|
this.data.c.o[optionId] = optionCondition === undefined ? [false] : optionCondition;
|
|
44
44
|
}
|
|
45
45
|
for (var i = 0; i < this.dataMap.c.v.length; i += 1) {
|
|
46
46
|
var variableId = this.dataMap.c.v[i];
|
|
47
|
-
var variableCondition = this.
|
|
47
|
+
var variableCondition = __spreadArrays(this.getVariablesConditions(variableId));
|
|
48
48
|
this.data.c.v[variableId] = variableCondition === undefined ? [false] : variableCondition;
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
+
DataPopulator.prototype.getOptionConditions = function (optionId) {
|
|
52
|
+
var conditions = this.optionConditionValue(optionId);
|
|
53
|
+
if (conditions === undefined)
|
|
54
|
+
return [true];
|
|
55
|
+
if (this.id === undefined || this.index === undefined) {
|
|
56
|
+
return conditions;
|
|
57
|
+
}
|
|
58
|
+
var optionRootParent = this.getOptionRootParent(optionId);
|
|
59
|
+
var optionRootRelations = this.references.relations.options[optionRootParent];
|
|
60
|
+
if (optionRootRelations.children.options.includes(this.id) ||
|
|
61
|
+
optionRootRelations.dependants.includes(this.id) ||
|
|
62
|
+
this.id === optionRootParent) {
|
|
63
|
+
if (conditions !== undefined && conditions[this.index] === false)
|
|
64
|
+
return [false];
|
|
65
|
+
return [conditions[this.index]];
|
|
66
|
+
}
|
|
67
|
+
return conditions;
|
|
68
|
+
};
|
|
69
|
+
DataPopulator.prototype.getVariablesConditions = function (variableId) {
|
|
70
|
+
var conditions = this.variableConditionValue(variableId);
|
|
71
|
+
if (conditions === undefined)
|
|
72
|
+
return [true];
|
|
73
|
+
if (this.id === undefined || this.index === undefined) {
|
|
74
|
+
return conditions;
|
|
75
|
+
}
|
|
76
|
+
var variableRootParent = this.getVariableRootParent(variableId);
|
|
77
|
+
var variableRootRelations = this.references.relations.options[variableRootParent];
|
|
78
|
+
if (variableRootRelations.children.options.includes(this.id) ||
|
|
79
|
+
variableRootRelations.dependants.includes(this.id) ||
|
|
80
|
+
this.id === variableRootParent) {
|
|
81
|
+
return [conditions[this.index]];
|
|
82
|
+
}
|
|
83
|
+
return conditions;
|
|
84
|
+
};
|
|
51
85
|
DataPopulator.prototype.populateVariables = function () {
|
|
52
86
|
var _loop_1 = function (i) {
|
|
53
87
|
var variableId = this_1.dataMap.v[i];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legalplace/prerenderx",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.2",
|
|
4
4
|
"description": "PrerenderX",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": "https://git.legalplace.eu/legalplace/prerenderx",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@legalplace/lplogic": "^2.1.4",
|
|
18
18
|
"@legalplace/models-v3-types": "^3.4.47",
|
|
19
|
-
"@legalplace/referencesparser": "^1.
|
|
19
|
+
"@legalplace/referencesparser": "^1.5.0",
|
|
20
20
|
"crypto": "^1.0.1",
|
|
21
21
|
"typescript": "3.9.3"
|
|
22
22
|
},
|
|
@@ -63,23 +63,74 @@ class DataPopulator {
|
|
|
63
63
|
for (let i = 0; i < this.dataMap.c.s.length; i += 1) {
|
|
64
64
|
const sectionId = this.dataMap.c.s[i]
|
|
65
65
|
const sectionCondition = this.sectionConditionValue(sectionId)
|
|
66
|
-
this.data.c.s[sectionId] = [sectionCondition
|
|
66
|
+
this.data.c.s[sectionId] = [sectionCondition !== false]
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
// Options
|
|
70
70
|
for (let i = 0; i < this.dataMap.c.o.length; i += 1) {
|
|
71
71
|
const optionId = this.dataMap.c.o[i]
|
|
72
|
-
const optionCondition = this.
|
|
72
|
+
const optionCondition = [...this.getOptionConditions(optionId)];
|
|
73
73
|
this.data.c.o[optionId] = optionCondition === undefined ? [false] : optionCondition
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
// Variables
|
|
77
77
|
for (let i = 0; i < this.dataMap.c.v.length; i += 1) {
|
|
78
78
|
const variableId = this.dataMap.c.v[i]
|
|
79
|
-
const variableCondition = this.
|
|
79
|
+
const variableCondition = [...this.getVariablesConditions(variableId)]
|
|
80
80
|
this.data.c.v[variableId] = variableCondition === undefined ? [false] : variableCondition
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Returns a give option's conditions
|
|
85
|
+
* @param optionId Option's id
|
|
86
|
+
*/
|
|
87
|
+
private getOptionConditions(optionId: number): Readonly<boolean[]> {
|
|
88
|
+
const conditions = this.optionConditionValue(optionId);
|
|
89
|
+
if (conditions === undefined) return [true];
|
|
90
|
+
if (this.id === undefined || this.index === undefined) {
|
|
91
|
+
return conditions;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Getting variable parent option
|
|
95
|
+
const optionRootParent = this.getOptionRootParent(optionId);
|
|
96
|
+
const optionRootRelations = this.references.relations.options[optionRootParent];
|
|
97
|
+
if (
|
|
98
|
+
optionRootRelations.children.options.includes(this.id) ||
|
|
99
|
+
optionRootRelations.dependants.includes(this.id) ||
|
|
100
|
+
this.id === optionRootParent
|
|
101
|
+
) {
|
|
102
|
+
if (conditions !== undefined && conditions[this.index] === false)
|
|
103
|
+
return [false];
|
|
104
|
+
return [conditions[this.index]];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return conditions;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Returns a give variables conditions
|
|
112
|
+
* @param variableId Variable's id
|
|
113
|
+
*/
|
|
114
|
+
private getVariablesConditions(variableId: number): Readonly<boolean[]> {
|
|
115
|
+
const conditions = this.variableConditionValue(variableId);
|
|
116
|
+
if (conditions === undefined) return [true];
|
|
117
|
+
if (this.id === undefined || this.index === undefined) {
|
|
118
|
+
return conditions;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Getting variable parent option
|
|
122
|
+
const variableRootParent = this.getVariableRootParent(variableId);
|
|
123
|
+
const variableRootRelations = this.references.relations.options[variableRootParent];
|
|
124
|
+
if (
|
|
125
|
+
variableRootRelations.children.options.includes(this.id) ||
|
|
126
|
+
variableRootRelations.dependants.includes(this.id) ||
|
|
127
|
+
this.id === variableRootParent
|
|
128
|
+
) {
|
|
129
|
+
return [conditions[this.index]];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return conditions;
|
|
133
|
+
}
|
|
83
134
|
|
|
84
135
|
/**
|
|
85
136
|
* Populates variables according to the current dataMap object
|