@beinformed/ui 1.48.0 → 1.49.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.
- package/CHANGELOG.md +16 -0
- package/esm/hooks/useForm.js +17 -2
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/models/attributes/AttributeModel.js +2 -1
- package/esm/models/attributes/AttributeModel.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeModel.js +16 -1
- package/esm/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeOptionCollection.js +10 -3
- package/esm/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
- package/esm/models/concepts/ConceptRelationModel.js +7 -0
- package/esm/models/concepts/ConceptRelationModel.js.map +1 -1
- package/esm/models/form/FormModel.js +22 -2
- package/esm/models/form/FormModel.js.map +1 -1
- package/esm/models/form/FormObjectModel.js +9 -1
- package/esm/models/form/FormObjectModel.js.map +1 -1
- package/esm/modularui/ModularUIRequest.js +1 -1
- package/esm/modularui/ModularUIRequest.js.map +1 -1
- package/esm/redux/_modularui/ModularUIActions.js +4 -10
- package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
- package/esm/redux/actions/FormAttributeSet.js +22 -6
- package/esm/redux/actions/FormAttributeSet.js.map +1 -1
- package/esm/redux/actions/FormAutosubmit.js +9 -1
- package/esm/redux/actions/FormAutosubmit.js.map +1 -1
- package/esm/redux/actions/FormAutoupdate.js +29 -0
- package/esm/redux/actions/FormAutoupdate.js.map +1 -0
- package/esm/redux/connectors/FormAttributeSet.js +3 -2
- package/esm/redux/connectors/FormAttributeSet.js.map +1 -1
- package/esm/redux/types.js.map +1 -1
- package/esm/utils/fetch/types.js.map +1 -1
- package/lib/hooks/useForm.js +17 -2
- package/lib/hooks/useForm.js.flow +22 -7
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/models/attributes/AttributeModel.js +2 -1
- package/lib/models/attributes/AttributeModel.js.flow +2 -1
- package/lib/models/attributes/AttributeModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeModel.js +16 -1
- package/lib/models/attributes/ChoiceAttributeModel.js.flow +23 -2
- package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeOptionCollection.js +10 -3
- package/lib/models/attributes/ChoiceAttributeOptionCollection.js.flow +16 -8
- package/lib/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
- package/lib/models/concepts/ConceptRelationModel.js +7 -0
- package/lib/models/concepts/ConceptRelationModel.js.flow +12 -0
- package/lib/models/concepts/ConceptRelationModel.js.map +1 -1
- package/lib/models/form/FormModel.js +22 -2
- package/lib/models/form/FormModel.js.flow +25 -5
- package/lib/models/form/FormModel.js.map +1 -1
- package/lib/models/form/FormObjectModel.js +9 -1
- package/lib/models/form/FormObjectModel.js.flow +9 -1
- package/lib/models/form/FormObjectModel.js.map +1 -1
- package/lib/modularui/ModularUIRequest.js +1 -1
- package/lib/modularui/ModularUIRequest.js.flow +1 -1
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/redux/_modularui/ModularUIActions.js +4 -10
- package/lib/redux/_modularui/ModularUIActions.js.flow +8 -16
- package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
- package/lib/redux/actions/FormAttributeSet.js +22 -6
- package/lib/redux/actions/FormAttributeSet.js.flow +36 -11
- package/lib/redux/actions/FormAttributeSet.js.map +1 -1
- package/lib/redux/actions/FormAutosubmit.js +10 -1
- package/lib/redux/actions/FormAutosubmit.js.flow +10 -3
- package/lib/redux/actions/FormAutosubmit.js.map +1 -1
- package/lib/redux/actions/FormAutoupdate.js +37 -0
- package/lib/redux/actions/FormAutoupdate.js.flow +43 -0
- package/lib/redux/actions/FormAutoupdate.js.map +1 -0
- package/lib/redux/connectors/FormAttributeSet.js +3 -2
- package/lib/redux/connectors/FormAttributeSet.js.flow +4 -2
- package/lib/redux/connectors/FormAttributeSet.js.map +1 -1
- package/lib/redux/types.js.flow +1 -0
- package/lib/redux/types.js.map +1 -1
- package/lib/utils/fetch/types.js.flow +2 -1
- package/lib/utils/fetch/types.js.map +1 -1
- package/package.json +18 -18
- package/src/hooks/useForm.js +22 -7
- package/src/models/attributes/AttributeModel.js +2 -1
- package/src/models/attributes/ChoiceAttributeModel.js +23 -2
- package/src/models/attributes/ChoiceAttributeOptionCollection.js +16 -8
- package/src/models/concepts/ConceptRelationModel.js +12 -0
- package/src/models/form/FormModel.js +25 -5
- package/src/models/form/FormObjectModel.js +9 -1
- package/src/modularui/ModularUIRequest.js +1 -1
- package/src/redux/_modularui/ModularUIActions.js +8 -16
- package/src/redux/actions/FormAttributeSet.js +36 -11
- package/src/redux/actions/FormAutosubmit.js +10 -3
- package/src/redux/actions/FormAutoupdate.js +43 -0
- package/src/redux/connectors/FormAttributeSet.js +4 -2
- package/src/redux/types.js +1 -0
- package/src/utils/fetch/types.js +2 -1
- package/types/hooks/useI18n.d.ts +1 -1
- package/types/models/application/ApplicationModel.d.ts +7 -0
- package/types/models/attributes/AttributeModel.d.ts +4 -3
- package/types/models/attributes/ChoiceAttributeModel.d.ts +4 -0
- package/types/models/attributes/ChoiceAttributeOptionCollection.d.ts +1 -1
- package/types/models/attributes/ChoiceAttributeOptionModel.d.ts +2 -1
- package/types/models/attributes/input-constraints/ConstraintModel.d.ts +1 -1
- package/types/models/base/ResourceCollection.d.ts +2 -1
- package/types/models/base/ResourceModel.d.ts +3 -2
- package/types/models/concepts/BusinessScenarioModel.d.ts +1 -1
- package/types/models/concepts/ConceptRelationModel.d.ts +19 -4
- package/types/models/content/ContentModel.d.ts +4 -0
- package/types/models/content/ContentTOCModel.d.ts +4 -0
- package/types/models/form/FormModel.d.ts +7 -1
- package/types/models/form/FormObjectModel.d.ts +11 -2
- package/types/models/links/normalizeLinkJSON.d.ts +2 -2
- package/types/models/list/ListModel.d.ts +4 -0
- package/types/models/panels/GroupingPanelModel.d.ts +4 -0
- package/types/models/tab/TabModel.d.ts +4 -0
- package/types/models/types.d.ts +2 -1
- package/types/models/user/UserServicesModel.d.ts +7 -0
- package/types/redux/types.d.ts +1 -0
- package/types/utils/fetch/types.d.ts +2 -1
|
@@ -6,6 +6,7 @@ import { getSetting } from "../../constants/Settings";
|
|
|
6
6
|
import { validateFormObject } from "./FormValidations";
|
|
7
7
|
import { autosaveFormObject } from "./FormAutosave";
|
|
8
8
|
import { autosubmitFormObject } from "./FormAutosubmit";
|
|
9
|
+
import { autoupdateFormObject } from "./FormAutoupdate";
|
|
9
10
|
|
|
10
11
|
import type { Dispatch, ThunkAction, UpdateFormOptions } from "../types";
|
|
11
12
|
import type { AttributeType } from "../../models/types";
|
|
@@ -23,7 +24,8 @@ export const updateFormAttribute =
|
|
|
23
24
|
inputvalue: string,
|
|
24
25
|
options: UpdateFormOptions = {
|
|
25
26
|
autosubmit: false,
|
|
26
|
-
autosave: false,
|
|
27
|
+
autosave: false, // autosave commits the form in the background
|
|
28
|
+
autoupdate: false, // autoupdate does not commit and updates the form with for example a new dynamicschema (work-around for form-tree iq)
|
|
27
29
|
forceUpdate: false,
|
|
28
30
|
validate: true,
|
|
29
31
|
},
|
|
@@ -56,18 +58,41 @@ export const updateFormAttribute =
|
|
|
56
58
|
}
|
|
57
59
|
}
|
|
58
60
|
|
|
59
|
-
if (options.
|
|
60
|
-
|
|
61
|
+
if (options.autoupdate && newForm.isValid) {
|
|
62
|
+
const autoupdateAction = autoupdateFormObject(newForm, attribute);
|
|
63
|
+
if (autoupdateAction) {
|
|
64
|
+
return dispatch(autoupdateAction);
|
|
65
|
+
}
|
|
61
66
|
}
|
|
62
67
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
getSetting("USE_INSTANT_SERVER_VALIDATION")
|
|
67
|
-
) {
|
|
68
|
-
// server form validations happens async, don't wait for the form to return
|
|
69
|
-
dispatch(validateFormObject(newForm));
|
|
70
|
-
}
|
|
68
|
+
handleAutoSave(dispatch, newForm, options);
|
|
69
|
+
|
|
70
|
+
handleValidate(dispatch, newForm, options);
|
|
71
71
|
|
|
72
72
|
return dispatch(updateForm(newForm));
|
|
73
73
|
};
|
|
74
|
+
|
|
75
|
+
const handleAutoSave = (
|
|
76
|
+
dispatch: Dispatch,
|
|
77
|
+
newForm: FormModel,
|
|
78
|
+
options: UpdateFormOptions,
|
|
79
|
+
) => {
|
|
80
|
+
if (options.autosave && newForm.isValid && newForm.isChanged()) {
|
|
81
|
+
dispatch(autosaveFormObject(newForm));
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const handleValidate = (
|
|
86
|
+
dispatch: Dispatch,
|
|
87
|
+
newForm: FormModel,
|
|
88
|
+
options: UpdateFormOptions,
|
|
89
|
+
) => {
|
|
90
|
+
if (
|
|
91
|
+
options.validate &&
|
|
92
|
+
newForm.currentFormObject?.hasDynamicValidations &&
|
|
93
|
+
getSetting("USE_INSTANT_SERVER_VALIDATION")
|
|
94
|
+
) {
|
|
95
|
+
// server form validations happens async, don't wait for the form to return
|
|
96
|
+
dispatch(validateFormObject(newForm));
|
|
97
|
+
}
|
|
98
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormAttributeSet.js","names":["_ModularUIActions","require","_Settings","_FormValidations","_FormAutosave","_FormAutosubmit","updateFormAttribute","form","formObject","attribute","inputvalue","options","arguments","length","undefined","autosubmit","autosave","forceUpdate","validate","dispatch","newForm","clone","currentFormObject","equals","updateAttribute","completedFormObjects","forEach","completeObject","isValid","autosubmitAction","autosubmitFormObject","
|
|
1
|
+
{"version":3,"file":"FormAttributeSet.js","names":["_ModularUIActions","require","_Settings","_FormValidations","_FormAutosave","_FormAutosubmit","_FormAutoupdate","updateFormAttribute","form","formObject","attribute","inputvalue","options","arguments","length","undefined","autosubmit","autosave","autoupdate","forceUpdate","validate","dispatch","newForm","clone","currentFormObject","equals","updateAttribute","completedFormObjects","forEach","completeObject","isValid","autosubmitAction","autosubmitFormObject","autoupdateAction","autoupdateFormObject","handleAutoSave","handleValidate","updateForm","exports","isChanged","autosaveFormObject","hasDynamicValidations","getSetting","validateFormObject"],"sources":["../../../src/redux/actions/FormAttributeSet.js"],"sourcesContent":["// @flow\nimport { updateForm } from \"../_modularui/ModularUIActions\";\n\nimport { getSetting } from \"../../constants/Settings\";\n\nimport { validateFormObject } from \"./FormValidations\";\nimport { autosaveFormObject } from \"./FormAutosave\";\nimport { autosubmitFormObject } from \"./FormAutosubmit\";\nimport { autoupdateFormObject } from \"./FormAutoupdate\";\n\nimport type { Dispatch, ThunkAction, UpdateFormOptions } from \"../types\";\nimport type { AttributeType } from \"../../models/types\";\nimport type FormModel from \"../../models/form/FormModel\";\nimport type FormObjectModel from \"../../models/form/FormObjectModel\";\n\n/**\n * Update an attribute on a form\n */\nexport const updateFormAttribute =\n (\n form: FormModel,\n formObject: FormObjectModel,\n attribute: AttributeType,\n inputvalue: string,\n options: UpdateFormOptions = {\n autosubmit: false,\n autosave: false, // autosave commits the form in the background\n autoupdate: false, // autoupdate does not commit and updates the form with for example a new dynamicschema (work-around for form-tree iq)\n forceUpdate: false,\n validate: true,\n },\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n const newForm = form.clone();\n\n if (options.validate === undefined) {\n options.validate = true;\n }\n\n if (newForm.currentFormObject?.equals(formObject)) {\n newForm.currentFormObject.updateAttribute(attribute, inputvalue);\n } else {\n newForm.completedFormObjects.forEach((completeObject) => {\n if (completeObject.equals(formObject)) {\n completeObject.updateAttribute(attribute, inputvalue);\n }\n });\n }\n\n if (options.autosubmit && newForm.isValid) {\n const autosubmitAction = autosubmitFormObject(\n newForm,\n attribute,\n options.forceUpdate,\n );\n if (autosubmitAction) {\n return dispatch(autosubmitAction);\n }\n }\n\n if (options.autoupdate && newForm.isValid) {\n const autoupdateAction = autoupdateFormObject(newForm, attribute);\n if (autoupdateAction) {\n return dispatch(autoupdateAction);\n }\n }\n\n handleAutoSave(dispatch, newForm, options);\n\n handleValidate(dispatch, newForm, options);\n\n return dispatch(updateForm(newForm));\n };\n\nconst handleAutoSave = (\n dispatch: Dispatch,\n newForm: FormModel,\n options: UpdateFormOptions,\n) => {\n if (options.autosave && newForm.isValid && newForm.isChanged()) {\n dispatch(autosaveFormObject(newForm));\n }\n};\n\nconst handleValidate = (\n dispatch: Dispatch,\n newForm: FormModel,\n options: UpdateFormOptions,\n) => {\n if (\n options.validate &&\n newForm.currentFormObject?.hasDynamicValidations &&\n getSetting(\"USE_INSTANT_SERVER_VALIDATION\")\n ) {\n // server form validations happens async, don't wait for the form to return\n dispatch(validateFormObject(newForm));\n }\n};\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAL,OAAA;AAOA;AACA;AACA;AACO,MAAMM,mBAAmB,GAC9B,SAAAA,CACEC,IAAe,EACfC,UAA2B,EAC3BC,SAAwB,EACxBC,UAAkB;EAAA,IAClBC,OAA0B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG;IAC3BG,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE,KAAK;IAAE;IACjBC,UAAU,EAAE,KAAK;IAAE;IACnBC,WAAW,EAAE,KAAK;IAClBC,QAAQ,EAAE;EACZ,CAAC;EAAA,OAEFC,QAAkB,IAAK;IACtB,MAAMC,OAAO,GAAGd,IAAI,CAACe,KAAK,CAAC,CAAC;IAE5B,IAAIX,OAAO,CAACQ,QAAQ,KAAKL,SAAS,EAAE;MAClCH,OAAO,CAACQ,QAAQ,GAAG,IAAI;IACzB;IAEA,IAAIE,OAAO,CAACE,iBAAiB,EAAEC,MAAM,CAAChB,UAAU,CAAC,EAAE;MACjDa,OAAO,CAACE,iBAAiB,CAACE,eAAe,CAAChB,SAAS,EAAEC,UAAU,CAAC;IAClE,CAAC,MAAM;MACLW,OAAO,CAACK,oBAAoB,CAACC,OAAO,CAAEC,cAAc,IAAK;QACvD,IAAIA,cAAc,CAACJ,MAAM,CAAChB,UAAU,CAAC,EAAE;UACrCoB,cAAc,CAACH,eAAe,CAAChB,SAAS,EAAEC,UAAU,CAAC;QACvD;MACF,CAAC,CAAC;IACJ;IAEA,IAAIC,OAAO,CAACI,UAAU,IAAIM,OAAO,CAACQ,OAAO,EAAE;MACzC,MAAMC,gBAAgB,GAAG,IAAAC,oCAAoB,EAC3CV,OAAO,EACPZ,SAAS,EACTE,OAAO,CAACO,WACV,CAAC;MACD,IAAIY,gBAAgB,EAAE;QACpB,OAAOV,QAAQ,CAACU,gBAAgB,CAAC;MACnC;IACF;IAEA,IAAInB,OAAO,CAACM,UAAU,IAAII,OAAO,CAACQ,OAAO,EAAE;MACzC,MAAMG,gBAAgB,GAAG,IAAAC,oCAAoB,EAACZ,OAAO,EAAEZ,SAAS,CAAC;MACjE,IAAIuB,gBAAgB,EAAE;QACpB,OAAOZ,QAAQ,CAACY,gBAAgB,CAAC;MACnC;IACF;IAEAE,cAAc,CAACd,QAAQ,EAAEC,OAAO,EAAEV,OAAO,CAAC;IAE1CwB,cAAc,CAACf,QAAQ,EAAEC,OAAO,EAAEV,OAAO,CAAC;IAE1C,OAAOS,QAAQ,CAAC,IAAAgB,4BAAU,EAACf,OAAO,CAAC,CAAC;EACtC,CAAC;AAAA;AAACgB,OAAA,CAAA/B,mBAAA,GAAAA,mBAAA;AAEJ,MAAM4B,cAAc,GAAGA,CACrBd,QAAkB,EAClBC,OAAkB,EAClBV,OAA0B,KACvB;EACH,IAAIA,OAAO,CAACK,QAAQ,IAAIK,OAAO,CAACQ,OAAO,IAAIR,OAAO,CAACiB,SAAS,CAAC,CAAC,EAAE;IAC9DlB,QAAQ,CAAC,IAAAmB,gCAAkB,EAAClB,OAAO,CAAC,CAAC;EACvC;AACF,CAAC;AAED,MAAMc,cAAc,GAAGA,CACrBf,QAAkB,EAClBC,OAAkB,EAClBV,OAA0B,KACvB;EACH,IACEA,OAAO,CAACQ,QAAQ,IAChBE,OAAO,CAACE,iBAAiB,EAAEiB,qBAAqB,IAChD,IAAAC,oBAAU,EAAC,+BAA+B,CAAC,EAC3C;IACA;IACArB,QAAQ,CAAC,IAAAsB,mCAAkB,EAACrB,OAAO,CAAC,CAAC;EACvC;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.autosubmitFormObject = void 0;
|
|
7
8
|
var _ModularUIActions = require("../_modularui/ModularUIActions");
|
|
8
9
|
var _Constants = require("../../constants/Constants");
|
|
10
|
+
var _FormModel = _interopRequireDefault(require("../../models/form/FormModel"));
|
|
9
11
|
/**
|
|
10
12
|
*/
|
|
11
13
|
const autosubmitFormObject = function (form, attribute) {
|
|
@@ -20,7 +22,14 @@ const autosubmitFormObject = function (form, attribute) {
|
|
|
20
22
|
return (0, _ModularUIActions.loadModularUI)(form.connectKey, form.selfhref, {
|
|
21
23
|
method: _Constants.HTTP_METHODS.POST,
|
|
22
24
|
data: form.formdata,
|
|
23
|
-
|
|
25
|
+
updateHandler: newModel => {
|
|
26
|
+
if (newModel instanceof _FormModel.default) {
|
|
27
|
+
const clonedModel = form.clone();
|
|
28
|
+
clonedModel.update(newModel);
|
|
29
|
+
return clonedModel;
|
|
30
|
+
}
|
|
31
|
+
return newModel;
|
|
32
|
+
}
|
|
24
33
|
});
|
|
25
34
|
}
|
|
26
35
|
return null;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import { loadModularUI } from "../_modularui/ModularUIActions";
|
|
3
3
|
import { HTTP_METHODS } from "../../constants/Constants";
|
|
4
|
+
import FormModel from "../../models/form/FormModel";
|
|
4
5
|
|
|
5
|
-
import type { AttributeType } from "../../models/types";
|
|
6
|
-
import type FormModel from "../../models/form/FormModel";
|
|
6
|
+
import type { ModularUIModel, AttributeType } from "../../models/types";
|
|
7
7
|
import type { ThunkAction } from "../types";
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -28,7 +28,14 @@ export const autosubmitFormObject = (
|
|
|
28
28
|
return loadModularUI(form.connectKey, form.selfhref, {
|
|
29
29
|
method: HTTP_METHODS.POST,
|
|
30
30
|
data: form.formdata,
|
|
31
|
-
|
|
31
|
+
updateHandler: (newModel: ModularUIModel): ModularUIModel => {
|
|
32
|
+
if (newModel instanceof FormModel) {
|
|
33
|
+
const clonedModel: FormModel = form.clone();
|
|
34
|
+
clonedModel.update(newModel);
|
|
35
|
+
return clonedModel;
|
|
36
|
+
}
|
|
37
|
+
return newModel;
|
|
38
|
+
},
|
|
32
39
|
});
|
|
33
40
|
}
|
|
34
41
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormAutosubmit.js","names":["_ModularUIActions","require","_Constants","autosubmitFormObject","form","attribute","forceUpdate","arguments","length","undefined","allObjects","currentFormObject","hasAttributeByKey","key","setPreviousObject","isChanged","loadModularUI","connectKey","selfhref","method","HTTP_METHODS","POST","data","formdata","
|
|
1
|
+
{"version":3,"file":"FormAutosubmit.js","names":["_ModularUIActions","require","_Constants","_FormModel","_interopRequireDefault","autosubmitFormObject","form","attribute","forceUpdate","arguments","length","undefined","allObjects","currentFormObject","hasAttributeByKey","key","setPreviousObject","isChanged","loadModularUI","connectKey","selfhref","method","HTTP_METHODS","POST","data","formdata","updateHandler","newModel","FormModel","clonedModel","clone","update","exports"],"sources":["../../../src/redux/actions/FormAutosubmit.js"],"sourcesContent":["// @flow\nimport { loadModularUI } from \"../_modularui/ModularUIActions\";\nimport { HTTP_METHODS } from \"../../constants/Constants\";\nimport FormModel from \"../../models/form/FormModel\";\n\nimport type { ModularUIModel, AttributeType } from \"../../models/types\";\nimport type { ThunkAction } from \"../types\";\n\n/**\n */\nexport const autosubmitFormObject = (\n form: FormModel,\n attribute: AttributeType,\n forceUpdate: boolean = false,\n): ?ThunkAction => {\n // As long as we have form objects,\n // and the current attribute is not found in the current form object, go back.\n // When a form has a result, the current form object is null\n while (\n form.allObjects.length > 0 &&\n (!form.currentFormObject ||\n !form.currentFormObject.hasAttributeByKey(attribute.key))\n ) {\n form.setPreviousObject();\n }\n\n if (form.isChanged() || forceUpdate) {\n return loadModularUI(form.connectKey, form.selfhref, {\n method: HTTP_METHODS.POST,\n data: form.formdata,\n updateHandler: (newModel: ModularUIModel): ModularUIModel => {\n if (newModel instanceof FormModel) {\n const clonedModel: FormModel = form.clone();\n clonedModel.update(newModel);\n return clonedModel;\n }\n return newModel;\n },\n });\n }\n\n return null;\n};\n"],"mappings":";;;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AAKA;AACA;AACO,MAAMI,oBAAoB,GAAG,SAAAA,CAClCC,IAAe,EACfC,SAAwB,EAEP;EAAA,IADjBC,WAAoB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;EAE5B;EACA;EACA;EACA,OACEH,IAAI,CAACM,UAAU,CAACF,MAAM,GAAG,CAAC,KACzB,CAACJ,IAAI,CAACO,iBAAiB,IACtB,CAACP,IAAI,CAACO,iBAAiB,CAACC,iBAAiB,CAACP,SAAS,CAACQ,GAAG,CAAC,CAAC,EAC3D;IACAT,IAAI,CAACU,iBAAiB,CAAC,CAAC;EAC1B;EAEA,IAAIV,IAAI,CAACW,SAAS,CAAC,CAAC,IAAIT,WAAW,EAAE;IACnC,OAAO,IAAAU,+BAAa,EAACZ,IAAI,CAACa,UAAU,EAAEb,IAAI,CAACc,QAAQ,EAAE;MACnDC,MAAM,EAAEC,uBAAY,CAACC,IAAI;MACzBC,IAAI,EAAElB,IAAI,CAACmB,QAAQ;MACnBC,aAAa,EAAGC,QAAwB,IAAqB;QAC3D,IAAIA,QAAQ,YAAYC,kBAAS,EAAE;UACjC,MAAMC,WAAsB,GAAGvB,IAAI,CAACwB,KAAK,CAAC,CAAC;UAC3CD,WAAW,CAACE,MAAM,CAACJ,QAAQ,CAAC;UAC5B,OAAOE,WAAW;QACpB;QACA,OAAOF,QAAQ;MACjB;IACF,CAAC,CAAC;EACJ;EAEA,OAAO,IAAI;AACb,CAAC;AAACK,OAAA,CAAA3B,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.autoupdateFormObject = void 0;
|
|
8
|
+
var _ModularUIActions = require("../_modularui/ModularUIActions");
|
|
9
|
+
var _Constants = require("../../constants/Constants");
|
|
10
|
+
var _FormModel = _interopRequireDefault(require("../../models/form/FormModel"));
|
|
11
|
+
/**
|
|
12
|
+
*/
|
|
13
|
+
const autoupdateFormObject = (form, attribute) => {
|
|
14
|
+
// As long as we have form objects,
|
|
15
|
+
// and the current attribute is not found in the current form object, go back.
|
|
16
|
+
// When a form has a result, the current form object is null
|
|
17
|
+
while (form.allObjects.length > 0 && (!form.currentFormObject || !form.currentFormObject.hasAttributeByKey(attribute.key))) {
|
|
18
|
+
form.setPreviousObject();
|
|
19
|
+
}
|
|
20
|
+
if (form.isChanged()) {
|
|
21
|
+
return (0, _ModularUIActions.loadModularUI)(form.connectKey, form.selfhref, {
|
|
22
|
+
method: _Constants.HTTP_METHODS.POST,
|
|
23
|
+
data: form.formdata,
|
|
24
|
+
updateHandler: newModel => {
|
|
25
|
+
if (newModel instanceof _FormModel.default) {
|
|
26
|
+
const clonedModel = form.clone();
|
|
27
|
+
clonedModel.updateCurrentFormObject(newModel);
|
|
28
|
+
return clonedModel;
|
|
29
|
+
}
|
|
30
|
+
return newModel;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
};
|
|
36
|
+
exports.autoupdateFormObject = autoupdateFormObject;
|
|
37
|
+
//# sourceMappingURL=FormAutoupdate.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { loadModularUI } from "../_modularui/ModularUIActions";
|
|
3
|
+
import { HTTP_METHODS } from "../../constants/Constants";
|
|
4
|
+
|
|
5
|
+
import FormModel from "../../models/form/FormModel";
|
|
6
|
+
|
|
7
|
+
import type { AttributeType, ModularUIModel } from "../../models/types";
|
|
8
|
+
import type { ThunkAction } from "../types";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
*/
|
|
12
|
+
export const autoupdateFormObject = (
|
|
13
|
+
form: FormModel,
|
|
14
|
+
attribute: AttributeType,
|
|
15
|
+
): ?ThunkAction => {
|
|
16
|
+
// As long as we have form objects,
|
|
17
|
+
// and the current attribute is not found in the current form object, go back.
|
|
18
|
+
// When a form has a result, the current form object is null
|
|
19
|
+
while (
|
|
20
|
+
form.allObjects.length > 0 &&
|
|
21
|
+
(!form.currentFormObject ||
|
|
22
|
+
!form.currentFormObject.hasAttributeByKey(attribute.key))
|
|
23
|
+
) {
|
|
24
|
+
form.setPreviousObject();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (form.isChanged()) {
|
|
28
|
+
return loadModularUI(form.connectKey, form.selfhref, {
|
|
29
|
+
method: HTTP_METHODS.POST,
|
|
30
|
+
data: form.formdata,
|
|
31
|
+
updateHandler: (newModel: ModularUIModel): ModularUIModel => {
|
|
32
|
+
if (newModel instanceof FormModel) {
|
|
33
|
+
const clonedModel: FormModel = form.clone();
|
|
34
|
+
clonedModel.updateCurrentFormObject(newModel);
|
|
35
|
+
return clonedModel;
|
|
36
|
+
}
|
|
37
|
+
return newModel;
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return null;
|
|
43
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormAutoupdate.js","names":["_ModularUIActions","require","_Constants","_FormModel","_interopRequireDefault","autoupdateFormObject","form","attribute","allObjects","length","currentFormObject","hasAttributeByKey","key","setPreviousObject","isChanged","loadModularUI","connectKey","selfhref","method","HTTP_METHODS","POST","data","formdata","updateHandler","newModel","FormModel","clonedModel","clone","updateCurrentFormObject","exports"],"sources":["../../../src/redux/actions/FormAutoupdate.js"],"sourcesContent":["// @flow\nimport { loadModularUI } from \"../_modularui/ModularUIActions\";\nimport { HTTP_METHODS } from \"../../constants/Constants\";\n\nimport FormModel from \"../../models/form/FormModel\";\n\nimport type { AttributeType, ModularUIModel } from \"../../models/types\";\nimport type { ThunkAction } from \"../types\";\n\n/**\n */\nexport const autoupdateFormObject = (\n form: FormModel,\n attribute: AttributeType,\n): ?ThunkAction => {\n // As long as we have form objects,\n // and the current attribute is not found in the current form object, go back.\n // When a form has a result, the current form object is null\n while (\n form.allObjects.length > 0 &&\n (!form.currentFormObject ||\n !form.currentFormObject.hasAttributeByKey(attribute.key))\n ) {\n form.setPreviousObject();\n }\n\n if (form.isChanged()) {\n return loadModularUI(form.connectKey, form.selfhref, {\n method: HTTP_METHODS.POST,\n data: form.formdata,\n updateHandler: (newModel: ModularUIModel): ModularUIModel => {\n if (newModel instanceof FormModel) {\n const clonedModel: FormModel = form.clone();\n clonedModel.updateCurrentFormObject(newModel);\n return clonedModel;\n }\n return newModel;\n },\n });\n }\n\n return null;\n};\n"],"mappings":";;;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AAKA;AACA;AACO,MAAMI,oBAAoB,GAAGA,CAClCC,IAAe,EACfC,SAAwB,KACP;EACjB;EACA;EACA;EACA,OACED,IAAI,CAACE,UAAU,CAACC,MAAM,GAAG,CAAC,KACzB,CAACH,IAAI,CAACI,iBAAiB,IACtB,CAACJ,IAAI,CAACI,iBAAiB,CAACC,iBAAiB,CAACJ,SAAS,CAACK,GAAG,CAAC,CAAC,EAC3D;IACAN,IAAI,CAACO,iBAAiB,CAAC,CAAC;EAC1B;EAEA,IAAIP,IAAI,CAACQ,SAAS,CAAC,CAAC,EAAE;IACpB,OAAO,IAAAC,+BAAa,EAACT,IAAI,CAACU,UAAU,EAAEV,IAAI,CAACW,QAAQ,EAAE;MACnDC,MAAM,EAAEC,uBAAY,CAACC,IAAI;MACzBC,IAAI,EAAEf,IAAI,CAACgB,QAAQ;MACnBC,aAAa,EAAGC,QAAwB,IAAqB;QAC3D,IAAIA,QAAQ,YAAYC,kBAAS,EAAE;UACjC,MAAMC,WAAsB,GAAGpB,IAAI,CAACqB,KAAK,CAAC,CAAC;UAC3CD,WAAW,CAACE,uBAAuB,CAACJ,QAAQ,CAAC;UAC7C,OAAOE,WAAW;QACpB;QACA,OAAOF,QAAQ;MACjB;IACF,CAAC,CAAC;EACJ;EAEA,OAAO,IAAI;AACb,CAAC;AAACK,OAAA,CAAAxB,oBAAA,GAAAA,oBAAA","ignoreList":[]}
|
|
@@ -10,8 +10,9 @@ var _FormAttributeSetRepeatable = require("../actions/FormAttributeSetRepeatable
|
|
|
10
10
|
const mapDispatchToProps = (dispatch, ownProps) => ({
|
|
11
11
|
onAttributeChange: function (attribute, value) {
|
|
12
12
|
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
13
|
-
autosubmit: ownProps.autosubmit
|
|
14
|
-
autosave: ownProps.autosave
|
|
13
|
+
autosubmit: ownProps.autosubmit ?? false,
|
|
14
|
+
autosave: ownProps.autosave ?? false,
|
|
15
|
+
autoupdate: ownProps.autoupdate ?? false
|
|
15
16
|
};
|
|
16
17
|
return dispatch((0, _FormAttributeSet.updateFormAttribute)(ownProps.form, ownProps.object, attribute, value, options));
|
|
17
18
|
},
|
|
@@ -24,6 +24,7 @@ type OwnProps = {
|
|
|
24
24
|
formLayout?: "vertical" | "horizontal" | "compact",
|
|
25
25
|
autosubmit?: boolean,
|
|
26
26
|
autosave?: boolean,
|
|
27
|
+
autoupdate?: boolean,
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
type DispatchProps = {
|
|
@@ -50,8 +51,9 @@ const mapDispatchToProps = (
|
|
|
50
51
|
attribute: AttributeType,
|
|
51
52
|
value: string,
|
|
52
53
|
options: UpdateFormOptions = {
|
|
53
|
-
autosubmit: ownProps.autosubmit
|
|
54
|
-
autosave: ownProps.autosave
|
|
54
|
+
autosubmit: ownProps.autosubmit ?? false,
|
|
55
|
+
autosave: ownProps.autosave ?? false,
|
|
56
|
+
autoupdate: ownProps.autoupdate ?? false,
|
|
55
57
|
},
|
|
56
58
|
) =>
|
|
57
59
|
dispatch(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormAttributeSet.js","names":["_reactRedux","require","_FormAttributeSet","_FormAttributeSetRepeatable","mapDispatchToProps","dispatch","ownProps","onAttributeChange","attribute","value","options","arguments","length","undefined","autosubmit","autosave","updateFormAttribute","form","object","onAddAttributeSetClick","addRepeatableAttributeSet","onCancelAttributeSetClick","formObject","cancelRepeatableAttributeSet","onRemoveAttributeSetClick","removeRepeatableAttributeSet","connectFormAttributeSet","exports","connect"],"sources":["../../../src/redux/connectors/FormAttributeSet.js"],"sourcesContent":["// @flow\nimport { connect } from \"react-redux\";\n\nimport { updateFormAttribute } from \"../actions/FormAttributeSet\";\nimport {\n addRepeatableAttributeSet,\n cancelRepeatableAttributeSet,\n removeRepeatableAttributeSet,\n} from \"../actions/FormAttributeSetRepeatable\";\n\nimport type { ThunkAction, UpdateFormOptions } from \"../types\";\nimport type { UpdateFormAction } from \"../_modularui/types\";\nimport type { AttributeType } from \"../../models/types\";\nimport type FormModel from \"../../models/form/FormModel\";\nimport type FormObjectModel from \"../../models/form/FormObjectModel\";\nimport type { DispatchAPI } from \"redux\";\nimport type { ComponentType } from \"react\";\n\ntype Dispatch = DispatchAPI<UpdateFormAction> & DispatchAPI<ThunkAction>;\n\ntype OwnProps = {\n form: FormModel,\n object: FormObjectModel,\n formLayout?: \"vertical\" | \"horizontal\" | \"compact\",\n autosubmit?: boolean,\n autosave?: boolean,\n};\n\ntype DispatchProps = {\n onAttributeChange: (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions,\n ) => ThunkAction,\n onAddAttributeSetClick: () => UpdateFormAction,\n onCancelAttributeSetClick: (formObject: FormObjectModel) => UpdateFormAction,\n onRemoveAttributeSetClick: (formObject: FormObjectModel) => UpdateFormAction,\n};\n\ntype Props = {\n ...OwnProps,\n ...DispatchProps,\n};\n\nconst mapDispatchToProps = (\n dispatch: Dispatch,\n ownProps: OwnProps,\n): DispatchProps => ({\n onAttributeChange: (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions = {\n autosubmit: ownProps.autosubmit
|
|
1
|
+
{"version":3,"file":"FormAttributeSet.js","names":["_reactRedux","require","_FormAttributeSet","_FormAttributeSetRepeatable","mapDispatchToProps","dispatch","ownProps","onAttributeChange","attribute","value","options","arguments","length","undefined","autosubmit","autosave","autoupdate","updateFormAttribute","form","object","onAddAttributeSetClick","addRepeatableAttributeSet","onCancelAttributeSetClick","formObject","cancelRepeatableAttributeSet","onRemoveAttributeSetClick","removeRepeatableAttributeSet","connectFormAttributeSet","exports","connect"],"sources":["../../../src/redux/connectors/FormAttributeSet.js"],"sourcesContent":["// @flow\nimport { connect } from \"react-redux\";\n\nimport { updateFormAttribute } from \"../actions/FormAttributeSet\";\nimport {\n addRepeatableAttributeSet,\n cancelRepeatableAttributeSet,\n removeRepeatableAttributeSet,\n} from \"../actions/FormAttributeSetRepeatable\";\n\nimport type { ThunkAction, UpdateFormOptions } from \"../types\";\nimport type { UpdateFormAction } from \"../_modularui/types\";\nimport type { AttributeType } from \"../../models/types\";\nimport type FormModel from \"../../models/form/FormModel\";\nimport type FormObjectModel from \"../../models/form/FormObjectModel\";\nimport type { DispatchAPI } from \"redux\";\nimport type { ComponentType } from \"react\";\n\ntype Dispatch = DispatchAPI<UpdateFormAction> & DispatchAPI<ThunkAction>;\n\ntype OwnProps = {\n form: FormModel,\n object: FormObjectModel,\n formLayout?: \"vertical\" | \"horizontal\" | \"compact\",\n autosubmit?: boolean,\n autosave?: boolean,\n autoupdate?: boolean,\n};\n\ntype DispatchProps = {\n onAttributeChange: (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions,\n ) => ThunkAction,\n onAddAttributeSetClick: () => UpdateFormAction,\n onCancelAttributeSetClick: (formObject: FormObjectModel) => UpdateFormAction,\n onRemoveAttributeSetClick: (formObject: FormObjectModel) => UpdateFormAction,\n};\n\ntype Props = {\n ...OwnProps,\n ...DispatchProps,\n};\n\nconst mapDispatchToProps = (\n dispatch: Dispatch,\n ownProps: OwnProps,\n): DispatchProps => ({\n onAttributeChange: (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions = {\n autosubmit: ownProps.autosubmit ?? false,\n autosave: ownProps.autosave ?? false,\n autoupdate: ownProps.autoupdate ?? false,\n },\n ) =>\n dispatch(\n updateFormAttribute(\n ownProps.form,\n ownProps.object,\n attribute,\n value,\n options,\n ),\n ),\n onAddAttributeSetClick: () =>\n dispatch(addRepeatableAttributeSet(ownProps.form)),\n onCancelAttributeSetClick: (formObject: FormObjectModel) =>\n dispatch(cancelRepeatableAttributeSet(ownProps.form, formObject)),\n onRemoveAttributeSetClick: (formObject: FormObjectModel) =>\n dispatch(removeRepeatableAttributeSet(ownProps.form, formObject)),\n});\n\n/**\n */\nexport const connectFormAttributeSet: ComponentType<any> = connect<\n Props,\n OwnProps,\n _,\n DispatchProps,\n _,\n _,\n>(null, mapDispatchToProps);\n"],"mappings":";;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,2BAAA,GAAAF,OAAA;AAyCA,MAAMG,kBAAkB,GAAGA,CACzBC,QAAkB,EAClBC,QAAkB,MACC;EACnBC,iBAAiB,EAAE,SAAAA,CACjBC,SAAwB,EACxBC,KAAa;IAAA,IACbC,OAA0B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG;MAC3BG,UAAU,EAAER,QAAQ,CAACQ,UAAU,IAAI,KAAK;MACxCC,QAAQ,EAAET,QAAQ,CAACS,QAAQ,IAAI,KAAK;MACpCC,UAAU,EAAEV,QAAQ,CAACU,UAAU,IAAI;IACrC,CAAC;IAAA,OAEDX,QAAQ,CACN,IAAAY,qCAAmB,EACjBX,QAAQ,CAACY,IAAI,EACbZ,QAAQ,CAACa,MAAM,EACfX,SAAS,EACTC,KAAK,EACLC,OACF,CACF,CAAC;EAAA;EACHU,sBAAsB,EAAEA,CAAA,KACtBf,QAAQ,CAAC,IAAAgB,qDAAyB,EAACf,QAAQ,CAACY,IAAI,CAAC,CAAC;EACpDI,yBAAyB,EAAGC,UAA2B,IACrDlB,QAAQ,CAAC,IAAAmB,wDAA4B,EAAClB,QAAQ,CAACY,IAAI,EAAEK,UAAU,CAAC,CAAC;EACnEE,yBAAyB,EAAGF,UAA2B,IACrDlB,QAAQ,CAAC,IAAAqB,wDAA4B,EAACpB,QAAQ,CAACY,IAAI,EAAEK,UAAU,CAAC;AACpE,CAAC,CAAC;;AAEF;AACA;AACO,MAAMI,uBAA2C,GAAAC,OAAA,CAAAD,uBAAA,GAAG,IAAAE,mBAAO,EAOhE,IAAI,EAAEzB,kBAAkB,CAAC","ignoreList":[]}
|
package/lib/redux/types.js.flow
CHANGED
|
@@ -46,6 +46,7 @@ export type PreferenceValue =
|
|
|
46
46
|
export type UpdateFormOptions = {
|
|
47
47
|
autosubmit: boolean,
|
|
48
48
|
autosave: boolean,
|
|
49
|
+
autoupdate: boolean,
|
|
49
50
|
forceUpdate?: boolean,
|
|
50
51
|
/** Default true: Activate/deactivate the form object validate by an update */
|
|
51
52
|
validate?: boolean,
|
package/lib/redux/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../src/redux/types.js"],"sourcesContent":["// @flow\nimport type { Store, DispatchAPI } from \"redux\";\n\nimport type ErrorResponse from \"../models/error/ErrorResponse\";\n\nimport type FormModel from \"../models/form/FormModel\";\nimport typeof {\n NOTIFICATION_TYPES,\n AUTOSAVE_STATUS,\n} from \"../constants/Constants\";\n\nimport type { MessageObject } from \"../i18n/types\";\nimport type {\n I18nState,\n UpdateLocaleAction,\n SetLocalesAction,\n} from \"./_i18n/types\";\nimport type {\n ModularUIState,\n ModularUIAction,\n UpdateStatusAction,\n SetModelAction,\n UpdateModelAction,\n UpdateFormAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n InitModelAction,\n} from \"./_modularui/types\";\nimport type {\n RouterState,\n LocationChangeAction,\n PushAction,\n ReplaceAction,\n GoAction,\n GoBackAction,\n GoForwardAction,\n} from \"./_router/types\";\n\nexport type PreferenceValue =\n | null\n | string\n | boolean\n | { [key: string]: any }\n | Array<PreferenceValue>;\n\nexport type UpdateFormOptions = {\n autosubmit: boolean,\n autosave: boolean,\n forceUpdate?: boolean,\n /** Default true: Activate/deactivate the form object validate by an update */\n validate?: boolean,\n};\n\nexport type NoAction = {\n type: \"NO_ACTION\",\n};\n\nexport type SaveErrorAction = {\n type: \"SAVE_ERROR\",\n payload: ErrorResponse,\n};\n\nexport type ShowModalAction = {\n type: \"SHOW_MODAL\",\n payload: string,\n};\n\nexport type CloseModalAction = {\n type: \"CLOSE_MODAL\",\n payload: string,\n};\n\nexport type DismissNotificationAction = {\n type: \"DISMISS_NOTIFICATION\",\n};\nexport type ShowNotificationAction = {\n type: \"SHOW_NOTIFICATION\",\n payload: {\n type: $Keys<NOTIFICATION_TYPES>,\n message: MessageObject,\n error: ?ErrorResponse,\n },\n};\n\nexport type SetPreferenceAction = {\n type: \"SET_PREFERENCE\",\n payload: { [name: string]: PreferenceValue },\n};\nexport type SetPreferencesAction = {\n type: \"SET_PREFERENCES\",\n payload: { [name: string]: PreferenceValue },\n};\n\nexport type StartProgressAction = {\n type: \"START_PROGRESS\",\n};\nexport type FinishProgressAction = {\n type: \"FINISH_PROGRESS\",\n};\nexport type ResetProgressAction = {\n type: \"RESET_PROGRESS\",\n};\nexport type UpdateProgressAction = {\n type: \"UPDATE_PROGRESS\",\n payload: { percentComplete: number },\n};\n\nexport type SendAuthenticationErrorAction = {\n type: \"AUTHENTICATION_ERROR\",\n payload: string,\n};\n\nexport type ResetAuthErrorsAction = {\n type: \"AUTHENTICATION_RESET_ERRORS\",\n};\n\nexport type LoginSuccessAction = {\n type: \"AUTHENTICATION_SUCCESS\",\n};\n\nexport type ChangePasswordAction = {\n type: \"CHANGE_PASSWORD\",\n};\n\nexport type LogoutSuccessAction = {\n type: \"AUTHENTICATION_LOGOUT\",\n};\n\nexport type UpdateAutosaveAction = {\n type: \"UPDATE_AUTOSAVE_STATUS\",\n payload: {\n status: $Keys<AUTOSAVE_STATUS>,\n model: FormModel,\n },\n};\n\nexport type ReduxAction =\n | UpdateStatusAction\n | SetModelAction\n | InitModelAction\n | UpdateModelAction\n | UpdateFormAction\n | RemoveModelByKeyAction\n | ResetModularUIAction\n | SaveErrorAction\n | UpdateLocaleAction\n | SetLocalesAction\n | ShowModalAction\n | CloseModalAction\n | DismissNotificationAction\n | ShowNotificationAction\n | SetPreferenceAction\n | SetPreferencesAction\n | StartProgressAction\n | FinishProgressAction\n | ResetProgressAction\n | UpdateProgressAction\n | ResetAuthErrorsAction\n | SendAuthenticationErrorAction\n | LoginSuccessAction\n | ChangePasswordAction\n | LogoutSuccessAction\n | UpdateAutosaveAction\n | LocationChangeAction\n | PushAction\n | ReplaceAction\n | GoAction\n | GoBackAction\n | GoForwardAction\n | ModularUIAction\n | NoAction;\n\n// Redux state\nexport type AuthState = {\n +mustChangePassword: boolean,\n +error: ?string,\n};\n\nexport type ErrorState = null | ErrorResponse;\n\nexport type ModalState = {\n +key: string,\n +visible: boolean,\n +size?: string,\n};\n\nexport type ModalsState = {\n +modals: Array<ModalState>,\n};\n\nexport type NotificationState = {\n +render: boolean,\n +messageType: string | null,\n +message: MessageObject | null,\n +error: ?ErrorResponse | null,\n};\n\nexport type PreferencesState = {\n +[name: string]: PreferenceValue,\n};\n\nexport type ProgressIndicatorState = {\n +count: number,\n +timestamp: number,\n +percentComplete: number,\n};\n\nexport type ReduxState = {\n +router: RouterState,\n +modularui: ModularUIState,\n +i18n: I18nState,\n +auth: AuthState,\n +error: ErrorState,\n +modals: ModalsState,\n +notification: NotificationState,\n +progressindicator: ProgressIndicatorState,\n +preferences: PreferencesState,\n ...\n};\n\nexport type GetState = () => ReduxState;\nexport type ThunkAction = (dispatch: Dispatch, getState: GetState) => any;\nexport type PromiseAction = Promise<PossibleAction>;\nexport type Dispatch = DispatchAPI<PossibleAction>;\nexport type ReduxStore = Store<ReduxState, ReduxAction, Dispatch>;\n\nexport type PossibleAction = ReduxAction | ThunkAction | PromiseAction;\n\nexport type CustomReducers = { [reducerKey: string]: any };\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/redux/types.js"],"sourcesContent":["// @flow\nimport type { Store, DispatchAPI } from \"redux\";\n\nimport type ErrorResponse from \"../models/error/ErrorResponse\";\n\nimport type FormModel from \"../models/form/FormModel\";\nimport typeof {\n NOTIFICATION_TYPES,\n AUTOSAVE_STATUS,\n} from \"../constants/Constants\";\n\nimport type { MessageObject } from \"../i18n/types\";\nimport type {\n I18nState,\n UpdateLocaleAction,\n SetLocalesAction,\n} from \"./_i18n/types\";\nimport type {\n ModularUIState,\n ModularUIAction,\n UpdateStatusAction,\n SetModelAction,\n UpdateModelAction,\n UpdateFormAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n InitModelAction,\n} from \"./_modularui/types\";\nimport type {\n RouterState,\n LocationChangeAction,\n PushAction,\n ReplaceAction,\n GoAction,\n GoBackAction,\n GoForwardAction,\n} from \"./_router/types\";\n\nexport type PreferenceValue =\n | null\n | string\n | boolean\n | { [key: string]: any }\n | Array<PreferenceValue>;\n\nexport type UpdateFormOptions = {\n autosubmit: boolean,\n autosave: boolean,\n autoupdate: boolean,\n forceUpdate?: boolean,\n /** Default true: Activate/deactivate the form object validate by an update */\n validate?: boolean,\n};\n\nexport type NoAction = {\n type: \"NO_ACTION\",\n};\n\nexport type SaveErrorAction = {\n type: \"SAVE_ERROR\",\n payload: ErrorResponse,\n};\n\nexport type ShowModalAction = {\n type: \"SHOW_MODAL\",\n payload: string,\n};\n\nexport type CloseModalAction = {\n type: \"CLOSE_MODAL\",\n payload: string,\n};\n\nexport type DismissNotificationAction = {\n type: \"DISMISS_NOTIFICATION\",\n};\nexport type ShowNotificationAction = {\n type: \"SHOW_NOTIFICATION\",\n payload: {\n type: $Keys<NOTIFICATION_TYPES>,\n message: MessageObject,\n error: ?ErrorResponse,\n },\n};\n\nexport type SetPreferenceAction = {\n type: \"SET_PREFERENCE\",\n payload: { [name: string]: PreferenceValue },\n};\nexport type SetPreferencesAction = {\n type: \"SET_PREFERENCES\",\n payload: { [name: string]: PreferenceValue },\n};\n\nexport type StartProgressAction = {\n type: \"START_PROGRESS\",\n};\nexport type FinishProgressAction = {\n type: \"FINISH_PROGRESS\",\n};\nexport type ResetProgressAction = {\n type: \"RESET_PROGRESS\",\n};\nexport type UpdateProgressAction = {\n type: \"UPDATE_PROGRESS\",\n payload: { percentComplete: number },\n};\n\nexport type SendAuthenticationErrorAction = {\n type: \"AUTHENTICATION_ERROR\",\n payload: string,\n};\n\nexport type ResetAuthErrorsAction = {\n type: \"AUTHENTICATION_RESET_ERRORS\",\n};\n\nexport type LoginSuccessAction = {\n type: \"AUTHENTICATION_SUCCESS\",\n};\n\nexport type ChangePasswordAction = {\n type: \"CHANGE_PASSWORD\",\n};\n\nexport type LogoutSuccessAction = {\n type: \"AUTHENTICATION_LOGOUT\",\n};\n\nexport type UpdateAutosaveAction = {\n type: \"UPDATE_AUTOSAVE_STATUS\",\n payload: {\n status: $Keys<AUTOSAVE_STATUS>,\n model: FormModel,\n },\n};\n\nexport type ReduxAction =\n | UpdateStatusAction\n | SetModelAction\n | InitModelAction\n | UpdateModelAction\n | UpdateFormAction\n | RemoveModelByKeyAction\n | ResetModularUIAction\n | SaveErrorAction\n | UpdateLocaleAction\n | SetLocalesAction\n | ShowModalAction\n | CloseModalAction\n | DismissNotificationAction\n | ShowNotificationAction\n | SetPreferenceAction\n | SetPreferencesAction\n | StartProgressAction\n | FinishProgressAction\n | ResetProgressAction\n | UpdateProgressAction\n | ResetAuthErrorsAction\n | SendAuthenticationErrorAction\n | LoginSuccessAction\n | ChangePasswordAction\n | LogoutSuccessAction\n | UpdateAutosaveAction\n | LocationChangeAction\n | PushAction\n | ReplaceAction\n | GoAction\n | GoBackAction\n | GoForwardAction\n | ModularUIAction\n | NoAction;\n\n// Redux state\nexport type AuthState = {\n +mustChangePassword: boolean,\n +error: ?string,\n};\n\nexport type ErrorState = null | ErrorResponse;\n\nexport type ModalState = {\n +key: string,\n +visible: boolean,\n +size?: string,\n};\n\nexport type ModalsState = {\n +modals: Array<ModalState>,\n};\n\nexport type NotificationState = {\n +render: boolean,\n +messageType: string | null,\n +message: MessageObject | null,\n +error: ?ErrorResponse | null,\n};\n\nexport type PreferencesState = {\n +[name: string]: PreferenceValue,\n};\n\nexport type ProgressIndicatorState = {\n +count: number,\n +timestamp: number,\n +percentComplete: number,\n};\n\nexport type ReduxState = {\n +router: RouterState,\n +modularui: ModularUIState,\n +i18n: I18nState,\n +auth: AuthState,\n +error: ErrorState,\n +modals: ModalsState,\n +notification: NotificationState,\n +progressindicator: ProgressIndicatorState,\n +preferences: PreferencesState,\n ...\n};\n\nexport type GetState = () => ReduxState;\nexport type ThunkAction = (dispatch: Dispatch, getState: GetState) => any;\nexport type PromiseAction = Promise<PossibleAction>;\nexport type Dispatch = DispatchAPI<PossibleAction>;\nexport type ReduxStore = Store<ReduxState, ReduxAction, Dispatch>;\n\nexport type PossibleAction = ReduxAction | ThunkAction | PromiseAction;\n\nexport type CustomReducers = { [reducerKey: string]: any };\n"],"mappings":"","ignoreList":[]}
|
|
@@ -31,11 +31,12 @@ export type RequestBaseOptions = {
|
|
|
31
31
|
|
|
32
32
|
export type RequestOptions = { ...RequestURLOptions, ...RequestBaseOptions };
|
|
33
33
|
|
|
34
|
+
export type UpdateHandler = (newModel: ModularUIModel) => ModularUIModel;
|
|
34
35
|
export type RequestModularUIOptions = {
|
|
35
36
|
...RequestBaseOptions,
|
|
36
37
|
targetModel?: TargetModel,
|
|
37
38
|
forceTargetModel?: boolean,
|
|
38
|
-
|
|
39
|
+
updateHandler?: UpdateHandler | void,
|
|
39
40
|
childmodels?: boolean,
|
|
40
41
|
isValidationRequest?: boolean,
|
|
41
42
|
removeOnUnmount?: boolean,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/utils/fetch/types.js"],"sourcesContent":["// @flow\nimport typeof { HTTP_METHODS } from \"../../constants/Constants\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { TargetModel } from \"../../modularui/types\";\n\nexport type RequestURLOptions = {\n url: string,\n};\n\nexport type RequestBaseOptions = {\n method?: $Keys<HTTP_METHODS>,\n params?: string,\n data?: any,\n timeout?: number,\n responseType?: string,\n headers?: {\n [headerName: string]: string,\n Accept?: string,\n \"Accept-Language\"?: string,\n \"Content-Type\"?: string,\n \"x-filename\"?: string,\n \"x-filesize\"?: string,\n },\n events?: { [eventName: string]: () => void },\n onProgress?: ProgressEventHandler,\n includeContext?: boolean,\n locale?: string,\n cache?: boolean,\n isReload?: boolean,\n};\n\nexport type RequestOptions = { ...RequestURLOptions, ...RequestBaseOptions };\n\nexport type RequestModularUIOptions = {\n ...RequestBaseOptions,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/utils/fetch/types.js"],"sourcesContent":["// @flow\nimport typeof { HTTP_METHODS } from \"../../constants/Constants\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { TargetModel } from \"../../modularui/types\";\n\nexport type RequestURLOptions = {\n url: string,\n};\n\nexport type RequestBaseOptions = {\n method?: $Keys<HTTP_METHODS>,\n params?: string,\n data?: any,\n timeout?: number,\n responseType?: string,\n headers?: {\n [headerName: string]: string,\n Accept?: string,\n \"Accept-Language\"?: string,\n \"Content-Type\"?: string,\n \"x-filename\"?: string,\n \"x-filesize\"?: string,\n },\n events?: { [eventName: string]: () => void },\n onProgress?: ProgressEventHandler,\n includeContext?: boolean,\n locale?: string,\n cache?: boolean,\n isReload?: boolean,\n};\n\nexport type RequestOptions = { ...RequestURLOptions, ...RequestBaseOptions };\n\nexport type UpdateHandler = (newModel: ModularUIModel) => ModularUIModel;\nexport type RequestModularUIOptions = {\n ...RequestBaseOptions,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n updateHandler?: UpdateHandler | void,\n childmodels?: boolean,\n isValidationRequest?: boolean,\n removeOnUnmount?: boolean,\n};\n"],"mappings":"","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beinformed/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.49.1",
|
|
4
4
|
"description": "Toolbox for be informed javascript layouts",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"bugs": "http://support.beinformed.com",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"beta-release": "commit-and-tag-version --prerelease beta",
|
|
38
38
|
"prepublishOnly": "npm run build",
|
|
39
39
|
"docs": "node ./.build/docs.mjs",
|
|
40
|
-
"prepare": "husky
|
|
40
|
+
"prepare": "husky",
|
|
41
41
|
"security-audit": "auditjs ossi --xml > npm-audit.xml",
|
|
42
42
|
"generate-ts": "npx -p typescript tsc src/index.js --declaration --allowJs --emitDeclarationOnly --outDir types"
|
|
43
43
|
},
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"styled-components": "^5.0.0"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@babel/runtime-corejs3": "^7.24.
|
|
85
|
+
"@babel/runtime-corejs3": "^7.24.7",
|
|
86
86
|
"big.js": "^6.2.1",
|
|
87
87
|
"date-fns": "^3.6.0",
|
|
88
88
|
"deepmerge": "^4.3.1",
|
|
@@ -98,19 +98,19 @@
|
|
|
98
98
|
"setimmediate": "^1.0.5"
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
|
101
|
-
"@babel/cli": "^7.24.
|
|
102
|
-
"@babel/core": "^7.24.
|
|
103
|
-
"@babel/eslint-parser": "^7.24.
|
|
104
|
-
"@babel/eslint-plugin": "^7.24.
|
|
101
|
+
"@babel/cli": "^7.24.7",
|
|
102
|
+
"@babel/core": "^7.24.7",
|
|
103
|
+
"@babel/eslint-parser": "^7.24.7",
|
|
104
|
+
"@babel/eslint-plugin": "^7.24.7",
|
|
105
105
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
106
106
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
107
|
-
"@babel/plugin-transform-runtime": "^7.24.
|
|
108
|
-
"@babel/preset-env": "^7.24.
|
|
109
|
-
"@babel/preset-flow": "^7.24.
|
|
110
|
-
"@babel/preset-react": "^7.24.
|
|
111
|
-
"@commitlint/cli": "^
|
|
112
|
-
"@commitlint/config-conventional": "^
|
|
113
|
-
"@testing-library/react": "^
|
|
107
|
+
"@babel/plugin-transform-runtime": "^7.24.7",
|
|
108
|
+
"@babel/preset-env": "^7.24.7",
|
|
109
|
+
"@babel/preset-flow": "^7.24.7",
|
|
110
|
+
"@babel/preset-react": "^7.24.7",
|
|
111
|
+
"@commitlint/cli": "^19.3.0",
|
|
112
|
+
"@commitlint/config-conventional": "^19.2.2",
|
|
113
|
+
"@testing-library/react": "^16.0.0",
|
|
114
114
|
"auditjs": "^4.0.45",
|
|
115
115
|
"babel-jest": "^29.7.0",
|
|
116
116
|
"babel-plugin-styled-components": "^2.1.4",
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"eslint-plugin-ft-flow": "^3.0.9",
|
|
125
125
|
"eslint-plugin-import": "^2.29.1",
|
|
126
126
|
"eslint-plugin-jest": "^27.9.0",
|
|
127
|
-
"eslint-plugin-jsdoc": "^48.2.
|
|
127
|
+
"eslint-plugin-jsdoc": "^48.2.9",
|
|
128
128
|
"eslint-plugin-react": "^7.34.1",
|
|
129
129
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
130
130
|
"eslint-plugin-you-dont-need-lodash-underscore": "^6.14.0",
|
|
@@ -133,15 +133,15 @@
|
|
|
133
133
|
"flow-typed": "^3.9.0",
|
|
134
134
|
"hermes-eslint": "^0.16.0",
|
|
135
135
|
"history": "^4.0.0",
|
|
136
|
-
"husky": "^
|
|
136
|
+
"husky": "^9.0.11",
|
|
137
137
|
"jest": "^29.7.0",
|
|
138
138
|
"jest-environment-jsdom": "^29.7.0",
|
|
139
139
|
"jest-junit": "^16.0.0",
|
|
140
140
|
"jest-sonar-reporter": "^2.0.0",
|
|
141
141
|
"jscodeshift": "^0.15.1",
|
|
142
|
-
"lint-staged": "^
|
|
142
|
+
"lint-staged": "^15.2.5",
|
|
143
143
|
"polished": "^4.0.0",
|
|
144
|
-
"prettier": "^3.2
|
|
144
|
+
"prettier": "^3.3.2",
|
|
145
145
|
"react": "^18.3.1",
|
|
146
146
|
"react-dom": "^18.3.1",
|
|
147
147
|
"react-helmet-async": "^2.0.5",
|
package/src/hooks/useForm.js
CHANGED
|
@@ -5,6 +5,10 @@ import Href from "../models/href/Href";
|
|
|
5
5
|
|
|
6
6
|
import { getSetting, HTTP_METHODS } from "../constants";
|
|
7
7
|
|
|
8
|
+
import type {
|
|
9
|
+
RemoveModelByKeyAction,
|
|
10
|
+
UpdateFormAction,
|
|
11
|
+
} from "../redux/_modularui";
|
|
8
12
|
import { loadModularUI, removeModelByKey } from "../redux/_modularui";
|
|
9
13
|
import { useModularUI } from "./useModularUI";
|
|
10
14
|
|
|
@@ -20,12 +24,8 @@ import {
|
|
|
20
24
|
|
|
21
25
|
import FormModel from "../models/form/FormModel";
|
|
22
26
|
|
|
23
|
-
import type { FormObjectModel,
|
|
27
|
+
import type { AttributeType, FormObjectModel, ModularUIModel } from "../models";
|
|
24
28
|
import type { UpdateFormOptions } from "../redux/types";
|
|
25
|
-
import type {
|
|
26
|
-
RemoveModelByKeyAction,
|
|
27
|
-
UpdateFormAction,
|
|
28
|
-
} from "../redux/_modularui";
|
|
29
29
|
|
|
30
30
|
type FormNavigationHook = {
|
|
31
31
|
previous: (form: FormModel) => UpdateFormAction,
|
|
@@ -84,7 +84,14 @@ export const useFormNavigation = (): FormNavigationHook => {
|
|
|
84
84
|
loadModularUI(form.connectKey, form.selfhref, {
|
|
85
85
|
method: HTTP_METHODS.POST,
|
|
86
86
|
data: form.formdata,
|
|
87
|
-
|
|
87
|
+
updateHandler: (newModel: ModularUIModel): ModularUIModel => {
|
|
88
|
+
if (newModel instanceof FormModel) {
|
|
89
|
+
const clonedModel: FormModel = form.clone();
|
|
90
|
+
clonedModel.update(newModel);
|
|
91
|
+
return clonedModel;
|
|
92
|
+
}
|
|
93
|
+
return newModel;
|
|
94
|
+
},
|
|
88
95
|
targetModel: FormModel,
|
|
89
96
|
}),
|
|
90
97
|
);
|
|
@@ -105,7 +112,15 @@ export const useFormNavigation = (): FormNavigationHook => {
|
|
|
105
112
|
};
|
|
106
113
|
|
|
107
114
|
/**
|
|
108
|
-
*
|
|
115
|
+
* Hook that returns a function to update attributes of a form object.
|
|
116
|
+
* <br >
|
|
117
|
+
* The returned function accepts the following options:
|
|
118
|
+
*
|
|
119
|
+
* - autosubmit: Automatically submit the form after a change
|
|
120
|
+
* - autosav: Automatically save the form (in the background) after a change
|
|
121
|
+
* - autoupdate: Automatically update the current form object after a change
|
|
122
|
+
* - forceUpdate: Force the update even if conditions are not met.
|
|
123
|
+
* - validate: Activate/deactivate the form object validation by an update.
|
|
109
124
|
*/
|
|
110
125
|
export const useAttributeUpdate = (
|
|
111
126
|
form: FormModel,
|
|
@@ -744,7 +744,8 @@ export default class AttributeModel
|
|
|
744
744
|
/**
|
|
745
745
|
* Registers a missing error that was received from the server
|
|
746
746
|
*/
|
|
747
|
-
|
|
747
|
+
// eslint-disable-next-line no-unused-vars
|
|
748
|
+
addMissingError(receivedAttribute?: AttributeType): void {
|
|
748
749
|
this._errorCollection.addServerError("Constraint.Missing");
|
|
749
750
|
}
|
|
750
751
|
|
|
@@ -303,11 +303,19 @@ export default class ChoiceAttributeModel extends AttributeModel {
|
|
|
303
303
|
|
|
304
304
|
/**
|
|
305
305
|
*/
|
|
306
|
-
mergeAttribute(
|
|
306
|
+
mergeAttribute(
|
|
307
|
+
oldAttribute: AttributeType,
|
|
308
|
+
addNotExistingOptions: boolean = false,
|
|
309
|
+
removeNotExistingOptions: boolean = false,
|
|
310
|
+
) {
|
|
307
311
|
// when attribute is readonly, don't merge the options no modifications necessary
|
|
308
312
|
if (!this.readonly && oldAttribute instanceof ChoiceAttributeModel) {
|
|
309
313
|
this.concept = oldAttribute.concept;
|
|
310
|
-
this.options.mergeOptions(
|
|
314
|
+
this.options.mergeOptions(
|
|
315
|
+
oldAttribute.options,
|
|
316
|
+
addNotExistingOptions ?? this.type === "lookup",
|
|
317
|
+
removeNotExistingOptions,
|
|
318
|
+
);
|
|
311
319
|
this.options.deselectAll();
|
|
312
320
|
|
|
313
321
|
if (oldAttribute.isValid && oldAttribute.inputvalue !== null) {
|
|
@@ -354,6 +362,19 @@ export default class ChoiceAttributeModel extends AttributeModel {
|
|
|
354
362
|
return this;
|
|
355
363
|
}
|
|
356
364
|
|
|
365
|
+
/**
|
|
366
|
+
* Registers a missing error that was received from the server
|
|
367
|
+
*/
|
|
368
|
+
addMissingError(receivedAttribute?: AttributeType): void {
|
|
369
|
+
if (this.isChangedSince(0)) {
|
|
370
|
+
this._errorCollection.addServerError("Constraint.Missing");
|
|
371
|
+
}
|
|
372
|
+
// update choice options
|
|
373
|
+
if (receivedAttribute instanceof ChoiceAttributeModel) {
|
|
374
|
+
this.mergeAttribute(receivedAttribute, true, true);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
357
378
|
/**
|
|
358
379
|
*/
|
|
359
380
|
set hasContentConfiguration(hasContentConfiguration: boolean) {
|
|
@@ -309,15 +309,9 @@ class ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceAttribute
|
|
|
309
309
|
mergeOptions(
|
|
310
310
|
withOptions: ChoiceAttributeOptionCollection,
|
|
311
311
|
addNotExistingOptions: boolean = false,
|
|
312
|
+
removeNotExistingOptions: boolean = false,
|
|
312
313
|
) {
|
|
313
|
-
|
|
314
|
-
this.collection = [
|
|
315
|
-
...this.collection,
|
|
316
|
-
...withOptions.filter(
|
|
317
|
-
(option) => !this.collection.some((opt) => opt.code === option.code),
|
|
318
|
-
),
|
|
319
|
-
];
|
|
320
|
-
}
|
|
314
|
+
const newCollection = [];
|
|
321
315
|
|
|
322
316
|
this.collection.forEach((option) => {
|
|
323
317
|
const foundOption = withOptions.find(
|
|
@@ -325,8 +319,22 @@ class ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceAttribute
|
|
|
325
319
|
);
|
|
326
320
|
if (foundOption) {
|
|
327
321
|
option.mergeOption(foundOption);
|
|
322
|
+
newCollection.push(option);
|
|
323
|
+
} else if (!removeNotExistingOptions) {
|
|
324
|
+
newCollection.push(option);
|
|
328
325
|
}
|
|
329
326
|
});
|
|
327
|
+
|
|
328
|
+
if (addNotExistingOptions) {
|
|
329
|
+
this.collection = [
|
|
330
|
+
...newCollection,
|
|
331
|
+
...withOptions.filter(
|
|
332
|
+
(option) => !this.collection.some((opt) => opt.code === option.code),
|
|
333
|
+
),
|
|
334
|
+
];
|
|
335
|
+
} else {
|
|
336
|
+
this.collection = newCollection;
|
|
337
|
+
}
|
|
330
338
|
}
|
|
331
339
|
|
|
332
340
|
/**
|