tuain-ng-forms-lib 15.1.17 → 15.2.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.
|
@@ -2115,6 +2115,9 @@ const HIDE = 'hide';
|
|
|
2115
2115
|
const ENABLE = 'enable';
|
|
2116
2116
|
const DISABLE = 'disable';
|
|
2117
2117
|
const CLEAN = 'clean';
|
|
2118
|
+
const alwaysVisible = 'ALWAYS';
|
|
2119
|
+
const neverVisible = 'NONE';
|
|
2120
|
+
const onStatesVisible = 'ONSTATES';
|
|
2118
2121
|
class FormStructureAndData {
|
|
2119
2122
|
constructor() {
|
|
2120
2123
|
this._stateChange = new Subject();
|
|
@@ -2158,6 +2161,7 @@ class FormStructureAndData {
|
|
|
2158
2161
|
}
|
|
2159
2162
|
loadDefinition(definitionReceived) {
|
|
2160
2163
|
this.state = '';
|
|
2164
|
+
let allStates = [];
|
|
2161
2165
|
this.cleanForm();
|
|
2162
2166
|
if (!definitionReceived) {
|
|
2163
2167
|
return;
|
|
@@ -2165,6 +2169,7 @@ class FormStructureAndData {
|
|
|
2165
2169
|
this.name = this.name ?? definitionReceived?.form?.formCode;
|
|
2166
2170
|
this.title = (definitionReceived.form && definitionReceived.form.formTitle)
|
|
2167
2171
|
? definitionReceived.form.formTitle : '';
|
|
2172
|
+
allStates = definitionReceived?.states?.map(sttInfo => sttInfo.name);
|
|
2168
2173
|
this.setStateFlow(definitionReceived?.states, definitionReceived?.transitions, definitionReceived?.defaultState, definitionReceived?.stateDescriptions);
|
|
2169
2174
|
this.immutableData = definitionReceived.immutableData;
|
|
2170
2175
|
this.extraInfo = definitionReceived.extraInfo;
|
|
@@ -2174,14 +2179,17 @@ class FormStructureAndData {
|
|
|
2174
2179
|
}
|
|
2175
2180
|
if (definitionReceived.actions) {
|
|
2176
2181
|
const formActions = definitionReceived.actions.map(objDef => {
|
|
2177
|
-
let visibleStates = objDef.visibleStates
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
enabledStates = [...visibleStates];
|
|
2182
|
+
let visibleStates = objDef.visibleStates
|
|
2183
|
+
?? (objDef.actionModes?.split(',')?.map(state => state.trim())?.filter(state => state))
|
|
2184
|
+
?? [];
|
|
2185
|
+
let enabledStates = objDef.enabledStates ?? objDef.editableStates ?? [];
|
|
2186
|
+
if (!Array.isArray(visibleStates) && typeof visibleStates === 'string') {
|
|
2187
|
+
visibleStates = (visibleStates === neverVisible) ? [] : allStates;
|
|
2184
2188
|
}
|
|
2189
|
+
if (!Array.isArray(enabledStates) && typeof enabledStates === 'string') {
|
|
2190
|
+
enabledStates = (enabledStates === neverVisible) ? [] : visibleStates;
|
|
2191
|
+
}
|
|
2192
|
+
enabledStates = enabledStates.filter(state => visibleStates.includes(state));
|
|
2185
2193
|
return { ...objDef, visibleStates, enabledStates };
|
|
2186
2194
|
});
|
|
2187
2195
|
for (const actionReceived of formActions) {
|
|
@@ -2195,14 +2203,17 @@ class FormStructureAndData {
|
|
|
2195
2203
|
}
|
|
2196
2204
|
if (definitionReceived.fields) {
|
|
2197
2205
|
const formFields = definitionReceived.fields.map(objDef => {
|
|
2198
|
-
let visibleStates = objDef.visibleStates
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
enabledStates = [...visibleStates];
|
|
2206
|
+
let visibleStates = objDef.visibleStates
|
|
2207
|
+
?? (objDef.fieldModes?.split(',')?.map(state => state.trim())?.filter(state => state))
|
|
2208
|
+
?? [];
|
|
2209
|
+
let enabledStates = objDef.enabledStates ?? objDef.editableStates ?? [];
|
|
2210
|
+
if (!Array.isArray(visibleStates) && typeof visibleStates === 'string') {
|
|
2211
|
+
visibleStates = (visibleStates === neverVisible) ? [] : allStates;
|
|
2205
2212
|
}
|
|
2213
|
+
if (!Array.isArray(enabledStates) && typeof enabledStates === 'string') {
|
|
2214
|
+
enabledStates = (enabledStates === neverVisible) ? [] : visibleStates;
|
|
2215
|
+
}
|
|
2216
|
+
enabledStates = enabledStates.filter(state => visibleStates.includes(state));
|
|
2206
2217
|
return { ...objDef, visibleStates, enabledStates };
|
|
2207
2218
|
});
|
|
2208
2219
|
for (const fieldReceived of formFields) {
|
|
@@ -2216,14 +2227,17 @@ class FormStructureAndData {
|
|
|
2216
2227
|
}
|
|
2217
2228
|
if (definitionReceived.tables) {
|
|
2218
2229
|
const tables = definitionReceived.tables.map(objDef => {
|
|
2219
|
-
let visibleStates = objDef.visibleStates
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
enabledStates = [...visibleStates];
|
|
2230
|
+
let visibleStates = objDef.visibleStates
|
|
2231
|
+
?? (objDef.tableModes?.split(',')?.map(state => state.trim())?.filter(state => state))
|
|
2232
|
+
?? [];
|
|
2233
|
+
let enabledStates = objDef.enabledStates ?? objDef.editableStates ?? [];
|
|
2234
|
+
if (!Array.isArray(visibleStates) && typeof visibleStates === 'string') {
|
|
2235
|
+
visibleStates = (visibleStates === neverVisible) ? [] : allStates;
|
|
2226
2236
|
}
|
|
2237
|
+
if (!Array.isArray(enabledStates) && typeof enabledStates === 'string') {
|
|
2238
|
+
enabledStates = (enabledStates === neverVisible) ? [] : visibleStates;
|
|
2239
|
+
}
|
|
2240
|
+
enabledStates = enabledStates.filter(state => visibleStates.includes(state));
|
|
2227
2241
|
return { ...objDef, visibleStates, enabledStates };
|
|
2228
2242
|
});
|
|
2229
2243
|
for (const tableReceived of tables) {
|
|
@@ -2237,11 +2251,11 @@ class FormStructureAndData {
|
|
|
2237
2251
|
}
|
|
2238
2252
|
if (definitionReceived.sections) {
|
|
2239
2253
|
const formSections = definitionReceived.sections.map(objDef => {
|
|
2240
|
-
let visibleStates = objDef.visibleStates
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2254
|
+
let visibleStates = objDef.visibleStates
|
|
2255
|
+
?? (objDef.sectionModes?.split(',')?.map(state => state.trim())?.filter(state => state))
|
|
2256
|
+
?? [];
|
|
2257
|
+
if (!Array.isArray(visibleStates) && typeof visibleStates === 'string') {
|
|
2258
|
+
visibleStates = (visibleStates === neverVisible) ? [] : allStates;
|
|
2245
2259
|
}
|
|
2246
2260
|
return { ...objDef, visibleStates };
|
|
2247
2261
|
});
|