@beinformed/ui 1.9.0-beta.6 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/esm/constants/Settings.js +10 -8
- package/esm/constants/Settings.js.map +1 -1
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/hooks/useNotification.js.map +1 -1
- package/esm/hooks/useRouter.js.map +1 -1
- package/esm/models/attributes/AttributeContent.js +126 -58
- package/esm/models/attributes/AttributeContent.js.map +1 -1
- package/esm/models/attributes/AttributeDataHelper.js +1 -1
- package/esm/models/attributes/AttributeDataHelper.js.map +1 -1
- package/esm/models/attributes/AttributeModel.js +3 -3
- package/esm/models/attributes/AttributeModel.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeOptionModel.js +4 -4
- package/esm/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/esm/models/attributes/HelptextAttributeModel.js +17 -1
- package/esm/models/attributes/HelptextAttributeModel.js.map +1 -1
- package/esm/models/caseview/CaseViewModel.js +26 -12
- package/esm/models/caseview/CaseViewModel.js.map +1 -1
- package/esm/models/content/SectionModel.js +2 -1
- package/esm/models/content/SectionModel.js.map +1 -1
- package/esm/models/content/SubSectionModel.js +3 -1
- package/esm/models/content/SubSectionModel.js.map +1 -1
- package/esm/models/contentconfiguration/ContentConfigurationResults.js +2 -2
- package/esm/models/contentconfiguration/ContentConfigurationResults.js.map +1 -1
- package/esm/models/form/FormObjectModel.js +8 -2
- package/esm/models/form/FormObjectModel.js.map +1 -1
- package/esm/models/layouthint/LayoutHintCollection.js +3 -2
- package/esm/models/layouthint/LayoutHintCollection.js.map +1 -1
- package/esm/models/list/ListDetailModel.js +25 -0
- package/esm/models/list/ListDetailModel.js.map +1 -1
- package/esm/models/list/ListModel.js +22 -16
- package/esm/models/list/ListModel.js.map +1 -1
- package/esm/models/panels/GroupingPanelModel.js +19 -17
- package/esm/models/panels/GroupingPanelModel.js.map +1 -1
- package/esm/modularui/ModularUIRequest.js +2 -1
- package/esm/modularui/ModularUIRequest.js.map +1 -1
- package/esm/utils/helpers/text.js +19 -0
- package/esm/utils/helpers/text.js.map +1 -0
- package/esm/utils/index.js +2 -1
- package/esm/utils/index.js.map +1 -1
- package/lib/constants/Settings.js +12 -1
- package/lib/constants/Settings.js.flow +9 -5
- package/lib/constants/Settings.js.map +1 -1
- package/lib/hooks/useForm.js.flow +10 -5
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/hooks/useNotification.js.flow +5 -2
- package/lib/hooks/useNotification.js.map +1 -1
- package/lib/hooks/useRouter.js.flow +12 -5
- package/lib/hooks/useRouter.js.map +1 -1
- package/lib/models/attributes/AttributeContent.js +136 -59
- package/lib/models/attributes/AttributeContent.js.flow +91 -39
- package/lib/models/attributes/AttributeContent.js.map +1 -1
- package/lib/models/attributes/AttributeDataHelper.js +1 -1
- package/lib/models/attributes/AttributeDataHelper.js.flow +2 -1
- package/lib/models/attributes/AttributeDataHelper.js.map +1 -1
- package/lib/models/attributes/AttributeModel.js +1 -1
- package/lib/models/attributes/AttributeModel.js.flow +2 -3
- package/lib/models/attributes/AttributeModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeOptionModel.js +3 -3
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.flow +4 -7
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/lib/models/attributes/HelptextAttributeModel.js +17 -1
- package/lib/models/attributes/HelptextAttributeModel.js.flow +11 -1
- package/lib/models/attributes/HelptextAttributeModel.js.map +1 -1
- package/lib/models/attributes/__tests__/AttributeContent.spec.js.flow +10 -2
- package/lib/models/attributes/__tests__/AttributeDataHelper.spec.js.flow +9 -3
- package/lib/models/attributes/__tests__/HelptextAttributeModel.spec.js.flow +39 -1
- package/lib/models/caseview/CaseViewModel.js +27 -13
- package/lib/models/caseview/CaseViewModel.js.flow +17 -7
- package/lib/models/caseview/CaseViewModel.js.map +1 -1
- package/lib/models/caseview/__tests__/CaseViewModel.spec.js.flow +68 -184
- package/lib/models/concepts/__mock__/business_scenario.js.flow +14 -1
- package/lib/models/concepts/__mock__/conceptdetail.js.flow +15 -6
- package/lib/models/concepts/__tests__/BusinessScenarioModel.spec.js.flow +5 -6
- package/lib/models/concepts/__tests__/ConceptDetailModel.spec.js.flow +58 -3
- package/lib/models/content/SectionModel.js +3 -1
- package/lib/models/content/SectionModel.js.flow +2 -1
- package/lib/models/content/SectionModel.js.map +1 -1
- package/lib/models/content/SubSectionModel.js +4 -1
- package/lib/models/content/SubSectionModel.js.flow +3 -1
- package/lib/models/content/SubSectionModel.js.map +1 -1
- package/lib/models/contentconfiguration/ContentConfigurationResults.js +2 -2
- package/lib/models/contentconfiguration/ContentConfigurationResults.js.flow +2 -2
- package/lib/models/contentconfiguration/ContentConfigurationResults.js.map +1 -1
- package/lib/models/contentconfiguration/__tests__/ContentConfigurationResults.spec.js.flow +6 -6
- package/lib/models/form/FormObjectModel.js +8 -2
- package/lib/models/form/FormObjectModel.js.flow +5 -1
- package/lib/models/form/FormObjectModel.js.map +1 -1
- package/lib/models/form/__tests__/FormObjectModel.spec.js.flow +2 -2
- package/lib/models/layouthint/LayoutHintCollection.js +4 -2
- package/lib/models/layouthint/LayoutHintCollection.js.flow +8 -7
- package/lib/models/layouthint/LayoutHintCollection.js.map +1 -1
- package/lib/models/list/ListDetailModel.js +25 -0
- package/lib/models/list/ListDetailModel.js.flow +19 -0
- package/lib/models/list/ListDetailModel.js.map +1 -1
- package/lib/models/list/ListModel.js +23 -16
- package/lib/models/list/ListModel.js.flow +9 -5
- package/lib/models/list/ListModel.js.map +1 -1
- package/lib/models/list/__tests__/ListDetailModel.spec.js.flow +64 -0
- package/lib/models/list/__tests__/ListModel.spec.js.flow +64 -2
- package/lib/models/panels/GroupingPanelModel.js +21 -18
- package/lib/models/panels/GroupingPanelModel.js.flow +10 -9
- package/lib/models/panels/GroupingPanelModel.js.map +1 -1
- package/lib/models/panels/__tests__/GroupingPanelModel.spec.js.flow +90 -0
- package/lib/models/types.js.flow +38 -11
- package/lib/modularui/ModularUIRequest.js +2 -1
- package/lib/modularui/ModularUIRequest.js.flow +1 -0
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/utils/helpers/text.js +28 -0
- package/lib/utils/helpers/text.js.flow +23 -0
- package/lib/utils/helpers/text.js.map +1 -0
- package/lib/utils/index.js +14 -0
- package/lib/utils/index.js.flow +1 -0
- package/lib/utils/index.js.map +1 -1
- package/package.json +13 -13
- package/src/constants/Settings.js +9 -5
- package/src/hooks/useForm.js +10 -5
- package/src/hooks/useNotification.js +5 -2
- package/src/hooks/useRouter.js +12 -5
- package/src/models/attributes/AttributeContent.js +91 -39
- package/src/models/attributes/AttributeDataHelper.js +2 -1
- package/src/models/attributes/AttributeModel.js +2 -3
- package/src/models/attributes/ChoiceAttributeOptionModel.js +4 -7
- package/src/models/attributes/HelptextAttributeModel.js +11 -1
- package/src/models/attributes/__tests__/AttributeContent.spec.js +10 -2
- package/src/models/attributes/__tests__/AttributeDataHelper.spec.js +9 -3
- package/src/models/attributes/__tests__/HelptextAttributeModel.spec.js +39 -1
- package/src/models/caseview/CaseViewModel.js +17 -7
- package/src/models/caseview/__tests__/CaseViewModel.spec.js +68 -184
- package/src/models/caseview/__tests__/caseview.json +38 -0
- package/src/models/caseview/__tests__/caseviewContributions.json +147 -0
- package/src/models/concepts/__mock__/business_scenario.js +14 -1
- package/src/models/concepts/__mock__/business_scenario_step.json +64 -0
- package/src/models/concepts/__mock__/conceptdetail.js +15 -6
- package/src/models/concepts/__mock__/conceptdetail_data.json +117 -17
- package/src/models/concepts/__mock__/concepttype_Calculation.json +75 -0
- package/src/models/concepts/__tests__/BusinessScenarioModel.spec.js +5 -6
- package/src/models/concepts/__tests__/ConceptDetailModel.spec.js +58 -3
- package/src/models/content/SectionModel.js +2 -1
- package/src/models/content/SubSectionModel.js +3 -1
- package/src/models/contentconfiguration/ContentConfigurationResults.js +2 -2
- package/src/models/contentconfiguration/__tests__/ContentConfigurationResults.spec.js +6 -6
- package/src/models/form/FormObjectModel.js +5 -1
- package/src/models/form/__tests__/FormObjectModel.spec.js +2 -2
- package/src/models/form/__tests__/FormWithContentData.json +1 -0
- package/src/models/layouthint/LayoutHintCollection.js +8 -7
- package/src/models/list/ListDetailModel.js +19 -0
- package/src/models/list/ListModel.js +9 -5
- package/src/models/list/__tests__/ListDetailModel.spec.js +64 -0
- package/src/models/list/__tests__/ListModel.spec.js +64 -2
- package/src/models/list/__tests__/caselist-34.contributions.json +1 -1
- package/src/models/list/__tests__/listContributions.json +1 -1
- package/src/models/panels/GroupingPanelModel.js +10 -9
- package/src/models/panels/__tests__/GroupingPanelModel.spec.js +90 -0
- package/src/models/panels/__tests__/groupingPanel.json +30 -0
- package/src/models/panels/__tests__/groupingPanelContributions.json +46 -0
- package/src/models/types.js +38 -11
- package/src/modularui/ModularUIRequest.js +1 -0
- package/src/utils/helpers/text.js +23 -0
- package/src/utils/index.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;;;;;;;;;;;;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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ACE,mCAA0B+C,YAA1B,EAAsE;AAAA;AAAA;;AACpE,UAAMC,eAAe,GAAGD,YAAY,CAACE,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 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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_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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.retrieveText = void 0;
|
|
7
|
+
|
|
8
|
+
var _objects = require("./objects");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Handles text that is in the ApplicationMessage form ({ id: string, message: string, properties: object })
|
|
12
|
+
* @param text
|
|
13
|
+
* @returns {string}
|
|
14
|
+
*/
|
|
15
|
+
var retrieveText = function retrieveText(text) {
|
|
16
|
+
if (typeof text === "string") {
|
|
17
|
+
return text;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if ((0, _objects.isPlainObject)(text) && "message" in text) {
|
|
21
|
+
return text.message;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return "";
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.retrieveText = retrieveText;
|
|
28
|
+
//# sourceMappingURL=text.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { isPlainObject } from "./objects";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Handles text that is in the ApplicationMessage form ({ id: string, message: string, properties: object })
|
|
6
|
+
* @param text
|
|
7
|
+
* @returns {string}
|
|
8
|
+
*/
|
|
9
|
+
export const retrieveText = (
|
|
10
|
+
text:
|
|
11
|
+
| string
|
|
12
|
+
| { id?: string, message: string, properties?: { [key: string]: any } }
|
|
13
|
+
): string => {
|
|
14
|
+
if (typeof text === "string") {
|
|
15
|
+
return text;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (isPlainObject(text) && "message" in text) {
|
|
19
|
+
return text.message;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return "";
|
|
23
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/helpers/text.js"],"names":["retrieveText","text","message"],"mappings":";;;;;;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACO,IAAMA,YAAY,GAAG,SAAfA,YAAe,CAC1BC,IAD0B,EAIf;AACX,MAAI,OAAOA,IAAP,KAAgB,QAApB,EAA8B;AAC5B,WAAOA,IAAP;AACD;;AAED,MAAI,4BAAcA,IAAd,KAAuB,aAAaA,IAAxC,EAA8C;AAC5C,WAAOA,IAAI,CAACC,OAAZ;AACD;;AAED,SAAO,EAAP;AACD,CAdM","sourcesContent":["// @flow\nimport { isPlainObject } from \"./objects\";\n\n/**\n * Handles text that is in the ApplicationMessage form ({ id: string, message: string, properties: object })\n * @param text\n * @returns {string}\n */\nexport const retrieveText = (\n text:\n | string\n | { id?: string, message: string, properties?: { [key: string]: any } }\n): string => {\n if (typeof text === \"string\") {\n return text;\n }\n\n if (isPlainObject(text) && \"message\" in text) {\n return text.message;\n }\n\n return \"\";\n};\n"],"file":"text.js"}
|
package/lib/utils/index.js
CHANGED
|
@@ -139,6 +139,20 @@ _Object$keys(_objects).forEach(function (key) {
|
|
|
139
139
|
});
|
|
140
140
|
});
|
|
141
141
|
|
|
142
|
+
var _text = require("./helpers/text");
|
|
143
|
+
|
|
144
|
+
_Object$keys(_text).forEach(function (key) {
|
|
145
|
+
if (key === "default" || key === "__esModule") return;
|
|
146
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
147
|
+
if (key in exports && exports[key] === _text[key]) return;
|
|
148
|
+
Object.defineProperty(exports, key, {
|
|
149
|
+
enumerable: true,
|
|
150
|
+
get: function get() {
|
|
151
|
+
return _text[key];
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
|
|
142
156
|
var _DecimalFormat = _interopRequireDefault(require("./number/DecimalFormat"));
|
|
143
157
|
|
|
144
158
|
var _formatValue = _interopRequireDefault(require("./number/formatValue"));
|
package/lib/utils/index.js.flow
CHANGED
|
@@ -18,6 +18,7 @@ export * from "./helpers/createHash";
|
|
|
18
18
|
export { default as createUUID } from "./helpers/createUUID";
|
|
19
19
|
export * from "./helpers/sanitizeHtml";
|
|
20
20
|
export * from "./helpers/objects";
|
|
21
|
+
export * from "./helpers/text";
|
|
21
22
|
|
|
22
23
|
// number
|
|
23
24
|
export { default as DecimalFormat } from "./number/DecimalFormat";
|
package/lib/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AACA;;AACA;;AAIA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["// @flow\n\n// browser\nexport { default as Cache } from \"./browser/Cache\";\nexport * from \"./browser/Cookies\";\n\n// datetime\nexport * from \"./datetime/DateTimeUtil\";\n\n// fetch\nexport { default as serverFetch } from \"./fetch/serverFetch\";\nexport { default as universalFetch } from \"./fetch/universalFetch\";\nexport { default as xhr } from \"./fetch/xhr\";\nexport type * from \"./fetch/types\";\n\n// helpers\nexport * from \"./helpers/createHash\";\nexport { default as createUUID } from \"./helpers/createUUID\";\nexport * from \"./helpers/sanitizeHtml\";\nexport * from \"./helpers/objects\";\n\n// number\nexport { default as DecimalFormat } from \"./number/DecimalFormat\";\nexport { default as formatValue } from \"./number/formatValue\";\nexport * from \"./number/parseNumbers\";\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AACA;;AACA;;AAIA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AACA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["// @flow\n\n// browser\nexport { default as Cache } from \"./browser/Cache\";\nexport * from \"./browser/Cookies\";\n\n// datetime\nexport * from \"./datetime/DateTimeUtil\";\n\n// fetch\nexport { default as serverFetch } from \"./fetch/serverFetch\";\nexport { default as universalFetch } from \"./fetch/universalFetch\";\nexport { default as xhr } from \"./fetch/xhr\";\nexport type * from \"./fetch/types\";\n\n// helpers\nexport * from \"./helpers/createHash\";\nexport { default as createUUID } from \"./helpers/createUUID\";\nexport * from \"./helpers/sanitizeHtml\";\nexport * from \"./helpers/objects\";\nexport * from \"./helpers/text\";\n\n// number\nexport { default as DecimalFormat } from \"./number/DecimalFormat\";\nexport { default as formatValue } from \"./number/formatValue\";\nexport * from \"./number/parseNumbers\";\n"],"file":"index.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beinformed/ui",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.1",
|
|
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.
|
|
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.
|
|
97
|
+
"@babel/cli": "^7.15.7",
|
|
98
98
|
"@babel/core": "^7.15.5",
|
|
99
|
-
"@babel/eslint-parser": "^7.15.
|
|
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.
|
|
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.
|
|
109
|
+
"babel-jest": "^27.2.1",
|
|
110
110
|
"babel-plugin-styled-components": "^1.13.2",
|
|
111
111
|
"cherry-pick": "^0.5.0",
|
|
112
112
|
"cross-env": "^7.0.3",
|
|
@@ -114,11 +114,11 @@
|
|
|
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": "^
|
|
117
|
+
"eslint-plugin-flowtype": "^6.1.0",
|
|
118
118
|
"eslint-plugin-import": "^2.24.2",
|
|
119
|
-
"eslint-plugin-jest": "^24.4.
|
|
119
|
+
"eslint-plugin-jest": "^24.4.2",
|
|
120
120
|
"eslint-plugin-jsdoc": "^36.1.0",
|
|
121
|
-
"eslint-plugin-react": "^7.25.
|
|
121
|
+
"eslint-plugin-react": "^7.25.3",
|
|
122
122
|
"eslint-plugin-react-hooks": "^4.2.0",
|
|
123
123
|
"flow-bin": "0.152.0",
|
|
124
124
|
"flow-copy-source": "^2.0.9",
|
|
@@ -126,13 +126,13 @@
|
|
|
126
126
|
"glob": "^7.1.7",
|
|
127
127
|
"history": "^4.0.0",
|
|
128
128
|
"husky": "^7.0.2",
|
|
129
|
-
"jest": "^27.
|
|
129
|
+
"jest": "^27.2.1",
|
|
130
130
|
"jest-junit": "^12.2.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.
|
|
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",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import { isPlainObject, has } from "../utils/helpers/objects";
|
|
3
|
+
import { ALL_CONTENT_IN_DATA_SETTING } from "./Constants";
|
|
3
4
|
|
|
4
5
|
type Setting = boolean | string | number | Array<string>;
|
|
5
6
|
|
|
@@ -69,7 +70,7 @@ let settings = defaultSettings;
|
|
|
69
70
|
|
|
70
71
|
/**
|
|
71
72
|
*/
|
|
72
|
-
const setSettings = (config: Object) => {
|
|
73
|
+
export const setSettings = (config: Object) => {
|
|
73
74
|
if (isPlainObject(config)) {
|
|
74
75
|
settings = Object.assign(defaultSettings, config);
|
|
75
76
|
}
|
|
@@ -77,7 +78,7 @@ const setSettings = (config: Object) => {
|
|
|
77
78
|
|
|
78
79
|
/**
|
|
79
80
|
*/
|
|
80
|
-
const getSetting = (key: string, defaultValue?: any): any => {
|
|
81
|
+
export const getSetting = (key: string, defaultValue?: any): any => {
|
|
81
82
|
if (!has(settings, key) && defaultValue === undefined) {
|
|
82
83
|
throw new Error(
|
|
83
84
|
`Setting with name ${key} not found and no defaultValue given`
|
|
@@ -89,12 +90,15 @@ const getSetting = (key: string, defaultValue?: any): any => {
|
|
|
89
90
|
|
|
90
91
|
/**
|
|
91
92
|
*/
|
|
92
|
-
const setSetting = (key: string, value: any) => {
|
|
93
|
+
export const setSetting = (key: string, value: any) => {
|
|
93
94
|
settings[key] = value;
|
|
94
95
|
};
|
|
95
96
|
|
|
96
97
|
/**
|
|
97
98
|
*/
|
|
98
|
-
const allSettings = (): { [name: string]: Setting } => settings;
|
|
99
|
+
export const allSettings = (): { [name: string]: Setting } => settings;
|
|
99
100
|
|
|
100
|
-
|
|
101
|
+
/**
|
|
102
|
+
*/
|
|
103
|
+
export const hasAllContentInData = (): boolean =>
|
|
104
|
+
getSetting(ALL_CONTENT_IN_DATA_SETTING, true);
|
package/src/hooks/useForm.js
CHANGED
|
@@ -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) =>
|
|
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) =>
|
|
36
|
+
remove: (form: FormModel) => RemoveModelByKeyAction,
|
|
32
37
|
};
|
|
33
38
|
|
|
34
39
|
type AttributeSetHook = {
|
|
35
|
-
save: () =>
|
|
36
|
-
cancel: (object: FormObjectModel) =>
|
|
37
|
-
remove: (object: FormObjectModel) =>
|
|
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 {
|
|
5
|
+
import type {
|
|
6
|
+
DismissNotificationAction,
|
|
7
|
+
NotificationState,
|
|
8
|
+
} from "../redux/types";
|
|
6
9
|
type NotificationHook = {
|
|
7
10
|
...NotificationState,
|
|
8
|
-
dismiss: () =>
|
|
11
|
+
dismiss: () => DismissNotificationAction,
|
|
9
12
|
};
|
|
10
13
|
|
|
11
14
|
/**
|
package/src/hooks/useRouter.js
CHANGED
|
@@ -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?: { ... }) =>
|
|
13
|
-
replace: (location: LocationShape | string, state?: { ... }) =>
|
|
14
|
-
go: (delta: number) =>
|
|
15
|
-
goBack: () =>
|
|
16
|
-
goForward: () =>
|
|
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,5 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import {
|
|
2
|
+
import { retrieveText } from "../../utils/helpers/text";
|
|
3
|
+
import { hasAllContentInData } from "../../constants/Settings";
|
|
3
4
|
import SectionModel from "../content/SectionModel";
|
|
4
5
|
|
|
5
6
|
import type {
|
|
@@ -9,6 +10,8 @@ import type {
|
|
|
9
10
|
ContentAll,
|
|
10
11
|
} from "../types";
|
|
11
12
|
import type SubSectionModel from "../content/SubSectionModel";
|
|
13
|
+
import LayoutHintCollection from "../layouthint/LayoutHintCollection";
|
|
14
|
+
import { isPlainObject } from "../../utils";
|
|
12
15
|
|
|
13
16
|
class AttributeContent {
|
|
14
17
|
_content: ?ContentData;
|
|
@@ -20,28 +23,106 @@ class AttributeContent {
|
|
|
20
23
|
/**
|
|
21
24
|
*/
|
|
22
25
|
get fromData(): boolean {
|
|
23
|
-
return
|
|
26
|
+
return hasAllContentInData();
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
/**
|
|
27
30
|
*/
|
|
28
|
-
get
|
|
29
|
-
|
|
31
|
+
get header(): {
|
|
32
|
+
label: ?string,
|
|
33
|
+
description: ?string,
|
|
34
|
+
} {
|
|
35
|
+
let headerLabel = null;
|
|
36
|
+
let headerDescription = null;
|
|
37
|
+
|
|
38
|
+
const label = this._content?.header?.label;
|
|
39
|
+
if (label) {
|
|
40
|
+
headerLabel = label;
|
|
41
|
+
}
|
|
42
|
+
|
|
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 };
|
|
30
53
|
}
|
|
31
54
|
|
|
32
55
|
/**
|
|
33
56
|
*/
|
|
34
|
-
|
|
57
|
+
get elements(): ContentAll {
|
|
35
58
|
if (this._content?.elements) {
|
|
36
|
-
return this._content.elements
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
59
|
+
return this._content.elements?.map((element) => {
|
|
60
|
+
if ("propertyElement" in element) {
|
|
61
|
+
// $FlowIssue
|
|
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;
|
|
77
|
+
return {
|
|
78
|
+
textFragmentElement: {
|
|
79
|
+
label,
|
|
80
|
+
layouthint: new LayoutHintCollection(layouthint),
|
|
81
|
+
textfragments: textfragments.map((textfragment) => ({
|
|
82
|
+
...textfragment,
|
|
83
|
+
text: retrieveText(textfragment.text),
|
|
84
|
+
})),
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if ("contentElement" in element) {
|
|
90
|
+
// $FlowIssue
|
|
91
|
+
const { label, layouthint, sections } = element.contentElement;
|
|
92
|
+
return {
|
|
93
|
+
contentElement: {
|
|
94
|
+
label,
|
|
95
|
+
layouthint: new LayoutHintCollection(layouthint),
|
|
96
|
+
sections: sections.map(
|
|
97
|
+
(section) => new SectionModel(section, null)
|
|
98
|
+
),
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// $FlowIssue
|
|
104
|
+
return element;
|
|
105
|
+
});
|
|
40
106
|
}
|
|
41
107
|
|
|
42
108
|
return [];
|
|
43
109
|
}
|
|
44
110
|
|
|
111
|
+
/**
|
|
112
|
+
*/
|
|
113
|
+
get label(): ?string {
|
|
114
|
+
return this._content?.label;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
*/
|
|
119
|
+
getContentElements<T>(elementName: string, collectionName: string): Array<T> {
|
|
120
|
+
return this.elements
|
|
121
|
+
.filter((element) => elementName in element)
|
|
122
|
+
.map((element) => element[elementName][collectionName])
|
|
123
|
+
.flat();
|
|
124
|
+
}
|
|
125
|
+
|
|
45
126
|
/**
|
|
46
127
|
*/
|
|
47
128
|
get properties(): Array<PropertyData> {
|
|
@@ -79,10 +160,7 @@ class AttributeContent {
|
|
|
79
160
|
/**
|
|
80
161
|
*/
|
|
81
162
|
get sections(): Array<SectionModel> {
|
|
82
|
-
return this.getContentElements<SectionModel>(
|
|
83
|
-
"contentElement",
|
|
84
|
-
"sections"
|
|
85
|
-
).map((section) => new SectionModel(section, null));
|
|
163
|
+
return this.getContentElements<SectionModel>("contentElement", "sections");
|
|
86
164
|
}
|
|
87
165
|
|
|
88
166
|
/**
|
|
@@ -102,32 +180,6 @@ class AttributeContent {
|
|
|
102
180
|
|
|
103
181
|
return referredSections;
|
|
104
182
|
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
*/
|
|
108
|
-
get all(): ContentAll {
|
|
109
|
-
if (this._content?.elements) {
|
|
110
|
-
return this._content.elements?.map((element) => {
|
|
111
|
-
if ("contentElement" in element) {
|
|
112
|
-
// $FlowIssue
|
|
113
|
-
const { label, sections } = element.contentElement;
|
|
114
|
-
return {
|
|
115
|
-
contentElement: {
|
|
116
|
-
label,
|
|
117
|
-
sections: sections.map(
|
|
118
|
-
(section) => new SectionModel(section, null)
|
|
119
|
-
),
|
|
120
|
-
},
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// $FlowIssue
|
|
125
|
-
return element;
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return [];
|
|
130
|
-
}
|
|
131
183
|
}
|
|
132
184
|
|
|
133
185
|
export default AttributeContent;
|