@beinformed/ui 1.14.2 → 1.15.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/CHANGELOG.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [1.15.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.14.5...v1.15.0) (2022-03-17)
6
+
7
+ ### Features
8
+
9
+ - **hooks:** add useRetrieveFormsOnModel hook ([042ba49](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/042ba49b33e62c1b6ac18c594b7ec358a153394a))
10
+
11
+ ### [1.14.5](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.14.4...v1.14.5) (2022-03-15)
12
+
13
+ ### Bug Fixes
14
+
15
+ - **react-router:** use correct package and version of react-router ([eb6644b](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/eb6644b235a2b8e02cca9be66b2d7ed4d0063585))
16
+
17
+ ### [1.14.4](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.14.3...v1.14.4) (2022-03-14)
18
+
19
+ ### [1.14.3](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.14.0...v1.14.3) (2022-03-14)
20
+
21
+ ### Bug Fixes
22
+
23
+ - **scenario:** add settings for business scenario concept types ([#16](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/issues/16)) ([d8510c3](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/d8510c3c076b9a1c71a7c83083df297d04ff2efc))
24
+ - **scenario:** allow multiple scenario concept types ([89d9e4e](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/89d9e4e396e1375abc1230090fa8e1c9cdfa1a3c))
25
+
5
26
  ### [1.14.2](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.14.1...v1.14.2) (2022-03-12)
6
27
 
7
28
  ### Bug Fixes
@@ -13,4 +13,5 @@ export * from "./useNotification";
13
13
  export * from "./usePreference";
14
14
  export * from "./useProgressIndicator";
15
15
  export * from "./useRouter";
16
+ export * from "./useAllFormsOnModel";
16
17
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/index.js"],"names":[],"mappings":"AACA,cAAc,qBAAd;AACA,cAAc,cAAd;AACA,cAAc,WAAd;AACA,cAAc,WAAd;AACA,cAAc,YAAd;AACA,cAAc,mBAAd;AACA,cAAc,aAAd;AACA,cAAc,gBAAd;AACA,cAAc,qBAAd;AACA,cAAc,qBAAd;AACA,cAAc,uBAAd;AACA,cAAc,mBAAd;AACA,cAAc,iBAAd;AACA,cAAc,wBAAd;AACA,cAAc,aAAd","sourcesContent":["// @flow\nexport * from \"./useAuthentication\";\nexport * from \"./useContent\";\nexport * from \"./useForm\";\nexport * from \"./useI18n\";\nexport * from \"./useModal\";\nexport * from \"./useModelCatalog\";\nexport * from \"./useModels\";\nexport * from \"./useModularUI\";\nexport * from \"./useModularUIBasic\";\nexport * from \"./useModularUIModel\";\nexport * from \"./useModularUIRequest\";\nexport * from \"./useNotification\";\nexport * from \"./usePreference\";\nexport * from \"./useProgressIndicator\";\nexport * from \"./useRouter\";\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/hooks/index.js"],"names":[],"mappings":"AACA,cAAc,qBAAd;AACA,cAAc,cAAd;AACA,cAAc,WAAd;AACA,cAAc,WAAd;AACA,cAAc,YAAd;AACA,cAAc,mBAAd;AACA,cAAc,aAAd;AACA,cAAc,gBAAd;AACA,cAAc,qBAAd;AACA,cAAc,qBAAd;AACA,cAAc,uBAAd;AACA,cAAc,mBAAd;AACA,cAAc,iBAAd;AACA,cAAc,wBAAd;AACA,cAAc,aAAd;AACA,cAAc,sBAAd","sourcesContent":["// @flow\nexport * from \"./useAuthentication\";\nexport * from \"./useContent\";\nexport * from \"./useForm\";\nexport * from \"./useI18n\";\nexport * from \"./useModal\";\nexport * from \"./useModelCatalog\";\nexport * from \"./useModels\";\nexport * from \"./useModularUI\";\nexport * from \"./useModularUIBasic\";\nexport * from \"./useModularUIModel\";\nexport * from \"./useModularUIRequest\";\nexport * from \"./useNotification\";\nexport * from \"./usePreference\";\nexport * from \"./useProgressIndicator\";\nexport * from \"./useRouter\";\nexport * from \"./useAllFormsOnModel\";\n"],"file":"index.js"}
@@ -0,0 +1,110 @@
1
+ import _toConsumableArray from "@babel/runtime-corejs3/helpers/esm/toConsumableArray";
2
+ import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
3
+ import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
4
+ import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
5
+ import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
6
+ import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
7
+ import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
8
+ import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
9
+ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
10
+ import { useState, useEffect } from "react";
11
+ import { useModularUIRequest } from "./useModularUIRequest";
12
+ import { HTTP_METHODS } from "../constants";
13
+ import ListModel from "../models/list/ListModel";
14
+ import FormModel from "../models/form/FormModel";
15
+
16
+ /**
17
+ * Retrieve all forms configured on a model with actions
18
+ * @param model
19
+ * @returns Object - { actionName: FormModel }
20
+ */
21
+ export var useRetrieveFormsOnModel = function useRetrieveFormsOnModel(model) {
22
+ var modularui = useModularUIRequest();
23
+
24
+ var _useState = useState(null),
25
+ _useState2 = _slicedToArray(_useState, 2),
26
+ forms = _useState2[0],
27
+ setForms = _useState2[1];
28
+
29
+ var _useState3 = useState(0),
30
+ _useState4 = _slicedToArray(_useState3, 2),
31
+ requestCount = _useState4[0],
32
+ setRequestCount = _useState4[1];
33
+
34
+ var _useState5 = useState(0),
35
+ _useState6 = _slicedToArray(_useState5, 2),
36
+ responseCount = _useState6[0],
37
+ setResponseCount = _useState6[1];
38
+
39
+ useEffect(function () {
40
+ var _context;
41
+
42
+ var requests = _mapInstanceProperty(_context = getActions(model)).call(_context, function (action) {
43
+ var href = action.selfhref.addParameter("commit", "false");
44
+ return modularui(href, {
45
+ method: HTTP_METHODS.POST
46
+ }).fetch().then(function (form) {
47
+ if (form instanceof FormModel) {
48
+ form.tokens = [];
49
+ }
50
+
51
+ return _defineProperty({}, action.name, form);
52
+ });
53
+ });
54
+
55
+ setRequestCount(requests.length);
56
+
57
+ _Promise.all(requests).then(function (responses) {
58
+ var _context2;
59
+
60
+ // put response array in object
61
+ var actionForms = _Object$assign.apply(Object, _concatInstanceProperty(_context2 = [{}]).call(_context2, _toConsumableArray(responses)));
62
+
63
+ setForms(actionForms);
64
+ setResponseCount(responses.length);
65
+ });
66
+ }, [model, modularui]);
67
+
68
+ if (responseCount === requestCount) {
69
+ return forms;
70
+ }
71
+
72
+ return null;
73
+ };
74
+
75
+ var getActions = function getActions(model) {
76
+ var _context3;
77
+
78
+ if (!model.actionCollection) {
79
+ return [];
80
+ }
81
+
82
+ var createActions = _filterInstanceProperty(_context3 = model.actionCollection.getActionsByType("create")).call(_context3, function (action) {
83
+ return !action.isDisabled;
84
+ });
85
+
86
+ var allActions = _toConsumableArray(createActions);
87
+
88
+ if (model instanceof ListModel) {
89
+ model.listItemCollection.forEach(function (listItem) {
90
+ var _context4;
91
+
92
+ var updateActions = _filterInstanceProperty(_context4 = listItem.actionCollection.getActionsByType("update")).call(_context4, function (action) {
93
+ return !action.isDisabled;
94
+ });
95
+
96
+ allActions.push.apply(allActions, _toConsumableArray(updateActions));
97
+ });
98
+ }
99
+
100
+ var actions = [];
101
+ var unique = [];
102
+ allActions.forEach(function (action) {
103
+ if (!_includesInstanceProperty(unique).call(unique, action.name)) {
104
+ unique.push(action.name);
105
+ actions.push(action);
106
+ }
107
+ });
108
+ return actions;
109
+ };
110
+ //# sourceMappingURL=useAllFormsOnModel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/useAllFormsOnModel.js"],"names":["useState","useEffect","useModularUIRequest","HTTP_METHODS","ListModel","FormModel","useRetrieveFormsOnModel","model","modularui","forms","setForms","requestCount","setRequestCount","responseCount","setResponseCount","requests","getActions","action","href","selfhref","addParameter","method","POST","fetch","then","form","tokens","name","length","all","responses","actionForms","Object","actionCollection","createActions","getActionsByType","isDisabled","allActions","listItemCollection","forEach","listItem","updateActions","push","actions","unique"],"mappings":"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","sourcesContent":["// @flow\nimport { useState, useEffect } from \"react\";\n\nimport { useModularUIRequest } from \"./useModularUIRequest\";\n\nimport { HTTP_METHODS } from \"../constants\";\n\nimport ListModel from \"../models/list/ListModel\";\nimport FormModel from \"../models/form/FormModel\";\n\nimport type DetailModel from \"../models/detail/DetailModel\";\nimport type TabModel from \"../models/tab/TabModel\";\nimport type ActionModel from \"../models/actions/ActionModel\";\n\n/**\n * Retrieve all forms configured on a model with actions\n * @param model\n * @returns Object - { actionName: FormModel }\n */\nexport const useRetrieveFormsOnModel = (\n model: ListModel | DetailModel | TabModel\n): null | { [actionName: string]: FormModel } => {\n const modularui = useModularUIRequest();\n const [forms, setForms] = useState(null);\n const [requestCount, setRequestCount] = useState(0);\n const [responseCount, setResponseCount] = useState(0);\n\n useEffect(() => {\n const requests = getActions(model).map((action) => {\n const href = action.selfhref.addParameter(\"commit\", \"false\");\n\n return modularui(href, { method: HTTP_METHODS.POST })\n .fetch()\n .then((form) => {\n if (form instanceof FormModel) {\n form.tokens = [];\n }\n return { [action.name]: form };\n });\n });\n\n setRequestCount(requests.length);\n\n Promise.all(requests).then((responses) => {\n // put response array in object\n const actionForms = Object.assign({}, ...responses);\n setForms(actionForms);\n setResponseCount(responses.length);\n });\n }, [model, modularui]);\n\n if (responseCount === requestCount) {\n return forms;\n }\n\n return null;\n};\n\nconst getActions = (\n model: ListModel | DetailModel | TabModel\n): Array<ActionModel> => {\n if (!model.actionCollection) {\n return [];\n }\n\n const createActions = model.actionCollection\n .getActionsByType(\"create\")\n .filter((action) => !action.isDisabled);\n\n const allActions = [...createActions];\n\n if (model instanceof ListModel) {\n model.listItemCollection.forEach((listItem) => {\n const updateActions = listItem.actionCollection\n .getActionsByType(\"update\")\n .filter((action) => !action.isDisabled);\n\n allActions.push(...updateActions);\n });\n }\n\n const actions = [];\n const unique = [];\n allActions.forEach((action) => {\n if (!unique.includes(action.name)) {\n unique.push(action.name);\n actions.push(action);\n }\n });\n\n return actions;\n};\n"],"file":"useAllFormsOnModel.js"}
@@ -11,7 +11,8 @@ export var updateFormAttribute = function updateFormAttribute(form, formObject,
11
11
  var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
12
12
  autosubmit: false,
13
13
  autosave: false,
14
- forceUpdate: false
14
+ forceUpdate: false,
15
+ validate: true
15
16
  };
16
17
  return function (dispatch) {
17
18
  var newForm = form.clone();
@@ -38,7 +39,7 @@ export var updateFormAttribute = function updateFormAttribute(form, formObject,
38
39
  dispatch(autosaveFormObject(newForm));
39
40
  }
40
41
 
41
- if (newForm.currentFormObject && newForm.currentFormObject.hasDynamicValidations && getSetting("USE_INSTANT_SERVER_VALIDATION")) {
42
+ if (newForm.currentFormObject && options.validate && newForm.currentFormObject.hasDynamicValidations && getSetting("USE_INSTANT_SERVER_VALIDATION")) {
42
43
  dispatch(validateFormObject(newForm));
43
44
  }
44
45
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/redux/actions/FormAttributeSet.js"],"names":["updateModel","getSetting","validateFormObject","autosaveFormObject","autosubmitFormObject","updateFormAttribute","form","formObject","attribute","inputvalue","options","autosubmit","autosave","forceUpdate","dispatch","newForm","clone","currentFormObject","equals","updateAttribute","completedFormObjects","forEach","completeObject","isValid","autosubmitAction","isChanged","hasDynamicValidations"],"mappings":"AACA,SAASA,WAAT,QAA4B,uBAA5B;AAEA,SAASC,UAAT,QAA2B,0BAA3B;AAEA,SAASC,kBAAT,QAAmC,mBAAnC;AACA,SAASC,kBAAT,QAAmC,gBAAnC;AACA,SAASC,oBAAT,QAAqC,kBAArC;;AAOA;AACA;AACA;AACA,OAAO,IAAMC,mBAAmB,GAC9B,SADWA,mBACX,CACEC,IADF,EAEEC,UAFF,EAGEC,SAHF,EAIEC,UAJF;AAAA,MAKEC,OALF,uEAK+B;AAC3BC,IAAAA,UAAU,EAAE,KADe;AAE3BC,IAAAA,QAAQ,EAAE,KAFiB;AAG3BC,IAAAA,WAAW,EAAE;AAHc,GAL/B;AAAA,SAWA,UAACC,QAAD,EAAwB;AACtB,QAAMC,OAAO,GAAGT,IAAI,CAACU,KAAL,EAAhB;;AAEA,QACED,OAAO,CAACE,iBAAR,IACAF,OAAO,CAACE,iBAAR,CAA0BC,MAA1B,CAAiCX,UAAjC,CAFF,EAGE;AACAQ,MAAAA,OAAO,CAACE,iBAAR,CAA0BE,eAA1B,CAA0CX,SAA1C,EAAqDC,UAArD;AACD,KALD,MAKO;AACLM,MAAAA,OAAO,CAACK,oBAAR,CAA6BC,OAA7B,CAAqC,UAACC,cAAD,EAAoB;AACvD,YAAIA,cAAc,CAACJ,MAAf,CAAsBX,UAAtB,CAAJ,EAAuC;AACrCe,UAAAA,cAAc,CAACH,eAAf,CAA+BX,SAA/B,EAA0CC,UAA1C;AACD;AACF,OAJD;AAKD;;AAED,QAAIC,OAAO,CAACC,UAAR,IAAsBI,OAAO,CAACQ,OAAlC,EAA2C;AACzC,UAAMC,gBAAgB,GAAGpB,oBAAoB,CAC3CW,OAD2C,EAE3CP,SAF2C,EAG3CE,OAAO,CAACG,WAHmC,CAA7C;;AAKA,UAAIW,gBAAJ,EAAsB;AACpB,eAAOV,QAAQ,CAACU,gBAAD,CAAf;AACD;AACF;;AAED,QAAId,OAAO,CAACE,QAAR,IAAoBG,OAAO,CAACQ,OAA5B,IAAuCR,OAAO,CAACU,SAAR,EAA3C,EAAgE;AAC9DX,MAAAA,QAAQ,CAACX,kBAAkB,CAACY,OAAD,CAAnB,CAAR;AACD;;AAED,QACEA,OAAO,CAACE,iBAAR,IACAF,OAAO,CAACE,iBAAR,CAA0BS,qBAD1B,IAEAzB,UAAU,CAAC,+BAAD,CAHZ,EAIE;AACAa,MAAAA,QAAQ,CAACZ,kBAAkB,CAACa,OAAD,CAAnB,CAAR;AACD;;AAED,WAAOD,QAAQ,CAACd,WAAW,CAACe,OAAD,CAAZ,CAAf;AACD,GAnDD;AAAA,CADK","sourcesContent":["// @flow\nimport { updateModel } from \"../_modularui/actions\";\n\nimport { getSetting } from \"../../constants/Settings\";\n\nimport { validateFormObject } from \"./FormValidations\";\nimport { autosaveFormObject } from \"./FormAutosave\";\nimport { autosubmitFormObject } from \"./FormAutosubmit\";\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,\n forceUpdate: false,\n }\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n const newForm = form.clone();\n\n if (\n newForm.currentFormObject &&\n newForm.currentFormObject.equals(formObject)\n ) {\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.autosave && newForm.isValid && newForm.isChanged()) {\n dispatch(autosaveFormObject(newForm));\n }\n\n if (\n newForm.currentFormObject &&\n newForm.currentFormObject.hasDynamicValidations &&\n getSetting(\"USE_INSTANT_SERVER_VALIDATION\")\n ) {\n dispatch(validateFormObject(newForm));\n }\n\n return dispatch(updateModel(newForm));\n };\n"],"file":"FormAttributeSet.js"}
1
+ {"version":3,"sources":["../../../src/redux/actions/FormAttributeSet.js"],"names":["updateModel","getSetting","validateFormObject","autosaveFormObject","autosubmitFormObject","updateFormAttribute","form","formObject","attribute","inputvalue","options","autosubmit","autosave","forceUpdate","validate","dispatch","newForm","clone","currentFormObject","equals","updateAttribute","completedFormObjects","forEach","completeObject","isValid","autosubmitAction","isChanged","hasDynamicValidations"],"mappings":"AACA,SAASA,WAAT,QAA4B,uBAA5B;AAEA,SAASC,UAAT,QAA2B,0BAA3B;AAEA,SAASC,kBAAT,QAAmC,mBAAnC;AACA,SAASC,kBAAT,QAAmC,gBAAnC;AACA,SAASC,oBAAT,QAAqC,kBAArC;;AAOA;AACA;AACA;AACA,OAAO,IAAMC,mBAAmB,GAC9B,SADWA,mBACX,CACEC,IADF,EAEEC,UAFF,EAGEC,SAHF,EAIEC,UAJF;AAAA,MAKEC,OALF,uEAK+B;AAC3BC,IAAAA,UAAU,EAAE,KADe;AAE3BC,IAAAA,QAAQ,EAAE,KAFiB;AAG3BC,IAAAA,WAAW,EAAE,KAHc;AAI3BC,IAAAA,QAAQ,EAAE;AAJiB,GAL/B;AAAA,SAYA,UAACC,QAAD,EAAwB;AACtB,QAAMC,OAAO,GAAGV,IAAI,CAACW,KAAL,EAAhB;;AAEA,QACED,OAAO,CAACE,iBAAR,IACAF,OAAO,CAACE,iBAAR,CAA0BC,MAA1B,CAAiCZ,UAAjC,CAFF,EAGE;AACAS,MAAAA,OAAO,CAACE,iBAAR,CAA0BE,eAA1B,CAA0CZ,SAA1C,EAAqDC,UAArD;AACD,KALD,MAKO;AACLO,MAAAA,OAAO,CAACK,oBAAR,CAA6BC,OAA7B,CAAqC,UAACC,cAAD,EAAoB;AACvD,YAAIA,cAAc,CAACJ,MAAf,CAAsBZ,UAAtB,CAAJ,EAAuC;AACrCgB,UAAAA,cAAc,CAACH,eAAf,CAA+BZ,SAA/B,EAA0CC,UAA1C;AACD;AACF,OAJD;AAKD;;AAED,QAAIC,OAAO,CAACC,UAAR,IAAsBK,OAAO,CAACQ,OAAlC,EAA2C;AACzC,UAAMC,gBAAgB,GAAGrB,oBAAoB,CAC3CY,OAD2C,EAE3CR,SAF2C,EAG3CE,OAAO,CAACG,WAHmC,CAA7C;;AAKA,UAAIY,gBAAJ,EAAsB;AACpB,eAAOV,QAAQ,CAACU,gBAAD,CAAf;AACD;AACF;;AAED,QAAIf,OAAO,CAACE,QAAR,IAAoBI,OAAO,CAACQ,OAA5B,IAAuCR,OAAO,CAACU,SAAR,EAA3C,EAAgE;AAC9DX,MAAAA,QAAQ,CAACZ,kBAAkB,CAACa,OAAD,CAAnB,CAAR;AACD;;AAED,QACEA,OAAO,CAACE,iBAAR,IACAR,OAAO,CAACI,QADR,IAEAE,OAAO,CAACE,iBAAR,CAA0BS,qBAF1B,IAGA1B,UAAU,CAAC,+BAAD,CAJZ,EAKE;AACAc,MAAAA,QAAQ,CAACb,kBAAkB,CAACc,OAAD,CAAnB,CAAR;AACD;;AAED,WAAOD,QAAQ,CAACf,WAAW,CAACgB,OAAD,CAAZ,CAAf;AACD,GArDD;AAAA,CADK","sourcesContent":["// @flow\nimport { updateModel } from \"../_modularui/actions\";\n\nimport { getSetting } from \"../../constants/Settings\";\n\nimport { validateFormObject } from \"./FormValidations\";\nimport { autosaveFormObject } from \"./FormAutosave\";\nimport { autosubmitFormObject } from \"./FormAutosubmit\";\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,\n forceUpdate: false,\n validate: true,\n }\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n const newForm = form.clone();\n\n if (\n newForm.currentFormObject &&\n newForm.currentFormObject.equals(formObject)\n ) {\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.autosave && newForm.isValid && newForm.isChanged()) {\n dispatch(autosaveFormObject(newForm));\n }\n\n if (\n newForm.currentFormObject &&\n options.validate &&\n newForm.currentFormObject.hasDynamicValidations &&\n getSetting(\"USE_INSTANT_SERVER_VALIDATION\")\n ) {\n dispatch(validateFormObject(newForm));\n }\n\n return dispatch(updateModel(newForm));\n };\n"],"file":"FormAttributeSet.js"}
@@ -200,4 +200,17 @@ _Object$keys(_useRouter).forEach(function (key) {
200
200
  }
201
201
  });
202
202
  });
203
+
204
+ var _useAllFormsOnModel = require("./useAllFormsOnModel");
205
+
206
+ _Object$keys(_useAllFormsOnModel).forEach(function (key) {
207
+ if (key === "default" || key === "__esModule") return;
208
+ if (key in exports && exports[key] === _useAllFormsOnModel[key]) return;
209
+ Object.defineProperty(exports, key, {
210
+ enumerable: true,
211
+ get: function get() {
212
+ return _useAllFormsOnModel[key];
213
+ }
214
+ });
215
+ });
203
216
  //# sourceMappingURL=index.js.map
@@ -14,3 +14,4 @@ export * from "./useNotification";
14
14
  export * from "./usePreference";
15
15
  export * from "./useProgressIndicator";
16
16
  export * from "./useRouter";
17
+ export * from "./useAllFormsOnModel";
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/index.js"],"names":[],"mappings":";;;;;;;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["// @flow\nexport * from \"./useAuthentication\";\nexport * from \"./useContent\";\nexport * from \"./useForm\";\nexport * from \"./useI18n\";\nexport * from \"./useModal\";\nexport * from \"./useModelCatalog\";\nexport * from \"./useModels\";\nexport * from \"./useModularUI\";\nexport * from \"./useModularUIBasic\";\nexport * from \"./useModularUIModel\";\nexport * from \"./useModularUIRequest\";\nexport * from \"./useNotification\";\nexport * from \"./usePreference\";\nexport * from \"./useProgressIndicator\";\nexport * from \"./useRouter\";\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../../src/hooks/index.js"],"names":[],"mappings":";;;;;;;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["// @flow\nexport * from \"./useAuthentication\";\nexport * from \"./useContent\";\nexport * from \"./useForm\";\nexport * from \"./useI18n\";\nexport * from \"./useModal\";\nexport * from \"./useModelCatalog\";\nexport * from \"./useModels\";\nexport * from \"./useModularUI\";\nexport * from \"./useModularUIBasic\";\nexport * from \"./useModularUIModel\";\nexport * from \"./useModularUIRequest\";\nexport * from \"./useNotification\";\nexport * from \"./usePreference\";\nexport * from \"./useProgressIndicator\";\nexport * from \"./useRouter\";\nexport * from \"./useAllFormsOnModel\";\n"],"file":"index.js"}
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.useRetrieveFormsOnModel = void 0;
9
+
10
+ var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
11
+
12
+ var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
13
+
14
+ var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
15
+
16
+ var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
17
+
18
+ var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
19
+
20
+ var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
21
+
22
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/toConsumableArray"));
23
+
24
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
25
+
26
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
27
+
28
+ var _react = require("react");
29
+
30
+ var _useModularUIRequest = require("./useModularUIRequest");
31
+
32
+ var _constants = require("../constants");
33
+
34
+ var _ListModel = _interopRequireDefault(require("../models/list/ListModel"));
35
+
36
+ var _FormModel = _interopRequireDefault(require("../models/form/FormModel"));
37
+
38
+ /**
39
+ * Retrieve all forms configured on a model with actions
40
+ * @param model
41
+ * @returns Object - { actionName: FormModel }
42
+ */
43
+ var useRetrieveFormsOnModel = function useRetrieveFormsOnModel(model) {
44
+ var modularui = (0, _useModularUIRequest.useModularUIRequest)();
45
+
46
+ var _useState = (0, _react.useState)(null),
47
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
48
+ forms = _useState2[0],
49
+ setForms = _useState2[1];
50
+
51
+ var _useState3 = (0, _react.useState)(0),
52
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
53
+ requestCount = _useState4[0],
54
+ setRequestCount = _useState4[1];
55
+
56
+ var _useState5 = (0, _react.useState)(0),
57
+ _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
58
+ responseCount = _useState6[0],
59
+ setResponseCount = _useState6[1];
60
+
61
+ (0, _react.useEffect)(function () {
62
+ var _context;
63
+
64
+ var requests = (0, _map.default)(_context = getActions(model)).call(_context, function (action) {
65
+ var href = action.selfhref.addParameter("commit", "false");
66
+ return modularui(href, {
67
+ method: _constants.HTTP_METHODS.POST
68
+ }).fetch().then(function (form) {
69
+ if (form instanceof _FormModel.default) {
70
+ form.tokens = [];
71
+ }
72
+
73
+ return (0, _defineProperty2.default)({}, action.name, form);
74
+ });
75
+ });
76
+ setRequestCount(requests.length);
77
+
78
+ _promise.default.all(requests).then(function (responses) {
79
+ var _context2;
80
+
81
+ // put response array in object
82
+ var actionForms = _assign.default.apply(Object, (0, _concat.default)(_context2 = [{}]).call(_context2, (0, _toConsumableArray2.default)(responses)));
83
+
84
+ setForms(actionForms);
85
+ setResponseCount(responses.length);
86
+ });
87
+ }, [model, modularui]);
88
+
89
+ if (responseCount === requestCount) {
90
+ return forms;
91
+ }
92
+
93
+ return null;
94
+ };
95
+
96
+ exports.useRetrieveFormsOnModel = useRetrieveFormsOnModel;
97
+
98
+ var getActions = function getActions(model) {
99
+ var _context3;
100
+
101
+ if (!model.actionCollection) {
102
+ return [];
103
+ }
104
+
105
+ var createActions = (0, _filter.default)(_context3 = model.actionCollection.getActionsByType("create")).call(_context3, function (action) {
106
+ return !action.isDisabled;
107
+ });
108
+ var allActions = (0, _toConsumableArray2.default)(createActions);
109
+
110
+ if (model instanceof _ListModel.default) {
111
+ model.listItemCollection.forEach(function (listItem) {
112
+ var _context4;
113
+
114
+ var updateActions = (0, _filter.default)(_context4 = listItem.actionCollection.getActionsByType("update")).call(_context4, function (action) {
115
+ return !action.isDisabled;
116
+ });
117
+ allActions.push.apply(allActions, (0, _toConsumableArray2.default)(updateActions));
118
+ });
119
+ }
120
+
121
+ var actions = [];
122
+ var unique = [];
123
+ allActions.forEach(function (action) {
124
+ if (!(0, _includes.default)(unique).call(unique, action.name)) {
125
+ unique.push(action.name);
126
+ actions.push(action);
127
+ }
128
+ });
129
+ return actions;
130
+ };
131
+ //# sourceMappingURL=useAllFormsOnModel.js.map
@@ -0,0 +1,92 @@
1
+ // @flow
2
+ import { useState, useEffect } from "react";
3
+
4
+ import { useModularUIRequest } from "./useModularUIRequest";
5
+
6
+ import { HTTP_METHODS } from "../constants";
7
+
8
+ import ListModel from "../models/list/ListModel";
9
+ import FormModel from "../models/form/FormModel";
10
+
11
+ import type DetailModel from "../models/detail/DetailModel";
12
+ import type TabModel from "../models/tab/TabModel";
13
+ import type ActionModel from "../models/actions/ActionModel";
14
+
15
+ /**
16
+ * Retrieve all forms configured on a model with actions
17
+ * @param model
18
+ * @returns Object - { actionName: FormModel }
19
+ */
20
+ export const useRetrieveFormsOnModel = (
21
+ model: ListModel | DetailModel | TabModel
22
+ ): null | { [actionName: string]: FormModel } => {
23
+ const modularui = useModularUIRequest();
24
+ const [forms, setForms] = useState(null);
25
+ const [requestCount, setRequestCount] = useState(0);
26
+ const [responseCount, setResponseCount] = useState(0);
27
+
28
+ useEffect(() => {
29
+ const requests = getActions(model).map((action) => {
30
+ const href = action.selfhref.addParameter("commit", "false");
31
+
32
+ return modularui(href, { method: HTTP_METHODS.POST })
33
+ .fetch()
34
+ .then((form) => {
35
+ if (form instanceof FormModel) {
36
+ form.tokens = [];
37
+ }
38
+ return { [action.name]: form };
39
+ });
40
+ });
41
+
42
+ setRequestCount(requests.length);
43
+
44
+ Promise.all(requests).then((responses) => {
45
+ // put response array in object
46
+ const actionForms = Object.assign({}, ...responses);
47
+ setForms(actionForms);
48
+ setResponseCount(responses.length);
49
+ });
50
+ }, [model, modularui]);
51
+
52
+ if (responseCount === requestCount) {
53
+ return forms;
54
+ }
55
+
56
+ return null;
57
+ };
58
+
59
+ const getActions = (
60
+ model: ListModel | DetailModel | TabModel
61
+ ): Array<ActionModel> => {
62
+ if (!model.actionCollection) {
63
+ return [];
64
+ }
65
+
66
+ const createActions = model.actionCollection
67
+ .getActionsByType("create")
68
+ .filter((action) => !action.isDisabled);
69
+
70
+ const allActions = [...createActions];
71
+
72
+ if (model instanceof ListModel) {
73
+ model.listItemCollection.forEach((listItem) => {
74
+ const updateActions = listItem.actionCollection
75
+ .getActionsByType("update")
76
+ .filter((action) => !action.isDisabled);
77
+
78
+ allActions.push(...updateActions);
79
+ });
80
+ }
81
+
82
+ const actions = [];
83
+ const unique = [];
84
+ allActions.forEach((action) => {
85
+ if (!unique.includes(action.name)) {
86
+ unique.push(action.name);
87
+ actions.push(action);
88
+ }
89
+ });
90
+
91
+ return actions;
92
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/useAllFormsOnModel.js"],"names":["useRetrieveFormsOnModel","model","modularui","forms","setForms","requestCount","setRequestCount","responseCount","setResponseCount","requests","getActions","action","href","selfhref","addParameter","method","HTTP_METHODS","POST","fetch","then","form","FormModel","tokens","name","length","all","responses","actionForms","Object","actionCollection","createActions","getActionsByType","isDisabled","allActions","ListModel","listItemCollection","forEach","listItem","updateActions","push","actions","unique"],"mappings":"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","sourcesContent":["// @flow\nimport { useState, useEffect } from \"react\";\n\nimport { useModularUIRequest } from \"./useModularUIRequest\";\n\nimport { HTTP_METHODS } from \"../constants\";\n\nimport ListModel from \"../models/list/ListModel\";\nimport FormModel from \"../models/form/FormModel\";\n\nimport type DetailModel from \"../models/detail/DetailModel\";\nimport type TabModel from \"../models/tab/TabModel\";\nimport type ActionModel from \"../models/actions/ActionModel\";\n\n/**\n * Retrieve all forms configured on a model with actions\n * @param model\n * @returns Object - { actionName: FormModel }\n */\nexport const useRetrieveFormsOnModel = (\n model: ListModel | DetailModel | TabModel\n): null | { [actionName: string]: FormModel } => {\n const modularui = useModularUIRequest();\n const [forms, setForms] = useState(null);\n const [requestCount, setRequestCount] = useState(0);\n const [responseCount, setResponseCount] = useState(0);\n\n useEffect(() => {\n const requests = getActions(model).map((action) => {\n const href = action.selfhref.addParameter(\"commit\", \"false\");\n\n return modularui(href, { method: HTTP_METHODS.POST })\n .fetch()\n .then((form) => {\n if (form instanceof FormModel) {\n form.tokens = [];\n }\n return { [action.name]: form };\n });\n });\n\n setRequestCount(requests.length);\n\n Promise.all(requests).then((responses) => {\n // put response array in object\n const actionForms = Object.assign({}, ...responses);\n setForms(actionForms);\n setResponseCount(responses.length);\n });\n }, [model, modularui]);\n\n if (responseCount === requestCount) {\n return forms;\n }\n\n return null;\n};\n\nconst getActions = (\n model: ListModel | DetailModel | TabModel\n): Array<ActionModel> => {\n if (!model.actionCollection) {\n return [];\n }\n\n const createActions = model.actionCollection\n .getActionsByType(\"create\")\n .filter((action) => !action.isDisabled);\n\n const allActions = [...createActions];\n\n if (model instanceof ListModel) {\n model.listItemCollection.forEach((listItem) => {\n const updateActions = listItem.actionCollection\n .getActionsByType(\"update\")\n .filter((action) => !action.isDisabled);\n\n allActions.push(...updateActions);\n });\n }\n\n const actions = [];\n const unique = [];\n allActions.forEach((action) => {\n if (!unique.includes(action.name)) {\n unique.push(action.name);\n actions.push(action);\n }\n });\n\n return actions;\n};\n"],"file":"useAllFormsOnModel.js"}
@@ -22,7 +22,8 @@ var updateFormAttribute = function updateFormAttribute(form, formObject, attribu
22
22
  var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
23
23
  autosubmit: false,
24
24
  autosave: false,
25
- forceUpdate: false
25
+ forceUpdate: false,
26
+ validate: true
26
27
  };
27
28
  return function (dispatch) {
28
29
  var newForm = form.clone();
@@ -49,7 +50,7 @@ var updateFormAttribute = function updateFormAttribute(form, formObject, attribu
49
50
  dispatch((0, _FormAutosave.autosaveFormObject)(newForm));
50
51
  }
51
52
 
52
- if (newForm.currentFormObject && newForm.currentFormObject.hasDynamicValidations && (0, _Settings.getSetting)("USE_INSTANT_SERVER_VALIDATION")) {
53
+ if (newForm.currentFormObject && options.validate && newForm.currentFormObject.hasDynamicValidations && (0, _Settings.getSetting)("USE_INSTANT_SERVER_VALIDATION")) {
53
54
  dispatch((0, _FormValidations.validateFormObject)(newForm));
54
55
  }
55
56
 
@@ -25,6 +25,7 @@ export const updateFormAttribute =
25
25
  autosubmit: false,
26
26
  autosave: false,
27
27
  forceUpdate: false,
28
+ validate: true,
28
29
  }
29
30
  ): ThunkAction =>
30
31
  (dispatch: Dispatch) => {
@@ -60,6 +61,7 @@ export const updateFormAttribute =
60
61
 
61
62
  if (
62
63
  newForm.currentFormObject &&
64
+ options.validate &&
63
65
  newForm.currentFormObject.hasDynamicValidations &&
64
66
  getSetting("USE_INSTANT_SERVER_VALIDATION")
65
67
  ) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/redux/actions/FormAttributeSet.js"],"names":["updateFormAttribute","form","formObject","attribute","inputvalue","options","autosubmit","autosave","forceUpdate","dispatch","newForm","clone","currentFormObject","equals","updateAttribute","completedFormObjects","forEach","completeObject","isValid","autosubmitAction","isChanged","hasDynamicValidations"],"mappings":";;;;;;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AAOA;AACA;AACA;AACO,IAAMA,mBAAmB,GAC9B,SADWA,mBACX,CACEC,IADF,EAEEC,UAFF,EAGEC,SAHF,EAIEC,UAJF;AAAA,MAKEC,OALF,uEAK+B;AAC3BC,IAAAA,UAAU,EAAE,KADe;AAE3BC,IAAAA,QAAQ,EAAE,KAFiB;AAG3BC,IAAAA,WAAW,EAAE;AAHc,GAL/B;AAAA,SAWA,UAACC,QAAD,EAAwB;AACtB,QAAMC,OAAO,GAAGT,IAAI,CAACU,KAAL,EAAhB;;AAEA,QACED,OAAO,CAACE,iBAAR,IACAF,OAAO,CAACE,iBAAR,CAA0BC,MAA1B,CAAiCX,UAAjC,CAFF,EAGE;AACAQ,MAAAA,OAAO,CAACE,iBAAR,CAA0BE,eAA1B,CAA0CX,SAA1C,EAAqDC,UAArD;AACD,KALD,MAKO;AACLM,MAAAA,OAAO,CAACK,oBAAR,CAA6BC,OAA7B,CAAqC,UAACC,cAAD,EAAoB;AACvD,YAAIA,cAAc,CAACJ,MAAf,CAAsBX,UAAtB,CAAJ,EAAuC;AACrCe,UAAAA,cAAc,CAACH,eAAf,CAA+BX,SAA/B,EAA0CC,UAA1C;AACD;AACF,OAJD;AAKD;;AAED,QAAIC,OAAO,CAACC,UAAR,IAAsBI,OAAO,CAACQ,OAAlC,EAA2C;AACzC,UAAMC,gBAAgB,GAAG,0CACvBT,OADuB,EAEvBP,SAFuB,EAGvBE,OAAO,CAACG,WAHe,CAAzB;;AAKA,UAAIW,gBAAJ,EAAsB;AACpB,eAAOV,QAAQ,CAACU,gBAAD,CAAf;AACD;AACF;;AAED,QAAId,OAAO,CAACE,QAAR,IAAoBG,OAAO,CAACQ,OAA5B,IAAuCR,OAAO,CAACU,SAAR,EAA3C,EAAgE;AAC9DX,MAAAA,QAAQ,CAAC,sCAAmBC,OAAnB,CAAD,CAAR;AACD;;AAED,QACEA,OAAO,CAACE,iBAAR,IACAF,OAAO,CAACE,iBAAR,CAA0BS,qBAD1B,IAEA,0BAAW,+BAAX,CAHF,EAIE;AACAZ,MAAAA,QAAQ,CAAC,yCAAmBC,OAAnB,CAAD,CAAR;AACD;;AAED,WAAOD,QAAQ,CAAC,0BAAYC,OAAZ,CAAD,CAAf;AACD,GAnDD;AAAA,CADK","sourcesContent":["// @flow\nimport { updateModel } from \"../_modularui/actions\";\n\nimport { getSetting } from \"../../constants/Settings\";\n\nimport { validateFormObject } from \"./FormValidations\";\nimport { autosaveFormObject } from \"./FormAutosave\";\nimport { autosubmitFormObject } from \"./FormAutosubmit\";\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,\n forceUpdate: false,\n }\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n const newForm = form.clone();\n\n if (\n newForm.currentFormObject &&\n newForm.currentFormObject.equals(formObject)\n ) {\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.autosave && newForm.isValid && newForm.isChanged()) {\n dispatch(autosaveFormObject(newForm));\n }\n\n if (\n newForm.currentFormObject &&\n newForm.currentFormObject.hasDynamicValidations &&\n getSetting(\"USE_INSTANT_SERVER_VALIDATION\")\n ) {\n dispatch(validateFormObject(newForm));\n }\n\n return dispatch(updateModel(newForm));\n };\n"],"file":"FormAttributeSet.js"}
1
+ {"version":3,"sources":["../../../src/redux/actions/FormAttributeSet.js"],"names":["updateFormAttribute","form","formObject","attribute","inputvalue","options","autosubmit","autosave","forceUpdate","validate","dispatch","newForm","clone","currentFormObject","equals","updateAttribute","completedFormObjects","forEach","completeObject","isValid","autosubmitAction","isChanged","hasDynamicValidations"],"mappings":";;;;;;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AAOA;AACA;AACA;AACO,IAAMA,mBAAmB,GAC9B,SADWA,mBACX,CACEC,IADF,EAEEC,UAFF,EAGEC,SAHF,EAIEC,UAJF;AAAA,MAKEC,OALF,uEAK+B;AAC3BC,IAAAA,UAAU,EAAE,KADe;AAE3BC,IAAAA,QAAQ,EAAE,KAFiB;AAG3BC,IAAAA,WAAW,EAAE,KAHc;AAI3BC,IAAAA,QAAQ,EAAE;AAJiB,GAL/B;AAAA,SAYA,UAACC,QAAD,EAAwB;AACtB,QAAMC,OAAO,GAAGV,IAAI,CAACW,KAAL,EAAhB;;AAEA,QACED,OAAO,CAACE,iBAAR,IACAF,OAAO,CAACE,iBAAR,CAA0BC,MAA1B,CAAiCZ,UAAjC,CAFF,EAGE;AACAS,MAAAA,OAAO,CAACE,iBAAR,CAA0BE,eAA1B,CAA0CZ,SAA1C,EAAqDC,UAArD;AACD,KALD,MAKO;AACLO,MAAAA,OAAO,CAACK,oBAAR,CAA6BC,OAA7B,CAAqC,UAACC,cAAD,EAAoB;AACvD,YAAIA,cAAc,CAACJ,MAAf,CAAsBZ,UAAtB,CAAJ,EAAuC;AACrCgB,UAAAA,cAAc,CAACH,eAAf,CAA+BZ,SAA/B,EAA0CC,UAA1C;AACD;AACF,OAJD;AAKD;;AAED,QAAIC,OAAO,CAACC,UAAR,IAAsBK,OAAO,CAACQ,OAAlC,EAA2C;AACzC,UAAMC,gBAAgB,GAAG,0CACvBT,OADuB,EAEvBR,SAFuB,EAGvBE,OAAO,CAACG,WAHe,CAAzB;;AAKA,UAAIY,gBAAJ,EAAsB;AACpB,eAAOV,QAAQ,CAACU,gBAAD,CAAf;AACD;AACF;;AAED,QAAIf,OAAO,CAACE,QAAR,IAAoBI,OAAO,CAACQ,OAA5B,IAAuCR,OAAO,CAACU,SAAR,EAA3C,EAAgE;AAC9DX,MAAAA,QAAQ,CAAC,sCAAmBC,OAAnB,CAAD,CAAR;AACD;;AAED,QACEA,OAAO,CAACE,iBAAR,IACAR,OAAO,CAACI,QADR,IAEAE,OAAO,CAACE,iBAAR,CAA0BS,qBAF1B,IAGA,0BAAW,+BAAX,CAJF,EAKE;AACAZ,MAAAA,QAAQ,CAAC,yCAAmBC,OAAnB,CAAD,CAAR;AACD;;AAED,WAAOD,QAAQ,CAAC,0BAAYC,OAAZ,CAAD,CAAf;AACD,GArDD;AAAA,CADK","sourcesContent":["// @flow\nimport { updateModel } from \"../_modularui/actions\";\n\nimport { getSetting } from \"../../constants/Settings\";\n\nimport { validateFormObject } from \"./FormValidations\";\nimport { autosaveFormObject } from \"./FormAutosave\";\nimport { autosubmitFormObject } from \"./FormAutosubmit\";\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,\n forceUpdate: false,\n validate: true,\n }\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n const newForm = form.clone();\n\n if (\n newForm.currentFormObject &&\n newForm.currentFormObject.equals(formObject)\n ) {\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.autosave && newForm.isValid && newForm.isChanged()) {\n dispatch(autosaveFormObject(newForm));\n }\n\n if (\n newForm.currentFormObject &&\n options.validate &&\n newForm.currentFormObject.hasDynamicValidations &&\n getSetting(\"USE_INSTANT_SERVER_VALIDATION\")\n ) {\n dispatch(validateFormObject(newForm));\n }\n\n return dispatch(updateModel(newForm));\n };\n"],"file":"FormAttributeSet.js"}
@@ -45,6 +45,8 @@ export type UpdateFormOptions = {
45
45
  autosubmit: boolean,
46
46
  autosave: boolean,
47
47
  forceUpdate?: boolean,
48
+ /** Default true: Activate/deactivate the form object validate by an update */
49
+ validate?: boolean,
48
50
  };
49
51
 
50
52
  export type NoAction = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.14.2",
3
+ "version": "1.15.0",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "http://support.beinformed.com",
@@ -72,7 +72,7 @@
72
72
  "react-dom": "^16.14.0 || ^17.0.0",
73
73
  "react-helmet-async": "^1.0.0",
74
74
  "react-redux": "^7.0.0",
75
- "react-router-dom": "^5.2.0",
75
+ "react-router": "^5.2.0",
76
76
  "redux": "^4.0.0",
77
77
  "redux-thunk": "^2.3.0",
78
78
  "styled-components": "^5.2.0"
@@ -104,7 +104,7 @@
104
104
  "@babel/preset-env": "^7.16.11",
105
105
  "@babel/preset-flow": "^7.16.7",
106
106
  "@babel/preset-react": "^7.16.7",
107
- "@commitlint/cli": "^16.2.1",
107
+ "@commitlint/cli": "^16.2.3",
108
108
  "@commitlint/config-conventional": "^16.2.1",
109
109
  "@testing-library/react-hooks": "^7.0.2",
110
110
  "auditjs": "^4.0.36",
@@ -119,7 +119,7 @@
119
119
  "eslint-plugin-ft-flow": "^2.0.1",
120
120
  "eslint-plugin-import": "^2.25.4",
121
121
  "eslint-plugin-jest": "^26.1.1",
122
- "eslint-plugin-jsdoc": "^37.9.4",
122
+ "eslint-plugin-jsdoc": "^38.0.4",
123
123
  "eslint-plugin-react": "^7.28.0",
124
124
  "eslint-plugin-react-hooks": "^4.3.0",
125
125
  "flow-bin": "^0.173.0",
@@ -132,14 +132,14 @@
132
132
  "jest-junit": "^13.0.0",
133
133
  "jest-sonar-reporter": "^2.0.0",
134
134
  "jscodeshift": "^0.13.1",
135
- "lint-staged": "^12.3.4",
135
+ "lint-staged": "^12.3.6",
136
136
  "polished": "^4.1.4",
137
- "prettier": "^2.5.1",
137
+ "prettier": "^2.6.0",
138
138
  "react": "^17.0.2",
139
139
  "react-dom": "^17.0.2",
140
140
  "react-helmet-async": "^1.2.3",
141
141
  "react-redux": "^7.2.6",
142
- "react-router-dom": "^5.3.0",
142
+ "react-router": "^5.2.0",
143
143
  "react-test-renderer": "^17.0.2",
144
144
  "redux": "^4.1.2",
145
145
  "redux-mock-store": "^1.5.4",
@@ -14,3 +14,4 @@ export * from "./useNotification";
14
14
  export * from "./usePreference";
15
15
  export * from "./useProgressIndicator";
16
16
  export * from "./useRouter";
17
+ export * from "./useAllFormsOnModel";
@@ -0,0 +1,92 @@
1
+ // @flow
2
+ import { useState, useEffect } from "react";
3
+
4
+ import { useModularUIRequest } from "./useModularUIRequest";
5
+
6
+ import { HTTP_METHODS } from "../constants";
7
+
8
+ import ListModel from "../models/list/ListModel";
9
+ import FormModel from "../models/form/FormModel";
10
+
11
+ import type DetailModel from "../models/detail/DetailModel";
12
+ import type TabModel from "../models/tab/TabModel";
13
+ import type ActionModel from "../models/actions/ActionModel";
14
+
15
+ /**
16
+ * Retrieve all forms configured on a model with actions
17
+ * @param model
18
+ * @returns Object - { actionName: FormModel }
19
+ */
20
+ export const useRetrieveFormsOnModel = (
21
+ model: ListModel | DetailModel | TabModel
22
+ ): null | { [actionName: string]: FormModel } => {
23
+ const modularui = useModularUIRequest();
24
+ const [forms, setForms] = useState(null);
25
+ const [requestCount, setRequestCount] = useState(0);
26
+ const [responseCount, setResponseCount] = useState(0);
27
+
28
+ useEffect(() => {
29
+ const requests = getActions(model).map((action) => {
30
+ const href = action.selfhref.addParameter("commit", "false");
31
+
32
+ return modularui(href, { method: HTTP_METHODS.POST })
33
+ .fetch()
34
+ .then((form) => {
35
+ if (form instanceof FormModel) {
36
+ form.tokens = [];
37
+ }
38
+ return { [action.name]: form };
39
+ });
40
+ });
41
+
42
+ setRequestCount(requests.length);
43
+
44
+ Promise.all(requests).then((responses) => {
45
+ // put response array in object
46
+ const actionForms = Object.assign({}, ...responses);
47
+ setForms(actionForms);
48
+ setResponseCount(responses.length);
49
+ });
50
+ }, [model, modularui]);
51
+
52
+ if (responseCount === requestCount) {
53
+ return forms;
54
+ }
55
+
56
+ return null;
57
+ };
58
+
59
+ const getActions = (
60
+ model: ListModel | DetailModel | TabModel
61
+ ): Array<ActionModel> => {
62
+ if (!model.actionCollection) {
63
+ return [];
64
+ }
65
+
66
+ const createActions = model.actionCollection
67
+ .getActionsByType("create")
68
+ .filter((action) => !action.isDisabled);
69
+
70
+ const allActions = [...createActions];
71
+
72
+ if (model instanceof ListModel) {
73
+ model.listItemCollection.forEach((listItem) => {
74
+ const updateActions = listItem.actionCollection
75
+ .getActionsByType("update")
76
+ .filter((action) => !action.isDisabled);
77
+
78
+ allActions.push(...updateActions);
79
+ });
80
+ }
81
+
82
+ const actions = [];
83
+ const unique = [];
84
+ allActions.forEach((action) => {
85
+ if (!unique.includes(action.name)) {
86
+ unique.push(action.name);
87
+ actions.push(action);
88
+ }
89
+ });
90
+
91
+ return actions;
92
+ };
@@ -25,6 +25,7 @@ export const updateFormAttribute =
25
25
  autosubmit: false,
26
26
  autosave: false,
27
27
  forceUpdate: false,
28
+ validate: true,
28
29
  }
29
30
  ): ThunkAction =>
30
31
  (dispatch: Dispatch) => {
@@ -60,6 +61,7 @@ export const updateFormAttribute =
60
61
 
61
62
  if (
62
63
  newForm.currentFormObject &&
64
+ options.validate &&
63
65
  newForm.currentFormObject.hasDynamicValidations &&
64
66
  getSetting("USE_INSTANT_SERVER_VALIDATION")
65
67
  ) {
@@ -45,6 +45,8 @@ export type UpdateFormOptions = {
45
45
  autosubmit: boolean,
46
46
  autosave: boolean,
47
47
  forceUpdate?: boolean,
48
+ /** Default true: Activate/deactivate the form object validate by an update */
49
+ validate?: boolean,
48
50
  };
49
51
 
50
52
  export type NoAction = {