tuain-ng-forms-lib 15.1.16 → 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.
- package/esm2020/lib/classes/forms/field.mjs +1 -11
- package/esm2020/lib/classes/forms/form.mjs +19 -7
- package/fesm2015/tuain-ng-forms-lib.mjs +19 -19
- package/fesm2015/tuain-ng-forms-lib.mjs.map +1 -1
- package/fesm2020/tuain-ng-forms-lib.mjs +18 -16
- package/fesm2020/tuain-ng-forms-lib.mjs.map +1 -1
- package/lib/classes/forms/form.d.ts +1 -0
- package/package.json +1 -1
|
@@ -912,16 +912,6 @@ class FieldDescriptor extends FormElement {
|
|
|
912
912
|
return true;
|
|
913
913
|
}
|
|
914
914
|
;
|
|
915
|
-
if (this._fieldType === this._formConfig.fieldTypes.daterange) {
|
|
916
|
-
if (!Array.isArray(fieldCurrentValue)) {
|
|
917
|
-
return true;
|
|
918
|
-
}
|
|
919
|
-
if (fieldCurrentValue.length !== 2 || !fieldCurrentValue[0] || !fieldCurrentValue[1]) {
|
|
920
|
-
return true;
|
|
921
|
-
}
|
|
922
|
-
return false;
|
|
923
|
-
}
|
|
924
|
-
;
|
|
925
915
|
if (this._fieldType === this._formConfig.fieldTypes.phone) {
|
|
926
916
|
if (!Array.isArray(fieldCurrentValue)) {
|
|
927
917
|
return true;
|
|
@@ -2125,6 +2115,9 @@ const HIDE = 'hide';
|
|
|
2125
2115
|
const ENABLE = 'enable';
|
|
2126
2116
|
const DISABLE = 'disable';
|
|
2127
2117
|
const CLEAN = 'clean';
|
|
2118
|
+
const alwaysVisible = 'ALWAYS';
|
|
2119
|
+
const neverVisible = 'NONE';
|
|
2120
|
+
const onStatesVisible = 'ONSTATES';
|
|
2128
2121
|
class FormStructureAndData {
|
|
2129
2122
|
constructor() {
|
|
2130
2123
|
this._stateChange = new Subject();
|
|
@@ -2168,6 +2161,7 @@ class FormStructureAndData {
|
|
|
2168
2161
|
}
|
|
2169
2162
|
loadDefinition(definitionReceived) {
|
|
2170
2163
|
this.state = '';
|
|
2164
|
+
let allStates = [];
|
|
2171
2165
|
this.cleanForm();
|
|
2172
2166
|
if (!definitionReceived) {
|
|
2173
2167
|
return;
|
|
@@ -2175,6 +2169,7 @@ class FormStructureAndData {
|
|
|
2175
2169
|
this.name = this.name ?? definitionReceived?.form?.formCode;
|
|
2176
2170
|
this.title = (definitionReceived.form && definitionReceived.form.formTitle)
|
|
2177
2171
|
? definitionReceived.form.formTitle : '';
|
|
2172
|
+
allStates = definitionReceived?.states?.map(sttInfo => sttInfo.name);
|
|
2178
2173
|
this.setStateFlow(definitionReceived?.states, definitionReceived?.transitions, definitionReceived?.defaultState, definitionReceived?.stateDescriptions);
|
|
2179
2174
|
this.immutableData = definitionReceived.immutableData;
|
|
2180
2175
|
this.extraInfo = definitionReceived.extraInfo;
|
|
@@ -2205,14 +2200,17 @@ class FormStructureAndData {
|
|
|
2205
2200
|
}
|
|
2206
2201
|
if (definitionReceived.fields) {
|
|
2207
2202
|
const formFields = definitionReceived.fields.map(objDef => {
|
|
2208
|
-
let visibleStates = objDef.visibleStates
|
|
2203
|
+
let visibleStates = objDef.visibleStates
|
|
2204
|
+
?? (objDef.fieldModes?.map(state => state.trim())?.filter(state => state))
|
|
2205
|
+
?? [];
|
|
2209
2206
|
let enabledStates = objDef.enabledStates ?? objDef.editableStates;
|
|
2210
|
-
if (!visibleStates) {
|
|
2211
|
-
visibleStates = (
|
|
2212
|
-
.map(state => state.trim())
|
|
2213
|
-
.filter(state => state.length > 0) || [];
|
|
2214
|
-
enabledStates = [...visibleStates];
|
|
2207
|
+
if (!Array.isArray(visibleStates) && typeof visibleStates === 'string') {
|
|
2208
|
+
visibleStates = (visibleStates === neverVisible) ? [] : allStates;
|
|
2215
2209
|
}
|
|
2210
|
+
if (!Array.isArray(enabledStates) && typeof enabledStates === 'string') {
|
|
2211
|
+
enabledStates = (enabledStates === neverVisible) ? [] : visibleStates;
|
|
2212
|
+
}
|
|
2213
|
+
enabledStates = enabledStates.filter(state => visibleStates.includes(state));
|
|
2216
2214
|
return { ...objDef, visibleStates, enabledStates };
|
|
2217
2215
|
});
|
|
2218
2216
|
for (const fieldReceived of formFields) {
|
|
@@ -2270,6 +2268,10 @@ class FormStructureAndData {
|
|
|
2270
2268
|
get states() { return this.stateFlow.states; }
|
|
2271
2269
|
get stateDescriptions() { return this.stateFlow.stateDescriptions; }
|
|
2272
2270
|
supportState(state = '') { return (!!state && this.stateFlow.states?.includes(state)); }
|
|
2271
|
+
getNextStates() {
|
|
2272
|
+
return this.stateFlow.transitions.filter(trns => trns.source === this.state)
|
|
2273
|
+
.map(trns => trns.destination);
|
|
2274
|
+
}
|
|
2273
2275
|
changeState(newState) {
|
|
2274
2276
|
const currentState = this.state;
|
|
2275
2277
|
if (!newState || !this.supportState(newState) || currentState === newState) {
|