@legalplace/prerenderx 2.3.55 → 2.4.1
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/libs/DataPopulator.d.ts +2 -0
- package/dist/libs/DataPopulator.js +37 -3
- package/dist/libs/OptionRender.js +1 -1
- package/dist/libs/OutputParser.d.ts +1 -1
- package/dist/libs/OutputParser.js +2 -1
- package/package.json +1 -1
- package/src/libs/DataPopulator.ts +54 -3
- package/src/libs/OptionRender.ts +1 -1
- package/src/libs/OutputParser.ts +5 -2
|
@@ -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];
|
|
@@ -38,7 +38,7 @@ var OptionRender = (function () {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
var variables = OutputParser_1.getRelatedVariablesValues(this.id, this.index, outputReference.variables, this.ovc, this.references);
|
|
41
|
-
var output = OutputParser_1.parseOutputWithVariables(option.meta.output, variables, autonums);
|
|
41
|
+
var output = OutputParser_1.parseOutputWithVariables(option.meta.output, this.index, variables, autonums);
|
|
42
42
|
output = output.replace(/>([\n\s]+)</g, '><');
|
|
43
43
|
output = output.replace(/\n/g, '<br />');
|
|
44
44
|
output = output.replace(/\xA0/g, ' ');
|
|
@@ -4,6 +4,6 @@ declare type relVarsValsT = Record<string, string | number>;
|
|
|
4
4
|
declare type getRelatedVarsT = (optionId: number, index: number, variables: number[], ovc: OVC_TYPE, references: Types.ReferencesType) => relVarsValsT;
|
|
5
5
|
export declare const getRelatedVariablesValues: getRelatedVarsT;
|
|
6
6
|
declare type autonumsType = [string, string, number, string | null][];
|
|
7
|
-
declare type parseOutputT = (output: string, variables: relVarsValsT, autonums: autonumsType) => string;
|
|
7
|
+
declare type parseOutputT = (output: string, index: number, variables: relVarsValsT, autonums: autonumsType) => string;
|
|
8
8
|
export declare const parseOutputWithVariables: parseOutputT;
|
|
9
9
|
export {};
|
|
@@ -28,7 +28,7 @@ exports.getRelatedVariablesValues = function (optionId, index, variables, ovc, r
|
|
|
28
28
|
});
|
|
29
29
|
return variablesValues;
|
|
30
30
|
};
|
|
31
|
-
exports.parseOutputWithVariables = function (output, variables, autonums) {
|
|
31
|
+
exports.parseOutputWithVariables = function (output, index, variables, autonums) {
|
|
32
32
|
var parsedOutput = "" + output;
|
|
33
33
|
Object.keys(variables).forEach(function (variableId) {
|
|
34
34
|
var value = variables[variableId].toString();
|
|
@@ -40,6 +40,7 @@ exports.parseOutputWithVariables = function (output, variables, autonums) {
|
|
|
40
40
|
});
|
|
41
41
|
parsedOutput = parsedOutput.replace(/\[\[PAGE_BREAK\]\]/gi, '<div style="page-break-after:always"></div>');
|
|
42
42
|
parsedOutput = parsedOutput.replace(/\[(E|B)_BLUR\]/gi, '');
|
|
43
|
+
parsedOutput = parsedOutput.replace(/\[signature:([0-9]+)\]/g, function (v, signatureId) { return "<span data-signature-id=\"" + signatureId + "\" data-signer-index=\"" + index + "\"></span>"; });
|
|
43
44
|
autonums.forEach(function (currentAn) {
|
|
44
45
|
if (currentAn[3] === null)
|
|
45
46
|
parsedOutput = parsedOutput.replace("[" + currentAn[0] + ":" + currentAn[1] + "]", "<span class=\"" + currentAn[0] + "\">" + currentAn[2] + "</span>");
|
package/package.json
CHANGED
|
@@ -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
|
package/src/libs/OptionRender.ts
CHANGED
|
@@ -56,7 +56,7 @@ class OptionRender {
|
|
|
56
56
|
|
|
57
57
|
// variables
|
|
58
58
|
const variables = getRelatedVariablesValues(this.id, this.index, outputReference.variables, this.ovc, this.references)
|
|
59
|
-
let output = parseOutputWithVariables(option.meta.output, variables, autonums)
|
|
59
|
+
let output = parseOutputWithVariables(option.meta.output, this.index, variables, autonums)
|
|
60
60
|
|
|
61
61
|
// Removing spaces between tags
|
|
62
62
|
output = output.replace(/>([\n\s]+)</g, '><');
|
package/src/libs/OutputParser.ts
CHANGED
|
@@ -55,8 +55,8 @@ export const getRelatedVariablesValues: getRelatedVarsT = (optionId, index, vari
|
|
|
55
55
|
* @param autonums Autonums values
|
|
56
56
|
*/
|
|
57
57
|
type autonumsType = [string, string, number, string | null][]
|
|
58
|
-
type parseOutputT = (output: string, variables: relVarsValsT, autonums: autonumsType) => string
|
|
59
|
-
export const parseOutputWithVariables: parseOutputT = (output, variables, autonums) => {
|
|
58
|
+
type parseOutputT = (output: string, index: number, variables: relVarsValsT, autonums: autonumsType) => string
|
|
59
|
+
export const parseOutputWithVariables: parseOutputT = (output, index, variables, autonums) => {
|
|
60
60
|
// Inserting values
|
|
61
61
|
let parsedOutput = `${output}`
|
|
62
62
|
Object.keys(variables).forEach(variableId => {
|
|
@@ -76,6 +76,9 @@ export const parseOutputWithVariables: parseOutputT = (output, variables, autonu
|
|
|
76
76
|
// Cleaning BLURS
|
|
77
77
|
parsedOutput = parsedOutput.replace(/\[(E|B)_BLUR\]/gi, '')
|
|
78
78
|
|
|
79
|
+
// Parsing Signatures
|
|
80
|
+
parsedOutput = parsedOutput.replace(/\[signature:([0-9]+)\]/g, (v, signatureId) => `<span data-signature-id="${signatureId}" data-signer-index="${index}"></span>`)
|
|
81
|
+
|
|
79
82
|
// Inserting autonums
|
|
80
83
|
autonums.forEach(currentAn => {
|
|
81
84
|
if (currentAn[3] === null) parsedOutput = parsedOutput.replace(`[${currentAn[0]}:${currentAn[1]}]`, `<span class="${currentAn[0]}">${currentAn[2]}</span>`)
|