tuain-ng-forms-lib 15.0.27 → 15.0.30
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/form.mjs +24 -3
- package/fesm2015/tuain-ng-forms-lib.mjs +25 -2
- package/fesm2015/tuain-ng-forms-lib.mjs.map +1 -1
- package/fesm2020/tuain-ng-forms-lib.mjs +23 -2
- package/fesm2020/tuain-ng-forms-lib.mjs.map +1 -1
- package/lib/classes/forms/form.d.ts +7 -1
- package/package.json +1 -1
|
@@ -2110,6 +2110,7 @@ class FormStructureAndData {
|
|
|
2110
2110
|
this._immutableData = {};
|
|
2111
2111
|
this._extraInfo = {};
|
|
2112
2112
|
this._exclusiveSectionsByAttr = {};
|
|
2113
|
+
this.customAttributes = {};
|
|
2113
2114
|
this.state = '';
|
|
2114
2115
|
this.actionArray = [];
|
|
2115
2116
|
this.fieldArray = [];
|
|
@@ -2118,6 +2119,7 @@ class FormStructureAndData {
|
|
|
2118
2119
|
this.stateFlow = {
|
|
2119
2120
|
defaultState: '',
|
|
2120
2121
|
states: [],
|
|
2122
|
+
stateDescriptions: [],
|
|
2121
2123
|
transitions: [],
|
|
2122
2124
|
};
|
|
2123
2125
|
}
|
|
@@ -2132,6 +2134,7 @@ class FormStructureAndData {
|
|
|
2132
2134
|
this.stateFlow = {
|
|
2133
2135
|
defaultState: '',
|
|
2134
2136
|
states: [],
|
|
2137
|
+
stateDescriptions: [],
|
|
2135
2138
|
transitions: [],
|
|
2136
2139
|
};
|
|
2137
2140
|
}
|
|
@@ -2144,9 +2147,13 @@ class FormStructureAndData {
|
|
|
2144
2147
|
this.name = this.name ?? definitionReceived?.form?.formCode;
|
|
2145
2148
|
this.title = (definitionReceived.form && definitionReceived.form.formTitle)
|
|
2146
2149
|
? definitionReceived.form.formTitle : '';
|
|
2147
|
-
this.setStateFlow(definitionReceived?.states, definitionReceived?.transitions, definitionReceived?.defaultState);
|
|
2150
|
+
this.setStateFlow(definitionReceived?.states, definitionReceived?.transitions, definitionReceived?.defaultState, definitionReceived?.stateDescriptions);
|
|
2148
2151
|
this.immutableData = definitionReceived.immutableData;
|
|
2149
2152
|
this.extraInfo = definitionReceived.extraInfo;
|
|
2153
|
+
this.customAttributes = {};
|
|
2154
|
+
if (definitionReceived?.customAttributes) {
|
|
2155
|
+
this.setCustomAttributes(definitionReceived?.customAttributes);
|
|
2156
|
+
}
|
|
2150
2157
|
if (definitionReceived.actions) {
|
|
2151
2158
|
const formActions = definitionReceived.actions.map(objDef => {
|
|
2152
2159
|
let visibleStates = objDef.visibleStates;
|
|
@@ -2233,6 +2240,7 @@ class FormStructureAndData {
|
|
|
2233
2240
|
// Estados
|
|
2234
2241
|
get defaultState() { return this.stateFlow.defaultState; }
|
|
2235
2242
|
get states() { return this.stateFlow.states; }
|
|
2243
|
+
get stateDescriptions() { return this.stateFlow.stateDescriptions; }
|
|
2236
2244
|
supportState(state = '') { return (!!state && this.stateFlow.states?.includes(state)); }
|
|
2237
2245
|
changeState(newState) {
|
|
2238
2246
|
const currentState = this.state;
|
|
@@ -2252,8 +2260,9 @@ class FormStructureAndData {
|
|
|
2252
2260
|
return (this.state === newState);
|
|
2253
2261
|
}
|
|
2254
2262
|
get stateChange() { return this._stateChange; }
|
|
2255
|
-
setStateFlow(states, transitions, defaultState) {
|
|
2263
|
+
setStateFlow(states, transitions, defaultState, stateDescriptions = []) {
|
|
2256
2264
|
this.stateFlow.states = states;
|
|
2265
|
+
this.stateFlow.stateDescriptions = stateDescriptions;
|
|
2257
2266
|
this.stateFlow.defaultState = defaultState || this.stateFlow.states[0];
|
|
2258
2267
|
this.stateFlow.transitions = transitions.map(transition => {
|
|
2259
2268
|
const name = transition.name;
|
|
@@ -2270,6 +2279,18 @@ class FormStructureAndData {
|
|
|
2270
2279
|
getExtraInfo(name) { return this._extraInfo?.[name]?.value ?? null; }
|
|
2271
2280
|
set extraInfo(extraInfo) { Object.assign(this._extraInfo, extraInfo); }
|
|
2272
2281
|
get extraInfo() { return JSON.parse(JSON.stringify(this._extraInfo)); }
|
|
2282
|
+
// Custom Attributes
|
|
2283
|
+
getCustomAttribute(name) { return this.customAttributes?.[name] ?? null; }
|
|
2284
|
+
setCustomAttribute(name, value) { if (name) {
|
|
2285
|
+
this.customAttributes[name] = value;
|
|
2286
|
+
} }
|
|
2287
|
+
setCustomAttributes(attributes) {
|
|
2288
|
+
if (attributes && typeof attributes === 'object') {
|
|
2289
|
+
Object.entries(attributes).forEach(([name, value]) => {
|
|
2290
|
+
this.setCustomAttribute(name, value);
|
|
2291
|
+
});
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2273
2294
|
// Fields
|
|
2274
2295
|
get fieldNames() { return this.getFieldNames(); }
|
|
2275
2296
|
getFields() { return this.fieldArray; }
|