@legalplace/tagextractor 1.1.0 → 1.1.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.
@@ -11,7 +11,6 @@ declare class TagExtractor {
11
11
  get getTags(): TagsType;
12
12
  private extractFromOptions;
13
13
  private extractFromVariables;
14
- private optionConditionValue;
15
14
  isVariableDisplayed(id: number, index: number): boolean;
16
15
  isOptionDisplayed(id: number, index: number): boolean;
17
16
  private getVariableCondition;
@@ -76,22 +76,13 @@ var TagExtractor = (function () {
76
76
  }
77
77
  });
78
78
  };
79
- TagExtractor.prototype.optionConditionValue = function (optionId) {
80
- var _this = this;
81
- var conditions = this.references.conditions.options[optionId];
82
- var inputs = this.inputs.options[optionId];
83
- if (conditions === undefined)
84
- return inputs.map(function () { return true; });
85
- return inputs.map(function (input, index) {
86
- return _this.conditionsRunner.executeCondition(conditions, optionId, index, 'options');
87
- });
88
- };
89
79
  TagExtractor.prototype.isVariableDisplayed = function (id, index) {
90
- var _a;
80
+ var _a, _b;
91
81
  var variableCondition = this.getVariableCondition(id, index);
92
82
  var variableParents = ((_a = this.references.relations.variables[id]) === null || _a === void 0 ? void 0 : _a.parents) || [];
93
83
  var parentOptionIsDisplayed = this.isOptionDisplayed(variableParents[0], index);
94
- return [variableCondition, parentOptionIsDisplayed].filter(function (c) { return c !== true; }).length === 0;
84
+ var parentOptionIsTruethful = ((_b = this.inputs.options[variableParents[0]]) === null || _b === void 0 ? void 0 : _b[index]) === true;
85
+ return [variableCondition, parentOptionIsDisplayed, parentOptionIsTruethful].filter(function (c) { return c !== true; }).length === 0;
95
86
  };
96
87
  TagExtractor.prototype.isOptionDisplayed = function (id, index) {
97
88
  var _this = this;
@@ -57,6 +57,13 @@ var OvcConverter = (function () {
57
57
  }
58
58
  });
59
59
  }
60
+ Object.keys(references.options).forEach(function (optionId) {
61
+ var option = references.options[optionId];
62
+ var parents = references.relations.options[optionId].parents;
63
+ if (inputs.options[optionId] === undefined && parents.length === 0 && option.meta.type === 'static') {
64
+ inputs.options[optionId] = [true];
65
+ }
66
+ });
60
67
  if (typeof ovc.c === 'object') {
61
68
  Object.keys(ovc.c).forEach(function (id) {
62
69
  var currentCheckbox = ovc.c[id];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/tagextractor",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "TagExtractor",
5
5
  "main": "dist/index.js",
6
6
  "repository": "https://git.legalplace.eu/legalplace/tagextractor",
@@ -89,23 +89,6 @@ class TagExtractor {
89
89
  })
90
90
  }
91
91
 
92
- /**
93
- * Calculates option's condition
94
- */
95
- private optionConditionValue(optionId: number) {
96
- // Getting option conditions
97
- const conditions = this.references.conditions.options[optionId]
98
-
99
- // Getting option inputs length
100
- const inputs = this.inputs.options[optionId]
101
-
102
- if (conditions === undefined) return inputs.map(() => true)
103
-
104
- return inputs.map((input, index) => {
105
- return this.conditionsRunner.executeCondition(conditions, optionId, index, 'options')
106
- })
107
- }
108
-
109
92
  /**
110
93
  * Checks whether a variable is displayed at a given index
111
94
  * @param id Variable's ID
@@ -116,8 +99,9 @@ class TagExtractor {
116
99
  const variableCondition = this.getVariableCondition(id, index)
117
100
  const variableParents = this.references.relations.variables[id]?.parents || []
118
101
  const parentOptionIsDisplayed = this.isOptionDisplayed(variableParents[0], index)
102
+ const parentOptionIsTruethful = this.inputs.options[variableParents[0]]?.[index] === true
119
103
 
120
- return [variableCondition, parentOptionIsDisplayed].filter(c => c !== true).length === 0
104
+ return [variableCondition, parentOptionIsDisplayed, parentOptionIsTruethful].filter(c => c !== true).length === 0
121
105
  }
122
106
 
123
107
  /**
@@ -58,6 +58,16 @@ class OvcConverter {
58
58
  })
59
59
  }
60
60
 
61
+ // Adding static root options
62
+ Object.keys(references.options).forEach(optionId => {
63
+ const option = references.options[optionId]
64
+ const { parents } = references.relations.options[optionId]
65
+
66
+ if (inputs.options[optionId] === undefined && parents.length === 0 && option.meta.type === 'static') {
67
+ inputs.options[optionId] = [true]
68
+ }
69
+ })
70
+
61
71
  // Reading checkboxes
62
72
  if (typeof ovc.c === 'object') {
63
73
  Object.keys(ovc.c).forEach(id => {
@@ -104,6 +114,7 @@ class OvcConverter {
104
114
  const foundKeys = Object.keys(_obj)
105
115
  .map((key): number => (ovcKeys.includes(key) ? 1 : 0))
106
116
  .reduce((a, b) => a + b, 0)
117
+
107
118
  return foundKeys > 1
108
119
  }
109
120