@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
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/modularui/ModularUIRequest.js"],"names":["ModularUIRequest","href","options","HTTP_METHODS","GET","IllegalArgumentException","_response","ModularUIResponse","Href","locale","parameters","targetModel","method","_contributionsHref","contributionsHref","_locale","_href","_method","_options","childmodels","_targetModel","Model","response","isApplicableModel","IllegalStateException","contributionsData","contributionsKey","error","handleContributionsError","key","contributions","errorMessage","properties","message","ModularUIError","path","toString","data","links","_links","Array","isArray","handleDataError","handleData","url","BASE","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","HIDE_WHEN_EMPTY","link","push","isHiddenList","all","hiddenLinks","newDataLinks","dataLinkKey","_embedded","actions","isHidden","catch","_progressEvent","progressEvent","model","prevData","JSON","parse","FormModel","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","ContentModel","childSectionLinks","length","fetchContentChildSections","contentModel","newContentModel","clone","childSectionLink","contentHrefWithEntryDate","selfhref","addParameter","TIMEVERSION_FILTER_NAME","entryDate","fetchContent","sectionModels","childSections"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AAMA;;AAEA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AAEA;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U,aAAhB,GAAgCD,aAAhC;AAEA,eAAOT,eAAP;AACD,OAjBM,CAAP;AAkBD;;;;;eAGYvI,gB","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":["ModularUIRequest","href","options","HTTP_METHODS","GET","IllegalArgumentException","_response","ModularUIResponse","Href","locale","parameters","targetModel","method","_contributionsHref","contributionsHref","_locale","_href","_method","_options","childmodels","_targetModel","Model","response","isApplicableModel","IllegalStateException","contributionsData","contributionsKey","error","handleContributionsError","key","contributions","errorMessage","properties","message","ModularUIError","path","toString","data","links","_links","Array","isArray","handleDataError","handleData","url","BASE","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","HIDE_WHEN_EMPTY","link","push","isHiddenList","all","hiddenLinks","newDataLinks","dataLinkKey","_embedded","actions","isHidden","catch","_progressEvent","progressEvent","model","prevData","JSON","parse","FormModel","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","ContentModel","childSectionLinks","length","fetchContentChildSections","contentModel","newContentModel","clone","childSectionLink","contentHrefWithEntryDate","selfhref","addParameter","TIMEVERSION_FILTER_NAME","entryDate","fetchContent","sectionModels","childSections"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AAMA;;AAEA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AAEA;;;;;;;;;;;;AAKA;AACA;AACA;AACA;IACMA,gB;AAYJ;AACF;AACE,4BAAYC,IAAZ,EAA2E;AAAA;;AAAA,QAA1CC,OAA0C,uEAAJ,EAAI;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mDANrCC,wBAAaC,GAMwB;AAAA;;AACzE,QAAI,CAACH,IAAL,EAAW;AACT,YAAM,IAAII,oCAAJ,CACJ,wDADI,CAAN;AAGD;;AAED,SAAKH,OAAL,GAAeA,OAAf;AAEA,SAAKI,SAAL,GAAiB,IAAIC,0BAAJ,EAAjB;AAEA,SAAKN,IAAL,GAAY,OAAOA,IAAP,KAAgB,QAAhB,GAA2B,IAAIO,aAAJ,CAASP,IAAT,CAA3B,GAA4CA,IAAxD;AACA,SAAKQ,MAAL,sBAAcP,OAAO,CAACO,MAAtB,6DAAgC,IAAhC,CAZyE,CAczE;AACA;;AACA,SAAKH,SAAL,CAAeI,UAAf,GAA4B,KAAKT,IAAL,CAAUS,UAAtC;;AAEA,QAAIR,OAAO,CAACS,WAAZ,EAAyB;AACvB,WAAKA,WAAL,GAAmBT,OAAO,CAACS,WAA3B;AACD;;AAED,QAAIT,OAAO,CAACU,MAAZ,EAAoB;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ACE,KAAb,EAAxB;AAEA,aAAO,iBAAQ3D,GAAR,CACL,8BAAAyD,YAAY,CAACH,iBAAb,kBAAmC,UAACM,gBAAD,EAAsB;AACvD,YAAMC,wBAAwB,GAAGD,gBAAgB,CAACE,QAAjB,CAA0BC,YAA1B,CAC/BC,kCAD+B,EAE/BP,YAAY,CAACQ,SAFkB,CAAjC;AAKA,YAAM1B,OAAO,GAAG,IAAIpH,gBAAJ,CAAqB0I,wBAArB,EAA+C;AAC7DjI,UAAAA,MAAM,EAAE,MAAI,CAACA;AADgD,SAA/C,CAAhB;AAIA,eAAO2G,OAAO,CAAC2B,YAAR,CAAqB,IAArB,CAAP;AACD,OAXD,CADK,EAaLhF,IAbK,CAaA,UAACiF,aAAD,EAAmB;AACxBT,QAAAA,eAAe,CAACU,aAAhB,GAAgCD,aAAhC;AAEA,eAAOT,eAAP;AACD,OAjBM,CAAP;AAkBD;;;;;eAGYvI,gB","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"}
@@ -40,7 +40,8 @@ var autosave = function autosave(dispatch, form) {
40
40
  new _ModularUIRequest.default(form.selfhref.setParameter("commit", "true"), {
41
41
  method: _Constants.HTTP_METHODS.POST,
42
42
  data: formdata,
43
- childmodels: false
43
+ childmodels: false,
44
+ locale: form.locale
44
45
  }).fetch().then(function (savedForm) {
45
46
  if (savedForm instanceof _FormModel.default) {
46
47
  // update last server update to indicate an update has happened
@@ -40,6 +40,7 @@ const autosave = (dispatch: Dispatch, form: FormModel) => {
40
40
  method: HTTP_METHODS.POST,
41
41
  data: formdata,
42
42
  childmodels: false,
43
+ locale: form.locale,
43
44
  })
44
45
  .fetch()
45
46
  .then((savedForm) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/redux/actions/FormAutosave.js"],"names":["updateAutosave","status","model","type","payload","autosave","dispatch","form","AUTOSAVE_STATUS","START","formdata","getFormData","ModularUIRequest","selfhref","setParameter","method","HTTP_METHODS","POST","data","childmodels","fetch","then","savedForm","FormModel","lastServerUpdate","FINISHED","debouncedAutosave","VALIDATE_DEBOUNCE_TIMEOUT","autosaveFormObject"],"mappings":";;;;;;;;;AACA;;AAEA;;AACA;;AAEA;;AAMA;;AAIA;AACA;AACA;AACA;AACA,IAAMA,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,CAACQ,2BAAgBC,KAAjB,EAAwBF,IAAxB,CAAf,CAAR;AAEA,MAAMG,QAAQ,GAAGH,IAAI,CAACI,WAAL,CAAiB,IAAjB,EAAuB,KAAvB,CAAjB;AAEA,MAAIC,yBAAJ,CAAqBL,IAAI,CAACM,QAAL,CAAcC,YAAd,CAA2B,QAA3B,EAAqC,MAArC,CAArB,EAAmE;AACjEC,IAAAA,MAAM,EAAEC,wBAAaC,IAD4C;AAEjEC,IAAAA,IAAI,EAAER,QAF2D;AAGjES,IAAAA,WAAW,EAAE;AAHoD,GAAnE,EAKGC,KALH,GAMGC,IANH,CAMQ,UAACC,SAAD,EAAe;AACnB,QAAIA,SAAS,YAAYC,kBAAzB,EAAoC;AAClC;AACA;AACAhB,MAAAA,IAAI,CAACiB,gBAAL,GAAwBF,SAAS,CAACE,gBAAlC;AAEAlB,MAAAA,QAAQ,CAAC,0BAAYC,IAAZ,CAAD,CAAR;AACAD,MAAAA,QAAQ,CAACN,cAAc,CAACQ,2BAAgBiB,QAAjB,EAA2BH,SAA3B,CAAf,CAAR;AACD;AACF,GAfH;AAgBD,CArBD;AAuBA;AACA;AACA;AACA;AACA;AACA;;;AACA,IAAMI,iBAAiB,GAAG,uBAAS,UAACpB,QAAD,EAAWC,IAAX,EAAoB;AACrDF,EAAAA,QAAQ,CAACC,QAAD,EAAWC,IAAX,CAAR;AACD,CAFyB,EAEvBoB,oCAFuB,CAA1B;AAIA;AACA;;AACO,IAAMC,kBAAkB,GAC7B,SADWA,kBACX,CAACrB,IAAD;AAAA,SACA,UAACD,QAAD;AAAA,WACEoB,iBAAiB,CAACpB,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":["updateAutosave","status","model","type","payload","autosave","dispatch","form","AUTOSAVE_STATUS","START","formdata","getFormData","ModularUIRequest","selfhref","setParameter","method","HTTP_METHODS","POST","data","childmodels","locale","fetch","then","savedForm","FormModel","lastServerUpdate","FINISHED","debouncedAutosave","VALIDATE_DEBOUNCE_TIMEOUT","autosaveFormObject"],"mappings":";;;;;;;;;AACA;;AAEA;;AACA;;AAEA;;AAMA;;AAIA;AACA;AACA;AACA;AACA,IAAMA,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;AA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import 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"}
@@ -49,7 +49,8 @@ var debouncedValidateFormObject = (0, _debounce.default)(function (dispatch, for
49
49
  method: _Constants.HTTP_METHODS.POST,
50
50
  data: form.validationData,
51
51
  childmodels: false,
52
- isValidationRequest: true
52
+ isValidationRequest: true,
53
+ locale: form.locale
53
54
  }).fetch().then(function (formWithValidations) {
54
55
  return dispatch(updateValidations(form, formWithValidations));
55
56
  });
@@ -47,6 +47,7 @@ const debouncedValidateFormObject = debounce<
47
47
  data: form.validationData,
48
48
  childmodels: false,
49
49
  isValidationRequest: true,
50
+ locale: form.locale,
50
51
  })
51
52
  .fetch()
52
53
  .then((formWithValidations) =>
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/redux/actions/FormValidations.js"],"names":["updateValidations","form","formWithValidations","dispatch","getState","currentForm","modularui","connectKey","validatedForm","model","clone","FormModel","data","debouncedValidateFormObject","ModularUIRequest","selfhref","setParameter","method","HTTP_METHODS","POST","validationData","childmodels","isValidationRequest","fetch","then","VALIDATE_DEBOUNCE_TIMEOUT","leading","trailing","validateFormObject"],"mappings":";;;;;;;;;AACA;;AAEA;;AAEA;;AAEA;;AAKA;;AAIA;AACA;AACA;AACA;AACA,IAAMA,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,YAAYG,kBAA7B,EAAwC;AACtCH,QAAAA,aAAa,CAACR,iBAAd,CAAgCE,mBAAmB,CAACU,IAApD;AACD;;AAEDT,MAAAA,QAAQ,CAAC,0BAAYK,aAAZ,CAAD,CAAR;AACD;AACF,GAXD;AAAA,CADF;AAcA;AACA;AACA;AACA;AACA;AACA;;;AACA,IAAMK,2BAA2B,GAAG,uBAGlC,UAACV,QAAD,EAAWF,IAAX,EAA+B;AAC7B,MAAIa,yBAAJ,CAAqBb,IAAI,CAACc,QAAL,CAAcC,YAAd,CAA2B,QAA3B,EAAqC,OAArC,CAArB,EAAoE;AAClEC,IAAAA,MAAM,EAAEC,wBAAaC,IAD6C;AAElEP,IAAAA,IAAI,EAAEX,IAAI,CAACmB,cAFuD;AAGlEC,IAAAA,WAAW,EAAE,KAHqD;AAIlEC,IAAAA,mBAAmB,EAAE;AAJ6C,GAApE,EAMGC,KANH,GAOGC,IAPH,CAOQ,UAACtB,mBAAD;AAAA,WACJC,QAAQ,CAACH,iBAAiB,CAACC,IAAD,EAAOC,mBAAP,CAAlB,CADJ;AAAA,GAPR;AAUD,CAdiC,EAelCuB,oCAfkC,EAgBlC;AACEC,EAAAA,OAAO,EAAE,IADX;AAEEC,EAAAA,QAAQ,EAAE;AAFZ,CAhBkC,CAApC;AAsBA;AACA;;AACO,IAAMC,kBAAkB,GAC7B,SADWA,kBACX,CAAC3B,IAAD;AAAA,SACA,UAACE,QAAD;AAAA,WACEU,2BAA2B,CAACV,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":["updateValidations","form","formWithValidations","dispatch","getState","currentForm","modularui","connectKey","validatedForm","model","clone","FormModel","data","debouncedValidateFormObject","ModularUIRequest","selfhref","setParameter","method","HTTP_METHODS","POST","validationData","childmodels","isValidationRequest","locale","fetch","then","VALIDATE_DEBOUNCE_TIMEOUT","leading","trailing","validateFormObject"],"mappings":";;;;;;;;;AACA;;AAEA;;AAEA;;AAEA;;AAKA;;AAIA;AACA;AACA;AACA;AACA,IAAMA,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,YAAYG,kBAA7B,EAAwC;AACtCH,QAAAA,aAAa,CAACR,iBAAd,CAAgCE,mBAAmB,CAACU,IAApD;AACD;;AAEDT,MAAAA,QAAQ,CAAC,0BAAYK,aAAZ,CAAD,CAAR;AACD;AACF,GAXD;AAAA,CADF;AAcA;AACA;AACA;AACA;AACA;AACA;;;AACA,IAAMK,2BAA2B,GAAG,uBAGlC,UAACV,QAAD,EAAWF,IAAX,EAA+B;AAC7B,MAAIa,yBAAJ,CAAqBb,IAAI,CAACc,QAAL,CAAcC,YAAd,CAA2B,QAA3B,EAAqC,OAArC,CAArB,EAAoE;AAClEC,IAAAA,MAAM,EAAEC,wBAAaC,IAD6C;AAElEP,IAAAA,IAAI,EAAEX,IAAI,CAACmB,cAFuD;AAGlEC,IAAAA,WAAW,EAAE,KAHqD;AAIlEC,IAAAA,mBAAmB,EAAE,IAJ6C;AAKlEC,IAAAA,MAAM,EAAEtB,IAAI,CAACsB;AALqD,GAApE,EAOGC,KAPH,GAQGC,IARH,CAQQ,UAACvB,mBAAD;AAAA,WACJC,QAAQ,CAACH,iBAAiB,CAACC,IAAD,EAAOC,mBAAP,CAAlB,CADJ;AAAA,GARR;AAWD,CAfiC,EAgBlCwB,oCAhBkC,EAiBlC;AACEC,EAAAA,OAAO,EAAE,IADX;AAEEC,EAAAA,QAAQ,EAAE;AAFZ,CAjBkC,CAApC;AAuBA;AACA;;AACO,IAAMC,kBAAkB,GAC7B,SADWA,kBACX,CAAC5B,IAAD;AAAA,SACA,UAACE,QAAD;AAAA,WACEU,2BAA2B,CAACV,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.9.0-beta.9",
3
+ "version": "1.9.3",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "http://support.beinformed.com",
@@ -28,7 +28,7 @@
28
28
  "prettier": "prettier --write \"./{src,.flow}/**/*.js\"",
29
29
  "flow": "flow",
30
30
  "flow:ci": "flow check",
31
- "flow-typed-install": "flow-typed install -l .flow/flow-typed/ --ignoreDeps peer",
31
+ "flow-typed-install": "flow-typed install -l .flow/flow-typed/ --ignoreDeps peer --overwrite",
32
32
  "test": "jest",
33
33
  "test:ci": "jest --ci",
34
34
  "test:changed": "jest --onlyChanged",
@@ -38,7 +38,7 @@
38
38
  "prepublishOnly": "npm run build",
39
39
  "docs": "node ./.build/docs.js",
40
40
  "prepare": "husky install",
41
- "security-audit": "npm audit --json | node ./.build/transform-audit.js > npm-audit.json"
41
+ "security-audit": "npm audit --production --json | node ./.build/transform-audit.js > npm-audit.json"
42
42
  },
43
43
  "repository": {
44
44
  "type": "git",
@@ -80,7 +80,7 @@
80
80
  "dependencies": {
81
81
  "@babel/runtime-corejs3": "^7.15.4",
82
82
  "big.js": "^6.1.1",
83
- "date-fns": "^2.23.0",
83
+ "date-fns": "^2.24.0",
84
84
  "deepmerge": "^4.2.2",
85
85
  "dequal": "^2.0.2",
86
86
  "element-closest": "^3.0.2",
@@ -94,19 +94,19 @@
94
94
  "setimmediate": "^1.0.5"
95
95
  },
96
96
  "devDependencies": {
97
- "@babel/cli": "^7.15.4",
97
+ "@babel/cli": "^7.15.7",
98
98
  "@babel/core": "^7.15.5",
99
- "@babel/eslint-parser": "^7.15.4",
99
+ "@babel/eslint-parser": "^7.15.7",
100
100
  "@babel/eslint-plugin": "^7.14.5",
101
101
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
102
102
  "@babel/plugin-transform-runtime": "^7.15.0",
103
- "@babel/preset-env": "^7.15.4",
103
+ "@babel/preset-env": "^7.15.6",
104
104
  "@babel/preset-flow": "^7.14.5",
105
105
  "@babel/preset-react": "^7.14.5",
106
106
  "@commitlint/cli": "^13.1.0",
107
107
  "@commitlint/config-conventional": "^13.1.0",
108
108
  "@testing-library/react-hooks": "^7.0.2",
109
- "babel-jest": "^27.1.1",
109
+ "babel-jest": "^27.2.2",
110
110
  "babel-plugin-styled-components": "^1.13.2",
111
111
  "cherry-pick": "^0.5.0",
112
112
  "cross-env": "^7.0.3",
@@ -114,25 +114,25 @@
114
114
  "eslint": "^7.32.0",
115
115
  "eslint-config-prettier": "^8.3.0",
116
116
  "eslint-plugin-babel": "^5.3.1",
117
- "eslint-plugin-flowtype": "^5.9.2",
117
+ "eslint-plugin-flowtype": "^6.1.0",
118
118
  "eslint-plugin-import": "^2.24.2",
119
- "eslint-plugin-jest": "^24.4.0",
119
+ "eslint-plugin-jest": "^24.4.2",
120
120
  "eslint-plugin-jsdoc": "^36.1.0",
121
- "eslint-plugin-react": "^7.25.1",
121
+ "eslint-plugin-react": "^7.26.0",
122
122
  "eslint-plugin-react-hooks": "^4.2.0",
123
123
  "flow-bin": "0.152.0",
124
124
  "flow-copy-source": "^2.0.9",
125
125
  "flow-typed": "^3.3.1",
126
- "glob": "^7.1.7",
126
+ "glob": "^7.2.0",
127
127
  "history": "^4.0.0",
128
128
  "husky": "^7.0.2",
129
- "jest": "^27.1.1",
130
- "jest-junit": "^12.2.0",
129
+ "jest": "^27.2.2",
130
+ "jest-junit": "^12.3.0",
131
131
  "jest-sonar-reporter": "^2.0.0",
132
132
  "jscodeshift": "^0.13.0",
133
133
  "lint-staged": "^11.1.2",
134
134
  "polished": "^4.1.3",
135
- "prettier": "^2.3.2",
135
+ "prettier": "^2.4.1",
136
136
  "react": "^17.0.2",
137
137
  "react-dom": "^17.0.2",
138
138
  "react-helmet-async": "^1.1.2",
@@ -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 = (
@@ -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
  /**
@@ -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
  /**
@@ -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
  /**
@@ -267,9 +267,10 @@ class AttributeDataHelper {
267
267
  const pickedContent = pick(this._attribute.content, [
268
268
  "header",
269
269
  "label",
270
- "description",
271
270
  "elements",
271
+ "layouthint",
272
272
  ]);
273
+
273
274
  if (Object.keys(pickedContent).length > 0) {
274
275
  return pickedContent;
275
276
  }
@@ -28,7 +28,7 @@ export default class HelptextAttributeModel extends LabelAttributeModel {
28
28
  get text(): string | null {
29
29
  const dataText = this.getData("value");
30
30
  if (dataText) {
31
- return dataText.message;
31
+ return dataText.message ?? dataText;
32
32
  }
33
33
 
34
34
  const contributionText = this.getContribution("text");
@@ -3,11 +3,12 @@ import SectionModel from "../../content/SectionModel";
3
3
 
4
4
  const json = {
5
5
  header: {
6
- label: "Blaastest geslaagd",
6
+ label: "Header label",
7
7
  description: {
8
8
  message: "Dit is de beschrijving",
9
9
  },
10
10
  },
11
+ label: "Blaastest geslaagd",
11
12
  elements: [
12
13
  {
13
14
  propertyElement: {
@@ -152,7 +153,8 @@ describe("AttributeContent", () => {
152
153
  it("Handles basic content elements", () => {
153
154
  const content = new AttributeContent(json);
154
155
  expect(content.label).toBe("Blaastest geslaagd");
155
- expect(content.description).toBe("Dit is de beschrijving");
156
+ expect(content.header.label).toBe("Header label");
157
+ expect(content.header.description).toBe("Dit is de beschrijving");
156
158
  expect(content.properties).toHaveLength(2);
157
159
  expect(content.textfragments).toHaveLength(1);
158
160
  expect(content.sections).toHaveLength(1);
@@ -499,18 +499,20 @@ describe("attributeDataHelper", () => {
499
499
  key: "results",
500
500
  content: {
501
501
  InvestigationNecessary: {
502
+ header: {
503
+ label: "label",
504
+ description: "description",
505
+ },
502
506
  elements: [
503
507
  {
504
508
  textFragmentElement: {
505
509
  label: "Text fragment: Description",
506
510
  textfragments: [
507
511
  {
508
- type: "Description",
509
- label: "Description",
510
512
  text: "Text fragment for investigation necessary",
511
513
  },
512
514
  ],
513
- "layout-hint": ["full"],
515
+ layouthint: ["full"],
514
516
  },
515
517
  },
516
518
  ],
@@ -536,6 +538,10 @@ describe("attributeDataHelper", () => {
536
538
  expect(firstChild.dynamicschemaId).toBe("results.InvestigationNecessary");
537
539
  expect(firstChild.key).toBe("InvestigationNecessary");
538
540
  expect(firstChild.value).toBe(true);
541
+ expect(firstChild.content.header).toStrictEqual({
542
+ label: "label",
543
+ description: "description",
544
+ });
539
545
  expect(firstChild.content.elements).toHaveLength(1);
540
546
 
541
547
  expect(firstChild.dynamicschema).toBeUndefined();
@@ -43,7 +43,7 @@ describe("helptextAttributeModel", () => {
43
43
  readonly: true,
44
44
  text: {
45
45
  id: "CarDetails.text",
46
- rawText:
46
+ message:
47
47
  "<p>Currently the person drives in a ${PersonPrivateCar}, although his favorite cars are ${PersonFavoriteCars}. Less favorite cars of the person are ${PersonLessFavoriteCars}.</p>",
48
48
  },
49
49
  }