@beinformed/ui 1.9.0-beta.9 → 1.9.3

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 (130) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/esm/hooks/useForm.js.map +1 -1
  3. package/esm/hooks/useNotification.js.map +1 -1
  4. package/esm/hooks/useRouter.js.map +1 -1
  5. package/esm/models/attributes/AttributeContent.js +49 -20
  6. package/esm/models/attributes/AttributeContent.js.map +1 -1
  7. package/esm/models/attributes/AttributeDataHelper.js +1 -1
  8. package/esm/models/attributes/AttributeDataHelper.js.map +1 -1
  9. package/esm/models/attributes/HelptextAttributeModel.js +3 -1
  10. package/esm/models/attributes/HelptextAttributeModel.js.map +1 -1
  11. package/esm/models/caseview/CaseViewModel.js +26 -12
  12. package/esm/models/caseview/CaseViewModel.js.map +1 -1
  13. package/esm/models/contentconfiguration/ContentConfigurationResults.js +2 -2
  14. package/esm/models/contentconfiguration/ContentConfigurationResults.js.map +1 -1
  15. package/esm/models/form/FormObjectModel.js +8 -2
  16. package/esm/models/form/FormObjectModel.js.map +1 -1
  17. package/esm/models/layouthint/LayoutHintCollection.js +3 -2
  18. package/esm/models/layouthint/LayoutHintCollection.js.map +1 -1
  19. package/esm/models/list/ListDetailModel.js +25 -0
  20. package/esm/models/list/ListDetailModel.js.map +1 -1
  21. package/esm/models/list/ListModel.js +22 -16
  22. package/esm/models/list/ListModel.js.map +1 -1
  23. package/esm/models/panels/GroupingPanelModel.js +19 -17
  24. package/esm/models/panels/GroupingPanelModel.js.map +1 -1
  25. package/esm/modularui/ModularUIRequest.js +2 -1
  26. package/esm/modularui/ModularUIRequest.js.map +1 -1
  27. package/esm/redux/actions/FormAutosave.js +2 -1
  28. package/esm/redux/actions/FormAutosave.js.map +1 -1
  29. package/esm/redux/actions/FormValidations.js +2 -1
  30. package/esm/redux/actions/FormValidations.js.map +1 -1
  31. package/lib/hooks/useForm.js.flow +10 -5
  32. package/lib/hooks/useForm.js.map +1 -1
  33. package/lib/hooks/useNotification.js.flow +5 -2
  34. package/lib/hooks/useNotification.js.map +1 -1
  35. package/lib/hooks/useRouter.js.flow +12 -5
  36. package/lib/hooks/useRouter.js.map +1 -1
  37. package/lib/models/attributes/AttributeContent.js +51 -20
  38. package/lib/models/attributes/AttributeContent.js.flow +38 -13
  39. package/lib/models/attributes/AttributeContent.js.map +1 -1
  40. package/lib/models/attributes/AttributeDataHelper.js +1 -1
  41. package/lib/models/attributes/AttributeDataHelper.js.flow +2 -1
  42. package/lib/models/attributes/AttributeDataHelper.js.map +1 -1
  43. package/lib/models/attributes/HelptextAttributeModel.js +3 -1
  44. package/lib/models/attributes/HelptextAttributeModel.js.flow +1 -1
  45. package/lib/models/attributes/HelptextAttributeModel.js.map +1 -1
  46. package/lib/models/attributes/__tests__/AttributeContent.spec.js.flow +4 -2
  47. package/lib/models/attributes/__tests__/AttributeDataHelper.spec.js.flow +9 -3
  48. package/lib/models/attributes/__tests__/HelptextAttributeModel.spec.js.flow +1 -1
  49. package/lib/models/caseview/CaseViewModel.js +27 -13
  50. package/lib/models/caseview/CaseViewModel.js.flow +17 -7
  51. package/lib/models/caseview/CaseViewModel.js.map +1 -1
  52. package/lib/models/caseview/__tests__/CaseViewModel.spec.js.flow +68 -184
  53. package/lib/models/concepts/__mock__/business_scenario.js.flow +14 -1
  54. package/lib/models/concepts/__mock__/conceptdetail.js.flow +15 -6
  55. package/lib/models/concepts/__tests__/BusinessScenarioModel.spec.js.flow +5 -6
  56. package/lib/models/concepts/__tests__/ConceptDetailModel.spec.js.flow +58 -3
  57. package/lib/models/contentconfiguration/ContentConfigurationResults.js +2 -2
  58. package/lib/models/contentconfiguration/ContentConfigurationResults.js.flow +2 -2
  59. package/lib/models/contentconfiguration/ContentConfigurationResults.js.map +1 -1
  60. package/lib/models/contentconfiguration/__tests__/ContentConfigurationResults.spec.js.flow +6 -6
  61. package/lib/models/form/FormObjectModel.js +8 -2
  62. package/lib/models/form/FormObjectModel.js.flow +5 -1
  63. package/lib/models/form/FormObjectModel.js.map +1 -1
  64. package/lib/models/form/__tests__/FormObjectModel.spec.js.flow +2 -2
  65. package/lib/models/layouthint/LayoutHintCollection.js +4 -2
  66. package/lib/models/layouthint/LayoutHintCollection.js.flow +8 -7
  67. package/lib/models/layouthint/LayoutHintCollection.js.map +1 -1
  68. package/lib/models/list/ListDetailModel.js +25 -0
  69. package/lib/models/list/ListDetailModel.js.flow +19 -0
  70. package/lib/models/list/ListDetailModel.js.map +1 -1
  71. package/lib/models/list/ListModel.js +23 -16
  72. package/lib/models/list/ListModel.js.flow +9 -5
  73. package/lib/models/list/ListModel.js.map +1 -1
  74. package/lib/models/list/__tests__/ListDetailModel.spec.js.flow +64 -0
  75. package/lib/models/list/__tests__/ListModel.spec.js.flow +64 -2
  76. package/lib/models/panels/GroupingPanelModel.js +21 -18
  77. package/lib/models/panels/GroupingPanelModel.js.flow +10 -9
  78. package/lib/models/panels/GroupingPanelModel.js.map +1 -1
  79. package/lib/models/panels/__tests__/GroupingPanelModel.spec.js.flow +90 -0
  80. package/lib/models/types.js.flow +24 -6
  81. package/lib/modularui/ModularUIRequest.js +2 -1
  82. package/lib/modularui/ModularUIRequest.js.flow +1 -0
  83. package/lib/modularui/ModularUIRequest.js.map +1 -1
  84. package/lib/redux/actions/FormAutosave.js +2 -1
  85. package/lib/redux/actions/FormAutosave.js.flow +1 -0
  86. package/lib/redux/actions/FormAutosave.js.map +1 -1
  87. package/lib/redux/actions/FormValidations.js +2 -1
  88. package/lib/redux/actions/FormValidations.js.flow +1 -0
  89. package/lib/redux/actions/FormValidations.js.map +1 -1
  90. package/package.json +15 -15
  91. package/src/hooks/useForm.js +10 -5
  92. package/src/hooks/useNotification.js +5 -2
  93. package/src/hooks/useRouter.js +12 -5
  94. package/src/models/attributes/AttributeContent.js +38 -13
  95. package/src/models/attributes/AttributeDataHelper.js +2 -1
  96. package/src/models/attributes/HelptextAttributeModel.js +1 -1
  97. package/src/models/attributes/__tests__/AttributeContent.spec.js +4 -2
  98. package/src/models/attributes/__tests__/AttributeDataHelper.spec.js +9 -3
  99. package/src/models/attributes/__tests__/HelptextAttributeModel.spec.js +1 -1
  100. package/src/models/caseview/CaseViewModel.js +17 -7
  101. package/src/models/caseview/__tests__/CaseViewModel.spec.js +68 -184
  102. package/src/models/caseview/__tests__/caseview.json +38 -0
  103. package/src/models/caseview/__tests__/caseviewContributions.json +147 -0
  104. package/src/models/concepts/__mock__/business_scenario.js +14 -1
  105. package/src/models/concepts/__mock__/business_scenario_step.json +64 -0
  106. package/src/models/concepts/__mock__/conceptdetail.js +15 -6
  107. package/src/models/concepts/__mock__/conceptdetail_data.json +117 -17
  108. package/src/models/concepts/__mock__/concepttype_Calculation.json +75 -0
  109. package/src/models/concepts/__tests__/BusinessScenarioModel.spec.js +5 -6
  110. package/src/models/concepts/__tests__/ConceptDetailModel.spec.js +58 -3
  111. package/src/models/contentconfiguration/ContentConfigurationResults.js +2 -2
  112. package/src/models/contentconfiguration/__tests__/ContentConfigurationResults.spec.js +6 -6
  113. package/src/models/form/FormObjectModel.js +5 -1
  114. package/src/models/form/__tests__/FormObjectModel.spec.js +2 -2
  115. package/src/models/form/__tests__/FormWithContentData.json +2 -1
  116. package/src/models/layouthint/LayoutHintCollection.js +8 -7
  117. package/src/models/list/ListDetailModel.js +19 -0
  118. package/src/models/list/ListModel.js +9 -5
  119. package/src/models/list/__tests__/ListDetailModel.spec.js +64 -0
  120. package/src/models/list/__tests__/ListModel.spec.js +64 -2
  121. package/src/models/list/__tests__/caselist-34.contributions.json +1 -1
  122. package/src/models/list/__tests__/listContributions.json +1 -1
  123. package/src/models/panels/GroupingPanelModel.js +10 -9
  124. package/src/models/panels/__tests__/GroupingPanelModel.spec.js +90 -0
  125. package/src/models/panels/__tests__/groupingPanel.json +30 -0
  126. package/src/models/panels/__tests__/groupingPanelContributions.json +46 -0
  127. package/src/models/types.js +24 -6
  128. package/src/modularui/ModularUIRequest.js +1 -0
  129. package/src/redux/actions/FormAutosave.js +1 -0
  130. package/src/redux/actions/FormValidations.js +1 -0
@@ -623,7 +623,8 @@ var ModularUIRequest = /*#__PURE__*/function () {
623
623
  var prevData = typeof this.options.data === "string" ? JSON.parse(this.options.data) : this.options.data;
624
624
 
625
625
  if (model instanceof FormModel) {
626
- var newData = JSON.parse(model.validationData);
626
+ var newData = JSON.parse(model.validationData); // $FlowFixMe incompatible-call
627
+
627
628
  return _JSON$stringify(deepmerge(prevData || {}, newData));
628
629
  }
629
630
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/modularui/ModularUIRequest.js"],"names":["deepmerge","BASE","HTTP_METHODS","TIMEVERSION_FILTER_NAME","HIDE_WHEN_EMPTY","getSetting","Href","universalFetch","resolveModel","FormModel","ContentModel","ModularUIResponse","ModularUIError","IllegalArgumentException","IllegalStateException","isPlainObject","ModularUIRequest","href","options","GET","_response","locale","parameters","targetModel","method","_contributionsHref","contributionsHref","_locale","_href","_method","_options","childmodels","_targetModel","Model","response","isApplicableModel","contributionsData","contributionsKey","error","handleContributionsError","key","contributions","errorMessage","properties","message","path","toString","data","links","_links","Array","isArray","handleDataError","handleData","url","cache","params","getQuerystringForModularUI","onProgress","processApplicationLinks","processTabLinks","processPanelLinks","resolve","contributionLinks","dataLinks","tab","contributionTabLink","dataTabLinks","dataLink","name","processLinks","components","then","newLinks","replaceApplicationLinks","tabName","tabLink","component","panel","isHiddenListChecks","contributionLink","layouthint","link","push","isHiddenList","all","hiddenLinks","newDataLinks","dataLinkKey","_embedded","actions","isHidden","catch","_progressEvent","progressEvent","model","prevData","JSON","parse","newData","validationData","isValidationRequest","currentFormObject","hasDynamicValidations","validationHref","setParameter","getDynamicValidationData","updateValidations","fetchDataService","Error","processDataService","fetchContributionsService","processContributionsService","processAsyncLayoutHints","createModel","loadDynamicValidations","withChildModels","fetchChildModels","fetch","childModelLinks","getInitialChildModelLinks","childModelRequests","childModelLink","request","isCacheable","fetchFromCache","allSettled","childModels","resolvedChildModels","forEach","childModel","status","reason","console","value","addChildModels","withChildSections","childSectionLinks","length","fetchContentChildSections","contentModel","newContentModel","clone","childSectionLink","contentHrefWithEntryDate","selfhref","addParameter","entryDate","fetchContent","sectionModels","childSections"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAOA,SAAP,MAAsB,WAAtB;AAEA,SACEC,IADF,EAEEC,YAFF,EAGEC,uBAHF,QAIO,wBAJP;AAMA,SAASC,eAAT,QAAgC,0BAAhC;AAEA,SAASC,UAAT,QAA2B,uBAA3B;AAEA,OAAOC,IAAP,MAAiB,qBAAjB;AAEA,OAAOC,cAAP,MAA2B,+BAA3B;AACA,OAAOC,YAAP,MAAyB,wBAAzB;AACA,OAAOC,SAAP,MAAsB,0BAAtB;AACA,OAAOC,YAAP,MAAyB,gCAAzB;AAEA,OAAOC,iBAAP,MAA8B,qBAA9B;AAEA,OAAOC,cAAP,MAA2B,kBAA3B;AACA,SAASC,wBAAT,EAAmCC,qBAAnC,QAAgE,eAAhE;AAEA,SAASC,aAAT,QAA8B,0BAA9B;;AAKA;AACA;AACA;AACA;IACMC,gB;AAYJ;AACF;AACE,4BAAYC,IAAZ,EAA2E;AAAA;;AAAA,QAA1CC,OAA0C,uEAAJ,EAAI;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA;;AAAA,qCANrChB,YAAY,CAACiB,GAMwB;;AAAA;;AACzE,QAAI,CAACF,IAAL,EAAW;AACT,YAAM,IAAIJ,wBAAJ,CACJ,wDADI,CAAN;AAGD;;AAED,SAAKK,OAAL,GAAeA,OAAf;AAEA,SAAKE,SAAL,GAAiB,IAAIT,iBAAJ,EAAjB;AAEA,SAAKM,IAAL,GAAY,OAAOA,IAAP,KAAgB,QAAhB,GAA2B,IAAIX,IAAJ,CAASW,IAAT,CAA3B,GAA4CA,IAAxD;AACA,SAAKI,MAAL,sBAAcH,OAAO,CAACG,MAAtB,6DAAgC,IAAhC,CAZyE,CAczE;AACA;;AACA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BC,MAAxB,GAAiC,CAHnC,EAIE;AACA,iBAAO,MAAI,CAACC,yBAAL,CAA+B5C,KAA/B,CAAP;AACD;;AAED,eAAO,SAAQjC,OAAR,CAAgBiC,KAAhB,CAAP;AACD,OAVM,CAAP;AAWD;AAED;AACF;AACA;;;;WACE,mCAA0B6C,YAA1B,EAAsE;AAAA;AAAA;;AACpE,UAAMC,eAAe,GAAGD,YAAY,CAACE,KAAb,EAAxB;AAEA,aAAO,SAAQzD,GAAR,CACL,iCAAAuD,YAAY,CAACH,iBAAb,kBAAmC,UAACM,gBAAD,EAAsB;AACvD,YAAMC,wBAAwB,GAAGD,gBAAgB,CAACE,QAAjB,CAA0BC,YAA1B,CAC/B/I,uBAD+B,EAE/ByI,YAAY,CAACO,SAFkB,CAAjC;AAKA,YAAMxB,OAAO,GAAG,IAAI3G,gBAAJ,CAAqBgI,wBAArB,EAA+C;AAC7D3H,UAAAA,MAAM,EAAE,MAAI,CAACA;AADgD,SAA/C,CAAhB;AAIA,eAAOsG,OAAO,CAACyB,YAAR,CAAqB,IAArB,CAAP;AACD,OAXD,CADK,EAaL5E,IAbK,CAaA,UAAC6E,aAAD,EAAmB;AACxBR,QAAAA,eAAe,CAACS,aAAhB,GAAgCD,aAAhC;AAEA,eAAOR,eAAP;AACD,OAjBM,CAAP;AAkBD;;;;;;AAGH,eAAe7H,gBAAf","sourcesContent":["// @flow\nimport deepmerge from \"deepmerge\";\n\nimport {\n BASE,\n HTTP_METHODS,\n TIMEVERSION_FILTER_NAME,\n} from \"../constants/Constants\";\n\nimport { HIDE_WHEN_EMPTY } from \"../constants/LayoutHints\";\n\nimport { getSetting } from \"../constants/Settings\";\n\nimport Href from \"../models/href/Href\";\n\nimport universalFetch from \"../utils/fetch/universalFetch\";\nimport resolveModel from \"../models/resolveModel\";\nimport FormModel from \"../models/form/FormModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport ModularUIResponse from \"./ModularUIResponse\";\n\nimport ModularUIError from \"./ModularUIError\";\nimport { IllegalArgumentException, IllegalStateException } from \"../exceptions\";\n\nimport { isPlainObject } from \"../utils/helpers/objects\";\n\nimport type { RequestBaseOptions } from \"../utils/fetch/types\";\nimport type { ModularUIModel } from \"../models/types\";\n\n/**\n * Helper for fetching data and contributions from the Be Informed modular ui\n * and merge it into a target or resolvable model.\n */\nclass ModularUIRequest {\n _response: ModularUIResponse;\n\n _href: Href;\n _options: RequestBaseOptions;\n _targetModel: ?Class<ModularUIModel>;\n _contributionsHref: string;\n _locale: string;\n _method: $Keys<typeof HTTP_METHODS> = HTTP_METHODS.GET;\n\n _progressEvent: ProgressEventHandler;\n\n /**\n */\n constructor(href: Href | string, options: $Shape<RequestBaseOptions> = {}) {\n if (!href) {\n throw new IllegalArgumentException(\n \"You must pass a href to the resource that is requested\"\n );\n }\n\n this.options = options;\n\n this._response = new ModularUIResponse();\n\n this.href = typeof href === \"string\" ? new Href(href) : href;\n this.locale = options.locale ?? \"en\";\n\n // copy request parameters to response, to be able to use them in the models\n // self links are missing the request parameters\n this._response.parameters = this.href.parameters;\n\n if (options.targetModel) {\n this.targetModel = options.targetModel;\n }\n\n if (options.method) {\n this.method = options.method;\n } else {\n this.method = this.href.method;\n }\n }\n\n /**\n */\n get contributionsHref(): string {\n return this._contributionsHref;\n }\n\n /**\n */\n set contributionsHref(contributionsHref: string) {\n this._contributionsHref = contributionsHref;\n }\n\n /**\n */\n set locale(locale: string) {\n this._locale = locale;\n this._response.locale = locale;\n }\n\n /**\n */\n get locale(): string {\n return this._locale;\n }\n\n /**\n */\n get response(): ModularUIResponse {\n return this._response;\n }\n\n /**\n */\n set href(href: Href) {\n this._href = href;\n }\n\n /**\n */\n get href(): Href {\n return this._href;\n }\n\n /**\n */\n set method(method: $Keys<typeof HTTP_METHODS>) {\n this._method = method;\n }\n\n /**\n */\n get method(): $Keys<typeof HTTP_METHODS> {\n return this._method;\n }\n\n /**\n */\n get options(): RequestBaseOptions {\n return {\n ...this._options,\n locale: this.locale,\n method: this.method,\n };\n }\n\n /**\n */\n set options(options: RequestBaseOptions) {\n this._options = options;\n }\n\n /**\n */\n get withChildModels(): boolean {\n return (\n !(\"childmodels\" in this.options) || this.options.childmodels === true\n );\n }\n\n /**\n */\n set targetModel(targetModel: ?Class<ModularUIModel>) {\n this._targetModel = targetModel;\n }\n\n /**\n */\n get targetModel(): ?Class<ModularUIModel> {\n return this._targetModel;\n }\n\n /**\n */\n createModel(): ModularUIModel {\n const Model = this.targetModel || resolveModel(this.response);\n\n // check for ResourceModel\n if (Model && Model.isApplicableModel) {\n return new Model(this.response);\n }\n\n throw new IllegalStateException(\n `No model available for data: ${JSON.stringify(this.response)}`\n );\n }\n\n /**\n */\n processContributionsService(contributionsData: Object) {\n if (!isPlainObject(contributionsData)) {\n throw new IllegalArgumentException(\n \"Missing contributions data or contributions is not JSON\"\n );\n }\n\n const [contributionsKey] = Object.keys(contributionsData);\n\n if (contributionsData.error && contributionsKey === \"error\") {\n this.handleContributionsError(contributionsData.error);\n }\n\n // The key of the data service is different from the contributions service for forms\n if (!(this.response.key in contributionsData)) {\n this.response.key = contributionsKey;\n }\n\n this.response.contributions = contributionsData[this.response.key];\n }\n\n /**\n */\n handleContributionsError(error: Object) {\n const errorMessage = error.properties?.message ?? \"Error in contribution\";\n throw new ModularUIError(errorMessage, error, this.contributionsHref);\n }\n\n /**\n */\n handleDataError(error: Object) {\n if (error.properties) {\n const errorMessage = error.properties?.message ?? \"Error in data\";\n throw new ModularUIError(errorMessage, error, this.href.path.toString());\n }\n\n throw new IllegalArgumentException(error);\n }\n\n /**\n */\n handleData(key: string, data: Object) {\n this.response.key = key;\n this.response.data = data;\n\n const links = data._links;\n\n if (links && links.contributions) {\n this.contributionsHref = links.contributions.href;\n } else if (Array.isArray(links) && links[0].contributions) {\n this.contributionsHref = links[0].contributions.href;\n } else {\n throw new IllegalArgumentException(\n `Contributions link not found for data with key ${key}`\n );\n }\n }\n\n /**\n */\n processDataService(data: Object) {\n if (!isPlainObject(data)) {\n throw new IllegalArgumentException(\"Missing data or data is not JSON\");\n }\n\n if (data.error) {\n this.handleDataError(data.error);\n } else {\n const [key] = Object.keys(data);\n this.handleData(key, data[key]);\n }\n }\n\n /**\n */\n fetchContributionsService(): Promise<any> {\n if (!this.contributionsHref) {\n throw new IllegalStateException(\"Missing a contributions href\");\n }\n\n return universalFetch({\n url: `${BASE}${this.contributionsHref}`,\n cache: true,\n locale: this.options.locale,\n });\n }\n\n /**\n */\n fetchDataService(): Promise<any> {\n return universalFetch({\n ...this.options,\n url: `${BASE}${this.href.path}`,\n params: this.href.getQuerystringForModularUI(),\n locale: this.options.locale,\n onProgress: this.onProgress,\n });\n }\n\n /**\n * Check if links contain a 'hide-when-empty' layout hint and remove the link from\n * the component when it exists and no results are available\n */\n async processAsyncLayoutHints(): Promise<void> {\n if (getSetting(\"ALLOW_HIDE_WHEN_EMPTY_ON_TABS\")) {\n await this.processApplicationLinks();\n await this.processTabLinks();\n }\n await this.processPanelLinks();\n\n return Promise.resolve();\n }\n\n /**\n * hide application links<br>\n * _links on application data contains an extra level of tab links\n */\n processApplicationLinks(): Promise<void> {\n const contributionLinks = this.response.contributions._links;\n const dataLinks = this.response.data._links;\n if (!contributionLinks || !dataLinks) {\n return Promise.resolve();\n }\n\n if (\"tab\" in contributionLinks && \"tab\" in dataLinks) {\n for (const contributionTabLink of contributionLinks.tab) {\n if (\"components\" in contributionTabLink) {\n const dataTabLinks = dataLinks.tab.find(\n (dataLink) => dataLink.name === contributionTabLink.name\n );\n\n if (dataTabLinks && \"components\" in dataTabLinks) {\n return this.processLinks(\n dataTabLinks.components,\n contributionTabLink.components\n ).then((newLinks) =>\n this.replaceApplicationLinks(contributionTabLink.name, newLinks)\n );\n }\n }\n }\n }\n\n return Promise.resolve();\n }\n\n /**\n * Replace hidden link in application link tree\n */\n replaceApplicationLinks(tabName: string, newLinks: Array<Object>): void {\n this.response.data._links.tab = this.response.data._links.tab.map(\n (tabLink) => {\n const key = tabLink.name;\n if (tabName === key) {\n tabLink.components = newLinks;\n }\n return tabLink;\n }\n );\n }\n\n /**\n */\n processTabLinks(): Promise<void> {\n const contributionLinks = this.response.contributions._links;\n\n if (!contributionLinks) {\n return Promise.resolve();\n }\n\n if (\"component\" in contributionLinks) {\n return this.processLinks(\n this.response.data._links.component,\n contributionLinks.component\n ).then((newLinks) => {\n this.response.data._links.component = newLinks;\n });\n }\n\n return Promise.resolve();\n }\n\n /**\n */\n processPanelLinks(): Promise<void> {\n const contributionLinks = this.response.contributions._links;\n\n if (!contributionLinks) {\n return Promise.resolve();\n }\n\n if (\"panel\" in contributionLinks) {\n return this.processLinks(\n this.response.data._links,\n contributionLinks.panel\n ).then((newLinks) => {\n this.response.data._links = newLinks;\n });\n }\n\n return Promise.resolve();\n }\n\n /**\n * Check if links are empty and hide them when hide-when-empty hint exists\n */\n processLinks(\n dataLinks: any,\n contributionLinks: any\n ): Promise<Object | Array<Object>> {\n const isHiddenListChecks = [];\n for (const contributionLink of contributionLinks) {\n if (contributionLink.layouthint?.includes(HIDE_WHEN_EMPTY)) {\n const dataLink = Array.isArray(dataLinks)\n ? dataLinks.find((link) => link.name === contributionLink.name)\n : dataLinks[contributionLink.name];\n\n if (dataLink?.href) {\n isHiddenListChecks.push(\n this.isHiddenList(contributionLink.name, dataLink.href)\n );\n }\n }\n }\n\n return Promise.all(isHiddenListChecks).then((hiddenLinks) => {\n let newDataLinks;\n if (Array.isArray(dataLinks)) {\n newDataLinks = dataLinks.filter(\n (dataLink) => !hiddenLinks.includes(dataLink.name)\n );\n } else {\n newDataLinks = {};\n for (const dataLinkKey in dataLinks) {\n if (!hiddenLinks.includes(dataLinkKey)) {\n newDataLinks[dataLinkKey] = dataLinks[dataLinkKey];\n }\n }\n }\n return newDataLinks;\n });\n }\n\n /**\n */\n isHiddenList(name: string, href: string): Promise<?string> {\n return universalFetch({\n ...this.options,\n url: `${BASE}${href}`,\n })\n .then((response: Object) => {\n if (isPlainObject(response)) {\n const [key] = Object.keys(response);\n const { _embedded, actions } = response[key];\n\n const isHidden = _embedded == null && actions == null;\n if (isHidden) {\n return name;\n }\n }\n return \"\";\n })\n .catch(() => {\n return \"\";\n });\n }\n\n /**\n */\n set onProgress(progressEvent: ProgressEventHandler) {\n this._progressEvent = progressEvent;\n }\n\n /**\n */\n get onProgress(): ProgressEventHandler {\n return this._progressEvent || null;\n }\n\n /**\n * Combine previous send request data with new validation data to create a complete request object\n * The received model is new FormModel containing ONLY the current question, not the previously entered questions\n * to create a complete request we append the originally send form objects\n */\n getDynamicValidationData(model: ModularUIModel): string {\n const prevData =\n typeof this.options.data === \"string\"\n ? JSON.parse(this.options.data)\n : this.options.data;\n\n if (model instanceof FormModel) {\n const newData = JSON.parse(model.validationData);\n return JSON.stringify(deepmerge(prevData || {}, newData));\n }\n\n return JSON.stringify(prevData) ?? \"{}\";\n }\n\n /**\n * First load of dynamic values when a form is loaded\n */\n loadDynamicValidations(model: ModularUIModel): Promise<ModularUIModel> {\n if (\n !this.options.isValidationRequest &&\n getSetting(\"USE_INSTANT_SERVER_VALIDATION\") &&\n model instanceof FormModel &&\n model.currentFormObject &&\n model.currentFormObject.hasDynamicValidations\n ) {\n const validationHref = this.href.setParameter(\"commit\", \"false\");\n return universalFetch({\n ...this.options,\n url: `${BASE}${this.href.path}`,\n params: validationHref.getQuerystringForModularUI(),\n childmodels: false,\n data: this.getDynamicValidationData(model),\n }).then((data) => {\n if (data == null || typeof data !== \"object\") {\n return model;\n }\n\n const [key] = Object.keys(data);\n return model.updateValidations(data[key]);\n });\n }\n\n return Promise.resolve(model);\n }\n\n /**\n */\n fetch(): Promise<ModularUIModel> {\n return this.fetchDataService()\n .then((data) => {\n if (data == null) {\n throw new Error(`No data received for ${this.href.toString()}`);\n }\n\n this.processDataService(data);\n return this.fetchContributionsService();\n })\n .then((contributionsData) => {\n if (contributionsData == null) {\n throw new Error(\n `No contributions data received for ${this.contributionsHref}`\n );\n }\n\n this.processContributionsService(contributionsData);\n return this.processAsyncLayoutHints();\n })\n .then(() => Promise.resolve(this.createModel()))\n .then((model) => this.loadDynamicValidations(model))\n .then((model) => {\n if (this.withChildModels) {\n return this.fetchChildModels(model);\n }\n\n return Promise.resolve(model);\n });\n }\n\n /**\n */\n fetchFromCache(): Promise<ModularUIModel> {\n this.options = {\n ...this.options,\n cache: true,\n };\n\n return this.fetch();\n }\n\n /**\n */\n fetchChildModels(model: ModularUIModel): Promise<ModularUIModel> {\n const childModelLinks = model.getInitialChildModelLinks();\n\n const childModelRequests = childModelLinks.map((childModelLink) => {\n const request = new ModularUIRequest(childModelLink.href, {\n locale: this.locale,\n });\n\n if (childModelLink.targetModel) {\n request.targetModel = childModelLink.targetModel;\n }\n\n if (childModelLink.isCacheable) {\n return request.fetchFromCache();\n }\n\n return request.fetch();\n });\n\n return Promise.allSettled(childModelRequests).then((childModels) => {\n const resolvedChildModels = [];\n\n childModels.forEach((childModel) => {\n if (childModel.status === \"rejected\") {\n const { reason } = childModel;\n if (reason.name !== \"Error.ChangePasswordRequired\") {\n console.error(\n \"Unexpected error when retrieving child model:\",\n reason\n );\n }\n } else {\n resolvedChildModels.push(childModel.value);\n }\n });\n\n model.addChildModels(resolvedChildModels);\n\n return model;\n });\n }\n\n /**\n */\n fetchContent(withChildSections: boolean): Promise<mixed> {\n return this.fetchFromCache().then((model) => {\n if (\n withChildSections &&\n model instanceof ContentModel &&\n model.childSectionLinks.length > 0\n ) {\n return this.fetchContentChildSections(model);\n }\n\n return Promise.resolve(model);\n });\n }\n\n /**\n * Recursively return child sections defined on the content model\n */\n fetchContentChildSections(contentModel: ContentModel): Promise<mixed> {\n const newContentModel = contentModel.clone();\n\n return Promise.all(\n contentModel.childSectionLinks.map((childSectionLink) => {\n const contentHrefWithEntryDate = childSectionLink.selfhref.addParameter(\n TIMEVERSION_FILTER_NAME,\n contentModel.entryDate\n );\n\n const request = new ModularUIRequest(contentHrefWithEntryDate, {\n locale: this.locale,\n });\n\n return request.fetchContent(true);\n })\n ).then((sectionModels) => {\n newContentModel.childSections = sectionModels;\n\n return newContentModel;\n });\n }\n}\n\nexport default ModularUIRequest;\n"],"file":"ModularUIRequest.js"}
1
+ {"version":3,"sources":["../../src/modularui/ModularUIRequest.js"],"names":["deepmerge","BASE","HTTP_METHODS","TIMEVERSION_FILTER_NAME","HIDE_WHEN_EMPTY","getSetting","Href","universalFetch","resolveModel","FormModel","ContentModel","ModularUIResponse","ModularUIError","IllegalArgumentException","IllegalStateException","isPlainObject","ModularUIRequest","href","options","GET","_response","locale","parameters","targetModel","method","_contributionsHref","contributionsHref","_locale","_href","_method","_options","childmodels","_targetModel","Model","response","isApplicableModel","contributionsData","contributionsKey","error","handleContributionsError","key","contributions","errorMessage","properties","message","path","toString","data","links","_links","Array","isArray","handleDataError","handleData","url","cache","params","getQuerystringForModularUI","onProgress","processApplicationLinks","processTabLinks","processPanelLinks","resolve","contributionLinks","dataLinks","tab","contributionTabLink","dataTabLinks","dataLink","name","processLinks","components","then","newLinks","replaceApplicationLinks","tabName","tabLink","component","panel","isHiddenListChecks","contributionLink","layouthint","link","push","isHiddenList","all","hiddenLinks","newDataLinks","dataLinkKey","_embedded","actions","isHidden","catch","_progressEvent","progressEvent","model","prevData","JSON","parse","newData","validationData","isValidationRequest","currentFormObject","hasDynamicValidations","validationHref","setParameter","getDynamicValidationData","updateValidations","fetchDataService","Error","processDataService","fetchContributionsService","processContributionsService","processAsyncLayoutHints","createModel","loadDynamicValidations","withChildModels","fetchChildModels","fetch","childModelLinks","getInitialChildModelLinks","childModelRequests","childModelLink","request","isCacheable","fetchFromCache","allSettled","childModels","resolvedChildModels","forEach","childModel","status","reason","console","value","addChildModels","withChildSections","childSectionLinks","length","fetchContentChildSections","contentModel","newContentModel","clone","childSectionLink","contentHrefWithEntryDate","selfhref","addParameter","entryDate","fetchContent","sectionModels","childSections"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAOA,SAAP,MAAsB,WAAtB;AAEA,SACEC,IADF,EAEEC,YAFF,EAGEC,uBAHF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GAAGD,YAAY,CAACE,KAAb,EAAxB;AAEA,aAAO,SAAQzD,GAAR,CACL,iCAAAuD,YAAY,CAACH,iBAAb,kBAAmC,UAACM,gBAAD,EAAsB;AACvD,YAAMC,wBAAwB,GAAGD,gBAAgB,CAACE,QAAjB,CAA0BC,YAA1B,CAC/B/I,uBAD+B,EAE/ByI,YAAY,CAACO,SAFkB,CAAjC;AAKA,YAAMxB,OAAO,GAAG,IAAI3G,gBAAJ,CAAqBgI,wBAArB,EAA+C;AAC7D3H,UAAAA,MAAM,EAAE,MAAI,CAACA;AADgD,SAA/C,CAAhB;AAIA,eAAOsG,OAAO,CAACyB,YAAR,CAAqB,IAArB,CAAP;AACD,OAXD,CADK,EAaL5E,IAbK,CAaA,UAAC6E,aAAD,EAAmB;AACxBR,QAAAA,eAAe,CAACS,aAAhB,GAAgCD,aAAhC;AAEA,eAAOR,eAAP;AACD,OAjBM,CAAP;AAkBD;;;;;;AAGH,eAAe7H,gBAAf","sourcesContent":["// @flow\nimport deepmerge from \"deepmerge\";\n\nimport {\n BASE,\n HTTP_METHODS,\n TIMEVERSION_FILTER_NAME,\n} from \"../constants/Constants\";\n\nimport { HIDE_WHEN_EMPTY } from \"../constants/LayoutHints\";\n\nimport { getSetting } from \"../constants/Settings\";\n\nimport Href from \"../models/href/Href\";\n\nimport universalFetch from \"../utils/fetch/universalFetch\";\nimport resolveModel from \"../models/resolveModel\";\nimport FormModel from \"../models/form/FormModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport ModularUIResponse from \"./ModularUIResponse\";\n\nimport ModularUIError from \"./ModularUIError\";\nimport { IllegalArgumentException, IllegalStateException } from \"../exceptions\";\n\nimport { isPlainObject } from \"../utils/helpers/objects\";\n\nimport type { RequestBaseOptions } from \"../utils/fetch/types\";\nimport type { ModularUIModel } from \"../models/types\";\n\n/**\n * Helper for fetching data and contributions from the Be Informed modular ui\n * and merge it into a target or resolvable model.\n */\nclass ModularUIRequest {\n _response: ModularUIResponse;\n\n _href: Href;\n _options: RequestBaseOptions;\n _targetModel: ?Class<ModularUIModel>;\n _contributionsHref: string;\n _locale: string;\n _method: $Keys<typeof HTTP_METHODS> = HTTP_METHODS.GET;\n\n _progressEvent: ProgressEventHandler;\n\n /**\n */\n constructor(href: Href | string, options: $Shape<RequestBaseOptions> = {}) {\n if (!href) {\n throw new IllegalArgumentException(\n \"You must pass a href to the resource that is requested\"\n );\n }\n\n this.options = options;\n\n this._response = new ModularUIResponse();\n\n this.href = typeof href === \"string\" ? new Href(href) : href;\n this.locale = options.locale ?? \"en\";\n\n // copy request parameters to response, to be able to use them in the models\n // self links are missing the request parameters\n this._response.parameters = this.href.parameters;\n\n if (options.targetModel) {\n this.targetModel = options.targetModel;\n }\n\n if (options.method) {\n this.method = options.method;\n } else {\n this.method = this.href.method;\n }\n }\n\n /**\n */\n get contributionsHref(): string {\n return this._contributionsHref;\n }\n\n /**\n */\n set contributionsHref(contributionsHref: string) {\n this._contributionsHref = contributionsHref;\n }\n\n /**\n */\n set locale(locale: string) {\n this._locale = locale;\n this._response.locale = locale;\n }\n\n /**\n */\n get locale(): string {\n return this._locale;\n }\n\n /**\n */\n get response(): ModularUIResponse {\n return this._response;\n }\n\n /**\n */\n set href(href: Href) {\n this._href = href;\n }\n\n /**\n */\n get href(): Href {\n return this._href;\n }\n\n /**\n */\n set method(method: $Keys<typeof HTTP_METHODS>) {\n this._method = method;\n }\n\n /**\n */\n get method(): $Keys<typeof HTTP_METHODS> {\n return this._method;\n }\n\n /**\n */\n get options(): RequestBaseOptions {\n return {\n ...this._options,\n locale: this.locale,\n method: this.method,\n };\n }\n\n /**\n */\n set options(options: RequestBaseOptions) {\n this._options = options;\n }\n\n /**\n */\n get withChildModels(): boolean {\n return (\n !(\"childmodels\" in this.options) || this.options.childmodels === true\n );\n }\n\n /**\n */\n set targetModel(targetModel: ?Class<ModularUIModel>) {\n this._targetModel = targetModel;\n }\n\n /**\n */\n get targetModel(): ?Class<ModularUIModel> {\n return this._targetModel;\n }\n\n /**\n */\n createModel(): ModularUIModel {\n const Model = this.targetModel || resolveModel(this.response);\n\n // check for ResourceModel\n if (Model && Model.isApplicableModel) {\n return new Model(this.response);\n }\n\n throw new IllegalStateException(\n `No model available for data: ${JSON.stringify(this.response)}`\n );\n }\n\n /**\n */\n processContributionsService(contributionsData: Object) {\n if (!isPlainObject(contributionsData)) {\n throw new IllegalArgumentException(\n \"Missing contributions data or contributions is not JSON\"\n );\n }\n\n const [contributionsKey] = Object.keys(contributionsData);\n\n if (contributionsData.error && contributionsKey === \"error\") {\n this.handleContributionsError(contributionsData.error);\n }\n\n // The key of the data service is different from the contributions service for forms\n if (!(this.response.key in contributionsData)) {\n this.response.key = contributionsKey;\n }\n\n this.response.contributions = contributionsData[this.response.key];\n }\n\n /**\n */\n handleContributionsError(error: Object) {\n const errorMessage = error.properties?.message ?? \"Error in contribution\";\n throw new ModularUIError(errorMessage, error, this.contributionsHref);\n }\n\n /**\n */\n handleDataError(error: Object) {\n if (error.properties) {\n const errorMessage = error.properties?.message ?? \"Error in data\";\n throw new ModularUIError(errorMessage, error, this.href.path.toString());\n }\n\n throw new IllegalArgumentException(error);\n }\n\n /**\n */\n handleData(key: string, data: Object) {\n this.response.key = key;\n this.response.data = data;\n\n const links = data._links;\n\n if (links && links.contributions) {\n this.contributionsHref = links.contributions.href;\n } else if (Array.isArray(links) && links[0].contributions) {\n this.contributionsHref = links[0].contributions.href;\n } else {\n throw new IllegalArgumentException(\n `Contributions link not found for data with key ${key}`\n );\n }\n }\n\n /**\n */\n processDataService(data: Object) {\n if (!isPlainObject(data)) {\n throw new IllegalArgumentException(\"Missing data or data is not JSON\");\n }\n\n if (data.error) {\n this.handleDataError(data.error);\n } else {\n const [key] = Object.keys(data);\n this.handleData(key, data[key]);\n }\n }\n\n /**\n */\n fetchContributionsService(): Promise<any> {\n if (!this.contributionsHref) {\n throw new IllegalStateException(\"Missing a contributions href\");\n }\n\n return universalFetch({\n url: `${BASE}${this.contributionsHref}`,\n cache: true,\n locale: this.options.locale,\n });\n }\n\n /**\n */\n fetchDataService(): Promise<any> {\n return universalFetch({\n ...this.options,\n url: `${BASE}${this.href.path}`,\n params: this.href.getQuerystringForModularUI(),\n locale: this.options.locale,\n onProgress: this.onProgress,\n });\n }\n\n /**\n * Check if links contain a 'hide-when-empty' layout hint and remove the link from\n * the component when it exists and no results are available\n */\n async processAsyncLayoutHints(): Promise<void> {\n if (getSetting(\"ALLOW_HIDE_WHEN_EMPTY_ON_TABS\")) {\n await this.processApplicationLinks();\n await this.processTabLinks();\n }\n await this.processPanelLinks();\n\n return Promise.resolve();\n }\n\n /**\n * hide application links<br>\n * _links on application data contains an extra level of tab links\n */\n processApplicationLinks(): Promise<void> {\n const contributionLinks = this.response.contributions._links;\n const dataLinks = this.response.data._links;\n if (!contributionLinks || !dataLinks) {\n return Promise.resolve();\n }\n\n if (\"tab\" in contributionLinks && \"tab\" in dataLinks) {\n for (const contributionTabLink of contributionLinks.tab) {\n if (\"components\" in contributionTabLink) {\n const dataTabLinks = dataLinks.tab.find(\n (dataLink) => dataLink.name === contributionTabLink.name\n );\n\n if (dataTabLinks && \"components\" in dataTabLinks) {\n return this.processLinks(\n dataTabLinks.components,\n contributionTabLink.components\n ).then((newLinks) =>\n this.replaceApplicationLinks(contributionTabLink.name, newLinks)\n );\n }\n }\n }\n }\n\n return Promise.resolve();\n }\n\n /**\n * Replace hidden link in application link tree\n */\n replaceApplicationLinks(tabName: string, newLinks: Array<Object>): void {\n this.response.data._links.tab = this.response.data._links.tab.map(\n (tabLink) => {\n const key = tabLink.name;\n if (tabName === key) {\n tabLink.components = newLinks;\n }\n return tabLink;\n }\n );\n }\n\n /**\n */\n processTabLinks(): Promise<void> {\n const contributionLinks = this.response.contributions._links;\n\n if (!contributionLinks) {\n return Promise.resolve();\n }\n\n if (\"component\" in contributionLinks) {\n return this.processLinks(\n this.response.data._links.component,\n contributionLinks.component\n ).then((newLinks) => {\n this.response.data._links.component = newLinks;\n });\n }\n\n return Promise.resolve();\n }\n\n /**\n */\n processPanelLinks(): Promise<void> {\n const contributionLinks = this.response.contributions._links;\n\n if (!contributionLinks) {\n return Promise.resolve();\n }\n\n if (\"panel\" in contributionLinks) {\n return this.processLinks(\n this.response.data._links,\n contributionLinks.panel\n ).then((newLinks) => {\n this.response.data._links = newLinks;\n });\n }\n\n return Promise.resolve();\n }\n\n /**\n * Check if links are empty and hide them when hide-when-empty hint exists\n */\n processLinks(\n dataLinks: any,\n contributionLinks: any\n ): Promise<Object | Array<Object>> {\n const isHiddenListChecks = [];\n for (const contributionLink of contributionLinks) {\n if (contributionLink.layouthint?.includes(HIDE_WHEN_EMPTY)) {\n const dataLink = Array.isArray(dataLinks)\n ? dataLinks.find((link) => link.name === contributionLink.name)\n : dataLinks[contributionLink.name];\n\n if (dataLink?.href) {\n isHiddenListChecks.push(\n this.isHiddenList(contributionLink.name, dataLink.href)\n );\n }\n }\n }\n\n return Promise.all(isHiddenListChecks).then((hiddenLinks) => {\n let newDataLinks;\n if (Array.isArray(dataLinks)) {\n newDataLinks = dataLinks.filter(\n (dataLink) => !hiddenLinks.includes(dataLink.name)\n );\n } else {\n newDataLinks = {};\n for (const dataLinkKey in dataLinks) {\n if (!hiddenLinks.includes(dataLinkKey)) {\n newDataLinks[dataLinkKey] = dataLinks[dataLinkKey];\n }\n }\n }\n return newDataLinks;\n });\n }\n\n /**\n */\n isHiddenList(name: string, href: string): Promise<?string> {\n return universalFetch({\n ...this.options,\n url: `${BASE}${href}`,\n })\n .then((response: Object) => {\n if (isPlainObject(response)) {\n const [key] = Object.keys(response);\n const { _embedded, actions } = response[key];\n\n const isHidden = _embedded == null && actions == null;\n if (isHidden) {\n return name;\n }\n }\n return \"\";\n })\n .catch(() => {\n return \"\";\n });\n }\n\n /**\n */\n set onProgress(progressEvent: ProgressEventHandler) {\n this._progressEvent = progressEvent;\n }\n\n /**\n */\n get onProgress(): ProgressEventHandler {\n return this._progressEvent || null;\n }\n\n /**\n * Combine previous send request data with new validation data to create a complete request object\n * The received model is new FormModel containing ONLY the current question, not the previously entered questions\n * to create a complete request we append the originally send form objects\n */\n getDynamicValidationData(model: ModularUIModel): string {\n const prevData =\n typeof this.options.data === \"string\"\n ? JSON.parse(this.options.data)\n : this.options.data;\n\n if (model instanceof FormModel) {\n const newData = JSON.parse(model.validationData);\n // $FlowFixMe incompatible-call\n return JSON.stringify(deepmerge(prevData || {}, newData));\n }\n\n return JSON.stringify(prevData) ?? \"{}\";\n }\n\n /**\n * First load of dynamic values when a form is loaded\n */\n loadDynamicValidations(model: ModularUIModel): Promise<ModularUIModel> {\n if (\n !this.options.isValidationRequest &&\n getSetting(\"USE_INSTANT_SERVER_VALIDATION\") &&\n model instanceof FormModel &&\n model.currentFormObject &&\n model.currentFormObject.hasDynamicValidations\n ) {\n const validationHref = this.href.setParameter(\"commit\", \"false\");\n return universalFetch({\n ...this.options,\n url: `${BASE}${this.href.path}`,\n params: validationHref.getQuerystringForModularUI(),\n childmodels: false,\n data: this.getDynamicValidationData(model),\n }).then((data) => {\n if (data == null || typeof data !== \"object\") {\n return model;\n }\n\n const [key] = Object.keys(data);\n return model.updateValidations(data[key]);\n });\n }\n\n return Promise.resolve(model);\n }\n\n /**\n */\n fetch(): Promise<ModularUIModel> {\n return this.fetchDataService()\n .then((data) => {\n if (data == null) {\n throw new Error(`No data received for ${this.href.toString()}`);\n }\n\n this.processDataService(data);\n return this.fetchContributionsService();\n })\n .then((contributionsData) => {\n if (contributionsData == null) {\n throw new Error(\n `No contributions data received for ${this.contributionsHref}`\n );\n }\n\n this.processContributionsService(contributionsData);\n return this.processAsyncLayoutHints();\n })\n .then(() => Promise.resolve(this.createModel()))\n .then((model) => this.loadDynamicValidations(model))\n .then((model) => {\n if (this.withChildModels) {\n return this.fetchChildModels(model);\n }\n\n return Promise.resolve(model);\n });\n }\n\n /**\n */\n fetchFromCache(): Promise<ModularUIModel> {\n this.options = {\n ...this.options,\n cache: true,\n };\n\n return this.fetch();\n }\n\n /**\n */\n fetchChildModels(model: ModularUIModel): Promise<ModularUIModel> {\n const childModelLinks = model.getInitialChildModelLinks();\n\n const childModelRequests = childModelLinks.map((childModelLink) => {\n const request = new ModularUIRequest(childModelLink.href, {\n locale: this.locale,\n });\n\n if (childModelLink.targetModel) {\n request.targetModel = childModelLink.targetModel;\n }\n\n if (childModelLink.isCacheable) {\n return request.fetchFromCache();\n }\n\n return request.fetch();\n });\n\n return Promise.allSettled(childModelRequests).then((childModels) => {\n const resolvedChildModels = [];\n\n childModels.forEach((childModel) => {\n if (childModel.status === \"rejected\") {\n const { reason } = childModel;\n if (reason.name !== \"Error.ChangePasswordRequired\") {\n console.error(\n \"Unexpected error when retrieving child model:\",\n reason\n );\n }\n } else {\n resolvedChildModels.push(childModel.value);\n }\n });\n\n model.addChildModels(resolvedChildModels);\n\n return model;\n });\n }\n\n /**\n */\n fetchContent(withChildSections: boolean): Promise<mixed> {\n return this.fetchFromCache().then((model) => {\n if (\n withChildSections &&\n model instanceof ContentModel &&\n model.childSectionLinks.length > 0\n ) {\n return this.fetchContentChildSections(model);\n }\n\n return Promise.resolve(model);\n });\n }\n\n /**\n * Recursively return child sections defined on the content model\n */\n fetchContentChildSections(contentModel: ContentModel): Promise<mixed> {\n const newContentModel = contentModel.clone();\n\n return Promise.all(\n contentModel.childSectionLinks.map((childSectionLink) => {\n const contentHrefWithEntryDate = childSectionLink.selfhref.addParameter(\n TIMEVERSION_FILTER_NAME,\n contentModel.entryDate\n );\n\n const request = new ModularUIRequest(contentHrefWithEntryDate, {\n locale: this.locale,\n });\n\n return request.fetchContent(true);\n })\n ).then((sectionModels) => {\n newContentModel.childSections = sectionModels;\n\n return newContentModel;\n });\n }\n}\n\nexport default ModularUIRequest;\n"],"file":"ModularUIRequest.js"}
@@ -27,7 +27,8 @@ var autosave = function autosave(dispatch, form) {
27
27
  new ModularUIRequest(form.selfhref.setParameter("commit", "true"), {
28
28
  method: HTTP_METHODS.POST,
29
29
  data: formdata,
30
- childmodels: false
30
+ childmodels: false,
31
+ locale: form.locale
31
32
  }).fetch().then(function (savedForm) {
32
33
  if (savedForm instanceof FormModel) {
33
34
  // update last server update to indicate an update has happened
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/redux/actions/FormAutosave.js"],"names":["debounce","ModularUIRequest","FormModel","HTTP_METHODS","VALIDATE_DEBOUNCE_TIMEOUT","AUTOSAVE_STATUS","updateModel","updateAutosave","status","model","type","payload","autosave","dispatch","form","START","formdata","getFormData","selfhref","setParameter","method","POST","data","childmodels","fetch","then","savedForm","lastServerUpdate","FINISHED","debouncedAutosave","autosaveFormObject"],"mappings":"AACA,OAAOA,QAAP,MAAqB,iBAArB;AAEA,OAAOC,gBAAP,MAA6B,kCAA7B;AACA,OAAOC,SAAP,MAAsB,6BAAtB;AAEA,SACEC,YADF,EAEEC,yBAFF,EAGEC,eAHF,QAIO,2BAJP;AAMA,SAASC,WAAT,QAA4B,uBAA5B;;AAIA;AACA;AACA;AACA;AACA,IAAMC,cAAc,GAAG,SAAjBA,cAAiB,CACrBC,MADqB,EAErBC,KAFqB;AAAA,SAGK;AAC1BC,IAAAA,IAAI,EAAE,wBADoB;AAE1BC,IAAAA,OAAO,EAAE;AACPH,MAAAA,MAAM,EAANA,MADO;AAEPC,MAAAA,KAAK,EAALA;AAFO;AAFiB,GAHL;AAAA,CAAvB;AAWA;AACA;;;AACA,IAAMG,QAAQ,GAAG,SAAXA,QAAW,CAACC,QAAD,EAAqBC,IAArB,EAAyC;AACxDD,EAAAA,QAAQ,CAACN,cAAc,CAACF,eAAe,CAACU,KAAjB,EAAwBD,IAAxB,CAAf,CAAR;AAEA,MAAME,QAAQ,GAAGF,IAAI,CAACG,WAAL,CAAiB,IAAjB,EAAuB,KAAvB,CAAjB;AAEA,MAAIhB,gBAAJ,CAAqBa,IAAI,CAACI,QAAL,CAAcC,YAAd,CAA2B,QAA3B,EAAqC,MAArC,CAArB,EAAmE;AACjEC,IAAAA,MAAM,EAAEjB,YAAY,CAACkB,IAD4C;AAEjEC,IAAAA,IAAI,EAAEN,QAF2D;AAGjEO,IAAAA,WAAW,EAAE;AAHoD,GAAnE,EAKGC,KALH,GAMGC,IANH,CAMQ,UAACC,SAAD,EAAe;AACnB,QAAIA,SAAS,YAAYxB,SAAzB,EAAoC;AAClC;AACA;AACAY,MAAAA,IAAI,CAACa,gBAAL,GAAwBD,SAAS,CAACC,gBAAlC;AAEAd,MAAAA,QAAQ,CAACP,WAAW,CAACQ,IAAD,CAAZ,CAAR;AACAD,MAAAA,QAAQ,CAACN,cAAc,CAACF,eAAe,CAACuB,QAAjB,EAA2BF,SAA3B,CAAf,CAAR;AACD;AACF,GAfH;AAgBD,CArBD;AAuBA;AACA;AACA;AACA;AACA;AACA;;;AACA,IAAMG,iBAAiB,GAAG7B,QAAQ,CAAC,UAACa,QAAD,EAAWC,IAAX,EAAoB;AACrDF,EAAAA,QAAQ,CAACC,QAAD,EAAWC,IAAX,CAAR;AACD,CAFiC,EAE/BV,yBAF+B,CAAlC;AAIA;AACA;;AACA,OAAO,IAAM0B,kBAAkB,GAC7B,SADWA,kBACX,CAAChB,IAAD;AAAA,SACA,UAACD,QAAD;AAAA,WACEgB,iBAAiB,CAAChB,QAAD,EAAWC,IAAX,CADnB;AAAA,GADA;AAAA,CADK","sourcesContent":["// @flow\nimport debounce from \"lodash/debounce\";\n\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\nimport FormModel from \"../../models/form/FormModel\";\n\nimport {\n HTTP_METHODS,\n VALIDATE_DEBOUNCE_TIMEOUT,\n AUTOSAVE_STATUS,\n} from \"../../constants/Constants\";\n\nimport { updateModel } from \"../_modularui/actions\";\n\nimport type { UpdateAutosaveAction, ThunkAction, Dispatch } from \"../types\";\n\n/**\n * Update validations of the form currently in the reducer\n * because of the debounce timeout there might have been an update on the form during validation\n */\nconst updateAutosave = (\n status: $Keys<typeof AUTOSAVE_STATUS>,\n model: FormModel\n): UpdateAutosaveAction => ({\n type: \"UPDATE_AUTOSAVE_STATUS\",\n payload: {\n status,\n model,\n },\n});\n\n/**\n */\nconst autosave = (dispatch: Dispatch, form: FormModel) => {\n dispatch(updateAutosave(AUTOSAVE_STATUS.START, form));\n\n const formdata = form.getFormData(true, false);\n\n new ModularUIRequest(form.selfhref.setParameter(\"commit\", \"true\"), {\n method: HTTP_METHODS.POST,\n data: formdata,\n childmodels: false,\n })\n .fetch()\n .then((savedForm) => {\n if (savedForm instanceof FormModel) {\n // update last server update to indicate an update has happened\n // send the existing form to prevent updates in the ui based on autosave results\n form.lastServerUpdate = savedForm.lastServerUpdate;\n\n dispatch(updateModel(form));\n dispatch(updateAutosave(AUTOSAVE_STATUS.FINISHED, savedForm));\n }\n });\n};\n\n/**\n * Validates form objects debounced to prevent overloading the (form) service\n * When a form with new errors (or complete) arrives, we send the validations\n * to the current form model where the errors are processed\n * A new form with the new constraints is send to the store\n */\nconst debouncedAutosave = debounce((dispatch, form) => {\n autosave(dispatch, form);\n}, VALIDATE_DEBOUNCE_TIMEOUT);\n\n/**\n */\nexport const autosaveFormObject =\n (form: FormModel): ThunkAction =>\n (dispatch) =>\n debouncedAutosave(dispatch, form);\n"],"file":"FormAutosave.js"}
1
+ {"version":3,"sources":["../../../src/redux/actions/FormAutosave.js"],"names":["debounce","ModularUIRequest","FormModel","HTTP_METHODS","VALIDATE_DEBOUNCE_TIMEOUT","AUTOSAVE_STATUS","updateModel","updateAutosave","status","model","type","payload","autosave","dispatch","form","START","formdata","getFormData","selfhref","setParameter","method","POST","data","childmodels","locale","fetch","then","savedForm","lastServerUpdate","FINISHED","debouncedAutosave","autosaveFormObject"],"mappings":"AACA,OAAOA,QAAP,MAAqB,iBAArB;AAEA,OAAOC,gBAAP,MAA6B,kCAA7B;AACA,OAAOC,SAAP,MAAsB,6BAAtB;AAEA,SACEC,YADF,EAEEC,yBAFF,EAGEC,eAHF,QAIO,2BAJP;AAMA,SAASC,WAAT,QAA4B,uBAA5B;;AAIA;AACA;AACA;AACA;AACA,IAAMC,cAAc,GAAG,SAAjBA,cA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AACD,CAFiC,EAE/BV,yBAF+B,CAAlC;AAIA;AACA;;AACA,OAAO,IAAM2B,kBAAkB,GAC7B,SADWA,kBACX,CAACjB,IAAD;AAAA,SACA,UAACD,QAAD;AAAA,WACEiB,iBAAiB,CAACjB,QAAD,EAAWC,IAAX,CADnB;AAAA,GADA;AAAA,CADK","sourcesContent":["// @flow\nimport debounce from \"lodash/debounce\";\n\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\nimport FormModel from \"../../models/form/FormModel\";\n\nimport {\n HTTP_METHODS,\n VALIDATE_DEBOUNCE_TIMEOUT,\n AUTOSAVE_STATUS,\n} from \"../../constants/Constants\";\n\nimport { updateModel } from \"../_modularui/actions\";\n\nimport type { UpdateAutosaveAction, ThunkAction, Dispatch } from \"../types\";\n\n/**\n * Update validations of the form currently in the reducer\n * because of the debounce timeout there might have been an update on the form during validation\n */\nconst updateAutosave = (\n status: $Keys<typeof AUTOSAVE_STATUS>,\n model: FormModel\n): UpdateAutosaveAction => ({\n type: \"UPDATE_AUTOSAVE_STATUS\",\n payload: {\n status,\n model,\n },\n});\n\n/**\n */\nconst autosave = (dispatch: Dispatch, form: FormModel) => {\n dispatch(updateAutosave(AUTOSAVE_STATUS.START, form));\n\n const formdata = form.getFormData(true, false);\n\n new ModularUIRequest(form.selfhref.setParameter(\"commit\", \"true\"), {\n method: HTTP_METHODS.POST,\n data: formdata,\n childmodels: false,\n locale: form.locale,\n })\n .fetch()\n .then((savedForm) => {\n if (savedForm instanceof FormModel) {\n // update last server update to indicate an update has happened\n // send the existing form to prevent updates in the ui based on autosave results\n form.lastServerUpdate = savedForm.lastServerUpdate;\n\n dispatch(updateModel(form));\n dispatch(updateAutosave(AUTOSAVE_STATUS.FINISHED, savedForm));\n }\n });\n};\n\n/**\n * Validates form objects debounced to prevent overloading the (form) service\n * When a form with new errors (or complete) arrives, we send the validations\n * to the current form model where the errors are processed\n * A new form with the new constraints is send to the store\n */\nconst debouncedAutosave = debounce((dispatch, form) => {\n autosave(dispatch, form);\n}, VALIDATE_DEBOUNCE_TIMEOUT);\n\n/**\n */\nexport const autosaveFormObject =\n (form: FormModel): ThunkAction =>\n (dispatch) =>\n debouncedAutosave(dispatch, form);\n"],"file":"FormAutosave.js"}
@@ -36,7 +36,8 @@ var debouncedValidateFormObject = debounce(function (dispatch, form) {
36
36
  method: HTTP_METHODS.POST,
37
37
  data: form.validationData,
38
38
  childmodels: false,
39
- isValidationRequest: true
39
+ isValidationRequest: true,
40
+ locale: form.locale
40
41
  }).fetch().then(function (formWithValidations) {
41
42
  return dispatch(updateValidations(form, formWithValidations));
42
43
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/redux/actions/FormValidations.js"],"names":["debounce","updateModel","ModularUIRequest","HTTP_METHODS","VALIDATE_DEBOUNCE_TIMEOUT","FormModel","updateValidations","form","formWithValidations","dispatch","getState","currentForm","modularui","connectKey","validatedForm","model","clone","data","debouncedValidateFormObject","selfhref","setParameter","method","POST","validationData","childmodels","isValidationRequest","fetch","then","leading","trailing","validateFormObject"],"mappings":"AACA,OAAOA,QAAP,MAAqB,iBAArB;AAEA,SAASC,WAAT,QAA4B,uBAA5B;AAEA,OAAOC,gBAAP,MAA6B,kCAA7B;AAEA,SACEC,YADF,EAEEC,yBAFF,QAGO,2BAHP;AAKA,OAAOC,SAAP,MAAsB,6BAAtB;;AAIA;AACA;AACA;AACA;AACA,IAAMC,iBAAiB,GACrB,SADIA,iBACJ,CAACC,IAAD,EAAOC,mBAAP;AAAA,SAA+B,UAACC,QAAD,EAAWC,QAAX,EAAwB;AACrD,QAAMC,WAAW,GAAGD,QAAQ,GAAGE,SAAX,CAAqBL,IAAI,CAACM,UAA1B,CAApB;;AAEA,QAAIF,WAAJ,EAAiB;AACf,UAAMG,aAAa,GAAGH,WAAW,CAACI,KAAZ,CAAkBC,KAAlB,CAAwB,IAAxB,CAAtB;;AACA,UAAIF,aAAa,YAAYT,SAA7B,EAAwC;AACtCS,QAAAA,aAAa,CAACR,iBAAd,CAAgCE,mBAAmB,CAACS,IAApD;AACD;;AAEDR,MAAAA,QAAQ,CAACR,WAAW,CAACa,aAAD,CAAZ,CAAR;AACD;AACF,GAXD;AAAA,CADF;AAcA;AACA;AACA;AACA;AACA;AACA;;;AACA,IAAMI,2BAA2B,GAAGlB,QAAQ,CAG1C,UAACS,QAAD,EAAWF,IAAX,EAA+B;AAC7B,MAAIL,gBAAJ,CAAqBK,IAAI,CAACY,QAAL,CAAcC,YAAd,CAA2B,QAA3B,EAAqC,OAArC,CAArB,EAAoE;AAClEC,IAAAA,MAAM,EAAElB,YAAY,CAACmB,IAD6C;AAElEL,IAAAA,IAAI,EAAEV,IAAI,CAACgB,cAFuD;AAGlEC,IAAAA,WAAW,EAAE,KAHqD;AAIlEC,IAAAA,mBAAmB,EAAE;AAJ6C,GAApE,EAMGC,KANH,GAOGC,IAPH,CAOQ,UAACnB,mBAAD;AAAA,WACJC,QAAQ,CAACH,iBAAiB,CAACC,IAAD,EAAOC,mBAAP,CAAlB,CADJ;AAAA,GAPR;AAUD,CAdyC,EAe1CJ,yBAf0C,EAgB1C;AACEwB,EAAAA,OAAO,EAAE,IADX;AAEEC,EAAAA,QAAQ,EAAE;AAFZ,CAhB0C,CAA5C;AAsBA;AACA;;AACA,OAAO,IAAMC,kBAAkB,GAC7B,SADWA,kBACX,CAACvB,IAAD;AAAA,SACA,UAACE,QAAD;AAAA,WACES,2BAA2B,CAACT,QAAD,EAAWF,IAAX,CAD7B;AAAA,GADA;AAAA,CADK","sourcesContent":["// @flow\nimport debounce from \"lodash/debounce\";\n\nimport { updateModel } from \"../_modularui/actions\";\n\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\n\nimport {\n HTTP_METHODS,\n VALIDATE_DEBOUNCE_TIMEOUT,\n} from \"../../constants/Constants\";\n\nimport FormModel from \"../../models/form/FormModel\";\n\nimport type { Dispatch, ThunkAction } from \"../types\";\n\n/**\n * Update validations of the form currently in the reducer\n * because of the debounce timeout there might have been an update on the form during validation\n */\nconst updateValidations =\n (form, formWithValidations) => (dispatch, getState) => {\n const currentForm = getState().modularui[form.connectKey];\n\n if (currentForm) {\n const validatedForm = currentForm.model.clone(true);\n if (validatedForm instanceof FormModel) {\n validatedForm.updateValidations(formWithValidations.data);\n }\n\n dispatch(updateModel(validatedForm));\n }\n };\n\n/**\n * Validates form objects debounced to prevent overloading the (form) service\n * When a form with new errors (or complete) arrives, we send the validations\n * to the current form model where the errors are processed\n * A new form with the new constraints is send to the store\n */\nconst debouncedValidateFormObject = debounce<\n (dispatch: Dispatch, form: FormModel) => void\n>(\n (dispatch, form: FormModel) => {\n new ModularUIRequest(form.selfhref.setParameter(\"commit\", \"false\"), {\n method: HTTP_METHODS.POST,\n data: form.validationData,\n childmodels: false,\n isValidationRequest: true,\n })\n .fetch()\n .then((formWithValidations) =>\n dispatch(updateValidations(form, formWithValidations))\n );\n },\n VALIDATE_DEBOUNCE_TIMEOUT,\n {\n leading: true,\n trailing: true,\n }\n);\n\n/**\n */\nexport const validateFormObject =\n (form: FormModel): ThunkAction =>\n (dispatch) =>\n debouncedValidateFormObject(dispatch, form);\n"],"file":"FormValidations.js"}
1
+ {"version":3,"sources":["../../../src/redux/actions/FormValidations.js"],"names":["debounce","updateModel","ModularUIRequest","HTTP_METHODS","VALIDATE_DEBOUNCE_TIMEOUT","FormModel","updateValidations","form","formWithValidations","dispatch","getState","currentForm","modularui","connectKey","validatedForm","model","clone","data","debouncedValidateFormObject","selfhref","setParameter","method","POST","validationData","childmodels","isValidationRequest","locale","fetch","then","leading","trailing","validateFormObject"],"mappings":"AACA,OAAOA,QAAP,MAAqB,iBAArB;AAEA,SAASC,WAAT,QAA4B,uBAA5B;AAEA,OAAOC,gBAAP,MAA6B,kCAA7B;AAEA,SACEC,YADF,EAEEC,yBAFF,QAGO,2BAHP;AAKA,OAAOC,SAAP,MAAsB,6BAAtB;;AAIA;AACA;AACA;AACA;AACA,IAAMC,iBAAiB,GACrB,SADIA,iBACJ,CAACC,IAAD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D;AAAA,WACES,2BAA2B,CAACT,QAAD,EAAWF,IAAX,CAD7B;AAAA,GADA;AAAA,CADK","sourcesContent":["// @flow\nimport debounce from \"lodash/debounce\";\n\nimport { updateModel } from \"../_modularui/actions\";\n\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\n\nimport {\n HTTP_METHODS,\n VALIDATE_DEBOUNCE_TIMEOUT,\n} from \"../../constants/Constants\";\n\nimport FormModel from \"../../models/form/FormModel\";\n\nimport type { Dispatch, ThunkAction } from \"../types\";\n\n/**\n * Update validations of the form currently in the reducer\n * because of the debounce timeout there might have been an update on the form during validation\n */\nconst updateValidations =\n (form, formWithValidations) => (dispatch, getState) => {\n const currentForm = getState().modularui[form.connectKey];\n\n if (currentForm) {\n const validatedForm = currentForm.model.clone(true);\n if (validatedForm instanceof FormModel) {\n validatedForm.updateValidations(formWithValidations.data);\n }\n\n dispatch(updateModel(validatedForm));\n }\n };\n\n/**\n * Validates form objects debounced to prevent overloading the (form) service\n * When a form with new errors (or complete) arrives, we send the validations\n * to the current form model where the errors are processed\n * A new form with the new constraints is send to the store\n */\nconst debouncedValidateFormObject = debounce<\n (dispatch: Dispatch, form: FormModel) => void\n>(\n (dispatch, form: FormModel) => {\n new ModularUIRequest(form.selfhref.setParameter(\"commit\", \"false\"), {\n method: HTTP_METHODS.POST,\n data: form.validationData,\n childmodels: false,\n isValidationRequest: true,\n locale: form.locale,\n })\n .fetch()\n .then((formWithValidations) =>\n dispatch(updateValidations(form, formWithValidations))\n );\n },\n VALIDATE_DEBOUNCE_TIMEOUT,\n {\n leading: true,\n trailing: true,\n }\n);\n\n/**\n */\nexport const validateFormObject =\n (form: FormModel): ThunkAction =>\n (dispatch) =>\n debouncedValidateFormObject(dispatch, form);\n"],"file":"FormValidations.js"}
@@ -23,18 +23,23 @@ import FormModel from "../models/form/FormModel";
23
23
  import type { FormObjectModel } from "../models";
24
24
  import type { AttributeType } from "../models";
25
25
  import type { UpdateFormOptions } from "../redux/types";
26
+ import type {
27
+ RemoveModelByKeyAction,
28
+ UpdateModelAction,
29
+ } from "../redux/_modularui";
30
+
26
31
  type FormNavigationHook = {
27
- previous: (form: FormModel) => void,
32
+ previous: (form: FormModel) => UpdateModelAction,
28
33
  cancel: (form: FormModel) => void,
29
34
  submit: (form: FormModel) => void,
30
35
  showFormNotification: (form: FormModel) => void,
31
- remove: (form: FormModel) => void,
36
+ remove: (form: FormModel) => RemoveModelByKeyAction,
32
37
  };
33
38
 
34
39
  type AttributeSetHook = {
35
- save: () => void,
36
- cancel: (object: FormObjectModel) => void,
37
- remove: (object: FormObjectModel) => void,
40
+ save: () => UpdateModelAction,
41
+ cancel: (object: FormObjectModel) => UpdateModelAction,
42
+ remove: (object: FormObjectModel) => UpdateModelAction,
38
43
  };
39
44
 
40
45
  type AttributeUpdateHook = (
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useForm.js"],"names":["useForm","href","formHref","Href","addParameter","form","method","HTTP_METHODS","POST","targetModel","FormModel","removeOnUnmount","model","useFormNavigation","dispatch","previous","cancel","submit","connectKey","selfhref","data","formdata","updateModel","remove","showFormNotificationAction","showFormNotification","useAttributeUpdate","object","attribute","value","options","useAttributeSet","save"],"mappings":";;;;;;;;;AACA;;AAEA;;AAEA;;AAEA;;AACA;;AAEA;;AAUA;;AAyBA;AACA;AACA;AACO,IAAMA,OAAO,GAAG,SAAVA,OAAU,CAACC,IAAD,EAAqC;AAC1D,MAAMC,QAAQ,GAAG,IAAIC,aAAJ,CAASF,IAAT,CAAjB;;AAEA,MAAI,CAAC,2BAAW,oBAAX,CAAL,EAAuC;AACrCC,IAAAA,QAAQ,CAACE,YAAT,CAAsB,QAAtB,EAAgC,OAAhC;AACD;;AAED,MAAMC,IAAI,GAAG,gCAAa,MAAb,EAAqBH,QAArB,EAA+B;AAC1CI,IAAAA,MAAM,EAAEC,wBAAaC,IADqB;AAE1CC,IAAAA,WAAW,EAAEC,kBAF6B;AAG1CC,IAAAA,eAAe,EAAE;AAHyB,G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ED;AALjB,GAAP;AAOD,CA9BM;AAgCP;AACA;AACA;;;;;AACO,IAAME,kBAAkB,GAAG,SAArBA,kBAAqB,CAChCrB,IADgC,EAEhCsB,MAFgC,EAGR;AACxB,MAAMb,QAAQ,GAAG,8BAAjB;AAEA,SAAO,UACLc,SADK,EAELC,KAFK,EAGLC,OAHK;AAAA,WAIFhB,QAAQ,CAAC,kCAAoBT,IAApB,EAA0BsB,MAA1B,EAAkCC,SAAlC,EAA6CC,KAA7C,EAAoDC,OAApD,CAAD,CAJN;AAAA,GAAP;AAKD,CAXM;AAaP;AACA;AACA;;;;;AACO,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAAC1B,IAAD,EAAuC;AACpE,MAAMS,QAAQ,GAAG,8BAAjB;AAEA,SAAO;AACLkB,IAAAA,IAAI,EAAE;AAAA,aAAMlB,QAAQ,CAAC,wCAA0BT,IAA1B,CAAD,CAAd;AAAA,KADD;AAELW,IAAAA,MAAM,EAAE,gBAACW,MAAD;AAAA,aACNb,QAAQ,CAAC,2CAA6BT,IAA7B,EAAmCsB,MAAnC,CAAD,CADF;AAAA,KAFH;AAILJ,IAAAA,MAAM,EAAE,gBAACI,MAAD;AAAA,aACNb,QAAQ,CAAC,2CAA6BT,IAA7B,EAAmCsB,MAAnC,CAAD,CADF;AAAA;AAJH,GAAP;AAOD,CAVM","sourcesContent":["// @flow\nimport { useDispatch } from \"react-redux\";\n\nimport Href from \"../models/href/Href\";\n\nimport { getSetting, HTTP_METHODS } from \"../constants\";\n\nimport { loadModularUI, removeModelByKey } from \"../redux/_modularui\";\nimport { useModularUI } from \"./useModularUI\";\n\nimport {\n addRepeatableAttributeSet,\n cancelForm,\n cancelRepeatableAttributeSet,\n previousObject,\n removeRepeatableAttributeSet,\n showFormNotification,\n updateFormAttribute,\n} from \"../redux/actions\";\n\nimport FormModel from \"../models/form/FormModel\";\n\nimport type { FormObjectModel } from \"../models\";\nimport type { AttributeType } from \"../models\";\nimport type { UpdateFormOptions } from \"../redux/types\";\ntype FormNavigationHook = {\n previous: (form: FormModel) => void,\n cancel: (form: FormModel) => void,\n submit: (form: FormModel) => void,\n showFormNotification: (form: FormModel) => void,\n remove: (form: FormModel) => void,\n};\n\ntype AttributeSetHook = {\n save: () => void,\n cancel: (object: FormObjectModel) => void,\n remove: (object: FormObjectModel) => void,\n};\n\ntype AttributeUpdateHook = (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions\n) => void;\n\n/**\n * Load a form by href\n */\nexport const useForm = (href: string | Href): ?FormModel => {\n const formHref = new Href(href);\n\n if (!getSetting(\"ALWAYS_COMMIT_FORM\")) {\n formHref.addParameter(\"commit\", \"false\");\n }\n\n const form = useModularUI(\"form\", formHref, {\n method: HTTP_METHODS.POST,\n targetModel: FormModel,\n removeOnUnmount: true,\n });\n\n if (form?.model) {\n return form.model;\n }\n};\n\n/**\n * Form navigation methods\n */\nexport const useFormNavigation = (): FormNavigationHook => {\n const dispatch = useDispatch();\n\n const previous = (form: FormModel) => dispatch(previousObject(form));\n\n const cancel = (form: FormModel) => dispatch(cancelForm(form));\n\n const submit = (form: FormModel) =>\n dispatch(\n loadModularUI(form.connectKey, form.selfhref, {\n method: HTTP_METHODS.POST,\n data: form.formdata,\n updateModel: form,\n targetModel: FormModel,\n })\n );\n\n const remove = (form: FormModel) =>\n dispatch(removeModelByKey(form.connectKey));\n\n const showFormNotificationAction = (form: FormModel) =>\n dispatch(showFormNotification(form));\n\n return {\n previous,\n cancel,\n submit,\n remove,\n showFormNotification: showFormNotificationAction,\n };\n};\n\n/**\n * Update attributes of a form\n */\nexport const useAttributeUpdate = (\n form: FormModel,\n object: FormObjectModel\n): AttributeUpdateHook => {\n const dispatch = useDispatch();\n\n return (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions\n ) => dispatch(updateFormAttribute(form, object, attribute, value, options));\n};\n\n/**\n * Attributeset actions\n */\nexport const useAttributeSet = (form: FormModel): AttributeSetHook => {\n const dispatch = useDispatch();\n\n return {\n save: () => dispatch(addRepeatableAttributeSet(form)),\n cancel: (object: FormObjectModel) =>\n dispatch(cancelRepeatableAttributeSet(form, object)),\n remove: (object: FormObjectModel) =>\n dispatch(removeRepeatableAttributeSet(form, object)),\n };\n};\n"],"file":"useForm.js"}
1
+ {"version":3,"sources":["../../src/hooks/useForm.js"],"names":["useForm","href","formHref","Href","addParameter","form","method","HTTP_METHODS","POST","targetModel","FormModel","removeOnUnmount","model","useFormNavigation","dispatch","previous","cancel","submit","connectKey","selfhref","data","formdata","updateModel","remove","showFormNotificationAction","showFormNotification","useAttributeUpdate","object","attribute","value","options","useAttributeSet","save"],"mappings":";;;;;;;;;AACA;;AAEA;;AAEA;;AAEA;;AACA;;AAEA;;AAUA;;AA8BA;AACA;AACA;AACO,IAAMA,OAAO,GAAG,SAAVA,OAAU,CAACC,IAAD,EAAqC;AAC1D,MAAMC,QAAQ,GAAG,IAAIC,aAAJ,CAASF,IAAT,CAAjB;;AAEA,MAAI,CAAC,2BAAW,oBAAX,CAAL,EAAuC;AACrCC,IAAAA,QAAQ,CAACE,YAAT,CAAsB,QAAtB,EAAgC,OAAhC;AACD;;AAED,MAAMC,IAAI,GAAG,gCAAa,MAAb,EAAqBH,QAArB,EAA+B;AAC1CI,IAAAA,MAAM,EAAEC,wBAAaC,IADqB;AAE1CC,IAAAA,WAAW,EAAEC,kBAF6B;AAG1CC,IAAAA,eAAe,EAAE;AAHyB,GAA/B,CAAb;;AAMA,MAAIN,IAAJ,aAAIA,IAAJ,eAAIA,IAAI,CAAEO,KAAV,EAAiB;AACf,WAAOP,IAAI,CAACO,KAAZ;AACD;AACF,CAhBM;AAkBP;AACA;AACA;;;;;AACO,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,GAA0B;AACzD,MAAMC,QAAQ,GAAG,8BAAjB;;AAEA,MAAMC,QAAQ,GAAG,SAAXA,QAAW,CAACV,IAAD;AAAA,WAAqBS,QAAQ,CAAC,6BAAeT,IAAf,CAAD,CAA7B;AAAA,GAAjB;;AA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A;AACA;;;;;AACO,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAAC1B,IAAD,EAAuC;AACpE,MAAMS,QAAQ,GAAG,8BAAjB;AAEA,SAAO;AACLkB,IAAAA,IAAI,EAAE;AAAA,aAAMlB,QAAQ,CAAC,wCAA0BT,IAA1B,CAAD,CAAd;AAAA,KADD;AAELW,IAAAA,MAAM,EAAE,gBAACW,MAAD;AAAA,aACNb,QAAQ,CAAC,2CAA6BT,IAA7B,EAAmCsB,MAAnC,CAAD,CADF;AAAA,KAFH;AAILJ,IAAAA,MAAM,EAAE,gBAACI,MAAD;AAAA,aACNb,QAAQ,CAAC,2CAA6BT,IAA7B,EAAmCsB,MAAnC,CAAD,CADF;AAAA;AAJH,GAAP;AAOD,CAVM","sourcesContent":["// @flow\nimport { useDispatch } from \"react-redux\";\n\nimport Href from \"../models/href/Href\";\n\nimport { getSetting, HTTP_METHODS } from \"../constants\";\n\nimport { loadModularUI, removeModelByKey } from \"../redux/_modularui\";\nimport { useModularUI } from \"./useModularUI\";\n\nimport {\n addRepeatableAttributeSet,\n cancelForm,\n cancelRepeatableAttributeSet,\n previousObject,\n removeRepeatableAttributeSet,\n showFormNotification,\n updateFormAttribute,\n} from \"../redux/actions\";\n\nimport FormModel from \"../models/form/FormModel\";\n\nimport type { FormObjectModel } from \"../models\";\nimport type { AttributeType } from \"../models\";\nimport type { UpdateFormOptions } from \"../redux/types\";\nimport type {\n RemoveModelByKeyAction,\n UpdateModelAction,\n} from \"../redux/_modularui\";\n\ntype FormNavigationHook = {\n previous: (form: FormModel) => UpdateModelAction,\n cancel: (form: FormModel) => void,\n submit: (form: FormModel) => void,\n showFormNotification: (form: FormModel) => void,\n remove: (form: FormModel) => RemoveModelByKeyAction,\n};\n\ntype AttributeSetHook = {\n save: () => UpdateModelAction,\n cancel: (object: FormObjectModel) => UpdateModelAction,\n remove: (object: FormObjectModel) => UpdateModelAction,\n};\n\ntype AttributeUpdateHook = (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions\n) => void;\n\n/**\n * Load a form by href\n */\nexport const useForm = (href: string | Href): ?FormModel => {\n const formHref = new Href(href);\n\n if (!getSetting(\"ALWAYS_COMMIT_FORM\")) {\n formHref.addParameter(\"commit\", \"false\");\n }\n\n const form = useModularUI(\"form\", formHref, {\n method: HTTP_METHODS.POST,\n targetModel: FormModel,\n removeOnUnmount: true,\n });\n\n if (form?.model) {\n return form.model;\n }\n};\n\n/**\n * Form navigation methods\n */\nexport const useFormNavigation = (): FormNavigationHook => {\n const dispatch = useDispatch();\n\n const previous = (form: FormModel) => dispatch(previousObject(form));\n\n const cancel = (form: FormModel) => dispatch(cancelForm(form));\n\n const submit = (form: FormModel) =>\n dispatch(\n loadModularUI(form.connectKey, form.selfhref, {\n method: HTTP_METHODS.POST,\n data: form.formdata,\n updateModel: form,\n targetModel: FormModel,\n })\n );\n\n const remove = (form: FormModel) =>\n dispatch(removeModelByKey(form.connectKey));\n\n const showFormNotificationAction = (form: FormModel) =>\n dispatch(showFormNotification(form));\n\n return {\n previous,\n cancel,\n submit,\n remove,\n showFormNotification: showFormNotificationAction,\n };\n};\n\n/**\n * Update attributes of a form\n */\nexport const useAttributeUpdate = (\n form: FormModel,\n object: FormObjectModel\n): AttributeUpdateHook => {\n const dispatch = useDispatch();\n\n return (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions\n ) => dispatch(updateFormAttribute(form, object, attribute, value, options));\n};\n\n/**\n * Attributeset actions\n */\nexport const useAttributeSet = (form: FormModel): AttributeSetHook => {\n const dispatch = useDispatch();\n\n return {\n save: () => dispatch(addRepeatableAttributeSet(form)),\n cancel: (object: FormObjectModel) =>\n dispatch(cancelRepeatableAttributeSet(form, object)),\n remove: (object: FormObjectModel) =>\n dispatch(removeRepeatableAttributeSet(form, object)),\n };\n};\n"],"file":"useForm.js"}
@@ -2,10 +2,13 @@
2
2
  import { useSelector, useDispatch } from "react-redux";
3
3
  import { dismissNotification } from "../redux/actions";
4
4
 
5
- import type { NotificationState } from "../redux/types";
5
+ import type {
6
+ DismissNotificationAction,
7
+ NotificationState,
8
+ } from "../redux/types";
6
9
  type NotificationHook = {
7
10
  ...NotificationState,
8
- dismiss: () => void,
11
+ dismiss: () => DismissNotificationAction,
9
12
  };
10
13
 
11
14
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useNotification.js"],"names":["useNotification","dispatch","state","notification","render","messageType","message","error","dismiss"],"mappings":";;;;;;;AACA;;AACA;;AAQA;AACA;AACO,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,GAAwB;AACrD,MAAMC,QAAQ,GAAG,8BAAjB;;AACA,qBAAgD,6BAC9C,UAACC,KAAD;AAAA,WAAWA,KAAK,CAACC,YAAjB;AAAA,GAD8C,CAAhD;AAAA,MAAQC,MAAR,gBAAQA,MAAR;AAAA,MAAgBC,WAAhB,gBAAgBA,WAAhB;AAAA,MAA6BC,OAA7B,gBAA6BA,OAA7B;AAAA,MAAsCC,KAAtC,gBAAsCA,KAAtC;;AAIA,SAAO;AACLH,IAAAA,MAAM,EAANA,MADK;AAELC,IAAAA,WAAW,EAAXA,WAFK;AAGLC,IAAAA,OAAO,EAAPA,OAHK;AAILC,IAAAA,KAAK,EAALA,KAJK;AAKLC,IAAAA,OAAO,EAAE;AAAA,aAAMP,QAAQ,CAAC,mCAAD,CAAd;AAAA;AALJ,GAAP;AAOD,CAbM","sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\nimport { dismissNotification } from \"../redux/actions\";\n\nimport type { NotificationState } from \"../redux/types\";\ntype NotificationHook = {\n ...NotificationState,\n dismiss: () => void,\n};\n\n/**\n */\nexport const useNotification = (): NotificationHook => {\n const dispatch = useDispatch();\n const { render, messageType, message, error } = useSelector(\n (state) => state.notification\n );\n\n return {\n render,\n messageType,\n message,\n error,\n dismiss: () => dispatch(dismissNotification()),\n };\n};\n"],"file":"useNotification.js"}
1
+ {"version":3,"sources":["../../src/hooks/useNotification.js"],"names":["useNotification","dispatch","state","notification","render","messageType","message","error","dismiss"],"mappings":";;;;;;;AACA;;AACA;;AAWA;AACA;AACO,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,GAAwB;AACrD,MAAMC,QAAQ,GAAG,8BAAjB;;AACA,qBAAgD,6BAC9C,UAACC,KAAD;AAAA,WAAWA,KAAK,CAACC,YAAjB;AAAA,GAD8C,CAAhD;AAAA,MAAQC,MAAR,gBAAQA,MAAR;AAAA,MAAgBC,WAAhB,gBAAgBA,WAAhB;AAAA,MAA6BC,OAA7B,gBAA6BA,OAA7B;AAAA,MAAsCC,KAAtC,gBAAsCA,KAAtC;;AAIA,SAAO;AACLH,IAAAA,MAAM,EAANA,MADK;AAELC,IAAAA,WAAW,EAAXA,WAFK;AAGLC,IAAAA,OAAO,EAAPA,OAHK;AAILC,IAAAA,KAAK,EAALA,KAJK;AAKLC,IAAAA,OAAO,EAAE;AAAA,aAAMP,QAAQ,CAAC,mCAAD,CAAd;AAAA;AALJ,GAAP;AAOD,CAbM","sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\nimport { dismissNotification } from \"../redux/actions\";\n\nimport type {\n DismissNotificationAction,\n NotificationState,\n} from \"../redux/types\";\ntype NotificationHook = {\n ...NotificationState,\n dismiss: () => DismissNotificationAction,\n};\n\n/**\n */\nexport const useNotification = (): NotificationHook => {\n const dispatch = useDispatch();\n const { render, messageType, message, error } = useSelector(\n (state) => state.notification\n );\n\n return {\n render,\n messageType,\n message,\n error,\n dismiss: () => dispatch(dismissNotification()),\n };\n};\n"],"file":"useNotification.js"}
@@ -3,17 +3,24 @@ import { useDispatch, useSelector } from "react-redux";
3
3
  import type { Location, LocationShape } from "react-router";
4
4
 
5
5
  import { push, replace, go, goBack, goForward } from "../redux/_router/actions";
6
+ import type {
7
+ GoAction,
8
+ GoBackAction,
9
+ GoForwardAction,
10
+ PushAction,
11
+ ReplaceAction,
12
+ } from "../redux";
6
13
 
7
14
  type UseLocationHook = () => Location;
8
15
  type UseLocationKeyHook = () => string;
9
16
  type UseQuerystringHook = () => string;
10
17
  type UsePathnameHook = () => string;
11
18
  type UseNavigationHook = () => {
12
- push: (location: LocationShape | string, state?: { ... }) => void,
13
- replace: (location: LocationShape | string, state?: { ... }) => void,
14
- go: (delta: number) => void,
15
- goBack: () => void,
16
- goForward: () => void,
19
+ push: (location: LocationShape | string, state?: { ... }) => PushAction,
20
+ replace: (location: LocationShape | string, state?: { ... }) => ReplaceAction,
21
+ go: (delta: number) => GoAction,
22
+ goBack: () => GoBackAction,
23
+ goForward: () => GoForwardAction,
17
24
  };
18
25
 
19
26
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hooks/useRouter.js"],"names":["useLocation","state","router","location","useLocationKey","key","useQuerystring","search","usePathname","pathname","useNavigation","dispatch","push","replace","go","delta","goBack","goForward"],"mappings":";;;;;;;AACA;;AAGA;;AAcA;AACA;AACO,IAAMA,WAA4B,GAAG,SAA/BA,WAA+B;AAAA,SAC1C,6BAAY,UAACC,KAAD;AAAA,WAAWA,KAAK,CAACC,MAAN,CAAaC,QAAxB;AAAA,GAAZ,CAD0C;AAAA,CAArC;AAGP;AACA;;;;;AACO,IAAMC,cAAkC,GAAG,SAArCA,cAAqC;AAAA;;AAAA,6CAChDJ,WAAW,EADqC,iDAChD,aAAeK,GADiC,+DAC1B,EAD0B;AAAA,CAA3C;AAGP;AACA;;;;;AACO,IAAMC,cAAkC,GAAG,SAArCA,cAAqC;AAAA;;AAAA,0BAAMN,WAAW,EAAjB,kDAAM,cAAeO,MAArB;AAAA,CAA3C;AAEP;AACA;;;;;AACO,IAAMC,WAA4B,GAAG,SAA/BA,WAA+B;AAAA;;AAAA,0BAAMR,WAAW,EAAjB,kDAAM,cAAeS,QAArB;AAAA,CAArC;AAEP;AACA;;;;;AACO,IAAMC,aAAgC,GAAG,SAAnCA,aAAmC,GAAM;AACpD,MAAMC,QAAQ,GAAG,8BAAjB;AAEA,SAAO;AACLC,IAAAA,IAAI,EAAE,cAACT,QAAD,EAAmCF,KAAnC;AAAA,aACJU,QAAQ,CAAC,mBAAKR,QAAL,EAAeF,KAAf,CAAD,CADJ;AAAA,KADD;AAGLY,IAAAA,OAAO,EAAE,iBAACV,QAAD,EAAmCF,KAAnC;AAAA,aACPU,QAAQ,CAAC,sBAAQR,QAAR,EAAkBF,KAAlB,CAAD,CADD;AAAA,KAHJ;AAKLa,IAAAA,EAAE,EAAE,YAACC,KAAD;AAAA,aAAmBJ,QAAQ,CAAC,iBAAGI,KAAH,CAAD,CAA3B;AAAA,KALC;AAMLC,IAAAA,MAAM,EAAE;AAAA,aAAML,QAAQ,CAAC,sBAAD,CAAd;AAAA,KANH;AAOLM,IAAAA,SAAS,EAAE;AAAA,aAAMN,QAAQ,CAAC,yBAAD,CAAd;AAAA;AAPN,GAAP;AASD,CAZM","sourcesContent":["// @flow\nimport { useDispatch, useSelector } from \"react-redux\";\nimport type { Location, LocationShape } from \"react-router\";\n\nimport { push, replace, go, goBack, goForward } from \"../redux/_router/actions\";\n\ntype UseLocationHook = () => Location;\ntype UseLocationKeyHook = () => string;\ntype UseQuerystringHook = () => string;\ntype UsePathnameHook = () => string;\ntype UseNavigationHook = () => {\n push: (location: LocationShape | string, state?: { ... }) => void,\n replace: (location: LocationShape | string, state?: { ... }) => void,\n go: (delta: number) => void,\n goBack: () => void,\n goForward: () => void,\n};\n\n/**\n */\nexport const useLocation: UseLocationHook = () =>\n useSelector((state) => state.router.location);\n\n/**\n */\nexport const useLocationKey: UseLocationKeyHook = () =>\n useLocation()?.key ?? \"\";\n\n/**\n */\nexport const useQuerystring: UseQuerystringHook = () => useLocation()?.search;\n\n/**\n */\nexport const usePathname: UsePathnameHook = () => useLocation()?.pathname;\n\n/**\n */\nexport const useNavigation: UseNavigationHook = () => {\n const dispatch = useDispatch();\n\n return {\n push: (location: LocationShape | string, state?: { ... }) =>\n dispatch(push(location, state)),\n replace: (location: LocationShape | string, state?: { ... }) =>\n dispatch(replace(location, state)),\n go: (delta: number) => dispatch(go(delta)),\n goBack: () => dispatch(goBack()),\n goForward: () => dispatch(goForward()),\n };\n};\n"],"file":"useRouter.js"}
1
+ {"version":3,"sources":["../../src/hooks/useRouter.js"],"names":["useLocation","state","router","location","useLocationKey","key","useQuerystring","search","usePathname","pathname","useNavigation","dispatch","push","replace","go","delta","goBack","goForward"],"mappings":";;;;;;;AACA;;AAGA;;AAqBA;AACA;AACO,IAAMA,WAA4B,GAAG,SAA/BA,WAA+B;AAAA,SAC1C,6BAAY,UAACC,KAAD;AAAA,WAAWA,KAAK,CAACC,MAAN,CAAaC,QAAxB;AAAA,GAAZ,CAD0C;AAAA,CAArC;AAGP;AACA;;;;;AACO,IAAMC,cAAkC,GAAG,SAArCA,cAAqC;AAAA;;AAAA,6CAChDJ,WAAW,EADqC,iDAChD,aAAeK,GADiC,+DAC1B,EAD0B;AAAA,CAA3C;AAGP;AACA;;;;;AACO,IAAMC,cAAkC,GAAG,SAArCA,cAAqC;AAAA;;AAAA,0BAAMN,WAAW,EAAjB,kDAAM,cAAeO,MAArB;AAAA,CAA3C;AAEP;AACA;;;;;AACO,IAAMC,WAA4B,GAAG,SAA/BA,WAA+B;AAAA;;AAAA,0BAAMR,WAAW,EAAjB,kDAAM,cAAeS,QAArB;AAAA,CAArC;AAEP;AACA;;;;;AACO,IAAMC,aAAgC,GAAG,SAAnCA,aAAmC,GAAM;AACpD,MAAMC,QAAQ,GAAG,8BAAjB;AAEA,SAAO;AACLC,IAAAA,IAAI,EAAE,cAACT,QAAD,EAAmCF,KAAnC;AAAA,aACJU,QAAQ,CAAC,mBAAKR,QAAL,EAAeF,KAAf,CAAD,CADJ;AAAA,KADD;AAGLY,IAAAA,OAAO,EAAE,iBAACV,QAAD,EAAmCF,KAAnC;AAAA,aACPU,QAAQ,CAAC,sBAAQR,QAAR,EAAkBF,KAAlB,CAAD,CADD;AAAA,KAHJ;AAKLa,IAAAA,EAAE,EAAE,YAACC,KAAD;AAAA,aAAmBJ,QAAQ,CAAC,iBAAGI,KAAH,CAAD,CAA3B;AAAA,KALC;AAMLC,IAAAA,MAAM,EAAE;AAAA,aAAML,QAAQ,CAAC,sBAAD,CAAd;AAAA,KANH;AAOLM,IAAAA,SAAS,EAAE;AAAA,aAAMN,QAAQ,CAAC,yBAAD,CAAd;AAAA;AAPN,GAAP;AASD,CAZM","sourcesContent":["// @flow\nimport { useDispatch, useSelector } from \"react-redux\";\nimport type { Location, LocationShape } from \"react-router\";\n\nimport { push, replace, go, goBack, goForward } from \"../redux/_router/actions\";\nimport type {\n GoAction,\n GoBackAction,\n GoForwardAction,\n PushAction,\n ReplaceAction,\n} from \"../redux\";\n\ntype UseLocationHook = () => Location;\ntype UseLocationKeyHook = () => string;\ntype UseQuerystringHook = () => string;\ntype UsePathnameHook = () => string;\ntype UseNavigationHook = () => {\n push: (location: LocationShape | string, state?: { ... }) => PushAction,\n replace: (location: LocationShape | string, state?: { ... }) => ReplaceAction,\n go: (delta: number) => GoAction,\n goBack: () => GoBackAction,\n goForward: () => GoForwardAction,\n};\n\n/**\n */\nexport const useLocation: UseLocationHook = () =>\n useSelector((state) => state.router.location);\n\n/**\n */\nexport const useLocationKey: UseLocationKeyHook = () =>\n useLocation()?.key ?? \"\";\n\n/**\n */\nexport const useQuerystring: UseQuerystringHook = () => useLocation()?.search;\n\n/**\n */\nexport const usePathname: UsePathnameHook = () => useLocation()?.pathname;\n\n/**\n */\nexport const useNavigation: UseNavigationHook = () => {\n const dispatch = useDispatch();\n\n return {\n push: (location: LocationShape | string, state?: { ... }) =>\n dispatch(push(location, state)),\n replace: (location: LocationShape | string, state?: { ... }) =>\n dispatch(replace(location, state)),\n go: (delta: number) => dispatch(go(delta)),\n goBack: () => dispatch(goBack()),\n goForward: () => dispatch(goForward()),\n };\n};\n"],"file":"useRouter.js"}
@@ -47,6 +47,10 @@ var _Settings = require("../../constants/Settings");
47
47
 
48
48
  var _SectionModel = _interopRequireDefault(require("../content/SectionModel"));
49
49
 
50
+ var _LayoutHintCollection = _interopRequireDefault(require("../layouthint/LayoutHintCollection"));
51
+
52
+ var _utils = require("../../utils");
53
+
50
54
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof _Symbol !== "undefined" && _getIteratorMethod(o) || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
51
55
 
52
56
  function _unsupportedIterableToArray(o, minLen) { var _context7; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = _sliceInstanceProperty(_context7 = Object.prototype.toString.call(o)).call(_context7, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return _Array$from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -78,13 +82,29 @@ var AttributeContent = /*#__PURE__*/function () {
78
82
  }, {
79
83
  key: "header",
80
84
  get: function get() {
81
- var _this$_content, _this$_content$header, _this$_content2, _this$_content2$heade, _this$_content2$heade2;
85
+ var _this$_content, _this$_content$header, _this$_content2, _this$_content2$heade;
82
86
 
87
+ var headerLabel = null;
88
+ var headerDescription = null;
83
89
  var label = (_this$_content = this._content) === null || _this$_content === void 0 ? void 0 : (_this$_content$header = _this$_content.header) === null || _this$_content$header === void 0 ? void 0 : _this$_content$header.label;
84
- var description = (_this$_content2 = this._content) === null || _this$_content2 === void 0 ? void 0 : (_this$_content2$heade = _this$_content2.header) === null || _this$_content2$heade === void 0 ? void 0 : (_this$_content2$heade2 = _this$_content2$heade.description) === null || _this$_content2$heade2 === void 0 ? void 0 : _this$_content2$heade2.message;
90
+
91
+ if (label) {
92
+ headerLabel = label;
93
+ }
94
+
95
+ var description = (_this$_content2 = this._content) === null || _this$_content2 === void 0 ? void 0 : (_this$_content2$heade = _this$_content2.header) === null || _this$_content2$heade === void 0 ? void 0 : _this$_content2$heade.description;
96
+
97
+ if (description) {
98
+ if ((0, _utils.isPlainObject)(description) && "message" in description) {
99
+ headerDescription = description.message;
100
+ } else if (typeof description === "string") {
101
+ headerDescription = description;
102
+ }
103
+ }
104
+
85
105
  return {
86
- label: label,
87
- description: description
106
+ label: headerLabel,
107
+ description: headerDescription
88
108
  };
89
109
  }
90
110
  /**
@@ -99,16 +119,31 @@ var AttributeContent = /*#__PURE__*/function () {
99
119
  var _this$_content$elemen;
100
120
 
101
121
  return (_this$_content$elemen = this._content.elements) === null || _this$_content$elemen === void 0 ? void 0 : (0, _map.default)(_this$_content$elemen).call(_this$_content$elemen, function (element) {
102
- if ("textFragmentElement" in element) {
122
+ if ("propertyElement" in element) {
103
123
  // $FlowIssue
104
- var _element$textFragment = element.textFragmentElement,
105
- label = _element$textFragment.label,
106
- id = _element$textFragment.id,
124
+ var _element$propertyElem = element.propertyElement,
125
+ label = _element$propertyElem.label,
126
+ layouthint = _element$propertyElem.layouthint,
127
+ properties = _element$propertyElem.properties;
128
+ return {
129
+ propertyElement: {
130
+ label: label,
131
+ layouthint: new _LayoutHintCollection.default(layouthint),
132
+ properties: properties
133
+ }
134
+ };
135
+ }
136
+
137
+ if ("textFragmentElement" in element) {
138
+ var _element$textFragment = // $FlowIssue
139
+ element.textFragmentElement,
140
+ _label = _element$textFragment.label,
141
+ _layouthint = _element$textFragment.layouthint,
107
142
  textfragments = _element$textFragment.textfragments;
108
143
  return {
109
144
  textFragmentElement: {
110
- id: id,
111
- label: label,
145
+ label: _label,
146
+ layouthint: new _LayoutHintCollection.default(_layouthint),
112
147
  textfragments: (0, _map.default)(textfragments).call(textfragments, function (textfragment) {
113
148
  return _objectSpread(_objectSpread({}, textfragment), {}, {
114
149
  text: (0, _text.retrieveText)(textfragment.text)
@@ -121,11 +156,13 @@ var AttributeContent = /*#__PURE__*/function () {
121
156
  if ("contentElement" in element) {
122
157
  // $FlowIssue
123
158
  var _element$contentEleme = element.contentElement,
124
- _label = _element$contentEleme.label,
159
+ _label2 = _element$contentEleme.label,
160
+ _layouthint2 = _element$contentEleme.layouthint,
125
161
  sections = _element$contentEleme.sections;
126
162
  return {
127
163
  contentElement: {
128
- label: _label,
164
+ label: _label2,
165
+ layouthint: new _LayoutHintCollection.default(_layouthint2),
129
166
  sections: (0, _map.default)(sections).call(sections, function (section) {
130
167
  return new _SectionModel.default(section, null);
131
168
  })
@@ -146,15 +183,9 @@ var AttributeContent = /*#__PURE__*/function () {
146
183
  }, {
147
184
  key: "label",
148
185
  get: function get() {
149
- return this.header.label;
150
- }
151
- /**
152
- */
186
+ var _this$_content4;
153
187
 
154
- }, {
155
- key: "description",
156
- get: function get() {
157
- return this.header.description;
188
+ return (_this$_content4 = this._content) === null || _this$_content4 === void 0 ? void 0 : _this$_content4.label;
158
189
  }
159
190
  /**
160
191
  */
@@ -10,6 +10,8 @@ import type {
10
10
  ContentAll,
11
11
  } from "../types";
12
12
  import type SubSectionModel from "../content/SubSectionModel";
13
+ import LayoutHintCollection from "../layouthint/LayoutHintCollection";
14
+ import { isPlainObject } from "../../utils";
13
15
 
14
16
  class AttributeContent {
15
17
  _content: ?ContentData;
@@ -30,10 +32,24 @@ class AttributeContent {
30
32
  label: ?string,
31
33
  description: ?string,
32
34
  } {
35
+ let headerLabel = null;
36
+ let headerDescription = null;
37
+
33
38
  const label = this._content?.header?.label;
34
- const description = this._content?.header?.description?.message;
39
+ if (label) {
40
+ headerLabel = label;
41
+ }
35
42
 
36
- return { label, description };
43
+ const description = this._content?.header?.description;
44
+ if (description) {
45
+ if (isPlainObject(description) && "message" in description) {
46
+ headerDescription = description.message;
47
+ } else if (typeof description === "string") {
48
+ headerDescription = description;
49
+ }
50
+ }
51
+
52
+ return { label: headerLabel, description: headerDescription };
37
53
  }
38
54
 
39
55
  /**
@@ -41,13 +57,27 @@ class AttributeContent {
41
57
  get elements(): ContentAll {
42
58
  if (this._content?.elements) {
43
59
  return this._content.elements?.map((element) => {
44
- if ("textFragmentElement" in element) {
60
+ if ("propertyElement" in element) {
45
61
  // $FlowIssue
46
- const { label, id, textfragments } = element.textFragmentElement;
62
+ const { label, layouthint, properties } = element.propertyElement;
63
+
64
+ return {
65
+ propertyElement: {
66
+ label,
67
+ layouthint: new LayoutHintCollection(layouthint),
68
+ properties,
69
+ },
70
+ };
71
+ }
72
+
73
+ if ("textFragmentElement" in element) {
74
+ const { label, layouthint, textfragments } =
75
+ // $FlowIssue
76
+ element.textFragmentElement;
47
77
  return {
48
78
  textFragmentElement: {
49
- id,
50
79
  label,
80
+ layouthint: new LayoutHintCollection(layouthint),
51
81
  textfragments: textfragments.map((textfragment) => ({
52
82
  ...textfragment,
53
83
  text: retrieveText(textfragment.text),
@@ -58,10 +88,11 @@ class AttributeContent {
58
88
 
59
89
  if ("contentElement" in element) {
60
90
  // $FlowIssue
61
- const { label, sections } = element.contentElement;
91
+ const { label, layouthint, sections } = element.contentElement;
62
92
  return {
63
93
  contentElement: {
64
94
  label,
95
+ layouthint: new LayoutHintCollection(layouthint),
65
96
  sections: sections.map(
66
97
  (section) => new SectionModel(section, null)
67
98
  ),
@@ -80,13 +111,7 @@ class AttributeContent {
80
111
  /**
81
112
  */
82
113
  get label(): ?string {
83
- return this.header.label;
84
- }
85
-
86
- /**
87
- */
88
- get description(): ?string {
89
- return this.header.description;
114
+ return this._content?.label;
90
115
  }
91
116
 
92
117
  /**