@aemforms/af-core 0.18.0 → 0.21.0
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/lib/BaseNode.d.ts +2 -2
- package/lib/BaseNode.js +6 -6
- package/lib/Checkbox.js +1 -1
- package/lib/Container.js +2 -1
- package/lib/controller/EventQueue.d.ts +1 -0
- package/lib/controller/EventQueue.js +5 -1
- package/lib/rules/RuleEngine.js +1 -14
- package/lib/types/Model.d.ts +4 -0
- package/package.json +1 -1
package/lib/BaseNode.d.ts
CHANGED
|
@@ -70,11 +70,11 @@ export declare abstract class BaseNode<T extends BaseJson> implements BaseModel
|
|
|
70
70
|
/**
|
|
71
71
|
* @private
|
|
72
72
|
*/
|
|
73
|
-
|
|
73
|
+
_addDependent(dependent: BaseModel): void;
|
|
74
74
|
/**
|
|
75
75
|
* @private
|
|
76
76
|
*/
|
|
77
|
-
removeDependent(
|
|
77
|
+
removeDependent(dependent: BaseModel): void;
|
|
78
78
|
abstract validate(): Array<ValidationError>;
|
|
79
79
|
abstract executeAction(action: Action): any;
|
|
80
80
|
/**
|
package/lib/BaseNode.js
CHANGED
|
@@ -216,8 +216,8 @@ class BaseNode {
|
|
|
216
216
|
/**
|
|
217
217
|
* @private
|
|
218
218
|
*/
|
|
219
|
-
|
|
220
|
-
if (this._dependents.find(({ node }) => node ===
|
|
219
|
+
_addDependent(dependent) {
|
|
220
|
+
if (this._dependents.find(({ node }) => node === dependent) === undefined) {
|
|
221
221
|
const subscription = this.subscribe((change) => {
|
|
222
222
|
const changes = change.payload.changes;
|
|
223
223
|
const propsToLook = ['value', 'items'];
|
|
@@ -226,17 +226,17 @@ class BaseNode {
|
|
|
226
226
|
return propsToLook.indexOf(x.propertyName) > -1;
|
|
227
227
|
}) > -1;
|
|
228
228
|
if (isPropChanged) {
|
|
229
|
-
|
|
229
|
+
dependent.dispatch(new controller_1.ExecuteRule());
|
|
230
230
|
}
|
|
231
231
|
});
|
|
232
|
-
this._dependents.push({ node:
|
|
232
|
+
this._dependents.push({ node: dependent, subscription });
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
/**
|
|
236
236
|
* @private
|
|
237
237
|
*/
|
|
238
|
-
removeDependent(
|
|
239
|
-
const index = this._dependents.findIndex(({ node }) => node ===
|
|
238
|
+
removeDependent(dependent) {
|
|
239
|
+
const index = this._dependents.findIndex(({ node }) => node === dependent);
|
|
240
240
|
if (index > -1) {
|
|
241
241
|
this._dependents[index].subscription.unsubscribe();
|
|
242
242
|
this._dependents.splice(index, 1);
|
package/lib/Checkbox.js
CHANGED
|
@@ -17,7 +17,7 @@ const ValidationUtils_1 = require("./utils/ValidationUtils");
|
|
|
17
17
|
* @private
|
|
18
18
|
*/
|
|
19
19
|
const requiredConstraint = (offValue) => (constraint, value) => {
|
|
20
|
-
const valid = ValidationUtils_1.Constraints.required(constraint, value) && (!constraint || value != offValue);
|
|
20
|
+
const valid = ValidationUtils_1.Constraints.required(constraint, value).valid && (!constraint || value != offValue);
|
|
21
21
|
return { valid, value };
|
|
22
22
|
};
|
|
23
23
|
/**
|
package/lib/Container.js
CHANGED
|
@@ -250,7 +250,8 @@ class Container extends Scriptable_1.default {
|
|
|
250
250
|
*/
|
|
251
251
|
importData(contextualDataModel) {
|
|
252
252
|
this._bindToDataModel(contextualDataModel);
|
|
253
|
-
this.
|
|
253
|
+
const dataNode = this.getDataNode() || contextualDataModel;
|
|
254
|
+
this.syncDataAndFormModel(dataNode);
|
|
254
255
|
}
|
|
255
256
|
/**
|
|
256
257
|
* prefill the form with data on the given element
|
|
@@ -66,7 +66,7 @@ class EventQueue {
|
|
|
66
66
|
const evntNode = new EventNode(node, e);
|
|
67
67
|
const counter = this._runningEventCount[evntNode.valueOf()] || 0;
|
|
68
68
|
const alreadyExists = this.isQueued(node, e);
|
|
69
|
-
if (!alreadyExists || counter <
|
|
69
|
+
if (!alreadyExists || counter < EventQueue.MAX_EVENT_CYCLE_COUNT) {
|
|
70
70
|
this.logger.info(`Queued event : ${e.type} node: ${node.id} - ${node.name}`);
|
|
71
71
|
//console.log(`Event Details ${e.toString()}`)
|
|
72
72
|
if (priority) {
|
|
@@ -78,6 +78,9 @@ class EventQueue {
|
|
|
78
78
|
}
|
|
79
79
|
this._runningEventCount[evntNode.valueOf()] = counter + 1;
|
|
80
80
|
}
|
|
81
|
+
else {
|
|
82
|
+
this.logger.info(`Skipped queueing event : ${e.type} node: ${node.id} - ${node.name} with count=${counter}`);
|
|
83
|
+
}
|
|
81
84
|
});
|
|
82
85
|
}
|
|
83
86
|
runPendingQueue() {
|
|
@@ -96,4 +99,5 @@ class EventQueue {
|
|
|
96
99
|
this._isProcessing = false;
|
|
97
100
|
}
|
|
98
101
|
}
|
|
102
|
+
EventQueue.MAX_EVENT_CYCLE_COUNT = 10;
|
|
99
103
|
exports.default = EventQueue;
|
package/lib/rules/RuleEngine.js
CHANGED
|
@@ -10,21 +10,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
10
10
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
const Controller_1 = require("../controller/Controller");
|
|
14
13
|
const json_formula_1 = require("@adobe/json-formula");
|
|
15
14
|
const FunctionRuntime_1 = __importDefault(require("./FunctionRuntime"));
|
|
16
|
-
/**
|
|
17
|
-
* Implementation of AddDependant event
|
|
18
|
-
* @private
|
|
19
|
-
*/
|
|
20
|
-
class AddDependent extends Controller_1.ActionImpl {
|
|
21
|
-
constructor(payload) {
|
|
22
|
-
super(payload, 'addDependent');
|
|
23
|
-
}
|
|
24
|
-
payloadToJson() {
|
|
25
|
-
return this.payload.getState();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
15
|
/**
|
|
29
16
|
* Implementation of rule engine
|
|
30
17
|
* @private
|
|
@@ -60,7 +47,7 @@ class RuleEngine {
|
|
|
60
47
|
*/
|
|
61
48
|
trackDependency(subscriber) {
|
|
62
49
|
if (this._context && this._context.field !== undefined && this._context.field !== subscriber) {
|
|
63
|
-
subscriber.
|
|
50
|
+
subscriber._addDependent(this._context.field);
|
|
64
51
|
}
|
|
65
52
|
}
|
|
66
53
|
}
|
package/lib/types/Model.d.ts
CHANGED