@beinformed/ui 1.53.0 → 1.54.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/esm/hooks/useModelCatalog.js +25 -10
  3. package/esm/hooks/useModelCatalog.js.map +1 -1
  4. package/esm/hooks/useModularUIBasic.js +5 -1
  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 +5 -1
  15. package/lib/hooks/useModularUIBasic.js.flow +7 -1
  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 +7 -1
  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,13 @@
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.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.53.0...v1.54.0) (2024-09-17)
6
+
7
+
8
+ ### Features
9
+
10
+ * **modularui:** allow caching data service of modularui ([d1c65f7](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/d1c65f7081853556aa2eb431064f2fb05a94b422))
11
+
5
12
  ## [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
13
 
7
14
 
@@ -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;AAE1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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,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;EAC3E,OAAOP,iBAAiB,CAACQ,GAAG,EAAEI,GAAG,EAAE;IACjCR,cAAc,EAAE,CAAC,cAAc,CAAC;IAChCC,WAAW,EAAEZ,iBAAiB;IAC9B,GAAGU;EACL,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA,O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;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())) {
@@ -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 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;AAWrD;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAG,SAAAA,CAC/BC,GAAW,EACXC,IAAmB,EAMN;EAAA,IAAAC,QAAA;EAAA,IALbC,OAAoC,GA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AE;QACnBI,OAAO,CAACC,KAAK,CAACP,SAAS,EAAE,oBAAoB,EAAEjB,OAAO,CAACI,cAAc,CAAC;QACtE,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,GAAI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ACrC,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(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,k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AACtC,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,IAAIP,gBAAgB,CAACM,SAAS,CAACE,IAAI,EAAE;IACnDC,MAAM,EAAEH,SAAS,CAACG,MAAM,IAAIR,YAAY,CAACS,GAAG;IAC5CC,IAAI,EAAEL,SAAS,CAACK,IAAI,IAAI,CAAC,CAAC;IAC1BC,MAAM,EAAEN,SAAS,CAACM,MAAM;IACxBC,WAAW,EAAEP,SAAS,CAACO,WAAW,IAAI,IAAI;IAC1CC,QAAQ,EAAER,SAAS,CAACQ;EACtB,CAAC,CAAC;EAEF,IAAIR,SAAS,CAACS,WAAW,EAAE;IACzBR,OAAO,CAACQ,WAAW,GAAGT,SAAS,CAACS,WAAW;IAC3CR,OAAO,CAACS,gBAAgB,GAAGV,SAAS,CAACU,gBAAgB,IAAI,KAAK;EAChE;EAEA,OAAOT,OAAO;AAChB,CAAC;;AAED;AACA;AACA,MAAMU,eAAe,GAAGA,CACtBC,IAAc,EACdC,QAAkB,EAClBC,aAA4B,EAC5BC,KAAqB,KAClB;EACH,IAAID,aAAa,EAAE;IACjB,MAAME,aAAa,GAAGF,aAAa,CAACC,KAAK,CAAC;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AGhC,aAAa,CAAC8B,cAAc,CAAC;EAEtD,OAAOE,gBAAgB,CACpBC,KAAK,CAAC,CAAC,CACPd,IAAI,CAAEH,KAAK,IAAKJ,eAAe,CAACC,IAAI,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,KAAK,CAAC,CAAC,CACtEK,KAAK,CAAEC,KAAK,IAAKE,YAAY,CAACX,IAAI,EAAEC,QAAQ,EAAEW,WAAW,EAAEH,KAAK,CAAC,CAAC;AACvE,CAAC;;AAED;AACA;AACA,OAAO,MAAMY,mBAIZ,GACEC,GAAqD,IACrDtB,IAAc,IACdgB,MAAsB,IAAK;EAC1B,IAAIA,MAAM,CAACO,IAAI,KAAK,iBAAiB,EAAE;IACrC,OAAOR,WAAW;IAChB;IACAC,MAAM,EACNM,GAAG,CAACE,QAAQ,CAAC,CAAC,CAACC,IAAI,CAAC/B,MAAM,EAC1B4B,GAAG,CAACrB,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,kBAAkB;AA0B9C;AACA;AACA;AACA,MAAMC,aAAa,GAAIC,SAAyB,IAAuB;EACrE,MAAMC,OAAO,GAAG,IAAIP,gBAAgB,CAACM,SAAS,CAACE,IAAI,EAAE;IACnDC,MAAM,EAAEH,SAAS,CAACG,MAAM,IAAIR,YAAY,CAACS,GAAG;IAC5CC,IAAI,EAAEL,SAAS,CAACK,IAAI,IAAI,CAAC,CAAC;IAC1BC,MAAM,EAAEN,SAAS,CAACM,MAAM;IACxBC,WAAW,EAAEP,SAAS,CAACO,WAAW,IAAI,IAAI;IAC1CC,QAAQ,EAAER,SAAS,CAACQ,QAAQ;IAC5BC,KAAK,EAAET,SAAS,CAACS;EACnB,CAAC,CAAC;EAEF,IAAIT,SAAS,CAACU,WAAW,EAAE;IACzBT,OAAO,CAACS,WAAW,GAAGV,SAAS,CAACU,WAAW;IAC3CT,OAAO,CAACU,gBAAgB,GAAGX,SAAS,CAACW,gBAAgB,IAAI,KAAK;EAChE;EAEA,OAAOV,OAAO;AAChB,CAAC;;AAED;AACA;AACA,MAAMW,eAAe,GAAGA,CACtB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Aa;IAAEU,WAAW;IAAE,GAAGK;EAAe,CAAC,GAAGD,MAAM,CAACE,OAAO;EACxED,cAAc,CAACxB,MAAM,GAAGA,MAAM;EAE9B,MAAM0B,gBAAgB,GAAGjC,aAAa,CAAC+B,cAAc,CAAC;EAEtD,OAAOE,gBAAgB,CACpBC,KAAK,CAAC,CAAC,CACPd,IAAI,CAAEH,KAAK,IAAKJ,eAAe,CAACC,IAAI,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,KAAK,CAAC,CAAC,CACtEK,KAAK,CAAEC,KAAK,IAAKE,YAAY,CAACX,IAAI,EAAEC,QAAQ,EAAEW,WAAW,EAAEH,KAAK,CAAC,CAAC;AACvE,CAAC;;AAED;AACA;AACA,OAAO,MAAMY,mBAIZ,GACEC,GAAqD,IACrDtB,IAAc,IACdgB,MAAsB,IAAK;EAC1B,IAAIA,MAAM,CAACO,IAAI,KAAK,iBAAiB,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
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useModelCatalog.js","names":["_useRouter","require","_createHref","_ModelCatalogModel","_interopRequireDefault","_ConceptIndexModel","_ConceptDetailModel","_BusinessScenarioModel","_ContentIndexModel","_ContentTOCModel","_ContentModel","_useModularUIBasic","_models","useModelCatalog","useModularUIBasic","expectedModels","targetModel","ModelCatalogModel","exports","useConceptIndex","href","key","arguments","length","undefined","url","filterParameters","ConceptIndexModel","useConceptDetail","concept","location","useLocation","createHref","useContentIndex","ContentIndexModel","useContentTOC","content","ContentTOCModel","useContent","contentSection","ContentModel","useContentType","contentType","ContentTypeModel","getSearchHref","uri","filters","filterString","_keys","default","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,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,kBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,mBAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,sBAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,kBAAA,GAAAJ,sBAAA,CAAAH,OAAA;AACA,IAAAQ,gBAAA,GAAAL,sBAAA,CAAAH,OAAA;AACA,IAAAS,aAAA,GAAAN,sBAAA,CAAAH,OAAA;AAEA,IAAAU,kBAAA,GAAAV,OAAA;AACA,IAAAW,OAAA,GAAAX,OAAA;AASA;AACA;AACO,MAAMY,eAAe,GAAGA,CAAA,KAC7B,IAAAC,oCAAiB,EAAC,cAAc,EAAE,eAAe,EAAE;EACjDC,cAAc,EAAE,CAAC,cAAc,CAAC;EAChCC,WAAW,EAAEC;AACf,CAAC,CAAC;;AAEJ;AACA;AADAC,OAAA,CAAAL,eAAA,GAAAA,eAAA;AAEO,MAAMM,eAAe,GAAG,SAAAA,CAC7BC,IAAY,EAEW;EAAA,IADvBC,GAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,cAAc;EAE7B,MAAMG,GAAG,GAAG,IAAAC,4BAAgB,EAACN,IAAI,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;EAC3E,OAAO,IAAAN,oCAAiB,EAACO,GAAG,EAAEI,GAAG,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AAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,eAAe;EAE9B,MAAMF,IAAI,GAAGwB,aAAa,CAAC,UAAU,EAAEE,OAAO,CAAC;EAC/C,OAAOb,eAAe,CAACb,IAAI,EAAEC,GAAG,CAAC;AACnC,CAAC;AAACH,OAAA,CAAAwC,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"file":"useModelCatalog.js","names":["_useRouter","require","_createHref","_ModelCatalogModel","_interopRequireDefault","_ConceptIndexModel","_ConceptDetailModel","_BusinessScenarioModel","_ContentIndexModel","_ContentTOCModel","_ContentModel","_useModularUIBasic","_models","useModelCatalog","options","useModularUIBasic","expectedModels","targetModel","ModelCatalogModel","exports","useConceptIndex","href","key","arguments","length","undefined","url","filterParameters","ConceptIndexModel","useConceptDetail","concept","location","useLocation","createHref","useContentIndex","ContentIndexModel","useContentTOC","content","ContentTOCModel","useContent","contentSection","ContentModel","useContentType","contentType","ContentTypeModel","getSearchHref","uri","filters","filterString","_keys","default","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,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,kBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,mBAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,sBAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,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AAe,CAACC,IAAI,EAAEC,GAAG,EAAER,OAAO,CAAC;AAC5C,CAAC;;AAED;AACA;AADAK,OAAA,CAAAuC,gBAAA,GAAAA,gBAAA;AAEO,MAAMC,gBAAgB,GAAG,SAAAA,CAC9BZ,OAAqB,EAGE;EAAA,IAFvBzB,GAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,eAAe;EAAA,IAC9BT,OAAqD,GAAAS,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAErD,MAAMJ,IAAI,GAAGwB,aAAa,CAAC,UAAU,EAAEE,OAAO,CAAC;EAC/C,OAAOb,eAAe,CAACb,IAAI,EAAEC,GAAG,EAAER,OAAO,CAAC;AAC5C,CAAC;AAACK,OAAA,CAAAwC,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -22,12 +22,16 @@ const useModularUIBasic = function (key, href) {
22
22
  const useModularUIOptions = {
23
23
  targetModel: undefined,
24
24
  forceTargetModel: undefined,
25
- isReload: false
25
+ isReload: false,
26
+ cache: false
26
27
  };
27
28
  if (options.targetModel) {
28
29
  useModularUIOptions.targetModel = options.targetModel;
29
30
  useModularUIOptions.forceTargetModel = options.forceTargetModel;
30
31
  }
32
+ if (options.cache) {
33
+ useModularUIOptions.cache = options.cache;
34
+ }
31
35
 
32
36
  // reload when the modular service starts with the current location
33
37
  if (location.state?.reload && (0, _startsWith.default)(_context = location.pathname).call(_context, href.toString())) {
@@ -7,10 +7,11 @@ import { IllegalStateException } from "../exceptions";
7
7
 
8
8
  import type { ModularUIModel, Href } from "../models";
9
9
 
10
- type UseModularUIBasicOptions<T: ModularUIModel> = {
10
+ export type UseModularUIBasicOptions<T: ModularUIModel> = {
11
11
  expectedModels: Array<string>,
12
12
  targetModel?: Class<T> | Array<Class<T>>,
13
13
  forceTargetModel?: boolean,
14
+ cache?: boolean,
14
15
  };
15
16
 
16
17
  /**
@@ -30,12 +31,17 @@ export const useModularUIBasic = <T: ModularUIModel>(
30
31
  targetModel: undefined,
31
32
  forceTargetModel: undefined,
32
33
  isReload: false,
34
+ cache: false,
33
35
  };
34
36
  if (options.targetModel) {
35
37
  useModularUIOptions.targetModel = options.targetModel;
36
38
  useModularUIOptions.forceTargetModel = options.forceTargetModel;
37
39
  }
38
40
 
41
+ if (options.cache) {
42
+ useModularUIOptions.cache = options.cache;
43
+ }
44
+
39
45
  // reload when the modular service starts with the current location
40
46
  if (location.state?.reload && location.pathname.startsWith(href.toString())) {
41
47
  useModularUIOptions.isReload = true;
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUIBasic.js","names":["_useModularUI","require","_useRouter","_exceptions","useModularUIBasic","key","href","_context","options","arguments","length","undefined","expectedModels","targetModel","forceTargetModel","location","useLocation","useModularUIOptions","isReload","state","reload","_startsWith","default","pathname","call","toString","modularUI","useModularUI","model","isCorrectModel","some","expectedModel","type","console","error","IllegalStateException","exports"],"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,IAAAA,aAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAUA;AACA;AACO,MAAMG,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,GAAG,IAAAC,sBAAW,EAAC,CAAC;EAE9B,MAAMC,mBAAmB,GAAG;IAC1BJ,WAAW,EAAEF,SAAS;IACtBG,gBAAgB,EAAEH,SAAS;IAC3BO,QAAQ,EAAE;EACZ,CAAC;EACD,IAAIV,OAAO,CAACK,WAAW,EAAE;IACvBI,mBAAmB,CAACJ,WAAW,GAAGL,OAAO,CAACK,WAAW;IACrDI,mBAAmB,CAACH,gBAAgB,GAAGN,OAAO,CAACM,gBAAgB;EACjE;;EAEA;EACA,IAAIC,QAAQ,CAACI,KAAK,EAAEC,MAAM,IAAI,IAAAC,WAAA,CAAAC,OAAA,EAAAf,QAAA,GAAAQ,QAAQ,CAACQ,QAAQ,EAAAC,IAAA,CAAAjB,QAAA,EAAYD,IAAI,CAACmB,QAAQ,CAAC,CAAC,CAAC,EAAE;IAC3ER,mBAAmB,CAACC,QAAQ,GAAG,IAAI;EACrC;;EAEA;EACA,MAAMQ,SAAS,GAAG,IAAAC,0BAAY,EAACtB,GAAG,EAAEC,IAAI,EAAEW,mBAAmB,CAAC;EAE9D,IAAIS,SAAS,EAAEE,KAAK,EAAE;IACpB,MAAM;MAAEA;IAAM,CAAC,GAAGF,SAAS;IAC3B,IAAIlB,OAAO,CAACI,cAAc,CAACF,MAAM,GAAG,CAAC,EAAE;MACrC,MAAMmB,cAAc,GAAGrB,OAAO,CAACI,cAAc,CAACkB,IAAI,CAAEC,aAAa,IAAK;QACpE,OAAOH,KAAK,CAACI,IAAI,KAAKD,aAAa;MACrC,CAAC,CAAC;MAEF,IAAI,CAACF,cAAc,EAAE;QACnBI,OAAO,CAACC,KAAK,CAACR,SAAS,EAAE,oBAAoB,EAAElB,OAAO,CAACI,cAAc,CAAC;QACtE,MAAM,IAAIuB,iCAAqB,CAAC,mCAAmC,CAAC;MACtE;IACF;IAEA,OAAOP,KAAK;EACd;EAEA,OAAO,IAAI;AACb,CAAC;AAACQ,OAAA,CAAAhC,iBAAA,GAAAA,iBAAA","ignoreList":[]}
1
+ {"version":3,"file":"useModularUIBasic.js","names":["_useModularUI","require","_useRouter","_exceptions","useModularUIBasic","key","href","_context","options","arguments","length","undefined","expectedModels","targetModel","forceTargetModel","location","useLocation","useModularUIOptions","isReload","cache","state","reload","_startsWith","default","pathname","call","toString","modularUI","useModularUI","model","isCorrectModel","some","expectedModel","type","console","error","IllegalStateException","exports"],"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 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,IAAAA,aAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAWA;AACA;AACO,MAAMG,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,GAAG,IAAAC,sBAAW,EAAC,CAAC;EAE9B,MAAMC,mBAAmB,GAAG;IAC1BJ,WAAW,EAAEF,SAAS;IACtBG,gBAAgB,EAAEH,SAAS;IAC3BO,QAAQ,EAAE,KAAK;IACfC,KAAK,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99
  childmodels: options?.childmodels,
100
100
  targetModel: options?.targetModel,
101
101
  forceTargetModel: options?.forceTargetModel,
102
+ cache: options?.cache,
102
103
  /**
103
104
  */
104
105
  successAction: model => loadModelSuccessAction(key, model, options?.updateHandler),
@@ -116,6 +116,7 @@ export const loadModel = (
116
116
  childmodels: options?.childmodels,
117
117
  targetModel: options?.targetModel,
118
118
  forceTargetModel: options?.forceTargetModel,
119
+ cache: options?.cache,
119
120
  /**
120
121
  */
121
122
  successAction: (model) =>
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIActions.js","names":["_Constants","require","_Href","_interopRequireDefault","_ErrorResponse","_ProgressIndicator","_Error","setModel","key","model","connectKey","type","payload","exports","initModels","models","updateModel","updateForm","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","updateHandler","loadModel","href","options","Href","method","HTTP_METHODS","GET","data","locale","childmodels","targetModel","forceTargetModel","successAction","errorAction","error","errorResponse","ErrorResponse","isChangePassword","isResourceNotFoundAfterReload","MODULARUI_STATUS","ERROR","loadModularUI","dispatch","LOADING","startProgress","loadModelPromise","_promise","default","resolve","then","response","FINISHED","finishProgress","catch","handleError","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,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,cAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAmBA;AACA;AACO,MAAMM,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;AADAI,OAAA,CAAAN,QAAA,GAAAA,QAAA;AAEO,MAAMO,UAAU,GACrBC,MAAqD,KAChC;EACrBJ,IAAI,EAAE,gBAAgB;EACtBC,OAAO,EAAEG;AACX,CAAC,CAAC;;AAEF;AACA;AADAF,OAAA,CAAAC,UAAA,GAAAA,UAAA;AAEO,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,CAAQC,OAAO,CAACH,gBAAgB,CAAC,CACrCI,IAAI,CAAEC,QAAQ,IAAK;IAClB,IAAIA,QAAQ,EAAE3C,IAAI,KAAK,iBAAiB,EAAE;MACxCmC,QAAQ,CAAC1B,YAAY,CAACZ,GAAG,EAAEmC,2BAAgB,CAACY,QAAQ,CAAC,CAAC;IACxD;IAEA,OAAOT,QAAQ,CAAC,IAAAU,iCAAc,EAAC,CAAC,CAAC;EACnC,CAAC,CAAC,CACDC,KAAK,CAAEnB,KAAK,IAAKQ,QAAQ,CAAC,IAAAY,kBAAW,EAACpB,KAAK,CAAC,CAAC,CAAC;AACnD,CAAC;;AAEH;AACA;AADAzB,OAAA,CAAAgC,aAAA,GAAAA,aAAA;AAEO,MAAMc,WAAW,GAAGA,CACzBlD,KAAqB,EACrBiB,OAAiC,KAEjCmB,aAAa,CAACpC,KAAK,CAACC,UAAU,EAAED,KAAK,CAACmD,QAAQ,EAAE;EAC9C,GAAGlC,OAAO;EACVmC,QAAQ,EAAE;AACZ,CAAC,CAAC;AAAChD,OAAA,CAAA8C,WAAA,GAAAA,WAAA","ignoreList":[]}
1
+ {"version":3,"file":"ModularUIActions.js","names":["_Constants","require","_Href","_interopRequireDefault","_ErrorResponse","_ProgressIndicator","_Error","setModel","key","model","connectKey","type","payload","exports","initModels","models","updateModel","updateForm","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","updateHandler","loadModel","href","options","Href","method","HTTP_METHODS","GET","data","locale","childmodels","targetModel","forceTargetModel","cache","successAction","errorAction","error","errorResponse","ErrorResponse","isChangePassword","isResourceNotFoundAfterReload","MODULARUI_STATUS","ERROR","loadModularUI","dispatch","LOADING","startProgress","loadModelPromise","_promise","default","resolve","then","response","FINISHED","finishProgress","catch","handleError","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(model.connectKey, model.selfhref, {\n ...options,\n isReload: true,\n });\n"],"mappings":";;;;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,cAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAmBA;AACA;AACO,MAAMM,QAAQ,GAAGA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,CAAC,CAAC;;AAEF;AACA;AADAhC,OAAA,CAAAW,SAAA,GAAAA,SAAA;AAEO,MAAMsB,aAAa,GACxBA,CACEtC,GAAW,EACXiB,IAAmB,EACnBC,OAAiC,KAElCqB,QAAkB,IAAK;EACtBA,QAAQ,CAAC3B,YAAY,CAACZ,GAAG,EAAEoC,2BAAgB,CAACI,OAAO,CAAC,CAAC;EACrDD,QAAQ,CAAC,IAAAE,gCAAa,EAAC,CAAC,CAAC;EAEzB,MAAMC,gBAAgB,GAAGH,QAAQ,CAACvB,SAAS,CAAChB,GAAG,EAAEiB,IAAI,EAAEC,OAAO,CAAC,CAAC;EAEhE,OAAOyB,QAAA,CAAAC,OAAA,CAAQC,OAAO,CAACH,gBAAgB,CAAC,CACrCI,IAAI,CAAEC,QAAQ,IAAK;IAClB,IAAIA,QAAQ,EAAE5C,IAAI,KAAK,iBAAiB,EAAE;MACxCoC,QAAQ,CAAC3B,YAAY,CAACZ,GAAG,EAAEoC,2BAAgB,CAACY,QAAQ,CAAC,CAAC;IACxD;IAEA,OAAOT,QAAQ,CAAC,IAAAU,iCAAc,EAAC,CAAC,CAAC;EACnC,CAAC,CAAC,CACDC,KAAK,CAAEnB,KAAK,IAAKQ,QAAQ,CAAC,IAAAY,kBAAW,EAACpB,KAAK,CAAC,CAAC,CAAC;AACnD,CAAC;;AAEH;AACA;AADA1B,OAAA,CAAAiC,aAAA,GAAAA,aAAA;AAEO,MAAMc,WAAW,GAAGA,CACzBnD,KAAqB,EACrBiB,OAAiC,KAEjCoB,aAAa,CAACrC,KAAK,CAACC,UAAU,EAAED,KAAK,CAACoD,QAAQ,EAAE;EAC9C,GAAGnC,OAAO;EACVoC,QAAQ,EAAE;AACZ,CAAC,CAAC;AAACjD,OAAA,CAAA+C,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -19,7 +19,8 @@ const createRequest = modularui => {
19
19
  data: modularui.data || {},
20
20
  locale: modularui.locale,
21
21
  childmodels: modularui.childmodels ?? true,
22
- isReload: modularui.isReload
22
+ isReload: modularui.isReload,
23
+ cache: modularui.cache
23
24
  });
24
25
  if (modularui.targetModel) {
25
26
  request.targetModel = modularui.targetModel;
@@ -27,6 +27,7 @@ type RequestOptions = {
27
27
  targetModel?: TargetModel,
28
28
  forceTargetModel?: boolean,
29
29
  isReload?: boolean,
30
+ cache?: boolean,
30
31
  };
31
32
 
32
33
  /**
@@ -39,6 +40,7 @@ const createRequest = (modularui: RequestOptions): ModularUIRequest => {
39
40
  locale: modularui.locale,
40
41
  childmodels: modularui.childmodels ?? true,
41
42
  isReload: modularui.isReload,
43
+ cache: modularui.cache,
42
44
  });
43
45
 
44
46
  if (modularui.targetModel) {
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIMiddleware.js","names":["_ModularUIRequest","_interopRequireDefault","require","_Constants","_ProgressIndicator","_Error","createRequest","modularui","request","ModularUIRequest","href","method","HTTP_METHODS","GET","data","locale","childmodels","isReload","targetModel","forceTargetModel","responseHandler","next","dispatch","successAction","model","successResult","_promise","default","then","result","catch","error","handleError","Error","finishProgress","errorHandler","errorAction","err","errorResult","handleFetch","action","startProgress","requestOptions","payload","modularuiRequest","fetch","modularUIMiddleware","api","type","getState","i18n","exports"],"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,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,kBAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AAyBA;AACA;AACA;AACA,MAAMI,aAAa,GAAIC,SAAyB,IAAuB;EACrE,MAAMC,OAAO,GAAG,IAAIC,yBAAgB,CAACF,SAAS,CAACG,IAAI,EAAE;IACnDC,MAAM,EAAEJ,SAAS,CAACI,MAAM,IAAIC,uBAAY,CAACC,GAAG;IAC5CC,IAAI,EAAEP,SAAS,CAACO,IAAI,IAAI,CAAC,CAAC;IAC1BC,MAAM,EAAER,SAAS,CAACQ,MAAM;IACxBC,WAAW,EAAET,SAAS,CAACS,WAAW,IAAI,IAAI;IAC1CC,QAAQ,EAAEV,SAAS,CAACU;EACtB,CAAC,CAAC;EAEF,IAAIV,SAAS,CAACW,WAAW,EAAE;IACzBV,OAAO,CAACU,WAAW,GAAGX,SAAS,CAACW,WAAW;IAC3CV,OAAO,CAACW,gBAAgB,GAAGZ,SAAS,CAACY,gBAAgB,IAAI,KAAK;EAChE;EAEA,OAAOX,OAAO;AAChB,CAAC;;AAED;AACA;AACA,MAAMY,eAAe,GAAGA,CACtBC,IAAc,EACdC,QAAkB,EAClBC,aAA4B,EAC5BC,KAAqB,KAClB;EACH,IAAID,aAAa,EAAE;IACjB,MAAME,aAAa,GAAGF,aAAa,CAACC,KAAK,CAAC;IAE1C,IAAIC,aAAa,YAAAC,QAAA,CAAAC,OAAmB,EAAE;MACpCF,aAAa,CACVG,IAAI,CAAEC,MAAM,IAAK;QAChBP,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OE,gBAAgB,CACpBC,KAAK,CAAC,CAAC,CACPjB,IAAI,CAAEJ,KAAK,IAAKJ,eAAe,CAACC,IAAI,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,KAAK,CAAC,CAAC,CACtEM,KAAK,CAAEC,KAAK,IAAKI,YAAY,CAACd,IAAI,EAAEC,QAAQ,EAAEc,WAAW,EAAEL,KAAK,CAAC,CAAC;AACvE,CAAC;;AAED;AACA;AACO,MAAMe,mBAIZ,GACEC,GAAqD,IACrD1B,IAAc,IACdmB,MAAsB,IAAK;EAC1B,IAAIA,MAAM,CAACQ,IAAI,KAAK,iBAAiB,EAAE;IACrC,OAAOT,WAAW;IAChB;IACAC,MAAM,EACNO,GAAG,CAACE,QAAQ,CAAC,CAAC,CAACC,IAAI,CAACnC,MAAM,EAC1BgC,GAAG,CAACzB,QAAQ,EACZD,IACF,CAAC;EACH;EAEA,OAAOA,IAAI,CAACmB,MAAM,CAAC;AACrB,CAAC;AAACW,OAAA,CAAAL,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"file":"ModularUIMiddleware.js","names":["_ModularUIRequest","_interopRequireDefault","require","_Constants","_ProgressIndicator","_Error","createRequest","modularui","request","ModularUIRequest","href","method","HTTP_METHODS","GET","data","locale","childmodels","isReload","cache","targetModel","forceTargetModel","responseHandler","next","dispatch","successAction","model","successResult","_promise","default","then","result","catch","error","handleError","Error","finishProgress","errorHandler","errorAction","err","errorResult","handleFetch","action","startProgress","requestOptions","payload","modularuiRequest","fetch","modularUIMiddleware","api","type","getState","i18n","exports"],"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,IAAAA,iBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAEA,IAAAE,kBAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AA0BA;AACA;AACA;AACA,MAAMI,aAAa,GAAIC,SAAyB,IAAuB;EACrE,MAAMC,OAAO,GAAG,IAAIC,yBAAgB,CAACF,SAAS,CAACG,IAAI,EAAE;IACnDC,MAAM,EAAEJ,SAAS,CAACI,MAAM,IAAIC,uBAAY,CAACC,GAAG;IAC5CC,IAAI,EAAEP,SAAS,CAACO,IAAI,IAAI,CAAC,CAAC;IAC1BC,MAAM,EAAER,SAAS,CAACQ,MAAM;IACxBC,WAAW,EAAET,SAAS,CAACS,WAAW,IAAI,IAAI;IAC1CC,QAAQ,EAAEV,SAAS,CAACU,QAAQ;IAC5BC,KAAK,EAAEX,SAAS,CAACW;EACnB,CAAC,CAAC;EAEF,IAAIX,SAAS,CAACY,WAAW,EAAE;IACzBX,OAAO,CAACW,WAAW,GAAGZ,SAAS,CAACY,WAAW;IAC3CX,OAAO,CAACY,gBAAgB,GAAGb,SAAS,CAACa,gBAAgB,IAAI,KAAK;EAChE;EAEA,OAAOZ,OAAO;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MAAc,EACdQ,QAAkB,EAClBD,IAAc,KACX;EACHC,QAAQ,CAAC,IAAAmB,gCAAa,EAAC,CAAC,CAAC;EAEzB,MAAM;IAAElB,aAAa;IAAEa,WAAW;IAAE,GAAGM;EAAe,CAAC,GAAGF,MAAM,CAACG,OAAO;EACxED,cAAc,CAAC5B,MAAM,GAAGA,MAAM;EAE9B,MAAM8B,gBAAgB,GAAGvC,aAAa,CAACqC,cAAc,CAAC;EAEtD,OAAOE,gBAAgB,CACpBC,KAAK,CAAC,CAAC,CACPjB,IAAI,CAAEJ,KAAK,IAAKJ,eAAe,CAACC,IAAI,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,KAAK,CAAC,CAAC,CACtEM,KAAK,CAAEC,KAAK,IAAKI,YAAY,CAACd,IAAI,EAAEC,QAAQ,EAAEc,WAAW,EAAEL,KAAK,CAAC,CAAC;AACvE,CAAC;;AAED;AACA;AACO,MAAMe,mBAIZ,GACEC,GAAqD,IACrD1B,IAAc,IACdmB,MAAsB,IAAK;EAC1B,IAAIA,MAAM,CAACQ,IAAI,KAAK,iBAAiB,EAAE;IACrC,OAAOT,WAAW;IAChB;IACAC,MAAM,EACNO,GAAG,CAACE,QAAQ,CAAC,CAAC,CAACC,IAAI,CAACpC,MAAM,EAC1BiC,GAAG,CAACzB,QAAQ,EACZD,IACF,CAAC;EACH;EAEA,OAAOA,IAAI,CAACmB,MAAM,CAAC;AACrB,CAAC;AAACW,OAAA,CAAAL,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -72,6 +72,7 @@ export type ModularUIAction = {
72
72
  childmodels?: boolean,
73
73
  targetModel?: TargetModel,
74
74
  forceTargetModel?: boolean,
75
+ cache?: boolean,
75
76
  successAction: (
76
77
  model: ModularUIModel,
77
78
  ) => UpdateModelAction | SetModelAction,
@@ -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":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.53.0",
3
+ "version": "1.54.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",
@@ -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
  };
@@ -7,10 +7,11 @@ import { IllegalStateException } from "../exceptions";
7
7
 
8
8
  import type { ModularUIModel, Href } from "../models";
9
9
 
10
- type UseModularUIBasicOptions<T: ModularUIModel> = {
10
+ export type UseModularUIBasicOptions<T: ModularUIModel> = {
11
11
  expectedModels: Array<string>,
12
12
  targetModel?: Class<T> | Array<Class<T>>,
13
13
  forceTargetModel?: boolean,
14
+ cache?: boolean,
14
15
  };
15
16
 
16
17
  /**
@@ -30,12 +31,17 @@ export const useModularUIBasic = <T: ModularUIModel>(
30
31
  targetModel: undefined,
31
32
  forceTargetModel: undefined,
32
33
  isReload: false,
34
+ cache: false,
33
35
  };
34
36
  if (options.targetModel) {
35
37
  useModularUIOptions.targetModel = options.targetModel;
36
38
  useModularUIOptions.forceTargetModel = options.forceTargetModel;
37
39
  }
38
40
 
41
+ if (options.cache) {
42
+ useModularUIOptions.cache = options.cache;
43
+ }
44
+
39
45
  // reload when the modular service starts with the current location
40
46
  if (location.state?.reload && location.pathname.startsWith(href.toString())) {
41
47
  useModularUIOptions.isReload = true;
@@ -116,6 +116,7 @@ export const loadModel = (
116
116
  childmodels: options?.childmodels,
117
117
  targetModel: options?.targetModel,
118
118
  forceTargetModel: options?.forceTargetModel,
119
+ cache: options?.cache,
119
120
  /**
120
121
  */
121
122
  successAction: (model) =>
@@ -27,6 +27,7 @@ type RequestOptions = {
27
27
  targetModel?: TargetModel,
28
28
  forceTargetModel?: boolean,
29
29
  isReload?: boolean,
30
+ cache?: boolean,
30
31
  };
31
32
 
32
33
  /**
@@ -39,6 +40,7 @@ const createRequest = (modularui: RequestOptions): ModularUIRequest => {
39
40
  locale: modularui.locale,
40
41
  childmodels: modularui.childmodels ?? true,
41
42
  isReload: modularui.isReload,
43
+ cache: modularui.cache,
42
44
  });
43
45
 
44
46
  if (modularui.targetModel) {
@@ -72,6 +72,7 @@ export type ModularUIAction = {
72
72
  childmodels?: boolean,
73
73
  targetModel?: TargetModel,
74
74
  forceTargetModel?: boolean,
75
+ cache?: boolean,
75
76
  successAction: (
76
77
  model: ModularUIModel,
77
78
  ) => UpdateModelAction | SetModelAction,
@@ -60,9 +60,17 @@ export default class ConceptDetailModel extends ResourceModel {
60
60
  */
61
61
  getSourceReferencesForCurrentLanguage(availableLocales: Array<string>): Array<Object>;
62
62
  /**
63
- * Retrieve entrydate of content toc
63
+ * Retrieve entrydate
64
64
  */
65
65
  get entryDate(): string;
66
+ /**
67
+ * Indicates if the given concept type id or href exists in the hierarchy of concept types for this concept
68
+ */
69
+ isOfConceptType(conceptTypeId: string): boolean;
70
+ /**
71
+ * Indicates if the given metamodel functional identifier exists in the hierarchy of concept types for this concept
72
+ */
73
+ hasMetamodelIdInConceptTypeHierarchy(metamodelId: string): boolean;
66
74
  }
67
75
  import ResourceModel from "../base/ResourceModel";
68
76
  import ConceptRelationCollection from "./ConceptRelationCollection";
@@ -56,6 +56,14 @@ export default class ConceptLinkModel extends BaseModel {
56
56
  /**
57
57
  */
58
58
  asLinkModel(): LinkModel;
59
+ /**
60
+ * Indicates if the given concept type id or href exists in the hierarchy of concept types for this concept
61
+ */
62
+ isOfConceptType(conceptTypeId: string): boolean;
63
+ /**
64
+ * Indicates if the given metamodel functional identifier exists in the hierarchy of concept types for this concept
65
+ */
66
+ hasMetamodelIdInConceptTypeHierarchy(metamodelId: string): boolean;
59
67
  }
60
68
  import BaseModel from "../base/BaseModel";
61
69
  import LinkCollection from "../links/LinkCollection";
@@ -3,6 +3,14 @@ export default ConceptTypeDetailModel;
3
3
  * Model for concept details, available through modelcatalog
4
4
  */
5
5
  declare class ConceptTypeDetailModel extends ResourceModel {
6
+ /**
7
+ * The name of the concept type consists of the functional id of the kmt and the functional id of the concept type separated by a #.<br>
8
+ * For example BEI_CaseManagement#Case
9
+ */
10
+ get name(): string;
11
+ /**
12
+ */
13
+ get isCoreTaxonomy(): boolean;
6
14
  /**
7
15
  * Get concept type icon
8
16
  */
@@ -35,5 +43,16 @@ declare class ConceptTypeDetailModel extends ResourceModel {
35
43
  * Get sectionReferenceTypes
36
44
  */
37
45
  get sectionReferenceTypes(): Object[];
46
+ /**
47
+ */
48
+ get conceptTypeHierarchy(): LinkCollection;
49
+ /**
50
+ */
51
+ isOfConceptType(conceptTypeId: string): boolean;
52
+ /**
53
+ * Indicates if the given metamodel functional identifier exists in the hierarchy of concept types
54
+ */
55
+ hasMetamodelIdInHierarchy(metamodelId: string): boolean;
38
56
  }
39
57
  import ResourceModel from "../base/ResourceModel";
58
+ import LinkCollection from "../links/LinkCollection";
@@ -19,6 +19,9 @@ export default class ContentIndexModel extends ResourceModel {
19
19
  /**
20
20
  */
21
21
  hasIndexFilter(): boolean;
22
+ /**
23
+ */
24
+ hasFiltersSet(): boolean;
22
25
  /**
23
26
  */
24
27
  hasNoFiltersSet(): boolean;
@@ -20,10 +20,18 @@ export default class LinkCollection extends BaseCollection<LinkModel> {
20
20
  * Get a link by it's key, handy for getting the self link
21
21
  */
22
22
  getLinkByKey(key: string): LinkModel | null;
23
+ /**
24
+ * Indicate if a link by key exists
25
+ */
26
+ hasLinkByKey(key: string): boolean;
23
27
  /**
24
28
  * Get a link by it's Href
25
29
  */
26
30
  getLinkByHref(href: Href | string): LinkModel | null;
31
+ /**
32
+ * Indicate if a link by href exists
33
+ */
34
+ hasLinkByHref(href: Href | string): boolean;
27
35
  /**
28
36
  * Getting the links by group key. For instance getting all 'tab' links of the web application.
29
37
  */
@@ -39,6 +39,7 @@ type ModularUIAction = {
39
39
  childmodels?: boolean;
40
40
  targetModel?: any;
41
41
  forceTargetModel?: boolean;
42
+ cache?: boolean;
42
43
  successAction: (model: ModularUIModel) => SetModelAction | UpdateModelAction;
43
44
  errorAction?: ErrorAction;
44
45
  };