@beinformed/ui 1.60.5 → 1.61.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 (139) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/esm/hooks/__tests__/useForm.spec.js.flow +1 -1
  3. package/esm/hooks/useForm.js +15 -20
  4. package/esm/hooks/useForm.js.flow +5 -14
  5. package/esm/hooks/useForm.js.map +1 -1
  6. package/esm/hooks/useModularUI.d.ts +0 -1
  7. package/esm/hooks/useModularUI.js +3 -11
  8. package/esm/hooks/useModularUI.js.flow +4 -23
  9. package/esm/hooks/useModularUI.js.map +1 -1
  10. package/esm/models/attributes/AttributeCollection.js +2 -2
  11. package/esm/models/attributes/AttributeCollection.js.map +1 -1
  12. package/esm/models/attributes/AttributeContent.js +1 -1
  13. package/esm/models/attributes/AttributeContent.js.flow +1 -1
  14. package/esm/models/attributes/AttributeContent.js.map +1 -1
  15. package/esm/models/attributes/CompositeAttributeChildCollection.js +4 -4
  16. package/esm/models/attributes/CompositeAttributeChildCollection.js.map +1 -1
  17. package/esm/models/concepts/ConceptDetailModel.js +9 -9
  18. package/esm/models/concepts/ConceptDetailModel.js.map +1 -1
  19. package/esm/models/content/ContentTOCModel.d.ts +7 -0
  20. package/esm/models/content/ContentTOCModel.js +35 -8
  21. package/esm/models/content/ContentTOCModel.js.flow +36 -9
  22. package/esm/models/content/ContentTOCModel.js.map +1 -1
  23. package/esm/models/content/SectionModel.d.ts +3 -0
  24. package/esm/models/content/SectionModel.js +11 -2
  25. package/esm/models/content/SectionModel.js.flow +11 -0
  26. package/esm/models/content/SectionModel.js.map +1 -1
  27. package/esm/models/content/SubSectionModel.d.ts +1 -1
  28. package/esm/models/content/SubSectionModel.js.flow +1 -1
  29. package/esm/models/content/SubSectionModel.js.map +1 -1
  30. package/esm/models/content/__tests__/Formalsource.spec.js.flow +91 -0
  31. package/esm/models/form/FormModel.js +33 -33
  32. package/esm/models/form/FormModel.js.map +1 -1
  33. package/esm/models/form/FormObjectModel.d.ts +13 -12
  34. package/esm/models/form/FormObjectModel.js +10 -9
  35. package/esm/models/form/FormObjectModel.js.flow +41 -27
  36. package/esm/models/form/FormObjectModel.js.map +1 -1
  37. package/esm/models/form/__tests__/FormValidation.spec.js.flow +79 -0
  38. package/esm/models/href/Href.js +6 -6
  39. package/esm/models/href/Href.js.map +1 -1
  40. package/esm/models/links/LinkCollection.js +4 -4
  41. package/esm/models/links/LinkCollection.js.map +1 -1
  42. package/esm/redux/_modularui/ModularUIActions.d.ts +2 -2
  43. package/esm/redux/_modularui/ModularUIActions.js +27 -10
  44. package/esm/redux/_modularui/ModularUIActions.js.flow +24 -5
  45. package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
  46. package/esm/redux/_modularui/ModularUIMiddleware.js +1 -1
  47. package/esm/redux/_modularui/ModularUIMiddleware.js.flow +1 -1
  48. package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  49. package/esm/redux/_modularui/ModularUIReducer.js +4 -2
  50. package/esm/redux/_modularui/ModularUIReducer.js.flow +10 -1
  51. package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
  52. package/esm/redux/_modularui/ModularUISelectors.js +2 -2
  53. package/esm/redux/_modularui/ModularUISelectors.js.map +1 -1
  54. package/esm/redux/_modularui/__tests__/actions.spec.js.flow +5 -1
  55. package/esm/redux/_modularui/types.d.ts +1 -0
  56. package/esm/redux/_modularui/types.js.flow +2 -0
  57. package/esm/redux/_modularui/types.js.map +1 -1
  58. package/esm/utils/helpers/text.d.ts +1 -1
  59. package/esm/utils/helpers/text.js +1 -1
  60. package/esm/utils/helpers/text.js.flow +2 -2
  61. package/esm/utils/helpers/text.js.map +1 -1
  62. package/lib/hooks/useDeepCompareEffect.js +1 -2
  63. package/lib/hooks/useDeepCompareEffect.js.map +1 -1
  64. package/lib/hooks/useForm.js +14 -19
  65. package/lib/hooks/useForm.js.map +1 -1
  66. package/lib/hooks/useModularUI.d.ts +0 -1
  67. package/lib/hooks/useModularUI.js +4 -13
  68. package/lib/hooks/useModularUI.js.map +1 -1
  69. package/lib/i18n/index.js +1 -2
  70. package/lib/i18n/index.js.map +1 -1
  71. package/lib/models/attributes/AttributeCollection.js +2 -2
  72. package/lib/models/attributes/AttributeCollection.js.map +1 -1
  73. package/lib/models/attributes/AttributeContent.js +1 -1
  74. package/lib/models/attributes/AttributeContent.js.map +1 -1
  75. package/lib/models/attributes/CompositeAttributeChildCollection.js +4 -4
  76. package/lib/models/attributes/CompositeAttributeChildCollection.js.map +1 -1
  77. package/lib/models/concepts/ConceptDetailModel.js +9 -9
  78. package/lib/models/concepts/ConceptDetailModel.js.map +1 -1
  79. package/lib/models/content/ContentTOCModel.d.ts +7 -0
  80. package/lib/models/content/ContentTOCModel.js +35 -8
  81. package/lib/models/content/ContentTOCModel.js.map +1 -1
  82. package/lib/models/content/SectionModel.d.ts +3 -0
  83. package/lib/models/content/SectionModel.js +11 -2
  84. package/lib/models/content/SectionModel.js.map +1 -1
  85. package/lib/models/content/SubSectionModel.d.ts +1 -1
  86. package/lib/models/content/SubSectionModel.js.map +1 -1
  87. package/lib/models/form/FormModel.js +33 -33
  88. package/lib/models/form/FormModel.js.map +1 -1
  89. package/lib/models/form/FormObjectModel.d.ts +13 -12
  90. package/lib/models/form/FormObjectModel.js +10 -9
  91. package/lib/models/form/FormObjectModel.js.map +1 -1
  92. package/lib/models/href/Href.js +6 -6
  93. package/lib/models/href/Href.js.map +1 -1
  94. package/lib/models/index.js +1 -2
  95. package/lib/models/index.js.map +1 -1
  96. package/lib/models/links/LinkCollection.js +4 -4
  97. package/lib/models/links/LinkCollection.js.map +1 -1
  98. package/lib/react-server/serverUtil.js +1 -2
  99. package/lib/react-server/serverUtil.js.map +1 -1
  100. package/lib/redux/_modularui/ModularUIActions.d.ts +2 -2
  101. package/lib/redux/_modularui/ModularUIActions.js +27 -10
  102. package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
  103. package/lib/redux/_modularui/ModularUIMiddleware.js +1 -1
  104. package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  105. package/lib/redux/_modularui/ModularUIReducer.js +4 -2
  106. package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
  107. package/lib/redux/_modularui/ModularUISelectors.js +2 -2
  108. package/lib/redux/_modularui/ModularUISelectors.js.map +1 -1
  109. package/lib/redux/_modularui/types.d.ts +1 -0
  110. package/lib/redux/_modularui/types.js.map +1 -1
  111. package/lib/utils/helpers/text.d.ts +1 -1
  112. package/lib/utils/helpers/text.js +1 -1
  113. package/lib/utils/helpers/text.js.map +1 -1
  114. package/package.json +17 -17
  115. package/src/hooks/__tests__/useForm.spec.js +1 -1
  116. package/src/hooks/useForm.js +5 -14
  117. package/src/hooks/useModularUI.js +4 -23
  118. package/src/models/attributes/AttributeContent.js +1 -1
  119. package/src/models/content/ContentTOCModel.js +36 -9
  120. package/src/models/content/SectionModel.js +11 -0
  121. package/src/models/content/SubSectionModel.js +1 -1
  122. package/src/models/content/__tests__/Formalsource.spec.js +91 -0
  123. package/src/models/content/__tests__/formalsource-complete.json +234 -0
  124. package/src/models/content/__tests__/formalsource-contributions.json +110 -0
  125. package/src/models/content/__tests__/formalsource-section-contributions.json +84 -0
  126. package/src/models/content/__tests__/formalsource-section.json +60 -0
  127. package/src/models/content/__tests__/formalsource-toc.json +119 -0
  128. package/src/models/form/FormObjectModel.js +41 -27
  129. package/src/models/form/__tests__/FormValidation.spec.js +79 -0
  130. package/src/models/form/__tests__/FormValidationContributions.json +45 -0
  131. package/src/models/form/__tests__/FormValidationDataInitial.json +33 -0
  132. package/src/models/form/__tests__/FormValidationDataUpdate1.json +25 -0
  133. package/src/models/form/__tests__/FormValidationDataUpdate2.json +33 -0
  134. package/src/redux/_modularui/ModularUIActions.js +24 -5
  135. package/src/redux/_modularui/ModularUIMiddleware.js +1 -1
  136. package/src/redux/_modularui/ModularUIReducer.js +10 -1
  137. package/src/redux/_modularui/__tests__/actions.spec.js +5 -1
  138. package/src/redux/_modularui/types.js +2 -0
  139. package/src/utils/helpers/text.js +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"LinkCollection.js","names":["BaseCollection","normalizeLinkJSON","LinkModel","LinkCollection","constructor","_context","linkData","arguments","length","undefined","linkContributions","modelOptions","collection","_mapInstanceProperty","call","_ref","data","contributions","links","getLinkByKey","key","_context2","_findInstanceProperty","link","hasLinkByKey","all","some","getLinkByHref","href","_context3","equals","hasLinkByHref","getLinksByGroup","_context4","_len","args","Array","_key","findGroups","groupLinks","_filterInstanceProperty","_includesInstanceProperty","group","linkCollection","getLinkByResourceType","resourceType","_context5","resourcetype","getLinksByLayoutHint","hint","_context6","newCollection","layouthint","has","hasLinksByLayoutHint","toHrefArray","_context7","hasLink","l","update","newLink","_context8","_context9","_context10","oldIndex","_findIndexInstanceProperty","_sliceInstanceProperty","routePath","_context11","path","join"],"sources":["../../../src/models/links/LinkCollection.js"],"sourcesContent":["// @flow\nimport BaseCollection from \"../base/BaseCollection\";\nimport normalizeLinkJSON from \"./normalizeLinkJSON\";\nimport LinkModel from \"./LinkModel\";\n\nimport type Href from \"../href/Href\";\nimport type { ModelOptions } from \"../types\";\n\n/**\n * Collection of links\n *\n * @see {LinkModel}\n */\nexport default class LinkCollection extends BaseCollection<LinkModel> {\n /**\n * Constructs the link collection\n */\n constructor(\n linkData: Object = {},\n linkContributions: Object = {},\n modelOptions?: ModelOptions,\n ) {\n super();\n\n // There can be links in data and/or contributions (e.g. concept link is available through contributions)\n this.collection = normalizeLinkJSON(linkData, linkContributions).map(\n ({ data, contributions }) =>\n new LinkModel(data, contributions, modelOptions),\n );\n }\n\n /**\n * Getting links\n */\n get links(): Array<LinkModel> {\n return this.collection;\n }\n\n /**\n * Set Link collection\n */\n set links(links: Array<LinkModel>) {\n this.collection = links;\n }\n\n /**\n * Get a link by it's key, handy for getting the self link\n */\n getLinkByKey(key: string): LinkModel | null {\n return this.links.find((link) => link.key === key) || null;\n }\n\n /**\n * Indicate if a link by key exists\n */\n hasLinkByKey(key: string): boolean {\n return this.all.some((link) => link.key === key);\n }\n\n /**\n * Get a link by it's Href\n */\n getLinkByHref(href: Href | string): LinkModel | null {\n return this.links.find((link) => link.href.equals(href)) || null;\n }\n\n /**\n * Indicate if a link by href exists\n */\n hasLinkByHref(href: Href | string): boolean {\n return this.all.some((link) => link.href.equals(href));\n }\n\n /**\n * Getting the links by group key. For instance getting all 'tab' links of the web application.\n */\n getLinksByGroup(...args: Array<string>): LinkCollection {\n const findGroups = args.length > 0 ? [...args] : [];\n const groupLinks = this.links.filter((link) =>\n findGroups.includes(link.group),\n );\n\n const linkCollection = new LinkCollection();\n\n linkCollection.links = groupLinks;\n\n return linkCollection;\n }\n\n /**\n * Retrieve links by resource type\n */\n getLinkByResourceType(resourceType: string): LinkCollection {\n const linkCollection = new LinkCollection();\n\n linkCollection.collection = this.links.filter(\n (link) => link.resourcetype === resourceType,\n );\n\n return linkCollection;\n }\n\n /**\n * Retrieve links including a layout hint\n */\n getLinksByLayoutHint(hint: string): LinkCollection {\n const newCollection = new LinkCollection();\n\n newCollection.collection = this.all.filter((link) =>\n link.layouthint.has(hint),\n );\n\n return newCollection;\n }\n\n /**\n * Indicates if a link with layout hint exists\n */\n hasLinksByLayoutHint(hint: string): boolean {\n return this.all.some((link) => link.layouthint.has(hint));\n }\n\n /**\n * Get all href of links in collection in an array of Href's\n */\n toHrefArray(): Array<Href> {\n return this.links.map((link) => link.href);\n }\n\n /**\n * Check if link exists in collection\n */\n hasLink(link: LinkModel): boolean {\n return this.some((l) => l.href.equals(link.href));\n }\n\n /**\n * Updates the collection with a new link, when the link to update does not exist, it is added to the collection\n */\n update(newLink: LinkModel): LinkCollection {\n const oldIndex = this.links.findIndex((link) => link.key === newLink.key);\n\n if (oldIndex === -1) {\n this.collection = [...this.collection, newLink];\n\n return this;\n }\n\n this.collection = [\n ...this.links.slice(0, oldIndex),\n newLink,\n ...this.links.slice(oldIndex + 1),\n ];\n\n return this;\n }\n\n /**\n * Use as path regex for react router routes\n */\n get routePath(): string {\n if (this.length === 0) {\n return \"__NON_EXISTING_ROUTE__\";\n }\n\n const path = this.collection.map((link) => link.href.path).join(\"|\");\n return this.length > 1 ? `(${path})` : path;\n }\n}\n"],"mappings":";;;;;;AACA,OAAOA,cAAc,MAAM,wBAAwB;AACnD,OAAOC,iBAAiB,MAAM,qBAAqB;AACnD,OAAOC,SAAS,MAAM,aAAa;AAKnC;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,cAAc,SAASH,cAAc,CAAY;EACpE;AACF;AACA;EACEI,WAAWA,CAAA,EAIT;IAAA,IAAAC,QAAA;IAAA,IAHAC,QAAgB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAA,IACrBG,iBAAyB,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAA,IAC9BI,YAA2B,GAAAJ,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IAE3B,KAAK,CAAC,CAAC;;IAEP;IACA,IAAI,CAACG,UAAU,GAAGC,oBAAA,CAAAR,QAAA,GAAAJ,iBAAiB,CAACK,QAAQ,EAAEI,iBAAiB,CAAC,EAAAI,IAAA,CAAAT,QAAA,EAC9DU,IAAA;MAAA,IAAC;QAAEC,IAAI;QAAEC;MAAc,CAAC,GAAAF,IAAA;MAAA,OACtB,IAAIb,SAAS,CAACc,IAAI,EAAEC,aAAa,EAAEN,YAAY,CAAC;IAAA,CACpD,CAAC;EACH;;EAEA;AACF;AACA;EACE,IAAIO,KAAKA,CAAA,EAAqB;IAC5B,OAAO,IAAI,CAACN,UAAU;EACxB;;EAEA;AACF;AACA;EACE,IAAIM,KAAKA,CAACA,KAAuB,EAAE;IACjC,IAAI,CAACN,UAAU,GAAGM,KAAK;EACzB;;EAEA;AACF;AACA;EACEC,YAAYA,CAACC,GAAW,EAAoB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,CAAC;IACpE,OAAO,IAAI,CAAC9D,MAAM,GAAG,CAAC,GAAG,IAAI6D,IAAI,GAAG,GAAGA,IAAI;EAC7C;AACF","ignoreList":[]}
1
+ {"version":3,"file":"LinkCollection.js","names":["BaseCollection","normalizeLinkJSON","LinkModel","LinkCollection","constructor","_context","linkData","arguments","length","undefined","linkContributions","modelOptions","collection","_mapInstanceProperty","call","_ref","data","contributions","links","getLinkByKey","key","_context2","_findInstanceProperty","link","hasLinkByKey","all","some","getLinkByHref","href","_context3","equals","hasLinkByHref","getLinksByGroup","_context4","_len","args","Array","_key","findGroups","groupLinks","_filterInstanceProperty","_includesInstanceProperty","group","linkCollection","getLinkByResourceType","resourceType","_context5","resourcetype","getLinksByLayoutHint","hint","_context6","newCollection","layouthint","has","hasLinksByLayoutHint","toHrefArray","_context7","hasLink","l","update","newLink","_context8","_context9","_context0","oldIndex","_findIndexInstanceProperty","_sliceInstanceProperty","routePath","_context1","path","join"],"sources":["../../../src/models/links/LinkCollection.js"],"sourcesContent":["// @flow\nimport BaseCollection from \"../base/BaseCollection\";\nimport normalizeLinkJSON from \"./normalizeLinkJSON\";\nimport LinkModel from \"./LinkModel\";\n\nimport type Href from \"../href/Href\";\nimport type { ModelOptions } from \"../types\";\n\n/**\n * Collection of links\n *\n * @see {LinkModel}\n */\nexport default class LinkCollection extends BaseCollection<LinkModel> {\n /**\n * Constructs the link collection\n */\n constructor(\n linkData: Object = {},\n linkContributions: Object = {},\n modelOptions?: ModelOptions,\n ) {\n super();\n\n // There can be links in data and/or contributions (e.g. concept link is available through contributions)\n this.collection = normalizeLinkJSON(linkData, linkContributions).map(\n ({ data, contributions }) =>\n new LinkModel(data, contributions, modelOptions),\n );\n }\n\n /**\n * Getting links\n */\n get links(): Array<LinkModel> {\n return this.collection;\n }\n\n /**\n * Set Link collection\n */\n set links(links: Array<LinkModel>) {\n this.collection = links;\n }\n\n /**\n * Get a link by it's key, handy for getting the self link\n */\n getLinkByKey(key: string): LinkModel | null {\n return this.links.find((link) => link.key === key) || null;\n }\n\n /**\n * Indicate if a link by key exists\n */\n hasLinkByKey(key: string): boolean {\n return this.all.some((link) => link.key === key);\n }\n\n /**\n * Get a link by it's Href\n */\n getLinkByHref(href: Href | string): LinkModel | null {\n return this.links.find((link) => link.href.equals(href)) || null;\n }\n\n /**\n * Indicate if a link by href exists\n */\n hasLinkByHref(href: Href | string): boolean {\n return this.all.some((link) => link.href.equals(href));\n }\n\n /**\n * Getting the links by group key. For instance getting all 'tab' links of the web application.\n */\n getLinksByGroup(...args: Array<string>): LinkCollection {\n const findGroups = args.length > 0 ? [...args] : [];\n const groupLinks = this.links.filter((link) =>\n findGroups.includes(link.group),\n );\n\n const linkCollection = new LinkCollection();\n\n linkCollection.links = groupLinks;\n\n return linkCollection;\n }\n\n /**\n * Retrieve links by resource type\n */\n getLinkByResourceType(resourceType: string): LinkCollection {\n const linkCollection = new LinkCollection();\n\n linkCollection.collection = this.links.filter(\n (link) => link.resourcetype === resourceType,\n );\n\n return linkCollection;\n }\n\n /**\n * Retrieve links including a layout hint\n */\n getLinksByLayoutHint(hint: string): LinkCollection {\n const newCollection = new LinkCollection();\n\n newCollection.collection = this.all.filter((link) =>\n link.layouthint.has(hint),\n );\n\n return newCollection;\n }\n\n /**\n * Indicates if a link with layout hint exists\n */\n hasLinksByLayoutHint(hint: string): boolean {\n return this.all.some((link) => link.layouthint.has(hint));\n }\n\n /**\n * Get all href of links in collection in an array of Href's\n */\n toHrefArray(): Array<Href> {\n return this.links.map((link) => link.href);\n }\n\n /**\n * Check if link exists in collection\n */\n hasLink(link: LinkModel): boolean {\n return this.some((l) => l.href.equals(link.href));\n }\n\n /**\n * Updates the collection with a new link, when the link to update does not exist, it is added to the collection\n */\n update(newLink: LinkModel): LinkCollection {\n const oldIndex = this.links.findIndex((link) => link.key === newLink.key);\n\n if (oldIndex === -1) {\n this.collection = [...this.collection, newLink];\n\n return this;\n }\n\n this.collection = [\n ...this.links.slice(0, oldIndex),\n newLink,\n ...this.links.slice(oldIndex + 1),\n ];\n\n return this;\n }\n\n /**\n * Use as path regex for react router routes\n */\n get routePath(): string {\n if (this.length === 0) {\n return \"__NON_EXISTING_ROUTE__\";\n }\n\n const path = this.collection.map((link) => link.href.path).join(\"|\");\n return this.length > 1 ? `(${path})` : path;\n }\n}\n"],"mappings":";;;;;;AACA,OAAOA,cAAc,MAAM,wBAAwB;AACnD,OAAOC,iBAAiB,MAAM,qBAAqB;AACnD,OAAOC,SAAS,MAAM,aAAa;AAKnC;AACA;AACA;AACA;AACA;AACA,eAAe,MAAMC,cAAc,SAASH,cAAc,CAAY;EACpE;AACF;AACA;EACEI,WAAWA,CAAA,EAIT;IAAA,IAAAC,QAAA;IAAA,IAHAC,QAAgB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAA,IACrBG,iBAAyB,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAA,IAC9BI,YAA2B,GAAAJ,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IAE3B,KAAK,CAAC,CAAC;;IAEP;IACA,IAAI,CAACG,UAAU,GAAGC,oBAAA,CAAAR,QAAA,GAAAJ,iBAAiB,CAACK,QAAQ,EAAEI,iBAAiB,CAAC,EAAAI,IAAA,CAAAT,QAAA,EAC9DU,IAAA;MAAA,IAAC;QAAEC,IAAI;QAAEC;MAAc,CAAC,GAAAF,IAAA;MAAA,OACtB,IAAIb,SAAS,CAACc,IAAI,EAAEC,aAAa,EAAEN,YAAY,CAAC;IAAA,CACpD,CAAC;EACH;;EAEA;AACF;AACA;EACE,IAAIO,KAAKA,CAAA,EAAqB;IAC5B,OAAO,IAAI,CAACN,UAAU;EACxB;;EAEA;AACF;AACA;EACE,IAAIM,KAAKA,CAACA,KAAuB,EAAE;IACjC,IAAI,CAACN,UAAU,GAAGM,KAAK;EACz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K,IAAI,CAACyC,IAAI,CAAC,CAACC,IAAI,CAAC,GAAG,CAAC;IACpE,OAAO,IAAI,CAAC9D,MAAM,GAAG,CAAC,GAAG,IAAI6D,IAAI,GAAG,GAAGA,IAAI;EAC7C;AACF","ignoreList":[]}
@@ -7,9 +7,9 @@ export function updateModel(model: ModularUIModel): UpdateModelAction;
7
7
  export function updateForm(model: ModularUIModel): UpdateFormAction;
8
8
  export function removeModelByKey(key: string): RemoveModelByKeyAction;
9
9
  export function resetModularUI(): ResetModularUIAction;
10
- export function updateStatus(key: string, status: $Keys<typeof MODULARUI_STATUS>): UpdateStatusAction;
10
+ export function updateStatus(key: string, status: $Keys<typeof MODULARUI_STATUS>, requestOptions: any): UpdateStatusAction;
11
11
  export function loadModel(key: string, href: Href | string, options?: RequestModularUIOptions): ModularUIAction;
12
- export function loadModularUI(key: string, href: Href | string, options?: RequestModularUIOptions): ThunkAction;
12
+ export function loadModularUI(key: string, href: Href | string, options?: RequestModularUIOptions, retryCount?: number, retryDelay?: number): ThunkAction;
13
13
  export function reloadModel(model: ModularUIModel, options?: RequestModularUIOptions): ThunkAction;
14
14
  import { ModularUIModel } from "../../models/types";
15
15
  import { SetModelAction } from "./types";
@@ -55,11 +55,12 @@ export const resetModularUI = () => ({
55
55
 
56
56
  /**
57
57
  */
58
- export const updateStatus = (key, status) => ({
58
+ export const updateStatus = (key, status, requestOptions) => ({
59
59
  type: "MODULARUI/STATUS",
60
60
  payload: {
61
61
  key,
62
- status
62
+ status,
63
+ requestOptions
63
64
  }
64
65
  });
65
66
 
@@ -132,14 +133,30 @@ export const loadModel = (key, href, options) => ({
132
133
 
133
134
  /**
134
135
  */
135
- export const loadModularUI = (key, href, options) => (dispatch, getState) => {
136
- const modularuiStore = getState()?.modularui;
137
- if (modularuiStore && modularuiStore[key]?.status === MODULARUI_STATUS.LOADING) {
138
- return _Promise.resolve();
139
- }
140
- dispatch(startProgress());
141
- const loadModelPromise = dispatch(loadModel(key, href, options));
142
- return _Promise.resolve(loadModelPromise).then(() => dispatch(finishProgress())).catch(error => dispatch(handleError(error)));
136
+ export const loadModularUI = function (key, href, options) {
137
+ let retryCount = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 3;
138
+ let retryDelay = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 200;
139
+ return (dispatch, getState) => {
140
+ const modularuiStore = getState()?.modularui;
141
+ const currentRequest = modularuiStore?.[key];
142
+ const isLoading = currentRequest?.status === MODULARUI_STATUS.LOADING;
143
+ if (isLoading) {
144
+ const isDifferentRequest = currentRequest.requestOptions?.href?.toString() !== href.toString();
145
+ if (isDifferentRequest && retryCount > 0) {
146
+ return new _Promise(resolve => {
147
+ setTimeout(() => {
148
+ resolve(dispatch(loadModularUI(key, href, options, retryCount - 1, retryDelay)));
149
+ }, retryDelay);
150
+ });
151
+ }
152
+
153
+ // Same request is already loading — do nothing
154
+ return _Promise.resolve();
155
+ }
156
+ dispatch(startProgress());
157
+ const loadModelPromise = dispatch(loadModel(key, href, options));
158
+ return _Promise.resolve(loadModelPromise).then(() => dispatch(finishProgress())).catch(error => dispatch(handleError(error)));
159
+ };
143
160
  };
144
161
 
145
162
  /**
@@ -81,9 +81,10 @@ export const resetModularUI = (): ResetModularUIAction => ({
81
81
  export const updateStatus = (
82
82
  key: string,
83
83
  status: $Keys<typeof MODULARUI_STATUS>,
84
+ requestOptions: any,
84
85
  ): UpdateStatusAction => ({
85
86
  type: "MODULARUI/STATUS",
86
- payload: { key, status },
87
+ payload: { key, status, requestOptions },
87
88
  });
88
89
 
89
90
  /**
@@ -177,13 +178,31 @@ export const loadModularUI =
177
178
  key: string,
178
179
  href: Href | string,
179
180
  options?: RequestModularUIOptions,
181
+ retryCount: number = 3,
182
+ retryDelay: number = 200,
180
183
  ): ThunkAction =>
181
184
  (dispatch: Dispatch, getState) => {
182
185
  const modularuiStore = getState()?.modularui;
183
- if (
184
- modularuiStore &&
185
- modularuiStore[key]?.status === MODULARUI_STATUS.LOADING
186
- ) {
186
+ const currentRequest = modularuiStore?.[key];
187
+
188
+ const isLoading = currentRequest?.status === MODULARUI_STATUS.LOADING;
189
+
190
+ if (isLoading) {
191
+ const isDifferentRequest =
192
+ currentRequest.requestOptions?.href?.toString() !== href.toString();
193
+ if (isDifferentRequest && retryCount > 0) {
194
+ return new Promise((resolve) => {
195
+ setTimeout(() => {
196
+ resolve(
197
+ dispatch(
198
+ loadModularUI(key, href, options, retryCount - 1, retryDelay),
199
+ ),
200
+ );
201
+ }, retryDelay);
202
+ });
203
+ }
204
+
205
+ // Same request is already loading — do nothing
187
206
  return Promise.resolve();
188
207
  }
189
208
 
@@ -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","getRequestLocale","optionLocale","navigator","language","split","loadModel","href","options","origin","contextPath","method","GET","params","data","timeout","headers","events","onProgress","locale","childmodels","targetModel","forceTargetModel","cache","isReload","withCredentials","successAction","errorAction","error","errorResponse","isChangePassword","isResourceNotFoundAfterReload","ERROR","loadModularUI","dispatch","getState","modularuiStore","modularui","LOADING","_Promise","resolve","loadModelPromise","then","catch","reloadModel","selfhref"],"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 * Retrieve the preferred language for this request, falls back to the browser language or english\n */\nconst getRequestLocale = (optionLocale: ?string): string => {\n if (optionLocale) {\n return optionLocale;\n }\n\n if (typeof navigator !== \"undefined\" && navigator?.language) {\n return navigator.language.split(\"-\")[0] || \"en\";\n }\n\n return \"en\";\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 key,\n origin: options?.origin,\n contextPath: options?.contextPath,\n href:\n href instanceof Href\n ? href\n : new Href(href, \"\", {\n origin: options?.origin,\n contextPath: options?.contextPath,\n }),\n method: options?.method ?? HTTP_METHODS.GET,\n params: options?.params,\n data: options?.data,\n timeout: options?.timeout,\n headers: options?.headers,\n events: options?.events,\n onProgress: options?.onProgress,\n locale: getRequestLocale(options?.locale),\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n cache: options?.cache,\n isReload: options?.isReload,\n withCredentials: options?.withCredentials,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateHandler),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key, {\n origin: options?.origin,\n contextPath: options?.contextPath,\n });\n if (\n errorResponse.isChangePassword ||\n errorResponse.isResourceNotFoundAfterReload\n ) {\n return removeModelByKey(key);\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, getState) => {\n const modularuiStore = getState()?.modularui;\n if (\n modularuiStore &&\n modularuiStore[key]?.status === MODULARUI_STATUS.LOADING\n ) {\n return Promise.resolve();\n }\n\n dispatch(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then(() => dispatch(finishProgress()))\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,a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ACC,gBAAgB,CAAC,CACrCC,IAAI,CAAC,MAAMR,QAAQ,CAACpD,cAAc,CAAC,CAAC,CAAC,CAAC,CACtC6D,KAAK,CAAEf,KAAK,IAAKM,QAAQ,CAAClD,WAAW,CAAC4C,KAAK,CAAC,CAAC,CAAC;AACnD,CAAC;;AAEH;AACA;AACA,OAAO,MAAMgB,WAAW,GAAGA,CACzBzD,KAAqB,EACrBqB,OAAiC,KAEjCyB,aAAa,CAAC9C,KAAK,CAACC,UAAU,EAAED,KAAK,CAAC0D,QAAQ,EAAE;EAC9C,GAAGrC,OAAO;EACVgB,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","requestOptions","loadModelSuccessAction","updateHandler","getRequestLocale","optionLocale","navigator","language","split","loadModel","href","options","origin","contextPath","method","GET","params","data","timeout","headers","events","onProgress","locale","childmodels","targetModel","forceTargetModel","cache","isReload","withCredentials","successAction","errorAction","error","errorResponse","isChangePassword","isResourceNotFoundAfterReload","ERROR","loadModularUI","retryCount","arguments","length","undefined","retryDelay","dispatch","getState","modularuiStore","modularui","currentRequest","isLoading","LOADING","isDifferentRequest","toString","_Promise","resolve","setTimeout","loadModelPromise","then","catch","reloadModel","selfhref"],"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 requestOptions: any,\n): UpdateStatusAction => ({\n type: \"MODULARUI/STATUS\",\n payload: { key, status, requestOptions },\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 * Retrieve the preferred language for this request, falls back to the browser language or english\n */\nconst getRequestLocale = (optionLocale: ?string): string => {\n if (optionLocale) {\n return optionLocale;\n }\n\n if (typeof navigator !== \"undefined\" && navigator?.language) {\n return navigator.language.split(\"-\")[0] || \"en\";\n }\n\n return \"en\";\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 key,\n origin: options?.origin,\n contextPath: options?.contextPath,\n href:\n href instanceof Href\n ? href\n : new Href(href, \"\", {\n origin: options?.origin,\n contextPath: options?.contextPath,\n }),\n method: options?.method ?? HTTP_METHODS.GET,\n params: options?.params,\n data: options?.data,\n timeout: options?.timeout,\n headers: options?.headers,\n events: options?.events,\n onProgress: options?.onProgress,\n locale: getRequestLocale(options?.locale),\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n cache: options?.cache,\n isReload: options?.isReload,\n withCredentials: options?.withCredentials,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateHandler),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key, {\n origin: options?.origin,\n contextPath: options?.contextPath,\n });\n if (\n errorResponse.isChangePassword ||\n errorResponse.isResourceNotFoundAfterReload\n ) {\n return removeModelByKey(key);\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 retryCount: number = 3,\n retryDelay: number = 200,\n ): ThunkAction =>\n (dispatch: Dispatch, getState) => {\n const modularuiStore = getState()?.modularui;\n const currentRequest = modularuiStore?.[key];\n\n const isLoading = currentRequest?.status === MODULARUI_STATUS.LOADING;\n\n if (isLoading) {\n const isDifferentRequest =\n currentRequest.requestOptions?.href?.toString() !== href.toString();\n if (isDifferentRequest && retryCount > 0) {\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve(\n dispatch(\n loadModularUI(key, href, options, retryCount - 1, retryDelay),\n ),\n );\n }, retryDelay);\n });\n }\n\n // Same request is already loading — do nothing\n return Promise.resolve();\n }\n\n dispatch(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then(() => dispatch(finishProgress()))\n .catch((error) => dispatch(handleError(error)));\n };\n\n/**\n */\nexport const reloadModel = (\n model: ModularUIModel,\n options?: RequestModularUIOptions,\n): ThunkAction =>\n loadModularUI(model.connectKey, model.selfhref, {\n ...options,\n isReload: true,\n });\n"],"mappings":";AACA,SAASA,YAAY,EAAEC,gBAAgB,QAAQ,2BAA2B;AAC1E,OAAOC,IAAI,MAAM,wBAAwB;AACzC,OAAOC,aAAa,MAAM,kCAAkC;AAC5D,SAASC,cAAc,EAAEC,aAAa,QAAQ,8BAA8B;AAC5E,SAASC,WAAW,QAAQ,kBAAkB;AAmB9C;AACA;AACA,OAAO,MAAMC,QAAQ,GAAGA,CACtBC,GAAW,EACXC,KAAqB,KACF;EACnB;EACAA,KAAK,CAACC,UAAU,GAAGF,GAAG;EACtB,OAAO;IACLG,IAAI,EAAE,eAAe;IACrBC,OAAO,EAAE;MACPJ,GAAG;MACHC;IACF;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA,OAAO,MAAMI,UAAU,GACrBC,MAAqD,KAChC;EACrBH,IAAI,EAAE,gBAAgB;EACtBC,OAAO,EAAEE;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMC,WAAW,GAAIN,KAAqB,KAAyB;EACxEE,IAAI,EAAE,kBAAkB;EACxBC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMO,UAAU,GAAIP,KAAqB,KAAwB;EACtEE,IAAI,EAAE,uBAAuB;EAC7BC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMQ,gBAAgB,GAAIT,GAAW,KAA8B;EACxEG,IAAI,EAAE,sBAAsB;EAC5BC,OAAO,EAAEJ;AACX,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,MAAMU,cAAc,GAAGA,CAAA,MAA6B;EACzDP,IAAI,EAAE;AACR,CAAC,CAAC;;AAEF;AACA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xD,WAAW,CAAC6C,KAAK,CAAC,CAAC,CAAC;EACnD,CAAC;AAAA;;AAEH;AACA;AACA,OAAO,MAAM0B,WAAW,GAAGA,CACzBpE,KAAqB,EACrBsB,OAAiC,KAEjCyB,aAAa,CAAC/C,KAAK,CAACC,UAAU,EAAED,KAAK,CAACqE,QAAQ,EAAE;EAC9C,GAAG/C,OAAO;EACVgB,QAAQ,EAAE;AACZ,CAAC,CAAC","ignoreList":[]}
@@ -82,7 +82,7 @@ const handleFetch = (action, locale, dispatch, next) => {
82
82
  } = action.payload;
83
83
  requestOptions.locale = locale;
84
84
  const modularuiRequest = createRequest(requestOptions);
85
- dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));
85
+ dispatch(updateStatus(key, MODULARUI_STATUS.LOADING, requestOptions));
86
86
  return modularuiRequest.fetch().then(model => responseHandler(next, dispatch, successAction, model)).catch(error => errorHandler(next, dispatch, errorAction, error));
87
87
  };
88
88
 
@@ -150,7 +150,7 @@ const handleFetch = (
150
150
 
151
151
  const modularuiRequest = createRequest(requestOptions);
152
152
 
153
- dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));
153
+ dispatch(updateStatus(key, MODULARUI_STATUS.LOADING, requestOptions));
154
154
 
155
155
  return modularuiRequest
156
156
  .fetch()
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIMiddleware.js","names":["ModularUIRequest","HTTP_METHODS","MODULARUI_STATUS","startProgress","finishProgress","handleError","updateStatus","createRequest","modularui","request","href","method","GET","params","data","locale","childmodels","isReload","cache","headers","events","onProgress","origin","contextPath","targetModel","forceTargetModel","responseHandler","next","dispatch","successAction","model","successResult","_Promise","then","result","catch","error","Error","errorHandler","errorAction","err","errorResult","handleFetch","action","key","requestOptions","payload","modularuiRequest","LOADING","fetch","modularUIMiddleware","api","type","getState","i18n"],"sources":["../../../src/redux/_modularui/ModularUIMiddleware.js"],"sourcesContent":["// @flow\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\n\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport { updateStatus } from \"./ModularUIActions\";\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 origin?: string,\n contextPath?: string,\n href: Href,\n method?: $Keys<typeof HTTP_METHODS>,\n params?: string,\n data?: any,\n timeout?: number,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n isReload?: boolean,\n cache?: boolean,\n headers?: {\n [headerName: string]: string,\n Accept?: string,\n \"Accept-Language\"?: string,\n \"Content-Type\"?: string,\n \"x-filename\"?: string,\n \"x-filesize\"?: string,\n },\n events?: { [eventName: string]: () => void },\n onProgress?: ProgressEventHandler,\n withCredentials?: 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 params: modularui.params || \"\",\n data: modularui.data || {},\n locale: modularui.locale,\n childmodels: modularui.childmodels ?? true,\n isReload: modularui.isReload,\n cache: modularui.cache,\n headers: modularui.headers,\n events: modularui.events,\n onProgress: modularui.onProgress,\n });\n\n if (modularui.origin) {\n request.origin = modularui.origin;\n }\n\n if (modularui.contextPath) {\n request.contextPath = modularui.contextPath;\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 { key, successAction, errorAction, ...requestOptions } = action.payload;\n requestOptions.locale = locale;\n\n const modularuiRequest = createRequest(requestOptions);\n\n dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));\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,EAAEC,gBAAgB,QAAQ,2BAA2B;AAE1E,SAASC,aAAa,EAAEC,cAAc,QAAQ,8BAA8B;AAC5E,SAASC,WAAW,QAAQ,kBAAkB;AAE9C,SA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Ac,CAAC;EAEtDjB,QAAQ,CAACtB,YAAY,CAACsC,GAAG,EAAE1C,gBAAgB,CAAC8C,OAAO,CAAC,CAAC;EAErD,OAAOD,gBAAgB,CACpBE,KAAK,CAAC,CAAC,CACPhB,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,MAAMc,mBAIZ,GACEC,GAAqD,IACrDxB,IAAc,IACdgB,MAAsB,IAAK;EAC1B,IAAIA,MAAM,CAACS,IAAI,KAAK,iBAAiB,EAAE;IACrC,OAAOV,WAAW;IAChB;IACAC,MAAM,EACNQ,GAAG,CAACE,QAAQ,CAAC,CAAC,CAACC,IAAI,CAACvC,MAAM,EAC1BoC,GAAG,CAACvB,QAAQ,EACZD,IACF,CAAC;EACH;EAEA,OAAOA,IAAI,CAACgB,MAAM,CAAC;AACrB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"ModularUIMiddleware.js","names":["ModularUIRequest","HTTP_METHODS","MODULARUI_STATUS","startProgress","finishProgress","handleError","updateStatus","createRequest","modularui","request","href","method","GET","params","data","locale","childmodels","isReload","cache","headers","events","onProgress","origin","contextPath","targetModel","forceTargetModel","responseHandler","next","dispatch","successAction","model","successResult","_Promise","then","result","catch","error","Error","errorHandler","errorAction","err","errorResult","handleFetch","action","key","requestOptions","payload","modularuiRequest","LOADING","fetch","modularUIMiddleware","api","type","getState","i18n"],"sources":["../../../src/redux/_modularui/ModularUIMiddleware.js"],"sourcesContent":["// @flow\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\n\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport { updateStatus } from \"./ModularUIActions\";\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 origin?: string,\n contextPath?: string,\n href: Href,\n method?: $Keys<typeof HTTP_METHODS>,\n params?: string,\n data?: any,\n timeout?: number,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n isReload?: boolean,\n cache?: boolean,\n headers?: {\n [headerName: string]: string,\n Accept?: string,\n \"Accept-Language\"?: string,\n \"Content-Type\"?: string,\n \"x-filename\"?: string,\n \"x-filesize\"?: string,\n },\n events?: { [eventName: string]: () => void },\n onProgress?: ProgressEventHandler,\n withCredentials?: 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 params: modularui.params || \"\",\n data: modularui.data || {},\n locale: modularui.locale,\n childmodels: modularui.childmodels ?? true,\n isReload: modularui.isReload,\n cache: modularui.cache,\n headers: modularui.headers,\n events: modularui.events,\n onProgress: modularui.onProgress,\n });\n\n if (modularui.origin) {\n request.origin = modularui.origin;\n }\n\n if (modularui.contextPath) {\n request.contextPath = modularui.contextPath;\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 { key, successAction, errorAction, ...requestOptions } = action.payload;\n requestOptions.locale = locale;\n\n const modularuiRequest = createRequest(requestOptions);\n\n dispatch(updateStatus(key, MODULARUI_STATUS.LOADING, 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,EAAEC,gBAAgB,QAAQ,2BAA2B;AAE1E,SAASC,aAAa,EAAEC,cAAc,QAAQ,8BAA8B;AAC5E,SAASC,WAAW,QAAQ,kBAAkB;AAE9C,SAASC,YAAY,QAAQ,oBAAoB;AAyCjD;AACA;AACA;AACA,MAAMC,aAAa,GAAIC,SAAyB,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C,OAAO,EAAEH,cAAc,CAAC,CAAC;EAErE,OAAOE,gBAAgB,CACpBE,KAAK,CAAC,CAAC,CACPhB,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,MAAMc,mBAIZ,GACEC,GAAqD,IACrDxB,IAAc,IACdgB,MAAsB,IAAK;EAC1B,IAAIA,MAAM,CAACS,IAAI,KAAK,iBAAiB,EAAE;IACrC,OAAOV,WAAW;IAChB;IACAC,MAAM,EACNQ,GAAG,CAACE,QAAQ,CAAC,CAAC,CAACC,IAAI,CAACvC,MAAM,EAC1BoC,GAAG,CAACvB,QAAQ,EACZD,IACF,CAAC;EACH;EAEA,OAAOA,IAAI,CAACgB,MAAM,CAAC;AACrB,CAAC","ignoreList":[]}
@@ -8,7 +8,8 @@ import { ApplicationModel } from "../../models";
8
8
  const updateStatus = (state, _ref) => {
9
9
  let {
10
10
  key,
11
- status
11
+ status,
12
+ requestOptions
12
13
  } = _ref;
13
14
  // model should always be available when status is not loading
14
15
  if (status !== MODULARUI_STATUS.LOADING && !state[key]) {
@@ -19,7 +20,8 @@ const updateStatus = (state, _ref) => {
19
20
  [key]: {
20
21
  ...state[key],
21
22
  status,
22
- lastModification: Date.now()
23
+ lastModification: Date.now(),
24
+ requestOptions: requestOptions || state[key]?.requestOptions
23
25
  }
24
26
  };
25
27
  };
@@ -11,7 +11,15 @@ import type { ModularUIModel } from "../../models";
11
11
  */
12
12
  const updateStatus = (
13
13
  state: ModularUIState,
14
- { key, status }: { key: string, status: $Keys<typeof MODULARUI_STATUS> },
14
+ {
15
+ key,
16
+ status,
17
+ requestOptions,
18
+ }: {
19
+ key: string,
20
+ status: $Keys<typeof MODULARUI_STATUS>,
21
+ requestOptions: any,
22
+ },
15
23
  ) => {
16
24
  // model should always be available when status is not loading
17
25
  if (status !== MODULARUI_STATUS.LOADING && !state[key]) {
@@ -24,6 +32,7 @@ const updateStatus = (
24
32
  ...state[key],
25
33
  status,
26
34
  lastModification: Date.now(),
35
+ requestOptions: requestOptions || state[key]?.requestOptions,
27
36
  },
28
37
  };
29
38
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIReducer.js","names":["MODULARUI_STATUS","ApplicationModel","updateStatus","state","_ref","key","status","LOADING","lastModification","Date","now","setModel","_ref2","model","FINISHED","console","debug","initModularUI","models","newState","_Object$assign","forEach","_ref3","getModelKey","_context","_findInstanceProperty","_Object$keys","call","connectKey","updateModel","modelKey","removeKey","resetModularUI","initialState","ModularUIReducer","arguments","length","undefined","action","type","payload"],"sources":["../../../src/redux/_modularui/ModularUIReducer.js"],"sourcesContent":["// @flow\nimport { MODULARUI_STATUS } from \"../../constants/Constants\";\nimport { ApplicationModel } from \"../../models\";\n\nimport type { Reducer } from \"redux\";\nimport type { ReduxAction } from \"../types\";\nimport type { ModularUIState } from \"./types\";\nimport type { ModularUIModel } from \"../../models\";\n\n/**\n */\nconst updateStatus = (\n state: ModularUIState,\n { key, status }: { key: string, status: $Keys<typeof MODULARUI_STATUS> },\n) => {\n // model should always be available when status is not loading\n if (status !== MODULARUI_STATUS.LOADING && !state[key]) {\n return state;\n }\n\n return {\n ...state,\n [key]: {\n ...state[key],\n status,\n lastModification: Date.now(),\n },\n };\n};\n\n/**\n */\nconst setModel = (\n state: ModularUIState,\n { key, model }: { key: string, model: ?ModularUIModel },\n) => {\n if (!state[key]) {\n return state;\n }\n\n if (model) {\n return {\n ...state,\n [key]: {\n ...state[key],\n model,\n lastModification: Date.now(),\n status: MODULARUI_STATUS.FINISHED,\n },\n };\n }\n\n // eslint-disable-next-line no-console\n console.debug(\"No model for setModel\");\n return state;\n};\n\n/**\n */\nconst initModularUI = (\n state: ModularUIState,\n models: Array<{ key: string, model: ModularUIModel }>,\n) => {\n const newState = Object.assign({}, state);\n\n models.forEach(({ key, model }) => {\n newState[key] = {\n status: MODULARUI_STATUS.FINISHED,\n lastModification: Date.now(),\n model,\n };\n });\n\n return newState;\n};\n\n/**\n */\nconst getModelKey = (state: ModularUIState, model: ModularUIModel) =>\n Object.keys(state).find((key) => {\n const connectKey = state[key]?.model?.connectKey ?? \"\";\n return connectKey === model.connectKey;\n });\n\n/**\n */\nconst updateModel = (state: ModularUIState, model: ModularUIModel) => {\n const modelKey = getModelKey(state, model);\n\n if (modelKey) {\n return setModel(state, { key: modelKey, model });\n }\n\n // eslint-disable-next-line no-console\n console.debug(\n `ModularUIReducer: Cannot update model with key ${model.connectKey}`,\n );\n return state;\n};\n\n/**\n */\nconst removeKey = (modelKey: string, state: ModularUIState): ModularUIState => {\n const newState = Object.assign({}, state);\n delete newState[modelKey];\n return newState;\n};\n\n/**\n * Remove all but application models\n */\nconst resetModularUI = (state: ModularUIState) => {\n const newState: ModularUIState = {};\n\n for (const key in state) {\n if (state[key].model instanceof ApplicationModel) {\n newState[key] = { ...state[key] };\n }\n }\n\n return newState;\n};\n\nconst initialState: ModularUIState = {};\n\n/**\n * Modular UI Reducer\n */\nexport const ModularUIReducer: Reducer<ModularUIState, ReduxAction> = (\n state = initialState,\n action,\n) => {\n if (!action) {\n return state;\n }\n\n switch (action.type) {\n case \"MODULARUI/INIT\":\n return initModularUI(state, action.payload);\n\n case \"MODULARUI/RESET\":\n return resetModularUI(state);\n\n case \"MODULARUI/STATUS\":\n return updateStatus(state, action.payload);\n\n case \"MODULARUI/SET\":\n return setModel(state, action.payload);\n\n case \"MODULARUI/UPDATE\":\n case \"MODULARUI/UPDATE_FORM\":\n return updateModel(state, action.payload);\n\n case \"MODULARUI/REMOVE_KEY\":\n return removeKey(action.payload, state);\n\n default:\n return state;\n }\n};\n"],"mappings":";;;AACA,SAASA,gBAAgB,QAAQ,2BAA2B;AAC5D,SAASC,gBAAgB,QAAQ,cAAc;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state","_ref","key","status","requestOptions","LOADING","lastModification","Date","now","setModel","_ref2","model","FINISHED","console","debug","initModularUI","models","newState","_Object$assign","forEach","_ref3","getModelKey","_context","_findInstanceProperty","_Object$keys","call","connectKey","updateModel","modelKey","removeKey","resetModularUI","initialState","ModularUIReducer","arguments","length","undefined","action","type","payload"],"sources":["../../../src/redux/_modularui/ModularUIReducer.js"],"sourcesContent":["// @flow\nimport { MODULARUI_STATUS } from \"../../constants/Constants\";\nimport { ApplicationModel } from \"../../models\";\n\nimport type { Reducer } from \"redux\";\nimport type { ReduxAction } from \"../types\";\nimport type { ModularUIState } from \"./types\";\nimport type { ModularUIModel } from \"../../models\";\n\n/**\n */\nconst updateStatus = (\n state: ModularUIState,\n {\n key,\n status,\n requestOptions,\n }: {\n key: string,\n status: $Keys<typeof MODULARUI_STATUS>,\n requestOptions: any,\n },\n) => {\n // model should always be available when status is not loading\n if (status !== MODULARUI_STATUS.LOADING && !state[key]) {\n return state;\n }\n\n return {\n ...state,\n [key]: {\n ...state[key],\n status,\n lastModification: Date.now(),\n requestOptions: requestOptions || state[key]?.requestOptions,\n },\n };\n};\n\n/**\n */\nconst setModel = (\n state: ModularUIState,\n { key, model }: { key: string, model: ?ModularUIModel },\n) => {\n if (!state[key]) {\n return state;\n }\n\n if (model) {\n return {\n ...state,\n [key]: {\n ...state[key],\n model,\n lastModification: Date.now(),\n status: MODULARUI_STATUS.FINISHED,\n },\n };\n }\n\n // eslint-disable-next-line no-console\n console.debug(\"No model for setModel\");\n return state;\n};\n\n/**\n */\nconst initModularUI = (\n state: ModularUIState,\n models: Array<{ key: string, model: ModularUIModel }>,\n) => {\n const newState = Object.assign({}, state);\n\n models.forEach(({ key, model }) => {\n newState[key] = {\n status: MODULARUI_STATUS.FINISHED,\n lastModification: Date.now(),\n model,\n };\n });\n\n return newState;\n};\n\n/**\n */\nconst getModelKey = (state: ModularUIState, model: ModularUIModel) =>\n Object.keys(state).find((key) => {\n const connectKey = state[key]?.model?.connectKey ?? \"\";\n return connectKey === model.connectKey;\n });\n\n/**\n */\nconst updateModel = (state: ModularUIState, model: ModularUIModel) => {\n const modelKey = getModelKey(state, model);\n\n if (modelKey) {\n return setModel(state, { key: modelKey, model });\n }\n\n // eslint-disable-next-line no-console\n console.debug(\n `ModularUIReducer: Cannot update model with key ${model.connectKey}`,\n );\n return state;\n};\n\n/**\n */\nconst removeKey = (modelKey: string, state: ModularUIState): ModularUIState => {\n const newState = Object.assign({}, state);\n delete newState[modelKey];\n return newState;\n};\n\n/**\n * Remove all but application models\n */\nconst resetModularUI = (state: ModularUIState) => {\n const newState: ModularUIState = {};\n\n for (const key in state) {\n if (state[key].model instanceof ApplicationModel) {\n newState[key] = { ...state[key] };\n }\n }\n\n return newState;\n};\n\nconst initialState: ModularUIState = {};\n\n/**\n * Modular UI Reducer\n */\nexport const ModularUIReducer: Reducer<ModularUIState, ReduxAction> = (\n state = initialState,\n action,\n) => {\n if (!action) {\n return state;\n }\n\n switch (action.type) {\n case \"MODULARUI/INIT\":\n return initModularUI(state, action.payload);\n\n case \"MODULARUI/RESET\":\n return resetModularUI(state);\n\n case \"MODULARUI/STATUS\":\n return updateStatus(state, action.payload);\n\n case \"MODULARUI/SET\":\n return setModel(state, action.payload);\n\n case \"MODULARUI/UPDATE\":\n case \"MODULARUI/UPDATE_FORM\":\n return updateModel(state, action.payload);\n\n case \"MODULARUI/REMOVE_KEY\":\n return removeKey(action.payload, state);\n\n default:\n return state;\n }\n};\n"],"mappings":";;;AACA,SAASA,gBAAgB,QAAQ,2BAA2B;AAC5D,SAASC,gBAAgB,QAAQ,cAAc;AAO/C;AACA;AACA,MAAMC,YAAY,GAAGA,CACnBC,KAAqB,EAAAC,IAAA,KAUlB;EAAA,IATH;IACEC,GAAG;IACHC,MAAM;IACNC;EAKF,CAAC,GAAAH,IAAA;EAED;EACA,IAAIE,MAAM,KAAKN,gBAAgB,CAACQ,OAAO,IAAI,CAACL,KAAK,CAACE,GAAG,CAAC,EAAE;IACtD,OAAO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AG;MAAE,CAAC;IACnC;EACF;EAEA,OAAOe,QAAQ;AACjB,CAAC;AAED,MAAMc,YAA4B,GAAG,CAAC,CAAC;;AAEvC;AACA;AACA;AACA,OAAO,MAAMC,gBAAsD,GAAG,SAAAA,CAAA,EAGjE;EAAA,IAFHhC,KAAK,GAAAiC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGF,YAAY;EAAA,IACpBK,MAAM,GAAAH,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAEN,IAAI,CAACC,MAAM,EAAE;IACX,OAAOpC,KAAK;EACd;EAEA,QAAQoC,MAAM,CAACC,IAAI;IACjB,KAAK,gBAAgB;MACnB,OAAOtB,aAAa,CAACf,KAAK,EAAEoC,MAAM,CAACE,OAAO,CAAC;IAE7C,KAAK,iBAAiB;MACpB,OAAOR,cAAc,CAAC9B,KAAK,CAAC;IAE9B,KAAK,kBAAkB;MACrB,OAAOD,YAAY,CAACC,KAAK,EAAEoC,MAAM,CAACE,OAAO,CAAC;IAE5C,KAAK,eAAe;MAClB,OAAO7B,QAAQ,CAACT,KAAK,EAAEoC,MAAM,CAACE,OAAO,CAAC;IAExC,KAAK,kBAAkB;IACvB,KAAK,uBAAuB;MAC1B,OAAOX,WAAW,CAAC3B,KAAK,EAAEoC,MAAM,CAACE,OAAO,CAAC;IAE3C,KAAK,sBAAsB;MACzB,OAAOT,SAAS,CAACO,MAAM,CAACE,OAAO,EAAEtC,KAAK,CAAC;IAEzC;MACE,OAAOA,KAAK;EAChB;AACF,CAAC","ignoreList":[]}
@@ -244,8 +244,8 @@ export const getModelsByType = (state, type) => {
244
244
  */
245
245
  export const getAllFinishedModels = createSelector(state => state.modularui, modularui => {
246
246
  if (modularui) {
247
- var _context10, _context11;
248
- return _mapInstanceProperty(_context10 = _filterInstanceProperty(_context11 = _Object$keys(modularui)).call(_context11, key => modularui[key] && modularui[key].status === MODULARUI_STATUS.FINISHED)).call(_context10, key => modularui[key].model);
247
+ var _context0, _context1;
248
+ return _mapInstanceProperty(_context0 = _filterInstanceProperty(_context1 = _Object$keys(modularui)).call(_context1, key => modularui[key] && modularui[key].status === MODULARUI_STATUS.FINISHED)).call(_context0, key => modularui[key].model);
249
249
  }
250
250
  return [];
251
251
  });
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUISelectors.js","names":["createSelector","createSelectorCreator","defaultMemoize","has","Href","ContentModel","ContentTOCModel","ApplicationModel","TabModel","CaseViewModel","FormModel","MODULARUI_STATUS","getAllModelsByInstance","state","instance","locale","i18n","modularui","_context","_context2","_mapInstanceProperty","_filterInstanceProperty","_Object$keys","call","key","model","getFirstModelByInstance","_context3","_findInstanceProperty","getActiveModelByInstance","location","getLocation","_context4","_startsWithInstanceProperty","selfhref","path","getApplication","getTab","getCaseView","getForm","modelByHref","href","_context5","findHref","modelConfigKey","equals","keyByHref","_context6","allKeysByHref","_context7","router","pathname","getModels","models","forEach","modelKey","modelEntry","label","type","modelInfo","selfContentLink","push","getActiveModels","value","other","_JSON$stringify","contextModels","locationParts","split","reduce","accumulator","current","comparePath","decodeURIComponent","replace","foundEntry","encodedHref","toString","getPreference","preferenceName","preferences","getModelsByType","_context8","_context9","getAllFinishedModels","_context10","_context11","status","FINISHED"],"sources":["../../../src/redux/_modularui/ModularUISelectors.js"],"sourcesContent":["// @flow\nimport {\n createSelector,\n createSelectorCreator,\n defaultMemoize,\n} from \"reselect\";\nimport { has } from \"../../utils/helpers/objects\";\n\nimport Href from \"../../models/href/Href\";\nimport ContentModel from \"../../models/content/ContentModel\";\nimport ContentTOCModel from \"../../models/content/ContentTOCModel\";\nimport ApplicationModel from \"../../models/application/ApplicationModel\";\nimport TabModel from \"../../models/tab/TabModel\";\nimport CaseViewModel from \"../../models/caseview/CaseViewModel\";\nimport FormModel from \"../../models/form/FormModel\";\n\nimport type { ReduxState, PreferenceValue } from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport { MODULARUI_STATUS } from \"../../constants\";\n\n/**\n */\nexport const getAllModelsByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): Array<ModularUIModel> => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n return Object.keys(modularui)\n .filter((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n })\n .map((key) => modularui[key].model);\n }\n\n return [];\n};\n\n/**\n */\nexport const getFirstModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): T | null => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n */\nexport const getActiveModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): T | null => {\n const location = getLocation(state);\n\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return (\n model instanceof instance &&\n model.locale === locale &&\n location.startsWith(model.selfhref.path)\n );\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n * Get the application model, which is the model with selfhref '/'\n */\nexport const getApplication = (state: ReduxState): null | ApplicationModel =>\n getFirstModelByInstance(state, ApplicationModel);\n\n/**\n */\nexport const getTab = (state: ReduxState): null | TabModel =>\n getFirstModelByInstance(state, TabModel);\n\n/**\n */\nexport const getCaseView = (state: ReduxState): null | CaseViewModel =>\n getFirstModelByInstance(state, CaseViewModel);\n\n/**\n */\nexport const getForm = (state: ReduxState): null | FormModel =>\n getFirstModelByInstance(state, FormModel);\n\n/**\n * Get the model by it's href\n */\nexport const modelByHref = (\n state: ReduxState,\n href: Href | string,\n): null | ModularUIModel => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n const modelConfigKey = Object.keys(state.modularui).find((key) => {\n const model = state.modularui[key];\n\n return (\n model.model &&\n model.model.selfhref &&\n model.model.selfhref.equals(findHref)\n );\n });\n\n if (modelConfigKey) {\n return state.modularui[modelConfigKey].model;\n }\n }\n\n return null;\n};\n\n/**\n * Return the key of a model by the selfhref the model is saved in the reducer\n */\nexport const keyByHref = (state: ReduxState, href: Href | string): ?string => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).find((key) => {\n const { model } = state.modularui[key];\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return null;\n};\n\n/**\n * Returns all model keys found in the store, restrict on href\n */\nexport const allKeysByHref = (\n state: ReduxState,\n href: Href | string,\n): Array<string> => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).filter((key) => {\n const { model } = state.modularui[key];\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return [];\n};\n\n/**\n */\nconst getLocation = (state: ReduxState): string =>\n state?.router?.location.pathname;\n\n/**\n */\nconst getModels = (state: ReduxState) => {\n const models = [];\n\n Object.keys(state.modularui).forEach((modelKey: string) => {\n const modelEntry = state.modularui[modelKey];\n\n if (has(modelEntry, \"model\")) {\n const { key, selfhref, label, type } = modelEntry.model;\n\n const modelInfo = {\n key,\n selfhref,\n label,\n type,\n selfContentLink: null,\n };\n\n if (\n modelEntry.model instanceof ContentModel ||\n modelEntry.model instanceof ContentTOCModel\n ) {\n models.push({\n ...modelInfo,\n selfContentLink: modelEntry.model.selfContentLink,\n });\n } else {\n models.push(modelInfo);\n }\n }\n });\n\n return models;\n};\n\nexport const getActiveModels: (state: ReduxState) => Array<{\n key: string,\n href: Href,\n label: string,\n type: string,\n}> = createSelectorCreator(\n defaultMemoize,\n (value, other) => JSON.stringify(value) === JSON.stringify(other),\n)([getLocation, getModels], (location, models) => {\n const contextModels = [];\n\n if (location) {\n const locationParts = location.split(\"/\");\n\n locationParts.reduce((accumulator, current) => {\n const path = `${accumulator}/${current}`;\n\n // Remove modelcatalog part to match breadcrumb parts\n const comparePath = decodeURIComponent(path).replace(\n \"/modelcatalog/\",\n \"/\",\n );\n\n const foundEntry = models.find(\n (model) => model.selfhref && model.selfhref.equals(comparePath),\n );\n\n if (foundEntry) {\n const { key, label, type, selfhref, selfContentLink } = foundEntry;\n\n const href =\n path.startsWith(\"/modelcatalog/\") && selfContentLink\n ? new Href(`/modelcatalog${selfContentLink.encodedHref.toString()}`)\n : selfhref;\n\n contextModels.push({ key, href, label, type });\n }\n\n return path;\n });\n }\n\n return contextModels;\n});\n\n/**\n */\nexport const getPreference = (\n state: ReduxState,\n preferenceName: string,\n): null | PreferenceValue => {\n if (state && state.preferences) {\n return state.preferences[preferenceName];\n }\n\n return null;\n};\n\n/**\n * @deprecated - Use getFirstModelByInstance or the appropriate getter for the model type: getApplication, getTab, etc\n */\nexport const getModelsByType = (\n state: ReduxState,\n type: string,\n): Array<ModularUIModel> => {\n if (state && state.modularui) {\n return Object.keys(state.modularui)\n .filter(\n (key) =>\n state.modularui[key] &&\n state.modularui[key].model &&\n state.modularui[key].model.type === type,\n )\n .map((key) => state.modularui[key].model);\n }\n\n return [];\n};\n\n/**\n */\nexport const getAllFinishedModels: (\n state: ReduxState,\n) => Array<ModularUIModel> = createSelector(\n (state: ReduxState) => state.modularui,\n (modularui): Array<ModularUIModel> => {\n if (modularui) {\n return Object.keys(modularui)\n .filter(\n (key) =>\n modularui[key] &&\n modularui[key].status === MODULARUI_STATUS.FINISHED,\n )\n .map((key) => modularui[key].model);\n }\n return [];\n },\n);\n"],"mappings":";;;;;;AACA,SACEA,cAAc,EACdC,qBAAqB,EACrBC,cAAc,QACT,UAAU;AACjB,SAASC,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,IAAI,MAAM,wBAAwB;AACzC,OAAOC,YAAY,MAAM,mCAAmC;AAC5D,OAAOC,eAAe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6C,IAAY,KACc;EAC1B,IAAI7C,KAAK,IAAIA,KAAK,CAACI,SAAS,EAAE;IAAA,IAAAiE,SAAA,EAAAC,SAAA;IAC5B,OAAO/D,oBAAA,CAAA8D,SAAA,GAAA7D,uBAAA,CAAA8D,SAAA,GAAA7D,YAAA,CAAYT,KAAK,CAACI,SAAS,CAAC,EAAAM,IAAA,CAAA4D,SAAA,EAE9B3D,GAAG,IACFX,KAAK,CAACI,SAAS,CAACO,GAAG,CAAC,IACpBX,KAAK,CAACI,SAAS,CAACO,GAAG,CAAC,CAACC,KAAK,IAC1BZ,KAAK,CAACI,SAAS,CAACO,GAAG,CAAC,CAACC,KAAK,CAACiC,IAAI,KAAKA,IACxC,CAAC,EAAAnC,IAAA,CAAA2D,SAAA,EACK1D,GAAG,IAAKX,KAAK,CAACI,SAAS,CAACO,GAAG,CAAC,CAACC,KAAK,CAAC;EAC7C;EAEA,OAAO,EAAE;AACX,CAAC;;AAED;AACA;AACA,OAAO,MAAM2D,oBAEa,GAAGpF,cAAc,CACxCa,KAAiB,IAAKA,KAAK,CAACI,SAAS,EACrCA,SAAS,IAA4B;EACpC,IAAIA,SAAS,EAAE;IAAA,IAAAoE,UAAA,EAAAC,UAAA;IACb,OAAOlE,oBAAA,CAAAiE,UAAA,GAAAhE,uBAAA,CAAAiE,UAAA,GAAAhE,YAAA,CAAYL,SAAS,CAAC,EAAAM,IAAA,CAAA+D,UAAA,EAExB9D,GAAG,IACFP,SAAS,CAACO,GAAG,CAAC,IACdP,SAAS,CAACO,GAAG,CAAC,CAAC+D,MAAM,KAAK5E,gBAAgB,CAAC6E,QAC/C,CAAC,EAAAjE,IAAA,CAAA8D,UAAA,EACK7D,GAAG,IAAKP,SAAS,CAACO,GAAG,CAAC,CAACC,KAAK,CAAC;EACvC;EACA,OAAO,EAAE;AACX,CACF,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"ModularUISelectors.js","names":["createSelector","createSelectorCreator","defaultMemoize","has","Href","ContentModel","ContentTOCModel","ApplicationModel","TabModel","CaseViewModel","FormModel","MODULARUI_STATUS","getAllModelsByInstance","state","instance","locale","i18n","modularui","_context","_context2","_mapInstanceProperty","_filterInstanceProperty","_Object$keys","call","key","model","getFirstModelByInstance","_context3","_findInstanceProperty","getActiveModelByInstance","location","getLocation","_context4","_startsWithInstanceProperty","selfhref","path","getApplication","getTab","getCaseView","getForm","modelByHref","href","_context5","findHref","modelConfigKey","equals","keyByHref","_context6","allKeysByHref","_context7","router","pathname","getModels","models","forEach","modelKey","modelEntry","label","type","modelInfo","selfContentLink","push","getActiveModels","value","other","_JSON$stringify","contextModels","locationParts","split","reduce","accumulator","current","comparePath","decodeURIComponent","replace","foundEntry","encodedHref","toString","getPreference","preferenceName","preferences","getModelsByType","_context8","_context9","getAllFinishedModels","_context0","_context1","status","FINISHED"],"sources":["../../../src/redux/_modularui/ModularUISelectors.js"],"sourcesContent":["// @flow\nimport {\n createSelector,\n createSelectorCreator,\n defaultMemoize,\n} from \"reselect\";\nimport { has } from \"../../utils/helpers/objects\";\n\nimport Href from \"../../models/href/Href\";\nimport ContentModel from \"../../models/content/ContentModel\";\nimport ContentTOCModel from \"../../models/content/ContentTOCModel\";\nimport ApplicationModel from \"../../models/application/ApplicationModel\";\nimport TabModel from \"../../models/tab/TabModel\";\nimport CaseViewModel from \"../../models/caseview/CaseViewModel\";\nimport FormModel from \"../../models/form/FormModel\";\n\nimport type { ReduxState, PreferenceValue } from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport { MODULARUI_STATUS } from \"../../constants\";\n\n/**\n */\nexport const getAllModelsByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): Array<ModularUIModel> => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n return Object.keys(modularui)\n .filter((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n })\n .map((key) => modularui[key].model);\n }\n\n return [];\n};\n\n/**\n */\nexport const getFirstModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): T | null => {\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return model instanceof instance && model.locale === locale;\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n */\nexport const getActiveModelByInstance = <T>(\n state: ReduxState,\n instance: Class<T>,\n): T | null => {\n const location = getLocation(state);\n\n const locale = state?.i18n?.locale || \"en\";\n const modularui = state?.modularui;\n\n if (modularui) {\n const key = Object.keys(modularui).find((key) => {\n const { model } = modularui[key];\n return (\n model instanceof instance &&\n model.locale === locale &&\n location.startsWith(model.selfhref.path)\n );\n });\n\n if (key) {\n const { model } = modularui[key];\n if (model instanceof instance) {\n return model;\n }\n }\n }\n\n return null;\n};\n\n/**\n * Get the application model, which is the model with selfhref '/'\n */\nexport const getApplication = (state: ReduxState): null | ApplicationModel =>\n getFirstModelByInstance(state, ApplicationModel);\n\n/**\n */\nexport const getTab = (state: ReduxState): null | TabModel =>\n getFirstModelByInstance(state, TabModel);\n\n/**\n */\nexport const getCaseView = (state: ReduxState): null | CaseViewModel =>\n getFirstModelByInstance(state, CaseViewModel);\n\n/**\n */\nexport const getForm = (state: ReduxState): null | FormModel =>\n getFirstModelByInstance(state, FormModel);\n\n/**\n * Get the model by it's href\n */\nexport const modelByHref = (\n state: ReduxState,\n href: Href | string,\n): null | ModularUIModel => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n const modelConfigKey = Object.keys(state.modularui).find((key) => {\n const model = state.modularui[key];\n\n return (\n model.model &&\n model.model.selfhref &&\n model.model.selfhref.equals(findHref)\n );\n });\n\n if (modelConfigKey) {\n return state.modularui[modelConfigKey].model;\n }\n }\n\n return null;\n};\n\n/**\n * Return the key of a model by the selfhref the model is saved in the reducer\n */\nexport const keyByHref = (state: ReduxState, href: Href | string): ?string => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).find((key) => {\n const { model } = state.modularui[key];\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return null;\n};\n\n/**\n * Returns all model keys found in the store, restrict on href\n */\nexport const allKeysByHref = (\n state: ReduxState,\n href: Href | string,\n): Array<string> => {\n if (state && state.modularui) {\n const findHref = href instanceof Href ? href : new Href(href);\n\n return Object.keys(state.modularui).filter((key) => {\n const { model } = state.modularui[key];\n return model && model.selfhref && model.selfhref.equals(findHref);\n });\n }\n\n return [];\n};\n\n/**\n */\nconst getLocation = (state: ReduxState): string =>\n state?.router?.location.pathname;\n\n/**\n */\nconst getModels = (state: ReduxState) => {\n const models = [];\n\n Object.keys(state.modularui).forEach((modelKey: string) => {\n const modelEntry = state.modularui[modelKey];\n\n if (has(modelEntry, \"model\")) {\n const { key, selfhref, label, type } = modelEntry.model;\n\n const modelInfo = {\n key,\n selfhref,\n label,\n type,\n selfContentLink: null,\n };\n\n if (\n modelEntry.model instanceof ContentModel ||\n modelEntry.model instanceof ContentTOCModel\n ) {\n models.push({\n ...modelInfo,\n selfContentLink: modelEntry.model.selfContentLink,\n });\n } else {\n models.push(modelInfo);\n }\n }\n });\n\n return models;\n};\n\nexport const getActiveModels: (state: ReduxState) => Array<{\n key: string,\n href: Href,\n label: string,\n type: string,\n}> = createSelectorCreator(\n defaultMemoize,\n (value, other) => JSON.stringify(value) === JSON.stringify(other),\n)([getLocation, getModels], (location, models) => {\n const contextModels = [];\n\n if (location) {\n const locationParts = location.split(\"/\");\n\n locationParts.reduce((accumulator, current) => {\n const path = `${accumulator}/${current}`;\n\n // Remove modelcatalog part to match breadcrumb parts\n const comparePath = decodeURIComponent(path).replace(\n \"/modelcatalog/\",\n \"/\",\n );\n\n const foundEntry = models.find(\n (model) => model.selfhref && model.selfhref.equals(comparePath),\n );\n\n if (foundEntry) {\n const { key, label, type, selfhref, selfContentLink } = foundEntry;\n\n const href =\n path.startsWith(\"/modelcatalog/\") && selfContentLink\n ? new Href(`/modelcatalog${selfContentLink.encodedHref.toString()}`)\n : selfhref;\n\n contextModels.push({ key, href, label, type });\n }\n\n return path;\n });\n }\n\n return contextModels;\n});\n\n/**\n */\nexport const getPreference = (\n state: ReduxState,\n preferenceName: string,\n): null | PreferenceValue => {\n if (state && state.preferences) {\n return state.preferences[preferenceName];\n }\n\n return null;\n};\n\n/**\n * @deprecated - Use getFirstModelByInstance or the appropriate getter for the model type: getApplication, getTab, etc\n */\nexport const getModelsByType = (\n state: ReduxState,\n type: string,\n): Array<ModularUIModel> => {\n if (state && state.modularui) {\n return Object.keys(state.modularui)\n .filter(\n (key) =>\n state.modularui[key] &&\n state.modularui[key].model &&\n state.modularui[key].model.type === type,\n )\n .map((key) => state.modularui[key].model);\n }\n\n return [];\n};\n\n/**\n */\nexport const getAllFinishedModels: (\n state: ReduxState,\n) => Array<ModularUIModel> = createSelector(\n (state: ReduxState) => state.modularui,\n (modularui): Array<ModularUIModel> => {\n if (modularui) {\n return Object.keys(modularui)\n .filter(\n (key) =>\n modularui[key] &&\n modularui[key].status === MODULARUI_STATUS.FINISHED,\n )\n .map((key) => modularui[key].model);\n }\n return [];\n },\n);\n"],"mappings":";;;;;;AACA,SACEA,cAAc,EACdC,qBAAqB,EACrBC,cAAc,QACT,UAAU;AACjB,SAASC,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,IAAI,MAAM,wBAAwB;AACzC,OAAOC,YAAY,MAAM,mCAAmC;AAC5D,OAAOC,eAAe,MAAM,sCAAsC;AAClE,OAAOC,gBAAgB,MAAM,2CAA2C;AACxE,OAAOC,QAAQ,MAAM,2BAA2B;AAChD,OAAOC,aAAa,MAAM,qCAAqC;AAC/D,OAAOC,SAAS,MAAM,6BAA6B;AAInD,SAASC,gBAAgB,QAAQ,iBAAiB;;AAElD;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAGA,CACpCC,KAAiB,EACjBC,QAAkB,KACQ;EAC1B,M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,CAACO,GAAG,CAAC,IACpBX,KAAK,CAACI,SAAS,CAACO,GAAG,CAAC,CAACC,KAAK,IAC1BZ,KAAK,CAACI,SAAS,CAACO,GAAG,CAAC,CAACC,KAAK,CAACiC,IAAI,KAAKA,IACxC,CAAC,EAAAnC,IAAA,CAAA2D,SAAA,EACK1D,GAAG,IAAKX,KAAK,CAACI,SAAS,CAACO,GAAG,CAAC,CAACC,KAAK,CAAC;EAC7C;EAEA,OAAO,EAAE;AACX,CAAC;;AAED;AACA;AACA,OAAO,MAAM2D,oBAEa,GAAGpF,cAAc,CACxCa,KAAiB,IAAKA,KAAK,CAACI,SAAS,EACrCA,SAAS,IAA4B;EACpC,IAAIA,SAAS,EAAE;IAAA,IAAAoE,SAAA,EAAAC,SAAA;IACb,OAAOlE,oBAAA,CAAAiE,SAAA,GAAAhE,uBAAA,CAAAiE,SAAA,GAAAhE,YAAA,CAAYL,SAAS,CAAC,EAAAM,IAAA,CAAA+D,SAAA,EAExB9D,GAAG,IACFP,SAAS,CAACO,GAAG,CAAC,IACdP,SAAS,CAACO,GAAG,CAAC,CAAC+D,MAAM,KAAK5E,gBAAgB,CAAC6E,QAC/C,CAAC,EAAAjE,IAAA,CAAA8D,SAAA,EACK7D,GAAG,IAAKP,SAAS,CAACO,GAAG,CAAC,CAACC,KAAK,CAAC;EACvC;EACA,OAAO,EAAE;AACX,CACF,CAAC","ignoreList":[]}
@@ -72,7 +72,11 @@ describe("modularui actions", () => {
72
72
  expect(store.getActions()).toStrictEqual([
73
73
  {
74
74
  type: "MODULARUI/STATUS",
75
- payload: { key: "application", status: MODULARUI_STATUS.LOADING },
75
+ payload: {
76
+ key: "application",
77
+ status: MODULARUI_STATUS.LOADING,
78
+ requestOptions: undefined,
79
+ },
76
80
  },
77
81
  ]);
78
82
  });
@@ -77,6 +77,7 @@ type UpdateStatusAction = {
77
77
  payload: {
78
78
  key: string;
79
79
  status: $Keys<MODULARUI_STATUS>;
80
+ requestOptions: any;
80
81
  };
81
82
  };
82
83
  type ModularUIConnector = (Component: ComponentType<any>) => ComponentType<any>;
@@ -21,6 +21,7 @@ export type ModelEntry = {
21
21
  +status: string,
22
22
  +model: ModularUIModel,
23
23
  +lastModification: number,
24
+ +requestOptions?: any,
24
25
  };
25
26
 
26
27
  export type ModularUIState = {
@@ -111,6 +112,7 @@ export type UpdateStatusAction = {
111
112
  payload: {
112
113
  key: string,
113
114
  status: $Keys<MODULARUI_STATUS>,
115
+ requestOptions: any,
114
116
  },
115
117
  };
116
118
 
@@ -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 key: string,\n origin?: string,\n contextPath?: string,\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n params?: string,\n data?: any,\n timeout?: number,\n headers?: {\n [headerName: string]: string,\n Accept?: string,\n \"Accept-Language\"?: string,\n \"Content-Type\"?: string,\n \"x-filename\"?: string,\n \"x-filesize\"?: string,\n },\n events?: { [eventName: string]: () => void },\n onProgress?: ProgressEventHandler,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n cache?: boolean,\n isReload?: boolean,\n withCredentials?: 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 +requestOptions?: any,\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 key: string,\n origin?: string,\n contextPath?: string,\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n params?: string,\n data?: any,\n timeout?: number,\n headers?: {\n [headerName: string]: string,\n Accept?: string,\n \"Accept-Language\"?: string,\n \"Content-Type\"?: string,\n \"x-filename\"?: string,\n \"x-filesize\"?: string,\n },\n events?: { [eventName: string]: () => void },\n onProgress?: ProgressEventHandler,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n cache?: boolean,\n isReload?: boolean,\n withCredentials?: 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 requestOptions: any,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>,\n) => ComponentType<any>;\n"],"mappings":"","ignoreList":[]}
@@ -4,4 +4,4 @@ export function retrieveText(text: string | {
4
4
  properties?: {
5
5
  [key: string]: any;
6
6
  };
7
- }): string;
7
+ }): string | null;
@@ -12,6 +12,6 @@ export const retrieveText = text => {
12
12
  if (isPlainObject(text) && "message" in text) {
13
13
  return text.message;
14
14
  }
15
- return "";
15
+ return null;
16
16
  };
17
17
  //# sourceMappingURL=text.js.map
@@ -10,7 +10,7 @@ export const retrieveText = (
10
10
  text:
11
11
  | string
12
12
  | { id?: string, message: string, properties?: { [key: string]: any } },
13
- ): string => {
13
+ ): string | null => {
14
14
  if (typeof text === "string") {
15
15
  return text;
16
16
  }
@@ -19,5 +19,5 @@ export const retrieveText = (
19
19
  return text.message;
20
20
  }
21
21
 
22
- return "";
22
+ return null;
23
23
  };
@@ -1 +1 @@
1
- {"version":3,"file":"text.js","names":["isPlainObject","retrieveText","text","message"],"sources":["../../../src/utils/helpers/text.js"],"sourcesContent":["// @flow\nimport { isPlainObject } from \"./objects\";\n\n/**\n * Handles text that is in the ApplicationMessage form ({ id: string, message: string, properties: object })\n * @param text\n * @returns {string}\n */\nexport const retrieveText = (\n text:\n | string\n | { id?: string, message: string, properties?: { [key: string]: any } },\n): string => {\n if (typeof text === \"string\") {\n return text;\n }\n\n if (isPlainObject(text) && \"message\" in text) {\n return text.message;\n }\n\n return \"\";\n};\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,WAAW;;AAEzC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GACvBC,IAEyE,IAC9D;EACX,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAOA,IAAI;EACb;EAEA,IAAIF,aAAa,CAACE,IAAI,CAAC,IAAI,SAAS,IAAIA,IAAI,EAAE;IAC5C,OAAOA,IAAI,CAACC,OAAO;EACrB;EAEA,OAAO,EAAE;AACX,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"text.js","names":["isPlainObject","retrieveText","text","message"],"sources":["../../../src/utils/helpers/text.js"],"sourcesContent":["// @flow\nimport { isPlainObject } from \"./objects\";\n\n/**\n * Handles text that is in the ApplicationMessage form ({ id: string, message: string, properties: object })\n * @param text\n * @returns {string}\n */\nexport const retrieveText = (\n text:\n | string\n | { id?: string, message: string, properties?: { [key: string]: any } },\n): string | null => {\n if (typeof text === \"string\") {\n return text;\n }\n\n if (isPlainObject(text) && \"message\" in text) {\n return text.message;\n }\n\n return null;\n};\n"],"mappings":"AACA,SAASA,aAAa,QAAQ,WAAW;;AAEzC;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,GACvBC,IAEyE,IACvD;EAClB,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAOA,IAAI;EACb;EAEA,IAAIF,aAAa,CAACE,IAAI,CAAC,IAAI,SAAS,IAAIA,IAAI,EAAE;IAC5C,OAAOA,IAAI,CAACC,OAAO;EACrB;EAEA,OAAO,IAAI;AACb,CAAC","ignoreList":[]}
@@ -9,8 +9,7 @@ exports.default = void 0;
9
9
  exports.useDeepCompareEffect = useDeepCompareEffect;
10
10
  var React = _interopRequireWildcard(require("react"));
11
11
  var _lite = require("dequal/lite");
12
- function _getRequireWildcardCache(e) { if ("function" != typeof _WeakMap) return null; var r = new _WeakMap(), t = new _WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && _Object$getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? _Object$getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
12
+ function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && _Object$getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
13
  /**
15
14
  * As copied from https://github.com/kentcdodds/use-deep-compare-effect/
16
15
  * Need to copy this, because the dependency on dequal breaks in ie11