@legalplace/wizardx-core 4.43.21 → 4.44.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.
|
@@ -92,22 +92,24 @@ const SmartScriptComponent = ({ inpiActivities = [] }) => {
|
|
|
92
92
|
window.triggerListeners = (type, id, inputs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
93
93
|
const hooks = SmartScriptStore.hooks[type === "option" ? "options" : "variables"];
|
|
94
94
|
const listeners = hooks[id];
|
|
95
|
-
if (Array.isArray(listeners)) {
|
|
95
|
+
if (Array.isArray(listeners) && listeners.length > 0) {
|
|
96
96
|
SmartScriptStore.inputs = inputs;
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
const validListeners = listeners.filter((_cb) => typeof _cb === "function");
|
|
98
|
+
if (validListeners.length > 0) {
|
|
99
|
+
const promises = validListeners.map((_cb) => __awaiter(void 0, void 0, void 0, function* () {
|
|
100
|
+
try {
|
|
100
101
|
return yield _cb();
|
|
101
102
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
103
|
+
catch (e) {
|
|
104
|
+
console.error("SmartScript (triggerListener) error:", e.message);
|
|
105
|
+
return Promise.resolve();
|
|
106
|
+
}
|
|
107
|
+
}));
|
|
108
|
+
yield Promise.all(promises);
|
|
109
|
+
}
|
|
110
|
+
else if (listeners.length > 0) {
|
|
111
|
+
console.warn("All listeners are invalid for", type, id);
|
|
112
|
+
}
|
|
111
113
|
}
|
|
112
114
|
return SmartScriptStore.grabActions();
|
|
113
115
|
});
|
|
@@ -127,9 +127,13 @@ SmartScriptStore.updateVariableInput = (id, value, index = 0) => {
|
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
129
|
if (((_a = SmartScriptStore.inputs.variables[id]) === null || _a === void 0 ? void 0 : _a[indexValue]) !== value) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
const currentArray = SmartScriptStore.inputs.variables[id] || [];
|
|
131
|
+
const newArray = [
|
|
132
|
+
...currentArray.slice(0, indexValue),
|
|
133
|
+
value,
|
|
134
|
+
...currentArray.slice(indexValue + 1),
|
|
135
|
+
];
|
|
136
|
+
SmartScriptStore.inputs.variables[id] = newArray;
|
|
133
137
|
SmartScriptStore.actionsQueue.push(updateVariableAction(id, value, indexValue));
|
|
134
138
|
}
|
|
135
139
|
};
|
|
@@ -141,9 +145,13 @@ SmartScriptStore.updateOptionInput = (id, value, index = 0) => {
|
|
|
141
145
|
return;
|
|
142
146
|
}
|
|
143
147
|
if (((_b = (_a = SmartScriptStore.inputs) === null || _a === void 0 ? void 0 : _a.options[id]) === null || _b === void 0 ? void 0 : _b[indexValue]) !== value) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
148
|
+
const currentArray = SmartScriptStore.inputs.options[id] || [];
|
|
149
|
+
const newArray = [
|
|
150
|
+
...currentArray.slice(0, indexValue),
|
|
151
|
+
value,
|
|
152
|
+
...currentArray.slice(indexValue + 1),
|
|
153
|
+
];
|
|
154
|
+
SmartScriptStore.inputs.options[id] = newArray;
|
|
147
155
|
SmartScriptStore.actionsQueue.push(updateOptionAction(id, value, indexValue));
|
|
148
156
|
}
|
|
149
157
|
};
|
|
@@ -7,7 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import cloneDeep from "lodash/cloneDeep";
|
|
11
10
|
import { generatePath } from "react-router-dom";
|
|
12
11
|
import { getConfig } from "../../config";
|
|
13
12
|
import { INIT_INPUTS, ADD_MULTIPLE_OCCURENCY, DELETE_MULTIPLE_OCCURENCY, UPDATE_OPTION_INPUT, UPDATE_VARIABLE_INPUT, } from "../constants/inputs";
|
|
@@ -30,10 +29,10 @@ const watchEnableSmartScript = (mpi, next, action) => {
|
|
|
30
29
|
iframe = document.createElement("iframe");
|
|
31
30
|
iframe.id = "lp-smartscript";
|
|
32
31
|
iframe.setAttribute("style", "position: absolute; width:0; height:0; border:0;");
|
|
33
|
-
const
|
|
34
|
-
const permalink = getConfig().permalink ||
|
|
35
|
-
const prefix = getConfig().prefix ||
|
|
36
|
-
const uniqid = getConfig().uniqid ||
|
|
32
|
+
const { app } = mpi.getState();
|
|
33
|
+
const permalink = getConfig().permalink || app.meta.permalink || "";
|
|
34
|
+
const prefix = getConfig().prefix || app.meta.prefix || "";
|
|
35
|
+
const uniqid = getConfig().uniqid || app.instance.uniqid || "";
|
|
37
36
|
const { modelVersion } = new PathReader(mpi.getState());
|
|
38
37
|
if (getConfig().router.smartscriptPath) {
|
|
39
38
|
const path = generatePath(getConfig().router.smartscriptPath, {
|
|
@@ -57,7 +56,10 @@ const watchEnableSmartScript = (mpi, next, action) => {
|
|
|
57
56
|
mpi.dispatch(_action);
|
|
58
57
|
});
|
|
59
58
|
}
|
|
60
|
-
},
|
|
59
|
+
}, {
|
|
60
|
+
variables: Object.assign({}, mpi.getState().inputs.variables),
|
|
61
|
+
options: Object.assign({}, mpi.getState().inputs.options),
|
|
62
|
+
}, isNewInstance);
|
|
61
63
|
}
|
|
62
64
|
});
|
|
63
65
|
document.body.append(iframe);
|
|
@@ -72,40 +74,52 @@ const watchResetState = (mpi, next, action) => {
|
|
|
72
74
|
const watchUpdateOptionInput = (mpi, next, action) => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
75
|
var _a;
|
|
74
76
|
next(action);
|
|
75
|
-
|
|
77
|
+
if (!iframe)
|
|
78
|
+
return;
|
|
76
79
|
const { id } = action;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
80
|
+
const { smartscript, inputs } = mpi.getState();
|
|
81
|
+
if (!smartscript.triggers.options.includes(id))
|
|
82
|
+
return;
|
|
83
|
+
try {
|
|
84
|
+
const inputsCopy = {
|
|
85
|
+
variables: Object.assign({}, inputs.variables),
|
|
86
|
+
options: Object.assign({}, inputs.options),
|
|
87
|
+
};
|
|
88
|
+
const actions = yield ((_a = iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.triggerListeners("option", id, inputsCopy));
|
|
89
|
+
if (Array.isArray(actions) && actions.length > 0) {
|
|
90
|
+
actions.forEach((_action) => {
|
|
91
|
+
mpi.dispatch(_action);
|
|
92
|
+
});
|
|
88
93
|
}
|
|
89
94
|
}
|
|
95
|
+
catch (e) {
|
|
96
|
+
console.error(e);
|
|
97
|
+
}
|
|
90
98
|
});
|
|
91
99
|
const watchUpdateVariableInput = (mpi, next, action) => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
100
|
var _b;
|
|
93
101
|
next(action);
|
|
94
|
-
|
|
102
|
+
if (!iframe)
|
|
103
|
+
return;
|
|
95
104
|
const { id } = action;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
const { smartscript, inputs } = mpi.getState();
|
|
106
|
+
if (!smartscript.triggers.variables.includes(id))
|
|
107
|
+
return;
|
|
108
|
+
try {
|
|
109
|
+
const inputsCopy = {
|
|
110
|
+
variables: Object.assign({}, inputs.variables),
|
|
111
|
+
options: Object.assign({}, inputs.options),
|
|
112
|
+
};
|
|
113
|
+
const actions = yield ((_b = iframe.contentWindow) === null || _b === void 0 ? void 0 : _b.triggerListeners("variable", id, inputsCopy));
|
|
114
|
+
if (Array.isArray(actions) && actions.length > 0) {
|
|
115
|
+
actions.forEach((_action) => {
|
|
116
|
+
mpi.dispatch(_action);
|
|
117
|
+
});
|
|
107
118
|
}
|
|
108
119
|
}
|
|
120
|
+
catch (e) {
|
|
121
|
+
console.error(e);
|
|
122
|
+
}
|
|
109
123
|
});
|
|
110
124
|
const watchInitInputs = (mpi, next, action) => {
|
|
111
125
|
next(action);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legalplace/wizardx-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.44.0",
|
|
4
4
|
"author": "Moncef Hammou (moncef@legalplace.fr)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"*.test.ts",
|
|
101
101
|
"*.test.tsx"
|
|
102
102
|
],
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "a0d146325038c9c3491807889d1c9746203db19a"
|
|
104
104
|
}
|