tuain-ng-forms-lib 15.1.17 → 15.2.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.
|
@@ -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;
|
|
@@ -2195,14 +2200,17 @@ class FormStructureAndData {
|
|
|
2195
2200
|
}
|
|
2196
2201
|
if (definitionReceived.fields) {
|
|
2197
2202
|
const formFields = definitionReceived.fields.map(objDef => {
|
|
2198
|
-
let visibleStates = objDef.visibleStates
|
|
2203
|
+
let visibleStates = objDef.visibleStates
|
|
2204
|
+
?? (objDef.fieldModes?.map(state => state.trim())?.filter(state => state))
|
|
2205
|
+
?? [];
|
|
2199
2206
|
let enabledStates = objDef.enabledStates ?? objDef.editableStates;
|
|
2200
|
-
if (!visibleStates) {
|
|
2201
|
-
visibleStates = (
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
enabledStates = [
|
|
2207
|
+
if (!Array.isArray(visibleStates) && typeof visibleStates === 'string') {
|
|
2208
|
+
visibleStates = (visibleStates === neverVisible) ? [] : allStates;
|
|
2209
|
+
}
|
|
2210
|
+
if (!Array.isArray(enabledStates) && typeof enabledStates === 'string') {
|
|
2211
|
+
enabledStates = (enabledStates === neverVisible) ? [] : visibleStates;
|
|
2205
2212
|
}
|
|
2213
|
+
enabledStates = enabledStates.filter(state => visibleStates.includes(state));
|
|
2206
2214
|
return { ...objDef, visibleStates, enabledStates };
|
|
2207
2215
|
});
|
|
2208
2216
|
for (const fieldReceived of formFields) {
|