@beinformed/ui 1.53.0 → 1.54.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/esm/hooks/useModelCatalog.js +25 -10
  3. package/esm/hooks/useModelCatalog.js.map +1 -1
  4. package/esm/hooks/useModularUIBasic.js +9 -4
  5. package/esm/hooks/useModularUIBasic.js.map +1 -1
  6. package/esm/redux/_modularui/ModularUIActions.js +1 -0
  7. package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
  8. package/esm/redux/_modularui/ModularUIMiddleware.js +2 -1
  9. package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  10. package/esm/redux/_modularui/types.js.map +1 -1
  11. package/lib/hooks/useModelCatalog.js +25 -10
  12. package/lib/hooks/useModelCatalog.js.flow +23 -3
  13. package/lib/hooks/useModelCatalog.js.map +1 -1
  14. package/lib/hooks/useModularUIBasic.js +9 -4
  15. package/lib/hooks/useModularUIBasic.js.flow +13 -5
  16. package/lib/hooks/useModularUIBasic.js.map +1 -1
  17. package/lib/redux/_modularui/ModularUIActions.js +1 -0
  18. package/lib/redux/_modularui/ModularUIActions.js.flow +1 -0
  19. package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
  20. package/lib/redux/_modularui/ModularUIMiddleware.js +2 -1
  21. package/lib/redux/_modularui/ModularUIMiddleware.js.flow +2 -0
  22. package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  23. package/lib/redux/_modularui/types.js.flow +1 -0
  24. package/lib/redux/_modularui/types.js.map +1 -1
  25. package/package.json +1 -1
  26. package/src/hooks/useModelCatalog.js +23 -3
  27. package/src/hooks/useModularUIBasic.js +13 -5
  28. package/src/redux/_modularui/ModularUIActions.js +1 -0
  29. package/src/redux/_modularui/ModularUIMiddleware.js +2 -0
  30. package/src/redux/_modularui/types.js +1 -0
  31. package/types/models/concepts/ConceptDetailModel.d.ts +9 -1
  32. package/types/models/concepts/ConceptLinkModel.d.ts +8 -0
  33. package/types/models/concepts/ConceptTypeDetailModel.d.ts +19 -0
  34. package/types/models/content/ContentIndexModel.d.ts +3 -0
  35. package/types/models/links/LinkCollection.d.ts +8 -0
  36. package/types/redux/_modularui/types.d.ts +1 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [1.54.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.54.0...v1.54.1) (2024-09-17)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **flowtype:** make expectedModels optional ([ebb6953](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/ebb6953be1e96ed9aebf31d3997ba5fe684f1c10))
11
+
12
+ ## [1.54.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.53.0...v1.54.0) (2024-09-17)
13
+
14
+
15
+ ### Features
16
+
17
+ * **modularui:** allow caching data service of modularui ([d1c65f7](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/d1c65f7081853556aa2eb431064f2fb05a94b422))
18
+
5
19
  ## [1.53.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.52.2...v1.53.0) (2024-09-17)
6
20
 
7
21
 
@@ -12,19 +12,22 @@ import { useModularUIBasic } from "./useModularUIBasic";
12
12
  import { ContentTypeModel } from "../models";
13
13
  /**
14
14
  */
15
- export const useModelCatalog = () => useModularUIBasic("modelcatalog", "/modelcatalog", {
15
+ export const useModelCatalog = options => useModularUIBasic("modelcatalog", "/modelcatalog", {
16
16
  expectedModels: ["ModelCatalog"],
17
- targetModel: ModelCatalogModel
17
+ targetModel: ModelCatalogModel,
18
+ ...options
18
19
  });
19
20
 
20
21
  /**
21
22
  */
22
23
  export const useConceptIndex = function (href) {
23
24
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "conceptindex";
25
+ let options = arguments.length > 2 ? arguments[2] : undefined;
24
26
  const url = filterParameters(href, ["entryDate", "index", "label", "type"]);
25
27
  return useModularUIBasic(key, url, {
26
28
  expectedModels: ["ConceptIndex"],
27
- targetModel: ConceptIndexModel
29
+ targetModel: ConceptIndexModel,
30
+ ...options
28
31
  });
29
32
  };
30
33
 
@@ -32,10 +35,12 @@ export const useConceptIndex = function (href) {
32
35
  */
33
36
  export const useConceptDetail = function (concept) {
34
37
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "conceptdetail";
38
+ let options = arguments.length > 2 ? arguments[2] : undefined;
35
39
  const location = useLocation();
36
40
  const href = createHref("concepts", concept, location, ["entryDate"]);
37
41
  return useModularUIBasic(key, href, {
38
- expectedModels: ["ConceptDetail", "BusinessScenario"]
42
+ expectedModels: ["ConceptDetail", "BusinessScenario"],
43
+ ...options
39
44
  });
40
45
  };
41
46
 
@@ -43,10 +48,12 @@ export const useConceptDetail = function (concept) {
43
48
  */
44
49
  export const useContentIndex = function (href) {
45
50
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contentindex";
51
+ let options = arguments.length > 2 ? arguments[2] : undefined;
46
52
  const url = filterParameters(href, ["index", "label", "type"]);
47
53
  return useModularUIBasic(key, url, {
48
54
  expectedModels: ["ContentIndex"],
49
- targetModel: ContentIndexModel
55
+ targetModel: ContentIndexModel,
56
+ ...options
50
57
  });
51
58
  };
52
59
 
@@ -54,11 +61,13 @@ export const useContentIndex = function (href) {
54
61
  */
55
62
  export const useContentTOC = function (content) {
56
63
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contenttoc";
64
+ let options = arguments.length > 2 ? arguments[2] : undefined;
57
65
  const location = useLocation();
58
66
  const href = createHref("content", content, location, ["entryDate"]);
59
67
  return useModularUIBasic(key, href, {
60
68
  expectedModels: ["ContentTOC"],
61
- targetModel: ContentTOCModel
69
+ targetModel: ContentTOCModel,
70
+ ...options
62
71
  });
63
72
  };
64
73
 
@@ -66,10 +75,12 @@ export const useContentTOC = function (content) {
66
75
  */
67
76
  export const useContent = function (contentSection) {
68
77
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "content";
78
+ let options = arguments.length > 2 ? arguments[2] : undefined;
69
79
  const href = createHref("content", contentSection, null, ["entryDate"]);
70
80
  return useModularUIBasic(key, href, {
71
81
  expectedModels: ["Content"],
72
- targetModel: ContentModel
82
+ targetModel: ContentModel,
83
+ ...options
73
84
  });
74
85
  };
75
86
 
@@ -77,10 +88,12 @@ export const useContent = function (contentSection) {
77
88
  */
78
89
  export const useContentType = function (contentType) {
79
90
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contenttypes";
91
+ let options = arguments.length > 2 ? arguments[2] : undefined;
80
92
  const href = createHref("contenttypes", contentType, null, ["entryDate"]);
81
93
  return useModularUIBasic(key, href, {
82
94
  expectedModels: ["ContentType"],
83
- targetModel: ContentTypeModel
95
+ targetModel: ContentTypeModel,
96
+ ...options
84
97
  });
85
98
  };
86
99
 
@@ -105,15 +118,17 @@ const getSearchHref = (uri, filters) => {
105
118
  */
106
119
  export const useConceptSearch = function (filters) {
107
120
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "conceptSearch";
121
+ let options = arguments.length > 2 ? arguments[2] : undefined;
108
122
  const href = getSearchHref("/concepts", filters);
109
- return useConceptIndex(href, key);
123
+ return useConceptIndex(href, key, options);
110
124
  };
111
125
 
112
126
  /**
113
127
  */
114
128
  export const useContentSearch = function (filters) {
115
129
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contentSearch";
130
+ let options = arguments.length > 2 ? arguments[2] : undefined;
116
131
  const href = getSearchHref("/content", filters);
117
- return useContentIndex(href, key);
132
+ return useContentIndex(href, key, options);
118
133
  };
119
134
  //# sourceMappingURL=useModelCatalog.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useModelCatalog.js","names":["useLocation","createHref","filterParameters","ModelCatalogModel","ConceptIndexModel","ConceptDetailModel","default","BusinessScenarioModel","ContentIndexModel","ContentTOCModel","ContentModel","useModularUIBasic","ContentTypeModel","useModelCatalog","expectedModels","targetModel","useConceptIndex","href","key","arguments","length","undefined","url","useConceptDetail","concept","location","useContentIndex","useContentTOC","content","useContent","contentSection","useContentType","contentType","getSearchHref","uri","filters","filterString","_Object$keys","filterValue","value","Array","isArray","join","replace","push","useConceptSearch","useContentSearch"],"sources":["../../src/hooks/useModelCatalog.js"],"sourcesContent":["// @flow\nimport { useLocation } from \"./useRouter\";\n\nimport { createHref, filterParameters } from \"../utils/helpers/createHref\";\n\nimport ModelCatalogModel from \"../models/modelcatalog/ModelCatalogModel\";\nimport ConceptIndexModel from \"../models/concepts/ConceptIndexModel\";\nimport ConceptDetailModel from \"../models/concepts/ConceptDetailModel\";\nimport { default as BusinessScenarioModel } from \"../models/concepts/BusinessScenarioModel\";\nimport ContentIndexModel from \"../models/content/ContentIndexModel\";\nimport ContentTOCModel from \"../models/content/ContentTOCModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { ContentTypeModel } from \"../models\";\n\nexport type SearchFilter = {\n index?: string,\n label?: string,\n type?: string | Array<string>,\n entryDate?: string,\n};\n\n/**\n */\nexport const useModelCatalog = (): ?ModelCatalogModel =>\n useModularUIBasic(\"modelcatalog\", \"/modelcatalog\", {\n expectedModels: [\"ModelCatalog\"],\n targetModel: ModelCatalogModel,\n });\n\n/**\n */\nexport const useConceptIndex = (\n href: string,\n key?: string = \"conceptindex\",\n): ?ConceptIndexModel => {\n const url = filterParameters(href, [\"entryDate\", \"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n });\n};\n\n/**\n */\nexport const useConceptDetail = (\n concept: string,\n key?: string = \"conceptdetail\",\n): ?ConceptDetailModel | ?BusinessScenarioModel => {\n const location = useLocation();\n\n const href = createHref(\"concepts\", concept, location, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ConceptDetail\", \"BusinessScenario\"],\n });\n};\n\n/**\n */\nexport const useContentIndex = (\n href: string,\n key?: string = \"contentindex\",\n): ?ContentIndexModel => {\n const url = filterParameters(href, [\"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ContentIndex\"],\n targetModel: ContentIndexModel,\n });\n};\n\n/**\n */\nexport const useContentTOC = (\n content: string,\n key?: string = \"contenttoc\",\n): ?ContentTOCModel => {\n const location = useLocation();\n const href = createHref(\"content\", content, location, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentTOC\"],\n targetModel: ContentTOCModel,\n });\n};\n\n/**\n */\nexport const useContent = (\n contentSection: string,\n key?: string = \"content\",\n): ?ContentModel => {\n const href = createHref(\"content\", contentSection, null, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\"],\n targetModel: ContentModel,\n });\n};\n\n/**\n */\nexport const useContentType = (\n contentType: string,\n key?: string = \"contenttypes\",\n): ?ContentTypeModel => {\n const href = createHref(\"contenttypes\", contentType, null, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentType\"],\n targetModel: ContentTypeModel,\n });\n};\n\n/**\n */\nconst getSearchHref = (uri: string, filters: SearchFilter): string => {\n const filterString = [];\n\n for (const key of Object.keys(filters)) {\n const filterValue = filters[key];\n if (filterValue) {\n let value: string = Array.isArray(filterValue)\n ? filterValue.join(\",\")\n : filterValue;\n if (key === \"type\") {\n value = value.replace(\"#\", \"%23\"); // handles un-encoded #\n }\n filterString.push(`${key}=${value}`);\n }\n }\n\n return filterString.length ? `${uri}?${filterString.join(\"&\")}` : uri;\n};\n\n/**\n */\nexport const useConceptSearch = (\n filters: SearchFilter,\n key?: string = \"conceptSearch\",\n): ?ConceptIndexModel => {\n const href = getSearchHref(\"/concepts\", filters);\n return useConceptIndex(href, key);\n};\n\n/**\n */\nexport const useContentSearch = (\n filters: SearchFilter,\n key?: string = \"contentSearch\",\n): ?ContentIndexModel => {\n const href = getSearchHref(\"/content\", filters);\n return useContentIndex(href, key);\n};\n"],"mappings":";AACA,SAASA,WAAW,QAAQ,aAAa;AAEzC,SAASC,UAAU,EAAEC,gBAAgB,QAAQ,6BAA6B;AAE1E,OAAOC,iBAAiB,MAAM,0CAA0C;AACxE,OAAOC,iBAAiB,MAAM,sCAAsC;AACpE,OAAOC,kBAAkB,MAAM,uCAAuC;AACtE,SAASC,OAAO,IAAIC,qBAAqB,QAAQ,0CAA0C;AAC3F,OAAOC,iBAAiB,MAAM,qCAAqC;AACnE,OAAOC,eAAe,MAAM,mCAAmC;AAC/D,OAAOC,YAAY,MAAM,gCAAgC;AAEzD,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,gBAAgB,QAAQ,WAAW;AAS5C;AACA;AACA,OAAO,MAAMC,eAAe,GAAGA,CAAA,KAC7BF,iBAAiB,CAAC,cAAc,EAAE,eAAe,EAAE;EACjDG,cAAc,EAAE,CAAC,cAAc,CAAC;EAChCC,WAAW,EAAEZ;AACf,CAAC,CAAC;;AAEJ;AACA;AACA,OAAO,MAAMa,eAAe,GAAG,SAAAA,CAC7BC,IAAY,EAEW;EAAA,IADvBC,GAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,cAAc;EAE7B,MAAMG,GAAG,GAAGpB,gBAAgB,CAACe,IAAI,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;EAC3E,OAAON,iBAAiB,CAACO,GAAG,EAAEI,GAAG,EAAE;IACjCR,cAAc,EAAE,CAAC,cAAc,CAAC;IAChCC,WAAW,EAAEX;EACf,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA,OAAO,MAAMmB,gBAAgB,GAAG,SAAAA,CAC9BC,OAAe,EA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G,KAAK,MAAM,EAAE;QAClBqB,KAAK,GAAGA,KAAK,CAACI,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;MACrC;MACAP,YAAY,CAACQ,IAAI,CAAC,GAAG1B,GAAG,IAAIqB,KAAK,EAAE,CAAC;IACtC;EACF;EAEA,OAAOH,YAAY,CAAChB,MAAM,GAAG,GAAGc,GAAG,IAAIE,YAAY,CAACM,IAAI,CAAC,GAAG,CAAC,EAAE,GAAGR,GAAG;AACvE,CAAC;;AAED;AACA;AACA,OAAO,MAAMW,gBAAgB,GAAG,SAAAA,CAC9BV,OAAqB,EAEE;EAAA,IADvBjB,GAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,eAAe;EAE9B,MAAMF,IAAI,GAAGgB,aAAa,CAAC,WAAW,EAAEE,OAAO,CAAC;EAChD,OAAOnB,eAAe,CAACC,IAAI,EAAEC,GAAG,CAAC;AACnC,CAAC;;AAED;AACA;AACA,OAAO,MAAM4B,gBAAgB,GAAG,SAAAA,CAC9BX,OAAqB,EAEE;EAAA,IADvBjB,GAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,eAAe;EAE9B,MAAMF,IAAI,GAAGgB,aAAa,CAAC,UAAU,EAAEE,OAAO,CAAC;EAC/C,OAAOT,eAAe,CAACT,IAAI,EAAEC,GAAG,CAAC;AACnC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useModelCatalog.js","names":["useLocation","createHref","filterParameters","ModelCatalogModel","ConceptIndexModel","ConceptDetailModel","default","BusinessScenarioModel","ContentIndexModel","ContentTOCModel","ContentModel","useModularUIBasic","ContentTypeModel","useModelCatalog","options","expectedModels","targetModel","useConceptIndex","href","key","arguments","length","undefined","url","useConceptDetail","concept","location","useContentIndex","useContentTOC","content","useContent","contentSection","useContentType","contentType","getSearchHref","uri","filters","filterString","_Object$keys","filterValue","value","Array","isArray","join","replace","push","useConceptSearch","useContentSearch"],"sources":["../../src/hooks/useModelCatalog.js"],"sourcesContent":["// @flow\nimport { useLocation } from \"./useRouter\";\n\nimport { createHref, filterParameters } from \"../utils/helpers/createHref\";\n\nimport ModelCatalogModel from \"../models/modelcatalog/ModelCatalogModel\";\nimport ConceptIndexModel from \"../models/concepts/ConceptIndexModel\";\nimport ConceptDetailModel from \"../models/concepts/ConceptDetailModel\";\nimport { default as BusinessScenarioModel } from \"../models/concepts/BusinessScenarioModel\";\nimport ContentIndexModel from \"../models/content/ContentIndexModel\";\nimport ContentTOCModel from \"../models/content/ContentTOCModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { ContentTypeModel } from \"../models\";\n\nimport type { UseModularUIBasicOptions } from \"./useModularUIBasic\";\nexport type SearchFilter = {\n index?: string,\n label?: string,\n type?: string | Array<string>,\n entryDate?: string,\n};\n\n/**\n */\nexport const useModelCatalog = (\n options?: UseModularUIBasicOptions<ModelCatalogModel>,\n): ?ModelCatalogModel =>\n useModularUIBasic(\"modelcatalog\", \"/modelcatalog\", {\n expectedModels: [\"ModelCatalog\"],\n targetModel: ModelCatalogModel,\n ...options,\n });\n\n/**\n */\nexport const useConceptIndex = (\n href: string,\n key?: string = \"conceptindex\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const url = filterParameters(href, [\"entryDate\", \"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ConceptIndex\"],\n targetModel: ConceptIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useConceptDetail = (\n concept: string,\n key?: string = \"conceptdetail\",\n options?: UseModularUIBasicOptions<\n ConceptDetailModel | BusinessScenarioModel,\n >,\n): ?ConceptDetailModel | ?BusinessScenarioModel => {\n const location = useLocation();\n\n const href = createHref(\"concepts\", concept, location, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ConceptDetail\", \"BusinessScenario\"],\n ...options,\n });\n};\n\n/**\n */\nexport const useContentIndex = (\n href: string,\n key?: string = \"contentindex\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const url = filterParameters(href, [\"index\", \"label\", \"type\"]);\n return useModularUIBasic(key, url, {\n expectedModels: [\"ContentIndex\"],\n targetModel: ContentIndexModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContentTOC = (\n content: string,\n key?: string = \"contenttoc\",\n options?: UseModularUIBasicOptions<ContentTOCModel>,\n): ?ContentTOCModel => {\n const location = useLocation();\n const href = createHref(\"content\", content, location, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentTOC\"],\n targetModel: ContentTOCModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContent = (\n contentSection: string,\n key?: string = \"content\",\n options?: UseModularUIBasicOptions<ContentModel>,\n): ?ContentModel => {\n const href = createHref(\"content\", contentSection, null, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"Content\"],\n targetModel: ContentModel,\n ...options,\n });\n};\n\n/**\n */\nexport const useContentType = (\n contentType: string,\n key?: string = \"contenttypes\",\n options?: UseModularUIBasicOptions<ContentTypeModel>,\n): ?ContentTypeModel => {\n const href = createHref(\"contenttypes\", contentType, null, [\"entryDate\"]);\n return useModularUIBasic(key, href, {\n expectedModels: [\"ContentType\"],\n targetModel: ContentTypeModel,\n ...options,\n });\n};\n\n/**\n */\nconst getSearchHref = (uri: string, filters: SearchFilter): string => {\n const filterString = [];\n\n for (const key of Object.keys(filters)) {\n const filterValue = filters[key];\n if (filterValue) {\n let value: string = Array.isArray(filterValue)\n ? filterValue.join(\",\")\n : filterValue;\n if (key === \"type\") {\n value = value.replace(\"#\", \"%23\"); // handles un-encoded #\n }\n filterString.push(`${key}=${value}`);\n }\n }\n\n return filterString.length ? `${uri}?${filterString.join(\"&\")}` : uri;\n};\n\n/**\n */\nexport const useConceptSearch = (\n filters: SearchFilter,\n key?: string = \"conceptSearch\",\n options?: UseModularUIBasicOptions<ConceptIndexModel>,\n): ?ConceptIndexModel => {\n const href = getSearchHref(\"/concepts\", filters);\n return useConceptIndex(href, key, options);\n};\n\n/**\n */\nexport const useContentSearch = (\n filters: SearchFilter,\n key?: string = \"contentSearch\",\n options?: UseModularUIBasicOptions<ContentIndexModel>,\n): ?ContentIndexModel => {\n const href = getSearchHref(\"/content\", filters);\n return useContentIndex(href, key, options);\n};\n"],"mappings":";AACA,SAASA,WAAW,QAAQ,aAAa;AAEzC,SAASC,UAAU,EAAEC,gBAAgB,QAAQ,6BAA6B;AAE1E,OAAOC,iBAAiB,MAAM,0CAA0C;AACxE,OAAOC,iBAAiB,MAAM,sCAAsC;AACpE,OAAOC,kBAAkB,MAAM,uCAAuC;AACtE,SAASC,OAAO,IAAIC,qBAAqB,QAAQ,0CAA0C;AAC3F,OAAOC,iBAAiB,MAAM,qCAAqC;AACnE,OAAOC,eAAe,MAAM,mCAAmC;AAC/D,OAAOC,YAAY,MAAM,gCAAgC;AAEzD,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASC,gBAAgB,QAAQ,WAAW;AAU5C;AACA;AACA,OAAO,MAAMC,eAAe,GAC1BC,OAAqD,IAErDH,iBAAiB,CAAC,cAAc,EAAE,eAAe,EAAE;EACjDI,cAAc,EAAE,CAAC,cAAc,CAAC;EAChCC,WAAW,EAAEb,iBAAiB;EAC9B,GAAGW;AACL,CAAC,CAAC;;AAEJ;AACA;AACA,OAAO,MAAMG,eAAe,GAAG,SAAAA,CAC7BC,IAAY,EAGW;EAAA,IAFvBC,GAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,cAAc;EAAA,IAC7BN,OAAqD,GAAAM,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAErD,MAAMC,GAAG,GAAGrB,gBAAgB,CAACgB,IAAI,EAAE,CAAC,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,SAAA,GAAAF,SAAA,MAAG,eAAe;EAAA,IAC9BN,OAAqD,GAAAM,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAErD,MAAMJ,IAAI,GAAGgB,aAAa,CAAC,WAAW,EAAEE,OAAO,CAAC;EAChD,OAAOnB,eAAe,CAACC,IAAI,EAAEC,GAAG,EAAEL,OAAO,CAAC;AAC5C,CAAC;;AAED;AACA;AACA,OAAO,MAAMiC,gBAAgB,GAAG,SAAAA,CAC9BX,OAAqB,EAGE;EAAA,IAFvBjB,GAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,eAAe;EAAA,IAC9BN,OAAqD,GAAAM,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAErD,MAAMJ,IAAI,GAAGgB,aAAa,CAAC,UAAU,EAAEE,OAAO,CAAC;EAC/C,OAAOT,eAAe,CAACT,IAAI,EAAEC,GAAG,EAAEL,OAAO,CAAC;AAC5C,CAAC","ignoreList":[]}
@@ -15,12 +15,16 @@ export const useModularUIBasic = function (key, href) {
15
15
  const useModularUIOptions = {
16
16
  targetModel: undefined,
17
17
  forceTargetModel: undefined,
18
- isReload: false
18
+ isReload: false,
19
+ cache: false
19
20
  };
20
21
  if (options.targetModel) {
21
22
  useModularUIOptions.targetModel = options.targetModel;
22
23
  useModularUIOptions.forceTargetModel = options.forceTargetModel;
23
24
  }
25
+ if (options.cache) {
26
+ useModularUIOptions.cache = options.cache;
27
+ }
24
28
 
25
29
  // reload when the modular service starts with the current location
26
30
  if (location.state?.reload && _startsWithInstanceProperty(_context = location.pathname).call(_context, href.toString())) {
@@ -33,12 +37,13 @@ export const useModularUIBasic = function (key, href) {
33
37
  const {
34
38
  model
35
39
  } = modularUI;
36
- if (options.expectedModels.length > 0) {
37
- const isCorrectModel = options.expectedModels.some(expectedModel => {
40
+ const expectedModels = options.expectedModels ?? [];
41
+ if (expectedModels.length > 0) {
42
+ const isCorrectModel = expectedModels.some(expectedModel => {
38
43
  return model.type === expectedModel;
39
44
  });
40
45
  if (!isCorrectModel) {
41
- console.error(modularUI, "is not of instance", options.expectedModels);
46
+ console.error(modularUI, "is not of instance", expectedModels);
42
47
  throw new IllegalStateException("Resolved model has incorrect type");
43
48
  }
44
49
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUIBasic.js","names":["useModularUI","useLocation","IllegalStateException","useModularUIBasic","key","href","_context","options","arguments","length","undefined","expectedModels","targetModel","forceTargetModel","location","useModularUIOptions","isReload","state","reload","_startsWithInstanceProperty","pathname","call","toString","modularUI","model","isCorrectModel","some","expectedModel","type","console","error"],"sources":["../../src/hooks/useModularUIBasic.js"],"sourcesContent":["// @flow\nimport { useModularUI } from \"./useModularUI\";\n\nimport { useLocation } from \"./useRouter\";\n\nimport { IllegalStateException } from \"../exceptions\";\n\nimport type { ModularUIModel, Href } from \"../models\";\n\ntype UseModularUIBasicOptions<T: ModularUIModel> = {\n expectedModels: Array<string>,\n targetModel?: Class<T> | Array<Class<T>>,\n forceTargetModel?: boolean,\n};\n\n/**\n */\nexport const useModularUIBasic = <T: ModularUIModel>(\n key: string,\n href: string | Href,\n options: UseModularUIBasicOptions<T> = {\n expectedModels: [],\n targetModel: undefined,\n forceTargetModel: false,\n },\n): T | null => {\n const location = useLocation();\n\n const useModularUIOptions = {\n targetModel: undefined,\n forceTargetModel: undefined,\n isReload: false,\n };\n if (options.targetModel) {\n useModularUIOptions.targetModel = options.targetModel;\n useModularUIOptions.forceTargetModel = options.forceTargetModel;\n }\n\n // reload when the modular service starts with the current location\n if (location.state?.reload && location.pathname.startsWith(href.toString())) {\n useModularUIOptions.isReload = true;\n }\n\n // $FlowFixMe[incompatible-call]\n const modularUI = useModularUI(key, href, useModularUIOptions);\n\n if (modularUI?.model) {\n const { model } = modularUI;\n if (options.expectedModels.length > 0) {\n const isCorrectModel = options.expectedModels.some((expectedModel) => {\n return model.type === expectedModel;\n });\n\n if (!isCorrectModel) {\n console.error(modularUI, \"is not of instance\", options.expectedModels);\n throw new IllegalStateException(\"Resolved model has incorrect type\");\n }\n }\n\n return model;\n }\n\n return null;\n};\n"],"mappings":";AACA,SAASA,YAAY,QAAQ,gBAAgB;AAE7C,SAASC,WAAW,QAAQ,aAAa;AAEzC,SAASC,qBAAqB,QAAQ,eAAe;AAUrD;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAG,SAAAA,CAC/BC,GAAW,EACXC,IAAmB,EAMN;EAAA,IAAAC,QAAA;EAAA,IALbC,OAAoC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG;IACrCG,cAAc,EAAE,EAAE;IAClBC,WAAW,EAAEF,SAAS;IACtBG,gBAAgB,EAAE;EACpB,CAAC;EAED,MAAMC,QAAQ,GAAGb,WAAW,CAAC,CAAC;EAE9B,MAAMc,mBAAmB,GAAG;IAC1BH,WAAW,EAAEF,SAAS;IACtBG,gBAAgB,EAAEH,SAAS;IAC3BM,QAAQ,EAAE;EACZ,CAAC;EACD,IAAIT,OAAO,CAACK,WAAW,EAAE;IACvBG,mBAAmB,CAACH,WAAW,GAAGL,OAAO,CAACK,WAAW;IACrDG,mBAAmB,CAACF,gBAAgB,GAAGN,OAAO,CAACM,gBAAgB;EACjE;;EAEA;EACA,IAAIC,QAAQ,CAACG,KAAK,EAAEC,MAAM,IAAIC,2BAAA,CAAAb,QAAA,GAAAQ,QAAQ,CAACM,QAAQ,EAAAC,IAAA,CAAAf,QAAA,EAAYD,IAAI,CAACiB,QAAQ,CAAC,CAAC,CAAC,EAAE;IAC3EP,mBAAmB,CAACC,QAAQ,GAAG,IAAI;EACrC;;EAEA;EACA,MAAMO,SAAS,GAAGvB,YAAY,CAACI,GAAG,EAAEC,IAAI,EAAEU,mBAAmB,CAAC;EAE9D,IAAIQ,SAAS,EAAEC,KAAK,EAAE;IACpB,MAAM;MAAEA;IAAM,CAAC,GAAGD,SAAS;IAC3B,IAAIhB,OAAO,CAACI,cAAc,CAACF,MAAM,GAAG,CAAC,EAAE;MACrC,MAAMgB,cAAc,GAAGlB,OAAO,CAACI,cAAc,CAACe,IAAI,CAAEC,aAAa,IAAK;QACpE,OAAOH,KAAK,CAACI,IAAI,KAAKD,aAAa;MACrC,CAAC,CAAC;MAEF,IAAI,CAACF,cAAc,EAAE;QACnBI,OAAO,CAACC,KAAK,CAACP,SAAS,EAAE,oBAAoB,EAAEhB,OAAO,CAACI,cAAc,CAAC;QACtE,MAAM,IAAIT,qBAAqB,CAAC,mCAAmC,CAAC;MACtE;IACF;IAEA,OAAOsB,KAAK;EACd;EAEA,OAAO,IAAI;AACb,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"useModularUIBasic.js","names":["useModularUI","useLocation","IllegalStateException","useModularUIBasic","key","href","_context","options","arguments","length","undefined","expectedModels","targetModel","forceTargetModel","location","useModularUIOptions","isReload","cache","state","reload","_startsWithInstanceProperty","pathname","call","toString","modularUI","model","isCorrectModel","some","expectedModel","type","console","error"],"sources":["../../src/hooks/useModularUIBasic.js"],"sourcesContent":["// @flow\nimport { useModularUI } from \"./useModularUI\";\n\nimport { useLocation } from \"./useRouter\";\n\nimport { IllegalStateException } from \"../exceptions\";\n\nimport type { ModularUIModel, Href } from \"../models\";\n\nexport type UseModularUIBasicOptions<T: ModularUIModel> = {\n expectedModels?: Array<string>,\n targetModel?: Class<T> | Array<Class<T>>,\n forceTargetModel?: boolean,\n cache?: boolean,\n};\n\n/**\n */\nexport const useModularUIBasic = <T: ModularUIModel>(\n key: string,\n href: string | Href,\n options: UseModularUIBasicOptions<T> = {\n expectedModels: [],\n targetModel: undefined,\n forceTargetModel: false,\n },\n): T | null => {\n const location = useLocation();\n\n const useModularUIOptions = {\n targetModel: undefined,\n forceTargetModel: undefined,\n isReload: false,\n cache: false,\n };\n if (options.targetModel) {\n useModularUIOptions.targetModel = options.targetModel;\n useModularUIOptions.forceTargetModel = options.forceTargetModel;\n }\n\n if (options.cache) {\n useModularUIOptions.cache = options.cache;\n }\n\n // reload when the modular service starts with the current location\n if (location.state?.reload && location.pathname.startsWith(href.toString())) {\n useModularUIOptions.isReload = true;\n }\n\n // $FlowFixMe[incompatible-call]\n const modularUI = useModularUI(key, href, useModularUIOptions);\n\n if (modularUI?.model) {\n const { model } = modularUI;\n\n const expectedModels = options.expectedModels ?? [];\n if (expectedModels.length > 0) {\n const isCorrectModel = expectedModels.some((expectedModel) => {\n return model.type === expectedModel;\n });\n\n if (!isCorrectModel) {\n console.error(modularUI, \"is not of instance\", expectedModels);\n throw new IllegalStateException(\"Resolved model has incorrect type\");\n }\n }\n\n return model;\n }\n\n return null;\n};\n"],"mappings":";AACA,SAASA,YAAY,QAAQ,gBAAgB;AAE7C,SAASC,WAAW,QAAQ,aAAa;AAEzC,SAASC,qBAAqB,QAAQ,eAAe;AAWrD;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAG,SAAAA,CAC/BC,GAAW,EACXC,IAAmB,EAMN;EAAA,IAAAC,QAAA;EAAA,IALbC,OAAoC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG;IACrCG,cAAc,EAAE,EAAE;IAClBC,WAAW,EAAEF,SAAS;IACtBG,gBAAgB,EAAE;EACpB,CAAC;EAED,MAAMC,QAAQ,GAAGb,WAAW,CAAC,CAAC;EAE9B,MAAMc,mBAAmB,GAAG;IAC1BH,WAAW,EAAEF,SAAS;IACtBG,gBAAgB,EAAEH,SAAS;IAC3BM,QAAQ,EAAE,KAAK;IACfC,KAAK,EAAE;EACT,CAAC;EACD,IAAIV,OAAO,CAACK,WAAW,EAAE;IACvBG,mBAAmB,CAACH,WAAW,GAAGL,OAAO,CAACK,WAAW;IACrDG,mBAAmB,CAACF,gBAAgB,GAAGN,OAAO,CAACM,gBAAgB;EACjE;EAEA,IAAIN,OAAO,CAACU,KAAK,EAAE;IACjBF,mBAAmB,CAACE,KAAK,GAAGV,OAAO,CAACU,KAAK;EAC3C;;EAEA;EACA,IAAIH,QAAQ,CAACI,KAAK,EAAEC,MAAM,IAAIC,2BAAA,CAAAd,QAAA,GAAAQ,QAAQ,CAACO,QAAQ,EAAAC,IAAA,CAAAhB,QAAA,EAAYD,IAAI,CAACkB,QAAQ,CAAC,CAAC,CAAC,EAAE;IAC3ER,mBAAmB,CAACC,QAAQ,GAAG,IAAI;EACrC;;EAEA;EACA,MAAMQ,SAAS,GAAGxB,YAAY,CAACI,GAAG,EAAEC,IAAI,EAAEU,mBAAmB,CAAC;EAE9D,IAAIS,SAAS,EAAEC,KAAK,EAAE;IACpB,MAAM;MAAEA;IAAM,CAAC,GAAGD,SAAS;IAE3B,MAAMb,cAAc,GAAGJ,OAAO,CAACI,cAAc,IAAI,EAAE;IACnD,IAAIA,cAAc,CAACF,MAAM,GAAG,CAAC,EAAE;MAC7B,MAAMiB,cAAc,GAAGf,cAAc,CAACgB,IAAI,CAAEC,aAAa,IAAK;QAC5D,OAAOH,KAAK,CAACI,IAAI,KAAKD,aAAa;MACrC,CAAC,CAAC;MAEF,IAAI,CAACF,cAAc,EAAE;QACnBI,OAAO,CAACC,KAAK,CAACP,SAAS,EAAE,oBAAoB,EAAEb,cAAc,CAAC;QAC9D,MAAM,IAAIT,qBAAqB,CAAC,mCAAmC,CAAC;MACtE;IACF;IAEA,OAAOuB,KAAK;EACd;EAEA,OAAO,IAAI;AACb,CAAC","ignoreList":[]}
@@ -85,6 +85,7 @@ export const loadModel = (key, href, options) => ({
85
85
  childmodels: options?.childmodels,
86
86
  targetModel: options?.targetModel,
87
87
  forceTargetModel: options?.forceTargetModel,
88
+ cache: options?.cache,
88
89
  /**
89
90
  */
90
91
  successAction: model => loadModelSuccessAction(key, model, options?.updateHandler),
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIActions.js","names":["HTTP_METHODS","MODULARUI_STATUS","Href","ErrorResponse","finishProgress","startProgress","handleError","setModel","key","model","connectKey","type","payload","initModels","models","updateModel","updateForm","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","updateHandler","loadModel","href","options","method","GET","data","locale","childmodels","targetModel","forceTargetModel","successAction","errorAction","error","errorResponse","isChangePassword","isResourceNotFoundAfterReload","ERROR","loadModularUI","dispatch","LOADING","loadModelPromise","_Promise","resolve","then","response","FINISHED","catch","reloadModel","selfhref","isReload"],"sources":["../../../src/redux/_modularui/ModularUIActions.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\nimport Href from \"../../models/href/Href\";\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\nimport { finishProgress, startProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { Dispatch, ThunkAction } from \"../types\";\nimport type {\n ModularUIAction,\n SetModelAction,\n InitModelAction,\n UpdateModelAction,\n UpdateFormAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n UpdateStatusAction,\n} from \"./types\";\nimport type {\n RequestModularUIOptions,\n UpdateHandler,\n} from \"../../utils/fetch/types\";\n\n/**\n */\nexport const setModel = (\n key: string,\n model: ModularUIModel,\n): SetModelAction => {\n // set key on model for later reference\n model.connectKey = key;\n return {\n type: \"MODULARUI/SET\",\n payload: {\n key,\n model,\n },\n };\n};\n\n/**\n */\nexport const initModels = (\n models: Array<{ key: string, model: ModularUIModel }>,\n): InitModelAction => ({\n type: \"MODULARUI/INIT\",\n payload: models,\n});\n\n/**\n */\nexport const updateModel = (model: ModularUIModel): UpdateModelAction => ({\n type: \"MODULARUI/UPDATE\",\n payload: model,\n});\n\n/**\n */\nexport const updateForm = (model: ModularUIModel): UpdateFormAction => ({\n type: \"MODULARUI/UPDATE_FORM\",\n payload: model,\n});\n\n/**\n */\nexport const removeModelByKey = (key: string): RemoveModelByKeyAction => ({\n type: \"MODULARUI/REMOVE_KEY\",\n payload: key,\n});\n\n/**\n * Removes all models except the application model from the modular ui reducer\n */\nexport const resetModularUI = (): ResetModularUIAction => ({\n type: \"MODULARUI/RESET\",\n});\n\n/**\n */\nexport const updateStatus = (\n key: string,\n status: $Keys<typeof MODULARUI_STATUS>,\n): UpdateStatusAction => ({\n type: \"MODULARUI/STATUS\",\n payload: { key, status },\n});\n\n/**\n */\nconst loadModelSuccessAction = (\n key: string,\n model: ModularUIModel,\n updateHandler: UpdateHandler | void,\n): UpdateModelAction | SetModelAction => {\n if (updateHandler) {\n return updateModel(updateHandler(model));\n }\n return setModel(key, model);\n};\n\n/**\n * This action is handled by the modularui middleware\n */\nexport const loadModel = (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n): ModularUIAction => ({\n type: \"MODULARUI/FETCH\",\n payload: {\n href: href instanceof Href ? href : new Href(href),\n method: options?.method ?? HTTP_METHODS.GET,\n data: options?.data,\n locale: options?.locale ?? \"en\",\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateHandler),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key);\n if (errorResponse.isChangePassword) {\n return {\n type: \"NO_ACTION\",\n };\n } else if (errorResponse.isResourceNotFoundAfterReload) {\n return removeModelByKey(key);\n }\n\n return updateStatus(key, MODULARUI_STATUS.ERROR);\n },\n },\n});\n\n/**\n */\nexport const loadModularUI =\n (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));\n dispatch(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then((response) => {\n if (response?.type === \"FINISH_PROGRESS\") {\n dispatch(updateStatus(key, MODULARUI_STATUS.FINISHED));\n }\n\n return dispatch(finishProgress());\n })\n .catch((error) => dispatch(handleError(error)));\n };\n\n/**\n */\nexport const reloadModel = (\n model: ModularUIModel,\n options?: RequestModularUIOptions,\n): ThunkAction =>\n loadModularUI(model.connectKey, model.selfhref, {\n ...options,\n isReload: true,\n });\n"],"mappings":";AACA,SAASA,YAAY,EAAEC,gBAAgB,QAAQ,2BAA2B;AAC1E,OAAOC,IAAI,MAAM,wBAAwB;AACzC,OAAOC,aAAa,MAAM,kCAAkC;AAC5D,SAASC,cAAc,EAAEC,aAAa,QAAQ,8BAA8B;AAC5E,SAASC,WAAW,QAAQ,kBAAkB;AAmB9C;AACA;AACA,OAAO,MAAMC,QAAQ,GAAGA,CACtBC,GAAW,EACXC,KAAqB,KACF;EACnB;EACAA,KAAK,CAACC,UAAU,GAAGF,GAAG;EACtB,OAAO;IACLG,IAAI,EAAE,eAAe;IACrBC,OAAO,EAAE;MACPJ,GAAG;MACHC;IACF;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA,OAAO,MAAMI,UAAU,GACrBC,MAAqD,KAChC;EACrBH,IAAI,EAAE,gBAAgB;EACtBC,OAAO,EAAEE;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMC,WAAW,GAAIN,KAAqB,KAAyB;EACxEE,IAAI,EAAE,kBAAkB;EACxBC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMO,UAAU,GAAIP,KAAqB,KAAwB;EACtEE,IAAI,EAAE,uBAAuB;EAC7BC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMQ,gBAAgB,GAAIT,GAAW,KAA8B;EACxEG,IAAI,EAAE,sBAAsB;EAC5BC,OAAO,EAAEJ;AACX,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,MAAMU,cAAc,GAAGA,CAAA,MAA6B;EACzDP,IAAI,EAAE;AACR,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMQ,YAAY,GAAGA,CAC1BX,GAAW,EACXY,MAAsC,MACd;EACxBT,IAAI,EAAE,kBAAkB;EACxBC,OAAO,EAAE;IAAEJ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Y,CAACX,GAAG,EAAEP,gBAAgB,CAACsC,KAAK,CAAC;IAClD;EACF;AACF,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMC,aAAa,GACxBA,CACEhC,GAAW,EACXgB,IAAmB,EACnBC,OAAiC,KAElCgB,QAAkB,IAAK;EACtBA,QAAQ,CAACtB,YAAY,CAACX,GAAG,EAAEP,gBAAgB,CAACyC,OAAO,CAAC,CAAC;EACrDD,QAAQ,CAACpC,aAAa,CAAC,CAAC,CAAC;EAEzB,MAAMsC,gBAAgB,GAAGF,QAAQ,CAAClB,SAAS,CAACf,GAAG,EAAEgB,IAAI,EAAEC,OAAO,CAAC,CAAC;EAEhE,OAAOmB,QAAA,CAAQC,OAAO,CAACF,gBAAgB,CAAC,CACrCG,IAAI,CAAEC,QAAQ,IAAK;IAClB,IAAIA,QAAQ,EAAEpC,IAAI,KAAK,iBAAiB,EAAE;MACxC8B,QAAQ,CAACtB,YAAY,CAACX,GAAG,EAAEP,gBAAgB,CAAC+C,QAAQ,CAAC,CAAC;IACxD;IAEA,OAAOP,QAAQ,CAACrC,cAAc,CAAC,CAAC,CAAC;EACnC,CAAC,CAAC,CACD6C,KAAK,CAAEd,KAAK,IAAKM,QAAQ,CAACnC,WAAW,CAAC6B,KAAK,CAAC,CAAC,CAAC;AACnD,CAAC;;AAEH;AACA;AACA,OAAO,MAAMe,WAAW,GAAGA,CACzBzC,KAAqB,EACrBgB,OAAiC,KAEjCe,aAAa,CAAC/B,KAAK,CAACC,UAAU,EAAED,KAAK,CAAC0C,QAAQ,EAAE;EAC9C,GAAG1B,OAAO;EACV2B,QAAQ,EAAE;AACZ,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"ModularUIActions.js","names":["HTTP_METHODS","MODULARUI_STATUS","Href","ErrorResponse","finishProgress","startProgress","handleError","setModel","key","model","connectKey","type","payload","initModels","models","updateModel","updateForm","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","updateHandler","loadModel","href","options","method","GET","data","locale","childmodels","targetModel","forceTargetModel","cache","successAction","errorAction","error","errorResponse","isChangePassword","isResourceNotFoundAfterReload","ERROR","loadModularUI","dispatch","LOADING","loadModelPromise","_Promise","resolve","then","response","FINISHED","catch","reloadModel","selfhref","isReload"],"sources":["../../../src/redux/_modularui/ModularUIActions.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\nimport Href from \"../../models/href/Href\";\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\nimport { finishProgress, startProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { Dispatch, ThunkAction } from \"../types\";\nimport type {\n ModularUIAction,\n SetModelAction,\n InitModelAction,\n UpdateModelAction,\n UpdateFormAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n UpdateStatusAction,\n} from \"./types\";\nimport type {\n RequestModularUIOptions,\n UpdateHandler,\n} from \"../../utils/fetch/types\";\n\n/**\n */\nexport const setModel = (\n key: string,\n model: ModularUIModel,\n): SetModelAction => {\n // set key on model for later reference\n model.connectKey = key;\n return {\n type: \"MODULARUI/SET\",\n payload: {\n key,\n model,\n },\n };\n};\n\n/**\n */\nexport const initModels = (\n models: Array<{ key: string, model: ModularUIModel }>,\n): InitModelAction => ({\n type: \"MODULARUI/INIT\",\n payload: models,\n});\n\n/**\n */\nexport const updateModel = (model: ModularUIModel): UpdateModelAction => ({\n type: \"MODULARUI/UPDATE\",\n payload: model,\n});\n\n/**\n */\nexport const updateForm = (model: ModularUIModel): UpdateFormAction => ({\n type: \"MODULARUI/UPDATE_FORM\",\n payload: model,\n});\n\n/**\n */\nexport const removeModelByKey = (key: string): RemoveModelByKeyAction => ({\n type: \"MODULARUI/REMOVE_KEY\",\n payload: key,\n});\n\n/**\n * Removes all models except the application model from the modular ui reducer\n */\nexport const resetModularUI = (): ResetModularUIAction => ({\n type: \"MODULARUI/RESET\",\n});\n\n/**\n */\nexport const updateStatus = (\n key: string,\n status: $Keys<typeof MODULARUI_STATUS>,\n): UpdateStatusAction => ({\n type: \"MODULARUI/STATUS\",\n payload: { key, status },\n});\n\n/**\n */\nconst loadModelSuccessAction = (\n key: string,\n model: ModularUIModel,\n updateHandler: UpdateHandler | void,\n): UpdateModelAction | SetModelAction => {\n if (updateHandler) {\n return updateModel(updateHandler(model));\n }\n return setModel(key, model);\n};\n\n/**\n * This action is handled by the modularui middleware\n */\nexport const loadModel = (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n): ModularUIAction => ({\n type: \"MODULARUI/FETCH\",\n payload: {\n href: href instanceof Href ? href : new Href(href),\n method: options?.method ?? HTTP_METHODS.GET,\n data: options?.data,\n locale: options?.locale ?? \"en\",\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n cache: options?.cache,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateHandler),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key);\n if (errorResponse.isChangePassword) {\n return {\n type: \"NO_ACTION\",\n };\n } else if (errorResponse.isResourceNotFoundAfterReload) {\n return removeModelByKey(key);\n }\n\n return updateStatus(key, MODULARUI_STATUS.ERROR);\n },\n },\n});\n\n/**\n */\nexport const loadModularUI =\n (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));\n dispatch(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then((response) => {\n if (response?.type === \"FINISH_PROGRESS\") {\n dispatch(updateStatus(key, MODULARUI_STATUS.FINISHED));\n }\n\n return dispatch(finishProgress());\n })\n .catch((error) => dispatch(handleError(error)));\n };\n\n/**\n */\nexport const reloadModel = (\n model: ModularUIModel,\n options?: RequestModularUIOptions,\n): ThunkAction =>\n loadModularUI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AAY,CAACX,GAAG,EAAEP,gBAAgB,CAACuC,KAAK,CAAC;IAClD;EACF;AACF,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMC,aAAa,GACxBA,CACEjC,GAAW,EACXgB,IAAmB,EACnBC,OAAiC,KAElCiB,QAAkB,IAAK;EACtBA,QAAQ,CAACvB,YAAY,CAACX,GAAG,EAAEP,gBAAgB,CAAC0C,OAAO,CAAC,CAAC;EACrDD,QAAQ,CAACrC,aAAa,CAAC,CAAC,CAAC;EAEzB,MAAMuC,gBAAgB,GAAGF,QAAQ,CAACnB,SAAS,CAACf,GAAG,EAAEgB,IAAI,EAAEC,OAAO,CAAC,CAAC;EAEhE,OAAOoB,QAAA,CAAQC,OAAO,CAACF,gBAAgB,CAAC,CACrCG,IAAI,CAAEC,QAAQ,IAAK;IAClB,IAAIA,QAAQ,EAAErC,IAAI,KAAK,iBAAiB,EAAE;MACxC+B,QAAQ,CAACvB,YAAY,CAACX,GAAG,EAAEP,gBAAgB,CAACgD,QAAQ,CAAC,CAAC;IACxD;IAEA,OAAOP,QAAQ,CAACtC,cAAc,CAAC,CAAC,CAAC;EACnC,CAAC,CAAC,CACD8C,KAAK,CAAEd,KAAK,IAAKM,QAAQ,CAACpC,WAAW,CAAC8B,KAAK,CAAC,CAAC,CAAC;AACnD,CAAC;;AAEH;AACA;AACA,OAAO,MAAMe,WAAW,GAAGA,CACzB1C,KAAqB,EACrBgB,OAAiC,KAEjCgB,aAAa,CAAChC,KAAK,CAACC,UAAU,EAAED,KAAK,CAAC2C,QAAQ,EAAE;EAC9C,GAAG3B,OAAO;EACV4B,QAAQ,EAAE;AACZ,CAAC,CAAC","ignoreList":[]}
@@ -12,7 +12,8 @@ const createRequest = modularui => {
12
12
  data: modularui.data || {},
13
13
  locale: modularui.locale,
14
14
  childmodels: modularui.childmodels ?? true,
15
- isReload: modularui.isReload
15
+ isReload: modularui.isReload,
16
+ cache: modularui.cache
16
17
  });
17
18
  if (modularui.targetModel) {
18
19
  request.targetModel = modularui.targetModel;
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIMiddleware.js","names":["ModularUIRequest","HTTP_METHODS","startProgress","finishProgress","handleError","createRequest","modularui","request","href","method","GET","data","locale","childmodels","isReload","targetModel","forceTargetModel","responseHandler","next","dispatch","successAction","model","successResult","_Promise","then","result","catch","error","Error","errorHandler","errorAction","err","errorResult","handleFetch","action","requestOptions","payload","modularuiRequest","fetch","modularUIMiddleware","api","type","getState","i18n"],"sources":["../../../src/redux/_modularui/ModularUIMiddleware.js"],"sourcesContent":["// @flow\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\nimport { HTTP_METHODS } from \"../../constants/Constants\";\n\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\n\nimport { handleError } from \"../actions/Error\";\n\nimport type { Middleware, MiddlewareAPI } from \"redux\";\nimport type {\n ReduxAction,\n ReduxState,\n Dispatch,\n PossibleAction,\n} from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { ModularUIAction, SuccessAction, ErrorAction } from \"./types\";\nimport type { TargetModel } from \"../../modularui/types\";\n\ntype RequestOptions = {\n href: Href,\n method?: $Keys<typeof HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n isReload?: boolean,\n};\n\n/**\n * Symbol key that carries API call info interpreted by this Redux middleware.\n */\nconst createRequest = (modularui: RequestOptions): ModularUIRequest => {\n const request = new ModularUIRequest(modularui.href, {\n method: modularui.method || HTTP_METHODS.GET,\n data: modularui.data || {},\n locale: modularui.locale,\n childmodels: modularui.childmodels ?? true,\n isReload: modularui.isReload,\n });\n\n if (modularui.targetModel) {\n request.targetModel = modularui.targetModel;\n request.forceTargetModel = modularui.forceTargetModel ?? false;\n }\n\n return request;\n};\n\n/**\n */\nconst responseHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n successAction: SuccessAction,\n model: ModularUIModel,\n) => {\n if (successAction) {\n const successResult = successAction(model);\n\n if (successResult instanceof Promise) {\n successResult\n .then((result) => {\n dispatch(result);\n })\n .catch((error) => {\n next(handleError(error));\n });\n } else {\n try {\n dispatch(successResult);\n } catch (error) {\n throw new Error(\n `Result of successResult is not a valid redux action: ${error}`,\n );\n }\n }\n }\n\n return next(finishProgress());\n};\n\n/**\n */\nconst errorHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n errorAction: ?ErrorAction,\n err: any,\n) => {\n dispatch(finishProgress());\n\n if (errorAction) {\n const errorResult = errorAction(err);\n\n if (errorResult instanceof Promise) {\n errorResult.then((result) => dispatch(result));\n } else {\n dispatch(errorResult);\n }\n }\n\n return next(handleError(err));\n};\n\n/**\n */\nconst handleFetch = (\n action: ModularUIAction,\n locale: string,\n dispatch: Dispatch,\n next: Dispatch,\n) => {\n dispatch(startProgress());\n\n const { successAction, errorAction, ...requestOptions } = action.payload;\n requestOptions.locale = locale;\n\n const modularuiRequest = createRequest(requestOptions);\n\n return modularuiRequest\n .fetch()\n .then((model) => responseHandler(next, dispatch, successAction, model))\n .catch((error) => errorHandler(next, dispatch, errorAction, error));\n};\n\n/**\n */\nexport const modularUIMiddleware: Middleware<\n ReduxState,\n ReduxAction,\n Dispatch,\n> =\n (api: MiddlewareAPI<ReduxState, ReduxAction, Dispatch>) =>\n (next: Dispatch) =>\n (action: PossibleAction) => {\n if (action.type === \"MODULARUI/FETCH\") {\n return handleFetch(\n // $FlowExpectedError[incompatible-exact]\n action,\n api.getState().i18n.locale,\n api.dispatch,\n next,\n );\n }\n\n return next(action);\n };\n"],"mappings":";AACA,OAAOA,gBAAgB,MAAM,kCAAkC;AAC/D,SAASC,YAAY,QAAQ,2BAA2B;AAExD,SAASC,aAAa,EAAEC,cAAc,QAAQ,8BAA8B;AAE5E,SAASC,WAAW,QAAQ,kBAAkB;AAyB9C;AACA;AACA;AACA,MAAMC,aAAa,GAAIC,SAAyB,IAAuB;EACrE,MAAMC,OAAO,GAAG,IAAI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rB,QAAQ,EACZD,IACF,CAAC;EACH;EAEA,OAAOA,IAAI,CAACgB,MAAM,CAAC;AACrB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"ModularUIMiddleware.js","names":["ModularUIRequest","HTTP_METHODS","startProgress","finishProgress","handleError","createRequest","modularui","request","href","method","GET","data","locale","childmodels","isReload","cache","targetModel","forceTargetModel","responseHandler","next","dispatch","successAction","model","successResult","_Promise","then","result","catch","error","Error","errorHandler","errorAction","err","errorResult","handleFetch","action","requestOptions","payload","modularuiRequest","fetch","modularUIMiddleware","api","type","getState","i18n"],"sources":["../../../src/redux/_modularui/ModularUIMiddleware.js"],"sourcesContent":["// @flow\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\nimport { HTTP_METHODS } from \"../../constants/Constants\";\n\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\n\nimport { handleError } from \"../actions/Error\";\n\nimport type { Middleware, MiddlewareAPI } from \"redux\";\nimport type {\n ReduxAction,\n ReduxState,\n Dispatch,\n PossibleAction,\n} from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { ModularUIAction, SuccessAction, ErrorAction } from \"./types\";\nimport type { TargetModel } from \"../../modularui/types\";\n\ntype RequestOptions = {\n href: Href,\n method?: $Keys<typeof HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n isReload?: boolean,\n cache?: boolean,\n};\n\n/**\n * Symbol key that carries API call info interpreted by this Redux middleware.\n */\nconst createRequest = (modularui: RequestOptions): ModularUIRequest => {\n const request = new ModularUIRequest(modularui.href, {\n method: modularui.method || HTTP_METHODS.GET,\n data: modularui.data || {},\n locale: modularui.locale,\n childmodels: modularui.childmodels ?? true,\n isReload: modularui.isReload,\n cache: modularui.cache,\n });\n\n if (modularui.targetModel) {\n request.targetModel = modularui.targetModel;\n request.forceTargetModel = modularui.forceTargetModel ?? false;\n }\n\n return request;\n};\n\n/**\n */\nconst responseHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n successAction: SuccessAction,\n model: ModularUIModel,\n) => {\n if (successAction) {\n const successResult = successAction(model);\n\n if (successResult instanceof Promise) {\n successResult\n .then((result) => {\n dispatch(result);\n })\n .catch((error) => {\n next(handleError(error));\n });\n } else {\n try {\n dispatch(successResult);\n } catch (error) {\n throw new Error(\n `Result of successResult is not a valid redux action: ${error}`,\n );\n }\n }\n }\n\n return next(finishProgress());\n};\n\n/**\n */\nconst errorHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n errorAction: ?ErrorAction,\n err: any,\n) => {\n dispatch(finishProgress());\n\n if (errorAction) {\n const errorResult = errorAction(err);\n\n if (errorResult instanceof Promise) {\n errorResult.then((result) => dispatch(result));\n } else {\n dispatch(errorResult);\n }\n }\n\n return next(handleError(err));\n};\n\n/**\n */\nconst handleFetch = (\n action: ModularUIAction,\n locale: string,\n dispatch: Dispatch,\n next: Dispatch,\n) => {\n dispatch(startProgress());\n\n const { successAction, errorAction, ...requestOptions } = action.payload;\n requestOptions.locale = locale;\n\n const modularuiRequest = createRequest(requestOptions);\n\n return modularuiRequest\n .fetch()\n .then((model) => responseHandler(next, dispatch, successAction, model))\n .catch((error) => errorHandler(next, dispatch, errorAction, error));\n};\n\n/**\n */\nexport const modularUIMiddleware: Middleware<\n ReduxState,\n ReduxAction,\n Dispatch,\n> =\n (api: MiddlewareAPI<ReduxState, ReduxAction, Dispatch>) =>\n (next: Dispatch) =>\n (action: PossibleAction) => {\n if (action.type === \"MODULARUI/FETCH\") {\n return handleFetch(\n // $FlowExpectedError[incompatible-exact]\n action,\n api.getState().i18n.locale,\n api.dispatch,\n next,\n );\n }\n\n return next(action);\n };\n"],"mappings":";AACA,OAAOA,gBAAgB,MAAM,kCAAkC;AAC/D,SAASC,YAAY,QAAQ,2BAA2B;AAExD,SAASC,aAAa,EAAEC,cAAc,QAAQ,8BAA8B;AAE5E,SAASC,WAAW,QAAQ,kBAA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AAiB,EAAE;IACrC,OAAOR,WAAW;IAChB;IACAC,MAAM,EACNM,GAAG,CAACE,QAAQ,CAAC,CAAC,CAACC,IAAI,CAAChC,MAAM,EAC1B6B,GAAG,CAACrB,QAAQ,EACZD,IACF,CAAC;EACH;EAEA,OAAOA,IAAI,CAACgB,MAAM,CAAC;AACrB,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/redux/_modularui/types.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { FetchException } from \"../../exceptions\";\nimport type { NoAction } from \"../types\";\nimport typeof {\n HTTP_METHODS,\n MODULARUI_STATUS,\n} from \"../../constants/Constants\";\nimport type { ComponentType } from \"react\";\nimport type { TargetModel } from \"../../modularui/types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\nexport type ModularUIOptions = {\n propName?: string,\n removeOnUnmount?: boolean,\n ...RequestModularUIOptions,\n};\n\nexport type ModelEntry = {\n +status: string,\n +model: ModularUIModel,\n +lastModification: number,\n};\n\nexport type ModularUIState = {\n [string]: ModelEntry,\n ...\n};\n\nexport type SetModelAction = {\n type: \"MODULARUI/SET\",\n payload: {\n key: string,\n model: ?ModularUIModel,\n },\n};\n\nexport type InitModelAction = {\n type: \"MODULARUI/INIT\",\n payload: Array<{\n key: string,\n model: ModularUIModel,\n }>,\n};\n\nexport type UpdateModelAction = {\n type: \"MODULARUI/UPDATE\",\n payload: ModularUIModel,\n};\n\nexport type UpdateFormAction = {\n type: \"MODULARUI/UPDATE_FORM\",\n payload: ModularUIModel,\n};\n\nexport type SuccessAction = (\n model: ModularUIModel,\n) => UpdateModelAction | SetModelAction;\n\nexport type ErrorAction = (\n error: FetchException,\n) => UpdateStatusAction | RemoveModelByKeyAction | NoAction;\n\nexport type ModularUIAction = {\n type: \"MODULARUI/FETCH\",\n payload: {\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n successAction: (\n model: ModularUIModel,\n ) => UpdateModelAction | SetModelAction,\n errorAction?: ErrorAction,\n },\n};\n\nexport type RemoveModelByKeyAction = {\n type: \"MODULARUI/REMOVE_KEY\",\n payload: string,\n};\n\nexport type ResetModularUIAction = {\n type: \"MODULARUI/RESET\",\n};\n\nexport type UpdateStatusAction = {\n type: \"MODULARUI/STATUS\",\n payload: {\n key: string,\n status: $Keys<MODULARUI_STATUS>,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>,\n) => ComponentType<any>;\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/redux/_modularui/types.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { FetchException } from \"../../exceptions\";\nimport type { NoAction } from \"../types\";\nimport typeof {\n HTTP_METHODS,\n MODULARUI_STATUS,\n} from \"../../constants/Constants\";\nimport type { ComponentType } from \"react\";\nimport type { TargetModel } from \"../../modularui/types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\nexport type ModularUIOptions = {\n propName?: string,\n removeOnUnmount?: boolean,\n ...RequestModularUIOptions,\n};\n\nexport type ModelEntry = {\n +status: string,\n +model: ModularUIModel,\n +lastModification: number,\n};\n\nexport type ModularUIState = {\n [string]: ModelEntry,\n ...\n};\n\nexport type SetModelAction = {\n type: \"MODULARUI/SET\",\n payload: {\n key: string,\n model: ?ModularUIModel,\n },\n};\n\nexport type InitModelAction = {\n type: \"MODULARUI/INIT\",\n payload: Array<{\n key: string,\n model: ModularUIModel,\n }>,\n};\n\nexport type UpdateModelAction = {\n type: \"MODULARUI/UPDATE\",\n payload: ModularUIModel,\n};\n\nexport type UpdateFormAction = {\n type: \"MODULARUI/UPDATE_FORM\",\n payload: ModularUIModel,\n};\n\nexport type SuccessAction = (\n model: ModularUIModel,\n) => UpdateModelAction | SetModelAction;\n\nexport type ErrorAction = (\n error: FetchException,\n) => UpdateStatusAction | RemoveModelByKeyAction | NoAction;\n\nexport type ModularUIAction = {\n type: \"MODULARUI/FETCH\",\n payload: {\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n cache?: boolean,\n successAction: (\n model: ModularUIModel,\n ) => UpdateModelAction | SetModelAction,\n errorAction?: ErrorAction,\n },\n};\n\nexport type RemoveModelByKeyAction = {\n type: \"MODULARUI/REMOVE_KEY\",\n payload: string,\n};\n\nexport type ResetModularUIAction = {\n type: \"MODULARUI/RESET\",\n};\n\nexport type UpdateStatusAction = {\n type: \"MODULARUI/STATUS\",\n payload: {\n key: string,\n status: $Keys<MODULARUI_STATUS>,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>,\n) => ComponentType<any>;\n"],"mappings":"","ignoreList":[]}
@@ -19,9 +19,10 @@ var _useModularUIBasic = require("./useModularUIBasic");
19
19
  var _models = require("../models");
20
20
  /**
21
21
  */
22
- const useModelCatalog = () => (0, _useModularUIBasic.useModularUIBasic)("modelcatalog", "/modelcatalog", {
22
+ const useModelCatalog = options => (0, _useModularUIBasic.useModularUIBasic)("modelcatalog", "/modelcatalog", {
23
23
  expectedModels: ["ModelCatalog"],
24
- targetModel: _ModelCatalogModel.default
24
+ targetModel: _ModelCatalogModel.default,
25
+ ...options
25
26
  });
26
27
 
27
28
  /**
@@ -29,10 +30,12 @@ const useModelCatalog = () => (0, _useModularUIBasic.useModularUIBasic)("modelca
29
30
  exports.useModelCatalog = useModelCatalog;
30
31
  const useConceptIndex = function (href) {
31
32
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "conceptindex";
33
+ let options = arguments.length > 2 ? arguments[2] : undefined;
32
34
  const url = (0, _createHref.filterParameters)(href, ["entryDate", "index", "label", "type"]);
33
35
  return (0, _useModularUIBasic.useModularUIBasic)(key, url, {
34
36
  expectedModels: ["ConceptIndex"],
35
- targetModel: _ConceptIndexModel.default
37
+ targetModel: _ConceptIndexModel.default,
38
+ ...options
36
39
  });
37
40
  };
38
41
 
@@ -41,10 +44,12 @@ const useConceptIndex = function (href) {
41
44
  exports.useConceptIndex = useConceptIndex;
42
45
  const useConceptDetail = function (concept) {
43
46
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "conceptdetail";
47
+ let options = arguments.length > 2 ? arguments[2] : undefined;
44
48
  const location = (0, _useRouter.useLocation)();
45
49
  const href = (0, _createHref.createHref)("concepts", concept, location, ["entryDate"]);
46
50
  return (0, _useModularUIBasic.useModularUIBasic)(key, href, {
47
- expectedModels: ["ConceptDetail", "BusinessScenario"]
51
+ expectedModels: ["ConceptDetail", "BusinessScenario"],
52
+ ...options
48
53
  });
49
54
  };
50
55
 
@@ -53,10 +58,12 @@ const useConceptDetail = function (concept) {
53
58
  exports.useConceptDetail = useConceptDetail;
54
59
  const useContentIndex = function (href) {
55
60
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contentindex";
61
+ let options = arguments.length > 2 ? arguments[2] : undefined;
56
62
  const url = (0, _createHref.filterParameters)(href, ["index", "label", "type"]);
57
63
  return (0, _useModularUIBasic.useModularUIBasic)(key, url, {
58
64
  expectedModels: ["ContentIndex"],
59
- targetModel: _ContentIndexModel.default
65
+ targetModel: _ContentIndexModel.default,
66
+ ...options
60
67
  });
61
68
  };
62
69
 
@@ -65,11 +72,13 @@ const useContentIndex = function (href) {
65
72
  exports.useContentIndex = useContentIndex;
66
73
  const useContentTOC = function (content) {
67
74
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contenttoc";
75
+ let options = arguments.length > 2 ? arguments[2] : undefined;
68
76
  const location = (0, _useRouter.useLocation)();
69
77
  const href = (0, _createHref.createHref)("content", content, location, ["entryDate"]);
70
78
  return (0, _useModularUIBasic.useModularUIBasic)(key, href, {
71
79
  expectedModels: ["ContentTOC"],
72
- targetModel: _ContentTOCModel.default
80
+ targetModel: _ContentTOCModel.default,
81
+ ...options
73
82
  });
74
83
  };
75
84
 
@@ -78,10 +87,12 @@ const useContentTOC = function (content) {
78
87
  exports.useContentTOC = useContentTOC;
79
88
  const useContent = function (contentSection) {
80
89
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "content";
90
+ let options = arguments.length > 2 ? arguments[2] : undefined;
81
91
  const href = (0, _createHref.createHref)("content", contentSection, null, ["entryDate"]);
82
92
  return (0, _useModularUIBasic.useModularUIBasic)(key, href, {
83
93
  expectedModels: ["Content"],
84
- targetModel: _ContentModel.default
94
+ targetModel: _ContentModel.default,
95
+ ...options
85
96
  });
86
97
  };
87
98
 
@@ -90,10 +101,12 @@ const useContent = function (contentSection) {
90
101
  exports.useContent = useContent;
91
102
  const useContentType = function (contentType) {
92
103
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contenttypes";
104
+ let options = arguments.length > 2 ? arguments[2] : undefined;
93
105
  const href = (0, _createHref.createHref)("contenttypes", contentType, null, ["entryDate"]);
94
106
  return (0, _useModularUIBasic.useModularUIBasic)(key, href, {
95
107
  expectedModels: ["ContentType"],
96
- targetModel: _models.ContentTypeModel
108
+ targetModel: _models.ContentTypeModel,
109
+ ...options
97
110
  });
98
111
  };
99
112
 
@@ -119,8 +132,9 @@ const getSearchHref = (uri, filters) => {
119
132
  */
120
133
  const useConceptSearch = function (filters) {
121
134
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "conceptSearch";
135
+ let options = arguments.length > 2 ? arguments[2] : undefined;
122
136
  const href = getSearchHref("/concepts", filters);
123
- return useConceptIndex(href, key);
137
+ return useConceptIndex(href, key, options);
124
138
  };
125
139
 
126
140
  /**
@@ -128,8 +142,9 @@ const useConceptSearch = function (filters) {
128
142
  exports.useConceptSearch = useConceptSearch;
129
143
  const useContentSearch = function (filters) {
130
144
  let key = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "contentSearch";
145
+ let options = arguments.length > 2 ? arguments[2] : undefined;
131
146
  const href = getSearchHref("/content", filters);
132
- return useContentIndex(href, key);
147
+ return useContentIndex(href, key, options);
133
148
  };
134
149
  exports.useContentSearch = useContentSearch;
135
150
  //# sourceMappingURL=useModelCatalog.js.map
@@ -14,6 +14,7 @@ import ContentModel from "../models/content/ContentModel";
14
14
  import { useModularUIBasic } from "./useModularUIBasic";
15
15
  import { ContentTypeModel } from "../models";
16
16
 
17
+ import type { UseModularUIBasicOptions } from "./useModularUIBasic";
17
18
  export type SearchFilter = {
18
19
  index?: string,
19
20
  label?: string,
@@ -23,10 +24,13 @@ export type SearchFilter = {
23
24
 
24
25
  /**
25
26
  */
26
- export const useModelCatalog = (): ?ModelCatalogModel =>
27
+ export const useModelCatalog = (
28
+ options?: UseModularUIBasicOptions<ModelCatalogModel>,
29
+ ): ?ModelCatalogModel =>
27
30
  useModularUIBasic("modelcatalog", "/modelcatalog", {
28
31
  expectedModels: ["ModelCatalog"],
29
32
  targetModel: ModelCatalogModel,
33
+ ...options,
30
34
  });
31
35
 
32
36
  /**
@@ -34,11 +38,13 @@ export const useModelCatalog = (): ?ModelCatalogModel =>
34
38
  export const useConceptIndex = (
35
39
  href: string,
36
40
  key?: string = "conceptindex",
41
+ options?: UseModularUIBasicOptions<ConceptIndexModel>,
37
42
  ): ?ConceptIndexModel => {
38
43
  const url = filterParameters(href, ["entryDate", "index", "label", "type"]);
39
44
  return useModularUIBasic(key, url, {
40
45
  expectedModels: ["ConceptIndex"],
41
46
  targetModel: ConceptIndexModel,
47
+ ...options,
42
48
  });
43
49
  };
44
50
 
@@ -47,12 +53,16 @@ export const useConceptIndex = (
47
53
  export const useConceptDetail = (
48
54
  concept: string,
49
55
  key?: string = "conceptdetail",
56
+ options?: UseModularUIBasicOptions<
57
+ ConceptDetailModel | BusinessScenarioModel,
58
+ >,
50
59
  ): ?ConceptDetailModel | ?BusinessScenarioModel => {
51
60
  const location = useLocation();
52
61
 
53
62
  const href = createHref("concepts", concept, location, ["entryDate"]);
54
63
  return useModularUIBasic(key, href, {
55
64
  expectedModels: ["ConceptDetail", "BusinessScenario"],
65
+ ...options,
56
66
  });
57
67
  };
58
68
 
@@ -61,11 +71,13 @@ export const useConceptDetail = (
61
71
  export const useContentIndex = (
62
72
  href: string,
63
73
  key?: string = "contentindex",
74
+ options?: UseModularUIBasicOptions<ContentIndexModel>,
64
75
  ): ?ContentIndexModel => {
65
76
  const url = filterParameters(href, ["index", "label", "type"]);
66
77
  return useModularUIBasic(key, url, {
67
78
  expectedModels: ["ContentIndex"],
68
79
  targetModel: ContentIndexModel,
80
+ ...options,
69
81
  });
70
82
  };
71
83
 
@@ -74,12 +86,14 @@ export const useContentIndex = (
74
86
  export const useContentTOC = (
75
87
  content: string,
76
88
  key?: string = "contenttoc",
89
+ options?: UseModularUIBasicOptions<ContentTOCModel>,
77
90
  ): ?ContentTOCModel => {
78
91
  const location = useLocation();
79
92
  const href = createHref("content", content, location, ["entryDate"]);
80
93
  return useModularUIBasic(key, href, {
81
94
  expectedModels: ["ContentTOC"],
82
95
  targetModel: ContentTOCModel,
96
+ ...options,
83
97
  });
84
98
  };
85
99
 
@@ -88,11 +102,13 @@ export const useContentTOC = (
88
102
  export const useContent = (
89
103
  contentSection: string,
90
104
  key?: string = "content",
105
+ options?: UseModularUIBasicOptions<ContentModel>,
91
106
  ): ?ContentModel => {
92
107
  const href = createHref("content", contentSection, null, ["entryDate"]);
93
108
  return useModularUIBasic(key, href, {
94
109
  expectedModels: ["Content"],
95
110
  targetModel: ContentModel,
111
+ ...options,
96
112
  });
97
113
  };
98
114
 
@@ -101,11 +117,13 @@ export const useContent = (
101
117
  export const useContentType = (
102
118
  contentType: string,
103
119
  key?: string = "contenttypes",
120
+ options?: UseModularUIBasicOptions<ContentTypeModel>,
104
121
  ): ?ContentTypeModel => {
105
122
  const href = createHref("contenttypes", contentType, null, ["entryDate"]);
106
123
  return useModularUIBasic(key, href, {
107
124
  expectedModels: ["ContentType"],
108
125
  targetModel: ContentTypeModel,
126
+ ...options,
109
127
  });
110
128
  };
111
129
 
@@ -135,9 +153,10 @@ const getSearchHref = (uri: string, filters: SearchFilter): string => {
135
153
  export const useConceptSearch = (
136
154
  filters: SearchFilter,
137
155
  key?: string = "conceptSearch",
156
+ options?: UseModularUIBasicOptions<ConceptIndexModel>,
138
157
  ): ?ConceptIndexModel => {
139
158
  const href = getSearchHref("/concepts", filters);
140
- return useConceptIndex(href, key);
159
+ return useConceptIndex(href, key, options);
141
160
  };
142
161
 
143
162
  /**
@@ -145,7 +164,8 @@ export const useConceptSearch = (
145
164
  export const useContentSearch = (
146
165
  filters: SearchFilter,
147
166
  key?: string = "contentSearch",
167
+ options?: UseModularUIBasicOptions<ContentIndexModel>,
148
168
  ): ?ContentIndexModel => {
149
169
  const href = getSearchHref("/content", filters);
150
- return useContentIndex(href, key);
170
+ return useContentIndex(href, key, options);
151
171
  };