@beinformed/ui 1.62.6 → 1.62.8
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 +16 -0
- package/esm/constants/Settings.d.ts +1 -0
- package/esm/constants/Settings.js +4 -0
- package/esm/constants/Settings.js.flow +5 -1
- package/esm/constants/Settings.js.map +1 -1
- package/esm/models/list/ListDetailModel.js +3 -2
- package/esm/models/list/ListDetailModel.js.flow +5 -5
- package/esm/models/list/ListDetailModel.js.map +1 -1
- package/esm/react-client/client.d.ts +1 -1
- package/esm/react-client/client.js +19 -0
- package/esm/react-client/client.js.flow +23 -1
- package/esm/react-client/client.js.map +1 -1
- package/esm/react-server/serverUtil.js +2 -2
- package/esm/react-server/serverUtil.js.flow +2 -2
- package/esm/react-server/serverUtil.js.map +1 -1
- package/esm/redux/_i18n/I18nActions.js.flow +0 -1
- package/esm/redux/_i18n/I18nActions.js.map +1 -1
- package/esm/redux/_i18n/I18nReducer.js +11 -3
- package/esm/redux/_i18n/I18nReducer.js.flow +11 -3
- package/esm/redux/_i18n/I18nReducer.js.map +1 -1
- package/esm/redux/reducers/createReducer.js +2 -2
- package/esm/redux/reducers/createReducer.js.flow +1 -1
- package/esm/redux/reducers/createReducer.js.map +1 -1
- package/esm/redux/store/configureStore.js +0 -5
- package/esm/redux/store/configureStore.js.flow +0 -7
- package/esm/redux/store/configureStore.js.map +1 -1
- package/esm/utils/datetime/DateTimeUtil.js +3 -2
- package/esm/utils/datetime/DateTimeUtil.js.flow +3 -1
- package/esm/utils/datetime/DateTimeUtil.js.map +1 -1
- package/lib/constants/Settings.d.ts +1 -0
- package/lib/constants/Settings.js +7 -2
- package/lib/constants/Settings.js.map +1 -1
- package/lib/models/list/ListDetailModel.js +3 -2
- package/lib/models/list/ListDetailModel.js.map +1 -1
- package/lib/react-client/client.d.ts +1 -1
- package/lib/react-client/client.js +20 -1
- package/lib/react-client/client.js.map +1 -1
- package/lib/react-server/serverUtil.js +1 -1
- package/lib/react-server/serverUtil.js.map +1 -1
- package/lib/redux/_i18n/I18nActions.js.map +1 -1
- package/lib/redux/_i18n/I18nReducer.js +10 -2
- package/lib/redux/_i18n/I18nReducer.js.map +1 -1
- package/lib/redux/reducers/createReducer.js +2 -2
- package/lib/redux/reducers/createReducer.js.map +1 -1
- package/lib/redux/store/configureStore.js +0 -5
- package/lib/redux/store/configureStore.js.map +1 -1
- package/lib/utils/datetime/DateTimeUtil.js +2 -1
- package/lib/utils/datetime/DateTimeUtil.js.map +1 -1
- package/package.json +8 -8
- package/src/constants/Settings.js +5 -1
- package/src/models/list/ListDetailModel.js +5 -5
- package/src/react-client/client.js +23 -1
- package/src/react-server/serverUtil.js +2 -2
- package/src/redux/_i18n/I18nActions.js +0 -1
- package/src/redux/_i18n/I18nReducer.js +11 -3
- package/src/redux/reducers/createReducer.js +1 -1
- package/src/redux/store/configureStore.js +0 -7
- package/src/utils/datetime/DateTimeUtil.js +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListDetailModel.js","names":["_objects","require","_ActionCollection","_interopRequireDefault","_DetailModel","_ContentConfiguration","_AttributeSetModel","_createAttribute","_CompositeAttributeModel","ListDetailModel","DetailModel","constructor","modularUIResponse","_defineProperty2","default","_actionCollection","ActionCollection","_contentConfiguration","ContentConfiguration","contributions","content","setResultSection","setEventData","getInitialChildModelLinks","listitemPanels","listitem","links","getLinksByGroup","all","hasResults","results","push","givenAnswers","setChildModels","models","errors","_attributeCollection","type","modelName","isApplicableModel","data","resourcetype","_endsWith","call","_listitem","actionCollection","panelLinks","contentConfiguration","configuration","introtext","_content","text","message","Array","isArray","texts","has","setResults","setGivenAnswers","resultsData","resultSection","resultsContributions","_context","children","_filter","child","childKey","_keys","createAttribute","key","dynamicschema","CompositeAttributeModel","isResult","indicateContentConfiguration","_results","_context2","givenAnswersData","givenAnswersContributions","filteredContributions","_givenAnswers","hasEventData","eventdata","addAttributes","eventData","eventContributions","_eventdata","AttributeSetModel","modelOptions","forEach","eventDataContribution","eventDataData","i","exports"],"sources":["../../../src/models/list/ListDetailModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ActionCollection from \"../actions/ActionCollection\";\nimport DetailModel from \"../detail/DetailModel\";\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\nimport AttributeSetModel from \"../attributes/AttributeSetModel\";\n\nimport createAttribute from \"../attributes/_createAttribute\";\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type ListItemModel from \"../list/ListItemModel\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\n\n/**\n * Detail of a list item\n */\nexport default class ListDetailModel extends DetailModel {\n _contentConfiguration: ContentConfiguration;\n _listitem: ListItemModel;\n _givenAnswers: ?CompositeAttributeModel;\n _results: ?CompositeAttributeModel;\n _eventdata: Array<AttributeSetModel>;\n\n /**\n * Construct\n */\n constructor(modularUIResponse: ModularUIResponse) {\n super(modularUIResponse);\n\n this._actionCollection = new ActionCollection();\n\n this._contentConfiguration = new ContentConfiguration(\n this.contributions ? this.contributions.content : {},\n );\n\n this.setResultSection();\n this.setEventData();\n }\n\n /**\n * Add links to expand on initialization of this model\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const listitemPanels = this.listitem\n ? this.listitem.links.getLinksByGroup(\"panel\").all\n : [];\n\n const links = [...super.getInitialChildModelLinks(), ...listitemPanels];\n\n if (this.hasResults) {\n if (this.results) {\n links.push(...this.results.getInitialChildModelLinks());\n }\n if (this.givenAnswers) {\n links.push(...this.givenAnswers.getInitialChildModelLinks());\n }\n }\n\n return links;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {\n this._attributeCollection.setChildModels(models, errors);\n\n if (this.results) {\n this.results.setChildModels(models, errors);\n }\n\n if (this.givenAnswers) {\n this.givenAnswers.setChildModels(models, errors);\n }\n }\n\n /**\n */\n get type(): string {\n return \"ListDetail\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ListDetailModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n const resourcetype = data.contributions?.resourcetype ?? \"unknown\";\n\n return (\n resourcetype.endsWith(\"ListPanelDetail\") ||\n resourcetype.endsWith(\"ListDetail\") ||\n resourcetype === \"DatastoreRelatedDatastorePanelDetail\" ||\n resourcetype === \"CaseRelatedDataStorePanelDetail\"\n );\n }\n\n /**\n * Set listitem of this listdetail and transfer listitem actions to listdetail actions\n */\n set listitem(listitem: ListItemModel) {\n this._listitem = listitem;\n\n // transfer listitem actions to _actions\n this._actionCollection = listitem.actionCollection;\n }\n\n /**\n * Get listitem\n */\n get listitem(): ListItemModel {\n return this._listitem;\n }\n\n /**\n * Getting panel links\n */\n get panelLinks(): LinkCollection {\n return this.listitem.links.getLinksByGroup(\"panel\");\n }\n\n /**\n * Getting the contentConfiguration\n */\n get contentConfiguration(): ContentConfiguration {\n return this._contentConfiguration;\n }\n\n /**\n */\n set contentConfiguration(configuration: ContentConfiguration) {\n this._contentConfiguration = configuration;\n }\n\n /**\n * Getting the introduction text configured on the case view\n */\n get introtext(): string {\n if (this.data._content) {\n return this.data._content.text.message;\n }\n\n if (this.contributions.text) {\n return this.contributions.text.message ?? this.contributions.text;\n }\n\n if (Array.isArray(this.contributions.texts)) {\n return this.contributions.texts[0].text;\n }\n\n return \"\";\n }\n\n /**\n */\n setResultSection() {\n if (\n has(this.contributions, \"resultSection\") &&\n has(this.data, \"resultSection\")\n ) {\n this.setResults();\n this.setGivenAnswers();\n }\n }\n\n /**\n */\n setResults() {\n if (\n has(this.data, \"resultSection.results\") &&\n has(this.contributions, \"resultSection.results\")\n ) {\n const resultsData = this.data.resultSection.results;\n const resultsContributions = this.contributions.resultSection.results;\n if (resultsContributions.type === \"composite\") {\n resultsContributions.children = resultsContributions.children.filter(\n (child) => {\n const childKey = Object.keys(child)[0];\n return childKey in resultsData;\n },\n );\n }\n\n const results = createAttribute(\n \"results\",\n {\n key: \"results\",\n dynamicschema: this.data.dynamicschema,\n content: this.data.content?.results,\n ...this.data.resultSection,\n },\n resultsContributions,\n );\n\n if (results instanceof CompositeAttributeModel) {\n results.isResult = true;\n results.indicateContentConfiguration(this.contentConfiguration);\n this._results = results;\n }\n }\n }\n\n /**\n */\n setGivenAnswers() {\n if (\n has(this.data, \"resultSection.givenAnswers\") &&\n has(this.contributions, \"resultSection.givenAnswers\")\n ) {\n const givenAnswersData = this.data.resultSection.givenAnswers;\n const givenAnswersContributions =\n this.contributions.resultSection.givenAnswers;\n\n const filteredContributions = {\n ...givenAnswersContributions,\n children: givenAnswersContributions.children.filter((child) => {\n const childKey = Object.keys(child)[0];\n return childKey in givenAnswersData;\n }),\n };\n\n const givenAnswers = createAttribute(\n \"givenAnswers\",\n {\n key: \"givenAnswers\",\n dynamicschema: this.data.dynamicschema,\n content: this.data.content?.givenAnswers,\n ...this.data.resultSection,\n },\n filteredContributions,\n );\n\n if (givenAnswers instanceof CompositeAttributeModel) {\n givenAnswers.isResult = true;\n this._givenAnswers = givenAnswers;\n }\n }\n }\n\n /**\n */\n get givenAnswers(): ?CompositeAttributeModel {\n return this._givenAnswers;\n }\n\n /**\n */\n get hasResults(): boolean {\n return has(this.contributions, \"resultSection\");\n }\n\n /**\n */\n get results(): ?CompositeAttributeModel {\n return this._results;\n }\n\n /**\n */\n get hasEventData(): boolean {\n return (\n has(this.contributions, \"eventdata\") &&\n has(this.data, \"eventdata\") &&\n this.data.eventdata != null &&\n this.contributions.eventdata != null\n );\n }\n\n /**\n */\n addAttributes(key: string, eventData: Object, eventContributions: Object) {\n this._eventdata.push(\n new AttributeSetModel(\n key,\n eventData,\n eventContributions,\n this.modelOptions,\n ),\n );\n }\n\n /**\n */\n setEventData() {\n if (this.hasEventData) {\n this._eventdata = [];\n\n this.contributions.eventdata.forEach((eventDataContribution) => {\n const [key] = Object.keys(eventDataContribution);\n if (key in this.data.eventdata) {\n if (Array.isArray(this.data.eventdata[key])) {\n this.data.eventdata[key].forEach((eventDataData, i) => {\n this.addAttributes(\n `${key}-${i + 1}`,\n {\n ...eventDataData,\n dynamicschema: this.data.dynamicschema,\n },\n eventDataContribution[key],\n );\n });\n } else {\n this.addAttributes(\n key,\n {\n ...this.data.eventdata[key],\n dynamicschema: this.data.dynamicschema,\n },\n eventDataContribution[key],\n );\n }\n }\n });\n }\n }\n\n /**\n */\n get eventdata(): Array<AttributeSetModel> {\n return this._eventdata;\n }\n}\n"],"mappings":";;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,qBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,kBAAA,GAAAH,sBAAA,CAAAF,OAAA;AAEA,IAAAM,gBAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,wBAAA,GAAAL,sBAAA,CAAAF,OAAA;AASA;AACA;AACA;AACe,MAAMQ,eAAe,SAASC,oBAAW,CAAC;EAOvD;AACF;AACA;EACEC,WAAWA,CAACC,iBAAoC,EAAE;IAChD,KAAK,CAACA,iBAAiB,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAEzB,IAAI,CAACC,iBAAiB,GAAG,IAAIC,yBAAgB,CAAC,CAAC;IAE/C,IAAI,CAACC,qBAAqB,GAAG,IAAIC,6BAAoB,CACnD,IAAI,CAACC,aAAa,GAAG,IAAI,CAACA,aAAa,CAACC,OAAO,GAAG,CAAC,CACrD,CAAC;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O,CAAEC,qBAAqB,IAAK;QAC9D,MAAM,CAACpB,GAAG,CAAC,GAAG,IAAAF,KAAA,CAAArD,OAAA,EAAY2E,qBAAqB,CAAC;QAChD,IAAIpB,GAAG,IAAI,IAAI,CAAC7B,IAAI,CAACyC,SAAS,EAAE;UAC9B,IAAI5B,KAAK,CAACC,OAAO,CAAC,IAAI,CAACd,IAAI,CAACyC,SAAS,CAACZ,GAAG,CAAC,CAAC,EAAE;YAC3C,IAAI,CAAC7B,IAAI,CAACyC,SAAS,CAACZ,GAAG,CAAC,CAACmB,OAAO,CAAC,CAACE,aAAa,EAAEC,CAAC,KAAK;cACrD,IAAI,CAACT,aAAa,CAChB,GAAGb,GAAG,IAAIsB,CAAC,GAAG,CAAC,EAAE,EACjB;gBACE,GAAGD,aAAa;gBAChBpB,aAAa,EAAE,IAAI,CAAC9B,IAAI,CAAC8B;cAC3B,CAAC,EACDmB,qBAAqB,CAACpB,GAAG,CAC3B,CAAC;YACH,CAAC,CAAC;UACJ,CAAC,MAAM;YACL,IAAI,CAACa,aAAa,CAChBb,GAAG,EACH;cACE,GAAG,IAAI,CAAC7B,IAAI,CAACyC,SAAS,CAACZ,GAAG,CAAC;cAC3BC,aAAa,EAAE,IAAI,CAAC9B,IAAI,CAAC8B;YAC3B,CAAC,EACDmB,qBAAqB,CAACpB,GAAG,CAC3B,CAAC;UACH;QACF;MACF,CAAC,CAAC;IACJ;EACF;;EAEA;AACF;EACE,IAAIY,SAASA,CAAA,EAA6B;IACxC,OAAO,IAAI,CAACI,UAAU;EACxB;AACF;AAACO,OAAA,CAAA9E,OAAA,GAAAL,eAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ListDetailModel.js","names":["_objects","require","_ActionCollection","_interopRequireDefault","_DetailModel","_ContentConfiguration","_AttributeSetModel","_createAttribute","_CompositeAttributeModel","ListDetailModel","DetailModel","constructor","modularUIResponse","_defineProperty2","default","_actionCollection","ActionCollection","_contentConfiguration","ContentConfiguration","contributions","content","setResultSection","setEventData","getInitialChildModelLinks","listitemPanels","listitem","links","getLinksByGroup","all","hasResults","results","push","givenAnswers","setChildModels","models","errors","_attributeCollection","type","modelName","isApplicableModel","data","resourcetype","toLowerCase","_endsWith","call","_listitem","actionCollection","panelLinks","contentConfiguration","configuration","introtext","_content","text","message","Array","isArray","texts","has","setResults","setGivenAnswers","resultsData","resultSection","resultsContributions","_context","children","_filter","child","childKey","_keys","createAttribute","key","dynamicschema","CompositeAttributeModel","isResult","indicateContentConfiguration","_results","_context2","givenAnswersData","givenAnswersContributions","filteredContributions","_givenAnswers","hasEventData","eventdata","addAttributes","eventData","eventContributions","_eventdata","AttributeSetModel","modelOptions","forEach","eventDataContribution","eventDataData","i","exports"],"sources":["../../../src/models/list/ListDetailModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ActionCollection from \"../actions/ActionCollection\";\nimport DetailModel from \"../detail/DetailModel\";\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\nimport AttributeSetModel from \"../attributes/AttributeSetModel\";\n\nimport createAttribute from \"../attributes/_createAttribute\";\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type ListItemModel from \"../list/ListItemModel\";\nimport type LinkModel from \"../links/LinkModel\";\nimport type ErrorResponse from \"../error/ErrorResponse\";\n\n/**\n * Detail of a list item\n */\nexport default class ListDetailModel extends DetailModel {\n _contentConfiguration: ContentConfiguration;\n _listitem: ListItemModel;\n _givenAnswers: ?CompositeAttributeModel;\n _results: ?CompositeAttributeModel;\n _eventdata: Array<AttributeSetModel>;\n\n /**\n * Construct\n */\n constructor(modularUIResponse: ModularUIResponse) {\n super(modularUIResponse);\n\n this._actionCollection = new ActionCollection();\n\n this._contentConfiguration = new ContentConfiguration(\n this.contributions ? this.contributions.content : {},\n );\n\n this.setResultSection();\n this.setEventData();\n }\n\n /**\n * Add links to expand on initialization of this model\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const listitemPanels = this.listitem\n ? this.listitem.links.getLinksByGroup(\"panel\").all\n : [];\n\n const links = [...super.getInitialChildModelLinks(), ...listitemPanels];\n\n if (this.hasResults) {\n if (this.results) {\n links.push(...this.results.getInitialChildModelLinks());\n }\n if (this.givenAnswers) {\n links.push(...this.givenAnswers.getInitialChildModelLinks());\n }\n }\n\n return links;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {\n this._attributeCollection.setChildModels(models, errors);\n\n if (this.results) {\n this.results.setChildModels(models, errors);\n }\n\n if (this.givenAnswers) {\n this.givenAnswers.setChildModels(models, errors);\n }\n }\n\n /**\n */\n get type(): string {\n return \"ListDetail\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ListDetailModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n let resourcetype = data.contributions?.resourcetype ?? \"unknown\";\n resourcetype = resourcetype.toLowerCase();\n\n return (\n resourcetype.endsWith(\"listdetail\") ||\n resourcetype.endsWith(\"listpaneldetail\") ||\n resourcetype.endsWith(\"datastorepaneldetail\")\n );\n }\n\n /**\n * Set listitem of this listdetail and transfer listitem actions to listdetail actions\n */\n set listitem(listitem: ListItemModel) {\n this._listitem = listitem;\n\n // transfer listitem actions to _actions\n this._actionCollection = listitem.actionCollection;\n }\n\n /**\n * Get listitem\n */\n get listitem(): ListItemModel {\n return this._listitem;\n }\n\n /**\n * Getting panel links\n */\n get panelLinks(): LinkCollection {\n return this.listitem.links.getLinksByGroup(\"panel\");\n }\n\n /**\n * Getting the contentConfiguration\n */\n get contentConfiguration(): ContentConfiguration {\n return this._contentConfiguration;\n }\n\n /**\n */\n set contentConfiguration(configuration: ContentConfiguration) {\n this._contentConfiguration = configuration;\n }\n\n /**\n * Getting the introduction text configured on the case view\n */\n get introtext(): string {\n if (this.data._content) {\n return this.data._content.text.message;\n }\n\n if (this.contributions.text) {\n return this.contributions.text.message ?? this.contributions.text;\n }\n\n if (Array.isArray(this.contributions.texts)) {\n return this.contributions.texts[0].text;\n }\n\n return \"\";\n }\n\n /**\n */\n setResultSection() {\n if (\n has(this.contributions, \"resultSection\") &&\n has(this.data, \"resultSection\")\n ) {\n this.setResults();\n this.setGivenAnswers();\n }\n }\n\n /**\n */\n setResults() {\n if (\n has(this.data, \"resultSection.results\") &&\n has(this.contributions, \"resultSection.results\")\n ) {\n const resultsData = this.data.resultSection.results;\n const resultsContributions = this.contributions.resultSection.results;\n if (resultsContributions.type === \"composite\") {\n resultsContributions.children = resultsContributions.children.filter(\n (child) => {\n const childKey = Object.keys(child)[0];\n return childKey in resultsData;\n },\n );\n }\n\n const results = createAttribute(\n \"results\",\n {\n key: \"results\",\n dynamicschema: this.data.dynamicschema,\n content: this.data.content?.results,\n ...this.data.resultSection,\n },\n resultsContributions,\n );\n\n if (results instanceof CompositeAttributeModel) {\n results.isResult = true;\n results.indicateContentConfiguration(this.contentConfiguration);\n this._results = results;\n }\n }\n }\n\n /**\n */\n setGivenAnswers() {\n if (\n has(this.data, \"resultSection.givenAnswers\") &&\n has(this.contributions, \"resultSection.givenAnswers\")\n ) {\n const givenAnswersData = this.data.resultSection.givenAnswers;\n const givenAnswersContributions =\n this.contributions.resultSection.givenAnswers;\n\n const filteredContributions = {\n ...givenAnswersContributions,\n children: givenAnswersContributions.children.filter((child) => {\n const childKey = Object.keys(child)[0];\n return childKey in givenAnswersData;\n }),\n };\n\n const givenAnswers = createAttribute(\n \"givenAnswers\",\n {\n key: \"givenAnswers\",\n dynamicschema: this.data.dynamicschema,\n content: this.data.content?.givenAnswers,\n ...this.data.resultSection,\n },\n filteredContributions,\n );\n\n if (givenAnswers instanceof CompositeAttributeModel) {\n givenAnswers.isResult = true;\n this._givenAnswers = givenAnswers;\n }\n }\n }\n\n /**\n */\n get givenAnswers(): ?CompositeAttributeModel {\n return this._givenAnswers;\n }\n\n /**\n */\n get hasResults(): boolean {\n return has(this.contributions, \"resultSection\");\n }\n\n /**\n */\n get results(): ?CompositeAttributeModel {\n return this._results;\n }\n\n /**\n */\n get hasEventData(): boolean {\n return (\n has(this.contributions, \"eventdata\") &&\n has(this.data, \"eventdata\") &&\n this.data.eventdata != null &&\n this.contributions.eventdata != null\n );\n }\n\n /**\n */\n addAttributes(key: string, eventData: Object, eventContributions: Object) {\n this._eventdata.push(\n new AttributeSetModel(\n key,\n eventData,\n eventContributions,\n this.modelOptions,\n ),\n );\n }\n\n /**\n */\n setEventData() {\n if (this.hasEventData) {\n this._eventdata = [];\n\n this.contributions.eventdata.forEach((eventDataContribution) => {\n const [key] = Object.keys(eventDataContribution);\n if (key in this.data.eventdata) {\n if (Array.isArray(this.data.eventdata[key])) {\n this.data.eventdata[key].forEach((eventDataData, i) => {\n this.addAttributes(\n `${key}-${i + 1}`,\n {\n ...eventDataData,\n dynamicschema: this.data.dynamicschema,\n },\n eventDataContribution[key],\n );\n });\n } else {\n this.addAttributes(\n key,\n {\n ...this.data.eventdata[key],\n dynamicschema: this.data.dynamicschema,\n },\n eventDataContribution[key],\n );\n }\n }\n });\n }\n }\n\n /**\n */\n get eventdata(): Array<AttributeSetModel> {\n return this._eventdata;\n }\n}\n"],"mappings":";;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,qBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,kBAAA,GAAAH,sBAAA,CAAAF,OAAA;AAEA,IAAAM,gBAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,wBAAA,GAAAL,sBAAA,CAAAF,OAAA;AASA;AACA;AACA;AACe,MAAMQ,eAAe,SAASC,oBAAW,CAAC;EAOvD;AACF;AACA;EACEC,WAAWA,CAACC,iBAAoC,EAAE;IAChD,KAAK,CAAC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,EAAE,IAAI,CAAC/B,IAAI,CAAC+B;YAC3B,CAAC,EACDmB,qBAAqB,CAACpB,GAAG,CAC3B,CAAC;UACH;QACF;MACF,CAAC,CAAC;IACJ;EACF;;EAEA;AACF;EACE,IAAIY,SAASA,CAAA,EAA6B;IACxC,OAAO,IAAI,CAACI,UAAU;EACxB;AACF;AAACO,OAAA,CAAA/E,OAAA,GAAAL,eAAA","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export function setUnhandledRejectionEvent(store: ReduxStore): void;
|
|
2
2
|
export function setModelCatalogEntryDate(store: ReduxStore): void;
|
|
3
|
-
export function setupClient(customReducers: CustomReducers | undefined, beforeRenderHooks: Array<BeforeRenderHook> | null): {
|
|
3
|
+
export function setupClient(customReducers: CustomReducers | undefined, beforeRenderHooks: Array<BeforeRenderHook> | null, theme?: Theme | Array<Theme>): {
|
|
4
4
|
store: ReduxStore;
|
|
5
5
|
routerHistory: RouterHistory;
|
|
6
6
|
};
|
|
@@ -25,6 +25,8 @@ var _RouterActions = require("../redux/_router/RouterActions");
|
|
|
25
25
|
var _exceptions = require("../exceptions");
|
|
26
26
|
var _Init = require("./Init");
|
|
27
27
|
var _beforeRenderHooks = require("../redux/store/beforeRenderHooks");
|
|
28
|
+
var _createTheme = _interopRequireDefault(require("../react-theme/createTheme"));
|
|
29
|
+
var _redux = require("../redux");
|
|
28
30
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
29
31
|
// eslint-disable-next-line react/no-deprecated
|
|
30
32
|
/*
|
|
@@ -63,11 +65,25 @@ const setUnhandledRejectionEvent = store => {
|
|
|
63
65
|
};
|
|
64
66
|
};
|
|
65
67
|
|
|
68
|
+
/**
|
|
69
|
+
*/
|
|
70
|
+
exports.setUnhandledRejectionEvent = setUnhandledRejectionEvent;
|
|
71
|
+
const initThemeSettings = (state, theme) => {
|
|
72
|
+
const storedTheme = state.preferences.theme;
|
|
73
|
+
// $FlowFixMe
|
|
74
|
+
(0, _createTheme.default)(storedTheme, theme); // on theme creation, the settings are set
|
|
75
|
+
};
|
|
76
|
+
const handleLocale = store => {
|
|
77
|
+
const locale = store.getState().i18n.locale;
|
|
78
|
+
if (locale) {
|
|
79
|
+
store.dispatch((0, _redux.receiveLocale)(locale));
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
66
83
|
/**
|
|
67
84
|
* The redirectURI querystring parameter is available when the server is redirecting an unauthorized deep link
|
|
68
85
|
* @param store
|
|
69
86
|
*/
|
|
70
|
-
exports.setUnhandledRejectionEvent = setUnhandledRejectionEvent;
|
|
71
87
|
const handleRedirectURI = store => {
|
|
72
88
|
const urlParams = new _urlSearchParams.default(window.location.search);
|
|
73
89
|
const redirectURI = urlParams.get("redirectURI");
|
|
@@ -107,6 +123,7 @@ exports.setModelCatalogEntryDate = setModelCatalogEntryDate;
|
|
|
107
123
|
const setupClient = function () {
|
|
108
124
|
let customReducers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
109
125
|
let beforeRenderHooks = arguments.length > 1 ? arguments[1] : undefined;
|
|
126
|
+
let theme = arguments.length > 2 ? arguments[2] : undefined;
|
|
110
127
|
if (typeof window.contextPath === "undefined") {
|
|
111
128
|
throw new Error("Missing contextPath on window object");
|
|
112
129
|
}
|
|
@@ -123,6 +140,8 @@ const setupClient = function () {
|
|
|
123
140
|
routerHistory,
|
|
124
141
|
store
|
|
125
142
|
} = (0, _configureStore.default)(browserHistory, customReducers, (0, _rehydrate.default)(data));
|
|
143
|
+
initThemeSettings(store.getState(), theme);
|
|
144
|
+
handleLocale(store);
|
|
126
145
|
handleRedirectURI(store);
|
|
127
146
|
setModelCatalogEntryDate(store);
|
|
128
147
|
(0, _Preferences.setAllContentInDataSetting)(store.getState());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":["_client","require","_objects","_setimmediate","_interopRequireDefault","_Cache","_xhr","_history","_configureStore","_rehydrate","_Settings","_Preferences","_Notification","_Error","_SignIn","_ModelCatalog","_RouterActions","_exceptions","_Init","_beforeRenderHooks","_jsxRuntime","parseDataToJSON","data","JSON","parse","error","JsonParseException","getDataFromServer","_context","dataElement","document","querySelector","Error","_trim","default","textContent","call","setUnhandledRejectionEvent","store","window","onunhandledrejection","event","detail","setImmediate","errorMessage","reason","message","toString","dispatch","showXHRErrorNotification","exports","handleRedirectURI","urlParams","_urlSearchParams","location","search","redirectURI","get","xhr","url","getBasePathModularUI","catch","e","id","LOGIN_PATH","getSetting","replace","from","pathname","modal","setModelCatalogEntryDate","entryDateFromUrl","updateEntryDate","Cache","hasItem","getItem","setupClient","customReducers","arguments","length","undefined","beforeRenderHooks","contextPath","clear","browserHistory","createBrowserHistory","basename","getBasePathServer","routerHistory","configureStore","rehydrate","setAllContentInDataSetting","getState","setLoginPreferences","setDateTimeSettings","loadOtherBrowserTabs","loginSuccess","has","FetchException","response","handleError","listen","action","locationChange","body","className","handleBeforeRenderHooks","addContentLoadedEvent","theme","render","ErrorFallbackComponent","mount","addEventListener","applicationNode","jsx","Init","children","mountClient","element","isSSR","hydrateRoot","root","createRoot","client","_ref"],"sources":["../../src/react-client/client.js"],"sourcesContent":["// @flow\n// eslint-disable-next-line react/no-deprecated\nimport { hydrateRoot, createRoot } from \"react-dom/client\";\n\nimport { has } from \"../utils/helpers/objects\";\nimport setImmediate from \"setimmediate\";\n\nimport Cache from \"../utils/browser/Cache\";\n\nimport xhr from \"../utils/fetch/xhr\";\n\nimport { createBrowserHistory } from \"history\";\nimport configureStore from \"../redux/store/configureStore\";\n\nimport rehydrate from \"./rehydrate\";\nimport {\n getBasePathModularUI,\n getBasePathServer,\n getSetting,\n} from \"../constants/Settings\";\n\nimport {\n setAllContentInDataSetting,\n setDateTimeSettings,\n setLoginPreferences,\n} from \"../redux/actions/Preferences\";\nimport { showXHRErrorNotification } from \"../redux/actions/Notification\";\nimport { handleError } from \"../redux/actions/Error\";\nimport { loginSuccess } from \"../redux/actions/SignIn\";\nimport { updateEntryDate } from \"../redux/actions/ModelCatalog\";\n\nimport { locationChange, replace } from \"../redux/_router/RouterActions\";\n\nimport { JsonParseException, FetchException } from \"../exceptions\";\n\nimport { Init } from \"./Init\";\n\nimport { handleBeforeRenderHooks } from \"../redux/store/beforeRenderHooks\";\n\nimport type {\n ComponentType,\n Element as ReactElement,\n ElementType,\n} from \"react\";\nimport type { Theme } from \"../react-theme/types\";\nimport type { CustomReducers, ReduxStore } from \"../redux/types\";\nimport type { RouterHistory } from \"react-router\";\nimport type { BeforeRenderHook } from \"../redux/store/beforeRenderHooks\";\nimport type { Props as FallbackProps } from \"../react/ErrorBoundaryFallback\";\n\ntype RenderFunction = () => ReactElement<ElementType>;\ntype MountFunction = (\n applicationNode: Element,\n element: ReactElement<ElementType>,\n) => void;\ntype Props = {\n customReducers?: CustomReducers,\n theme?: Theme | Array<Theme>,\n render: RenderFunction,\n mount: MountFunction,\n beforeRenderHooks?: Array<BeforeRenderHook>,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n};\n\n/*\n * deserialize serialized data from the server to provide a smooth dehydration.\n */\nconst parseDataToJSON = (data: string) => {\n try {\n return JSON.parse(data);\n } catch (error) {\n throw new JsonParseException(`Error parsing content ${data}`);\n }\n};\n\nconst getDataFromServer = () => {\n const dataElement = document.querySelector(\n 'script[type=\"application/json\"][data-app-state=\"app-json\"]',\n );\n\n if (!dataElement) {\n throw new Error(\"Error loading state, json not found\");\n } else if (dataElement.textContent.trim() === \"\") {\n return {};\n }\n\n return parseDataToJSON(dataElement.textContent);\n};\n\n/**\n */\nexport const setUnhandledRejectionEvent = (store: ReduxStore) => {\n window.onunhandledrejection = (event) => {\n if (event.detail) {\n return setImmediate(() => {\n const errorMessage = event.detail.reason.message.toString();\n\n store.dispatch(showXHRErrorNotification(errorMessage));\n throw event.detail.reason;\n });\n }\n\n return event;\n };\n};\n\n/**\n * The redirectURI querystring parameter is available when the server is redirecting an unauthorized deep link\n * @param store\n */\nconst handleRedirectURI = (store: ReduxStore) => {\n const urlParams = new URLSearchParams(window.location.search);\n const redirectURI = urlParams.get(\"redirectURI\");\n if (redirectURI) {\n xhr({ url: `${getBasePathModularUI()}${redirectURI}` }).catch((e) => {\n if (\n e.id === \"UnauthorizedException\" ||\n e.id === \"Error.NotAuthorized\" ||\n e.id === \"Error.Authentication.Required\" ||\n e.id === \"Error.Authentication.InvalidCredentials\"\n ) {\n const LOGIN_PATH = getSetting(\"LOGIN_PATH\", \"/signin\");\n store.dispatch(\n replace(LOGIN_PATH, {\n from: { pathname: redirectURI },\n modal: false,\n }),\n );\n }\n });\n }\n};\n\n/**\n */\nexport const setModelCatalogEntryDate = (store: ReduxStore) => {\n if (typeof window !== \"undefined\") {\n const entryDateFromUrl = new URLSearchParams(window.location?.search).get(\n \"entryDate\",\n );\n if (entryDateFromUrl) {\n store.dispatch(updateEntryDate(entryDateFromUrl));\n } else if (Cache.hasItem(\"ModelCatalogEntryDate\")) {\n store.dispatch(Cache.getItem(\"ModelCatalogEntryDate\"));\n }\n }\n};\n\n/**\n */\nexport const setupClient = (\n customReducers: CustomReducers = {},\n beforeRenderHooks: ?Array<BeforeRenderHook>,\n): { store: ReduxStore, routerHistory: RouterHistory } => {\n if (typeof window.contextPath === \"undefined\") {\n throw new Error(\"Missing contextPath on window object\");\n }\n\n const data = getDataFromServer();\n\n // remove all resources from cache\n Cache.clear(\"^res:\");\n\n // $FlowExpectedError\n const browserHistory: RouterHistory = createBrowserHistory({\n basename: getBasePathServer(),\n });\n const { routerHistory, store } = configureStore(\n browserHistory,\n customReducers,\n rehydrate(data),\n );\n\n handleRedirectURI(store);\n setModelCatalogEntryDate(store);\n\n setAllContentInDataSetting(store.getState());\n setLoginPreferences(store.getState());\n setDateTimeSettings(store.getState());\n\n // load existing cache from other browser tabs\n Cache.loadOtherBrowserTabs(() => {\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n });\n\n if (has(data, \"error.name\")) {\n const error = new FetchException(data?.error?.response);\n store.dispatch(handleError(error));\n }\n\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n\n // listen to history change and update the redux router store\n routerHistory.listen((location, action) => {\n store.dispatch(locationChange(location, action));\n });\n\n setUnhandledRejectionEvent(store);\n\n if (document.body) {\n document.body.className = \"js\";\n }\n\n if (beforeRenderHooks) {\n handleBeforeRenderHooks(beforeRenderHooks, { store });\n }\n\n return { store, routerHistory };\n};\n\n/**\n */\nexport const addContentLoadedEvent = (\n store: ReduxStore,\n routerHistory: RouterHistory,\n theme?: Theme | Array<Theme>,\n render: RenderFunction,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n mount: MountFunction,\n) => {\n window.addEventListener(\"DOMContentLoaded\", () => {\n const applicationNode = document.querySelector(\"#application\");\n if (!applicationNode) {\n throw new Error(\n \"No DOM element with id application found to attach client to\",\n );\n }\n\n mount(\n applicationNode,\n <Init\n store={store}\n routerHistory={routerHistory}\n contextPath={window.contextPath}\n theme={theme}\n ErrorFallbackComponent={ErrorFallbackComponent}\n >\n {render()}\n </Init>,\n );\n });\n};\n\n/**\n */\nconst mountClient = (\n applicationNode: Element,\n element: ReactElement<ElementType>,\n) => {\n const isSSR = applicationNode.querySelector(\".application\");\n if (isSSR) {\n hydrateRoot(element, applicationNode);\n } else {\n const root = createRoot(element);\n root.render(applicationNode);\n }\n};\n\n/**\n * Mount the webapplication to the DOM, setup redux store and caches, add unhandledRejectionEvent, used client side when JavaScript is enabled.\n */\nexport const client = ({\n customReducers,\n theme,\n render,\n beforeRenderHooks,\n ErrorFallbackComponent,\n mount,\n}: Props) => {\n const { store, routerHistory } = setupClient(\n customReducers,\n beforeRenderHooks,\n );\n\n addContentLoadedEvent(\n store,\n routerHistory,\n theme,\n render,\n ErrorFallbackComponent,\n mount ?? mountClient,\n );\n};\n"],"mappings":";;;;;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAC,sBAAA,CAAAH,OAAA;A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GAAG,IAAAC,kBAAU,EAACJ,OAAO,CAAC;IAChCG,IAAI,CAACZ,MAAM,CAACI,eAAe,CAAC;EAC9B;AACF,CAAC;;AAED;AACA;AACA;AACO,MAAMU,MAAM,GAAGC,IAAA,IAOT;EAAA,IAPU;IACrB/C,cAAc;IACd+B,KAAK;IACLC,MAAM;IACN5B,iBAAiB;IACjB6B,sBAAsB;IACtBC;EACK,CAAC,GAAAa,IAAA;EACN,MAAM;IAAEtF,KAAK;IAAEkD;EAAc,CAAC,GAAGZ,WAAW,CAC1CC,cAAc,EACdI,iBACF,CAAC;EAED0B,qBAAqB,CACnBrE,KAAK,EACLkD,aAAa,EACboB,KAAK,EACLC,MAAM,EACNC,sBAAsB,EACtBC,KAAK,IAAIM,WACX,CAAC;AACH,CAAC;AAACnE,OAAA,CAAAyE,MAAA,GAAAA,MAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"client.js","names":["_client","require","_objects","_setimmediate","_interopRequireDefault","_Cache","_xhr","_history","_configureStore","_rehydrate","_Settings","_Preferences","_Notification","_Error","_SignIn","_ModelCatalog","_RouterActions","_exceptions","_Init","_beforeRenderHooks","_createTheme","_redux","_jsxRuntime","parseDataToJSON","data","JSON","parse","error","JsonParseException","getDataFromServer","_context","dataElement","document","querySelector","Error","_trim","default","textContent","call","setUnhandledRejectionEvent","store","window","onunhandledrejection","event","detail","setImmediate","errorMessage","reason","message","toString","dispatch","showXHRErrorNotification","exports","initThemeSettings","state","theme","storedTheme","preferences","createTheme","handleLocale","locale","getState","i18n","receiveLocale","handleRedirectURI","urlParams","_urlSearchParams","location","search","redirectURI","get","xhr","url","getBasePathModularUI","catch","e","id","LOGIN_PATH","getSetting","replace","from","pathname","modal","setModelCatalogEntryDate","entryDateFromUrl","updateEntryDate","Cache","hasItem","getItem","setupClient","customReducers","arguments","length","undefined","beforeRenderHooks","contextPath","clear","browserHistory","createBrowserHistory","basename","getBasePathServer","routerHistory","configureStore","rehydrate","setAllContentInDataSetting","setLoginPreferences","setDateTimeSettings","loadOtherBrowserTabs","loginSuccess","has","FetchException","response","handleError","listen","action","locationChange","body","className","handleBeforeRenderHooks","addContentLoadedEvent","render","ErrorFallbackComponent","mount","addEventListener","applicationNode","jsx","Init","children","mountClient","element","isSSR","hydrateRoot","root","createRoot","client","_ref"],"sources":["../../src/react-client/client.js"],"sourcesContent":["// @flow\n// eslint-disable-next-line react/no-deprecated\nimport { hydrateRoot, createRoot } from \"react-dom/client\";\n\nimport { has } from \"../utils/helpers/objects\";\nimport setImmediate from \"setimmediate\";\n\nimport Cache from \"../utils/browser/Cache\";\n\nimport xhr from \"../utils/fetch/xhr\";\n\nimport { createBrowserHistory } from \"history\";\nimport configureStore from \"../redux/store/configureStore\";\n\nimport rehydrate from \"./rehydrate\";\nimport {\n getBasePathModularUI,\n getBasePathServer,\n getSetting,\n} from \"../constants/Settings\";\n\nimport {\n setAllContentInDataSetting,\n setDateTimeSettings,\n setLoginPreferences,\n} from \"../redux/actions/Preferences\";\nimport { showXHRErrorNotification } from \"../redux/actions/Notification\";\nimport { handleError } from \"../redux/actions/Error\";\nimport { loginSuccess } from \"../redux/actions/SignIn\";\nimport { updateEntryDate } from \"../redux/actions/ModelCatalog\";\n\nimport { locationChange, replace } from \"../redux/_router/RouterActions\";\n\nimport { JsonParseException, FetchException } from \"../exceptions\";\n\nimport { Init } from \"./Init\";\n\nimport { handleBeforeRenderHooks } from \"../redux/store/beforeRenderHooks\";\n\nimport type {\n ComponentType,\n Element as ReactElement,\n ElementType,\n} from \"react\";\nimport type { Theme } from \"../react-theme/types\";\nimport type { CustomReducers, ReduxState, ReduxStore } from \"../redux/types\";\nimport type { RouterHistory } from \"react-router\";\nimport type { BeforeRenderHook } from \"../redux/store/beforeRenderHooks\";\nimport type { Props as FallbackProps } from \"../react/ErrorBoundaryFallback\";\nimport createTheme from \"../react-theme/createTheme\";\nimport { receiveLocale } from \"../redux\";\n\ntype RenderFunction = () => ReactElement<ElementType>;\ntype MountFunction = (\n applicationNode: Element,\n element: ReactElement<ElementType>,\n) => void;\ntype Props = {\n customReducers?: CustomReducers,\n theme?: Theme | Array<Theme>,\n render: RenderFunction,\n mount: MountFunction,\n beforeRenderHooks?: Array<BeforeRenderHook>,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n};\n\n/*\n * deserialize serialized data from the server to provide a smooth dehydration.\n */\nconst parseDataToJSON = (data: string) => {\n try {\n return JSON.parse(data);\n } catch (error) {\n throw new JsonParseException(`Error parsing content ${data}`);\n }\n};\n\nconst getDataFromServer = () => {\n const dataElement = document.querySelector(\n 'script[type=\"application/json\"][data-app-state=\"app-json\"]',\n );\n\n if (!dataElement) {\n throw new Error(\"Error loading state, json not found\");\n } else if (dataElement.textContent.trim() === \"\") {\n return {};\n }\n\n return parseDataToJSON(dataElement.textContent);\n};\n\n/**\n */\nexport const setUnhandledRejectionEvent = (store: ReduxStore) => {\n window.onunhandledrejection = (event) => {\n if (event.detail) {\n return setImmediate(() => {\n const errorMessage = event.detail.reason.message.toString();\n\n store.dispatch(showXHRErrorNotification(errorMessage));\n throw event.detail.reason;\n });\n }\n\n return event;\n };\n};\n\n/**\n */\nconst initThemeSettings = (state: ReduxState, theme?: Theme | Array<Theme>) => {\n const storedTheme = state.preferences.theme;\n // $FlowFixMe\n createTheme(storedTheme, theme); // on theme creation, the settings are set\n};\n\nconst handleLocale = (store: ReduxStore) => {\n const locale = store.getState().i18n.locale;\n if (locale) {\n store.dispatch(receiveLocale(locale));\n }\n};\n\n/**\n * The redirectURI querystring parameter is available when the server is redirecting an unauthorized deep link\n * @param store\n */\nconst handleRedirectURI = (store: ReduxStore) => {\n const urlParams = new URLSearchParams(window.location.search);\n const redirectURI = urlParams.get(\"redirectURI\");\n if (redirectURI) {\n xhr({ url: `${getBasePathModularUI()}${redirectURI}` }).catch((e) => {\n if (\n e.id === \"UnauthorizedException\" ||\n e.id === \"Error.NotAuthorized\" ||\n e.id === \"Error.Authentication.Required\" ||\n e.id === \"Error.Authentication.InvalidCredentials\"\n ) {\n const LOGIN_PATH = getSetting(\"LOGIN_PATH\", \"/signin\");\n store.dispatch(\n replace(LOGIN_PATH, {\n from: { pathname: redirectURI },\n modal: false,\n }),\n );\n }\n });\n }\n};\n\n/**\n */\nexport const setModelCatalogEntryDate = (store: ReduxStore) => {\n if (typeof window !== \"undefined\") {\n const entryDateFromUrl = new URLSearchParams(window.location?.search).get(\n \"entryDate\",\n );\n if (entryDateFromUrl) {\n store.dispatch(updateEntryDate(entryDateFromUrl));\n } else if (Cache.hasItem(\"ModelCatalogEntryDate\")) {\n store.dispatch(Cache.getItem(\"ModelCatalogEntryDate\"));\n }\n }\n};\n\n/**\n */\nexport const setupClient = (\n customReducers: CustomReducers = {},\n beforeRenderHooks: ?Array<BeforeRenderHook>,\n theme?: Theme | Array<Theme>,\n): { store: ReduxStore, routerHistory: RouterHistory } => {\n if (typeof window.contextPath === \"undefined\") {\n throw new Error(\"Missing contextPath on window object\");\n }\n\n const data = getDataFromServer();\n\n // remove all resources from cache\n Cache.clear(\"^res:\");\n\n // $FlowExpectedError\n const browserHistory: RouterHistory = createBrowserHistory({\n basename: getBasePathServer(),\n });\n const { routerHistory, store } = configureStore(\n browserHistory,\n customReducers,\n rehydrate(data),\n );\n\n initThemeSettings(store.getState(), theme);\n\n handleLocale(store);\n\n handleRedirectURI(store);\n setModelCatalogEntryDate(store);\n\n setAllContentInDataSetting(store.getState());\n setLoginPreferences(store.getState());\n setDateTimeSettings(store.getState());\n\n // load existing cache from other browser tabs\n Cache.loadOtherBrowserTabs(() => {\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n });\n\n if (has(data, \"error.name\")) {\n const error = new FetchException(data?.error?.response);\n store.dispatch(handleError(error));\n }\n\n if (Cache.getItem(\"auth\")) {\n store.dispatch(loginSuccess());\n }\n\n // listen to history change and update the redux router store\n routerHistory.listen((location, action) => {\n store.dispatch(locationChange(location, action));\n });\n\n setUnhandledRejectionEvent(store);\n\n if (document.body) {\n document.body.className = \"js\";\n }\n\n if (beforeRenderHooks) {\n handleBeforeRenderHooks(beforeRenderHooks, { store });\n }\n\n return { store, routerHistory };\n};\n\n/**\n */\nexport const addContentLoadedEvent = (\n store: ReduxStore,\n routerHistory: RouterHistory,\n theme?: Theme | Array<Theme>,\n render: RenderFunction,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n mount: MountFunction,\n) => {\n window.addEventListener(\"DOMContentLoaded\", () => {\n const applicationNode = document.querySelector(\"#application\");\n if (!applicationNode) {\n throw new Error(\n \"No DOM element with id application found to attach client to\",\n );\n }\n\n mount(\n applicationNode,\n <Init\n store={store}\n routerHistory={routerHistory}\n contextPath={window.contextPath}\n theme={theme}\n ErrorFallbackComponent={ErrorFallbackComponent}\n >\n {render()}\n </Init>,\n );\n });\n};\n\n/**\n */\nconst mountClient = (\n applicationNode: Element,\n element: ReactElement<ElementType>,\n) => {\n const isSSR = applicationNode.querySelector(\".application\");\n if (isSSR) {\n hydrateRoot(element, applicationNode);\n } else {\n const root = createRoot(element);\n root.render(applicationNode);\n }\n};\n\n/**\n * Mount the webapplication to the DOM, setup redux store and caches, add unhandledRejectionEvent, used client side when JavaScript is enabled.\n */\nexport const client = ({\n customReducers,\n theme,\n render,\n beforeRenderHooks,\n ErrorFallbackComponent,\n mount,\n}: Props) => {\n const { store, routerHistory } = setupClient(\n customReducers,\n beforeRenderHooks,\n );\n\n addContentLoadedEvent(\n store,\n routerHistory,\n theme,\n render,\n ErrorFallbackComponent,\n mount ?? mountClient,\n );\n};\n"],"mappings":";;;;;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAD,sBAAA,CAAAH,OAAA;AAEA,IAAAK,IAAA,GAAAF,sBAAA,CAAAH,OAAA;AAEA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,eAAA,GAAAJ,sBAAA,C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AAA,EAAC3G,KAAA,CAAA4G,IAAI;MACHtF,KAAK,EAAEA,KAAM;MACb6D,aAAa,EAAEA,aAAc;MAC7BN,WAAW,EAAEtD,MAAM,CAACsD,WAAY;MAChCxC,KAAK,EAAEA,KAAM;MACbkE,sBAAsB,EAAEA,sBAAuB;MAAAM,QAAA,EAE9CP,MAAM,CAAC;IAAC,CACL,CACR,CAAC;EACH,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AADApE,OAAA,CAAAmE,qBAAA,GAAAA,qBAAA;AAEA,MAAMS,WAAW,GAAGA,CAClBJ,eAAwB,EACxBK,OAAkC,KAC/B;EACH,MAAMC,KAAK,GAAGN,eAAe,CAAC3F,aAAa,CAAC,cAAc,CAAC;EAC3D,IAAIiG,KAAK,EAAE;IACT,IAAAC,mBAAW,EAACF,OAAO,EAAEL,eAAe,CAAC;EACvC,CAAC,MAAM;IACL,MAAMQ,IAAI,GAAG,IAAAC,kBAAU,EAACJ,OAAO,CAAC;IAChCG,IAAI,CAACZ,MAAM,CAACI,eAAe,CAAC;EAC9B;AACF,CAAC;;AAED;AACA;AACA;AACO,MAAMU,MAAM,GAAGC,IAAA,IAOT;EAAA,IAPU;IACrB7C,cAAc;IACdnC,KAAK;IACLiE,MAAM;IACN1B,iBAAiB;IACjB2B,sBAAsB;IACtBC;EACK,CAAC,GAAAa,IAAA;EACN,MAAM;IAAE/F,KAAK;IAAE6D;EAAc,CAAC,GAAGZ,WAAW,CAC1CC,cAAc,EACdI,iBACF,CAAC;EAEDyB,qBAAqB,CACnB/E,KAAK,EACL6D,aAAa,EACb9C,KAAK,EACLiE,MAAM,EACNC,sBAAsB,EACtBC,KAAK,IAAIM,WACX,CAAC;AACH,CAAC;AAAC5E,OAAA,CAAAkF,MAAA,GAAAA,MAAA","ignoreList":[]}
|
|
@@ -67,7 +67,7 @@ const setI18n = function (store) {
|
|
|
67
67
|
});
|
|
68
68
|
const enabledLocales = (0, _filter.default)(mergedLocales).call(mergedLocales, locale => {
|
|
69
69
|
var _context;
|
|
70
|
-
return (0, _includes.default)(_context = (0, _Settings.
|
|
70
|
+
return (0, _includes.default)(_context = (0, _Settings.getEnabledLocales)()).call(_context, locale.code);
|
|
71
71
|
});
|
|
72
72
|
const localesInstance = new _Locales.default(enabledLocales);
|
|
73
73
|
const preferredLocale = (0, _requestInformation.getPreferredLocale)(request, localesInstance);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverUtil.js","names":["_history","require","_objects","_deepmerge","_interopRequireDefault","_configureStore","_Locales","_interopRequireWildcard","_requestInformation","_I18nActions","_Preferences","_Settings","_exceptions","_redux","_i18n","_ModularUIRequest","e","t","_WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","_Object$getOwnPropertyDescriptor","createReduxStore","requestHref","customReducers","initialState","history","createMemoryHistory","initialEntries","toString","store","configureStore","exports","setI18n","locales","arguments","length","undefined","request","Array","isArray","IllegalArgumentException","mergedLocales","_map","availableLocales","locale","code","customLocale","_find","custLocale","deepmerge","forEach","some","push","enabledLocales","_filter","_context","_includes","getSetting","localesInstance","Locales","preferredLocale","getPreferredLocale","dispatch","setLocales","setServerPreferencesFromArray","serverPreferences","serverPreference","name","defaultValue","type","setServerPreference","setServerPreferences","setAllContentInDataSetting","setLoginPreferences","setDateTimeSettings","preferencesProvider","isStudioContext","setPreference","setConfigurationTheme","configTheme","configFileLocation","getLayoutConfigFileLocation","configFilePath","_startsWith","dataFetcher","fetch","setThemePreference","Error","setApplication","getLocale","getState","application","ModularUIRequest","fetchSync","connectKey","initModels","key","model","handleErrors","state","error","shouldThrowOnServer","dehydrate","modularui","status","lastModification","filteredState","_stringify","replace","createHead","sheet","UUID","helmetContext","style","getStyleTags","meta","helmet"],"sources":["../../src/react-server/serverUtil.js"],"sourcesContent":["// @flow\nimport { createMemoryHistory } from \"history\";\nimport { has } from \"../utils/helpers/objects\";\nimport deepmerge from \"deepmerge\";\n\nimport configureStore from \"../redux/store/configureStore\";\n\nimport { availableLocales } from \"../i18n/Locales\";\nimport Locales from \"../i18n/Locales\";\n\nimport { getPreferredLocale } from \"./requestInformation\";\nimport { setLocales } from \"../redux/_i18n/I18nActions\";\n\nimport {\n setServerPreference,\n setThemePreference,\n setPreference,\n setAllContentInDataSetting,\n setLoginPreferences,\n setDateTimeSettings,\n} from \"../redux/actions/Preferences\";\n\nimport { getSetting } from \"../constants/Settings\";\n\nimport { IllegalArgumentException } from \"../exceptions\";\n\nimport { initModels } from \"../redux\";\nimport { getLocale } from \"../redux/selectors/i18n\";\n\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\n\nimport type { LocaleConfiguration } from \"../i18n/types\";\nimport type { ReduxState, ReduxStore } from \"../redux/types\";\nimport type Href from \"../models/href/Href\";\nimport type { RouterHistory } from \"react-router\";\n\nexport type PreferenceValue = {\n name: string,\n defaultValue?: string | null,\n type?: string,\n};\n\n/**\n */\nconst createReduxStore = (\n requestHref: Href,\n customReducers: Object,\n initialState?: $Shape<ReduxState>,\n): ReduxStore => {\n // $FlowExpectedError\n const history: RouterHistory = createMemoryHistory({\n initialEntries: [requestHref.toString()],\n });\n\n const { store } = configureStore(history, customReducers, initialState);\n\n return store;\n};\n\n/**\n */\nconst setI18n = (\n store: ReduxStore,\n locales: Array<LocaleConfiguration> = [],\n request: HttpServletRequestJava,\n) => {\n if (!Array.isArray(locales)) {\n throw new IllegalArgumentException(\"locales must be an array of objects\");\n }\n if (!request) {\n throw new IllegalArgumentException(\"missing request argument\");\n }\n\n const mergedLocales = availableLocales.map((locale) => {\n const code = locale.code;\n const customLocale = locales.find((custLocale) => custLocale.code === code);\n\n if (customLocale) {\n return deepmerge(locale, customLocale);\n }\n\n return locale;\n });\n\n locales.forEach((customLocale) => {\n if (!mergedLocales.some((locale) => locale.code === customLocale.code)) {\n mergedLocales.push(customLocale);\n }\n });\n\n const enabledLocales = mergedLocales.filter((locale: LocaleConfiguration) =>\n getSetting(\"ENABLED_LOCALES\").includes(locale.code),\n );\n\n const localesInstance = new Locales(enabledLocales);\n const preferredLocale = getPreferredLocale(request, localesInstance);\n store.dispatch(setLocales(localesInstance, preferredLocale ?? \"en\"));\n};\n\nconst setServerPreferencesFromArray = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>,\n) => {\n serverPreferences.forEach((serverPreference) => {\n if (typeof serverPreference === \"object\") {\n const { name, defaultValue, type } = serverPreference;\n store.dispatch(setServerPreference(name, defaultValue, type));\n } else {\n store.dispatch(setServerPreference(serverPreference, null));\n }\n });\n};\n\n/**\n * Server preferences can be suplied by an array of preference names,\n * or an array of objects which has the name, an optional default value and an optional type.<br>\n * When the type is set to string, a comma separated value is not converted to an array:\n *\n * @example\n * // value becomes an array [default1, default2]\n * { name: \"prefName\", defaultValue: \"default1, default2\" }\n * // value remains a string \"default1, default2\"\n * { name: \"prefName\", defaultValue: \"default1, default2\", type: \"string\" }\n *\n * @param store\n * @param serverPreferences\n */\nconst setServerPreferences = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>,\n) => {\n if (Array.isArray(serverPreferences)) {\n setServerPreferencesFromArray(store, serverPreferences);\n }\n\n store.dispatch(setAllContentInDataSetting());\n store.dispatch(setLoginPreferences());\n store.dispatch(setDateTimeSettings());\n\n if (\n preferencesProvider &&\n preferencesProvider.isStudioContext &&\n preferencesProvider.isStudioContext()\n ) {\n store.dispatch(setPreference(\"isStudioContext\", true));\n }\n};\n\n/**\n */\nconst setConfigurationTheme = (store: ReduxStore) => {\n let configTheme = null;\n\n const configFileLocation = preferencesProvider.getLayoutConfigFileLocation();\n if (typeof configFileLocation === \"string\") {\n const configFilePath = configFileLocation.startsWith(\"/\")\n ? `/resource${configFileLocation}`\n : `/resource/${configFileLocation}`;\n\n configTheme = dataFetcher.fetch(configFilePath);\n\n if (configTheme) {\n store.dispatch(setThemePreference(configTheme));\n } else {\n throw new Error(\n `Could not read theme configuration file from: ${configFilePath}`,\n );\n }\n }\n};\n\n/**\n */\nconst setApplication = (store: ReduxStore) => {\n try {\n const locale = getLocale(store.getState());\n const application = new ModularUIRequest(\"/\", {\n locale: locale,\n }).fetchSync();\n\n application.connectKey = `application(/)(${locale})`;\n\n store.dispatch(\n initModels([\n {\n key: `application(/)(${locale})`,\n model: application,\n },\n ]),\n );\n } catch (e) {\n // swallow error, in this case we just don't pre-cache the webapplication,\n // which has not much difference for the end user\n }\n};\n\n/**\n */\nconst handleErrors = (store: ReduxStore) => {\n const state = store.getState();\n\n if (\n state.error &&\n (state.error.shouldThrowOnServer ||\n !has(state.error, \"shouldThrowOnServer\"))\n ) {\n throw state.error;\n }\n};\n\n/**\n */\nconst dehydrate = (store: ReduxStore): string => {\n const state = store.getState();\n\n const modularui: {\n [key: string]: { status: string, lastModification: number, model: ?Object },\n } = {};\n\n for (const key in state.modularui) {\n const { status, model, lastModification } = state.modularui[key];\n\n if (model) {\n modularui[key] = {\n status,\n lastModification,\n model: model.dehydrate(),\n };\n } else {\n modularui[key] = {\n status,\n lastModification,\n model: undefined,\n };\n }\n }\n\n const filteredState = {\n ...state,\n modularui,\n };\n\n return JSON.stringify(filteredState).replace(/</g, \"\\\\u003c\");\n};\n\n/**\n */\nconst createHead = (\n sheet: any,\n UUID: string,\n helmetContext?: Object,\n): Object => {\n const style = sheet.getStyleTags();\n const meta = helmetContext ? [...helmetContext.helmet.meta] : [];\n\n if (helmetContext) {\n return {\n ...helmetContext.helmet,\n style,\n meta,\n };\n }\n\n return {\n style,\n meta,\n };\n};\n\nexport {\n createReduxStore,\n setI18n,\n setApplication,\n setServerPreferences,\n setConfigurationTheme,\n createHead,\n handleErrors,\n dehydrate,\n};\n"],"mappings":";;;;;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,eAAA,GAAAD,sBAAA,CAAAH,OAAA;AAEA,IAAAK,QAAA,GAAAC,uBAAA,CAAAN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_deepmerge","_interopRequireDefault","_configureStore","_Locales","_interopRequireWildcard","_requestInformation","_I18nActions","_Preferences","_Settings","_exceptions","_redux","_i18n","_ModularUIRequest","e","t","_WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","_Object$getOwnPropertyDescriptor","createReduxStore","requestHref","customReducers","initialState","history","createMemoryHistory","initialEntries","toString","store","configureStore","exports","setI18n","locales","arguments","length","undefined","request","Array","isArray","IllegalArgumentException","mergedLocales","_map","availableLocales","locale","code","customLocale","_find","custLocale","deepmerge","forEach","some","push","enabledLocales","_filter","_context","_includes","getEnabledLocales","localesInstance","Locales","preferredLocale","getPreferredLocale","dispatch","setLocales","setServerPreferencesFromArray","serverPreferences","serverPreference","name","defaultValue","type","setServerPreference","setServerPreferences","setAllContentInDataSetting","setLoginPreferences","setDateTimeSettings","preferencesProvider","isStudioContext","setPreference","setConfigurationTheme","configTheme","configFileLocation","getLayoutConfigFileLocation","configFilePath","_startsWith","dataFetcher","fetch","setThemePreference","Error","setApplication","getLocale","getState","application","ModularUIRequest","fetchSync","connectKey","initModels","key","model","handleErrors","state","error","shouldThrowOnServer","dehydrate","modularui","status","lastModification","filteredState","_stringify","replace","createHead","sheet","UUID","helmetContext","style","getStyleTags","meta","helmet"],"sources":["../../src/react-server/serverUtil.js"],"sourcesContent":["// @flow\nimport { createMemoryHistory } from \"history\";\nimport { has } from \"../utils/helpers/objects\";\nimport deepmerge from \"deepmerge\";\n\nimport configureStore from \"../redux/store/configureStore\";\n\nimport { availableLocales } from \"../i18n/Locales\";\nimport Locales from \"../i18n/Locales\";\n\nimport { getPreferredLocale } from \"./requestInformation\";\nimport { setLocales } from \"../redux/_i18n/I18nActions\";\n\nimport {\n setServerPreference,\n setThemePreference,\n setPreference,\n setAllContentInDataSetting,\n setLoginPreferences,\n setDateTimeSettings,\n} from \"../redux/actions/Preferences\";\n\nimport { getEnabledLocales } from \"../constants/Settings\";\n\nimport { IllegalArgumentException } from \"../exceptions\";\n\nimport { initModels } from \"../redux\";\nimport { getLocale } from \"../redux/selectors/i18n\";\n\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\n\nimport type { LocaleConfiguration } from \"../i18n/types\";\nimport type { ReduxState, ReduxStore } from \"../redux/types\";\nimport type Href from \"../models/href/Href\";\nimport type { RouterHistory } from \"react-router\";\n\nexport type PreferenceValue = {\n name: string,\n defaultValue?: string | null,\n type?: string,\n};\n\n/**\n */\nconst createReduxStore = (\n requestHref: Href,\n customReducers: Object,\n initialState?: $Shape<ReduxState>,\n): ReduxStore => {\n // $FlowExpectedError\n const history: RouterHistory = createMemoryHistory({\n initialEntries: [requestHref.toString()],\n });\n\n const { store } = configureStore(history, customReducers, initialState);\n\n return store;\n};\n\n/**\n */\nconst setI18n = (\n store: ReduxStore,\n locales: Array<LocaleConfiguration> = [],\n request: HttpServletRequestJava,\n) => {\n if (!Array.isArray(locales)) {\n throw new IllegalArgumentException(\"locales must be an array of objects\");\n }\n if (!request) {\n throw new IllegalArgumentException(\"missing request argument\");\n }\n\n const mergedLocales = availableLocales.map((locale) => {\n const code = locale.code;\n const customLocale = locales.find((custLocale) => custLocale.code === code);\n\n if (customLocale) {\n return deepmerge(locale, customLocale);\n }\n\n return locale;\n });\n\n locales.forEach((customLocale) => {\n if (!mergedLocales.some((locale) => locale.code === customLocale.code)) {\n mergedLocales.push(customLocale);\n }\n });\n\n const enabledLocales = mergedLocales.filter((locale: LocaleConfiguration) =>\n getEnabledLocales().includes(locale.code),\n );\n\n const localesInstance = new Locales(enabledLocales);\n const preferredLocale = getPreferredLocale(request, localesInstance);\n store.dispatch(setLocales(localesInstance, preferredLocale ?? \"en\"));\n};\n\nconst setServerPreferencesFromArray = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>,\n) => {\n serverPreferences.forEach((serverPreference) => {\n if (typeof serverPreference === \"object\") {\n const { name, defaultValue, type } = serverPreference;\n store.dispatch(setServerPreference(name, defaultValue, type));\n } else {\n store.dispatch(setServerPreference(serverPreference, null));\n }\n });\n};\n\n/**\n * Server preferences can be suplied by an array of preference names,\n * or an array of objects which has the name, an optional default value and an optional type.<br>\n * When the type is set to string, a comma separated value is not converted to an array:\n *\n * @example\n * // value becomes an array [default1, default2]\n * { name: \"prefName\", defaultValue: \"default1, default2\" }\n * // value remains a string \"default1, default2\"\n * { name: \"prefName\", defaultValue: \"default1, default2\", type: \"string\" }\n *\n * @param store\n * @param serverPreferences\n */\nconst setServerPreferences = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>,\n) => {\n if (Array.isArray(serverPreferences)) {\n setServerPreferencesFromArray(store, serverPreferences);\n }\n\n store.dispatch(setAllContentInDataSetting());\n store.dispatch(setLoginPreferences());\n store.dispatch(setDateTimeSettings());\n\n if (\n preferencesProvider &&\n preferencesProvider.isStudioContext &&\n preferencesProvider.isStudioContext()\n ) {\n store.dispatch(setPreference(\"isStudioContext\", true));\n }\n};\n\n/**\n */\nconst setConfigurationTheme = (store: ReduxStore) => {\n let configTheme = null;\n\n const configFileLocation = preferencesProvider.getLayoutConfigFileLocation();\n if (typeof configFileLocation === \"string\") {\n const configFilePath = configFileLocation.startsWith(\"/\")\n ? `/resource${configFileLocation}`\n : `/resource/${configFileLocation}`;\n\n configTheme = dataFetcher.fetch(configFilePath);\n\n if (configTheme) {\n store.dispatch(setThemePreference(configTheme));\n } else {\n throw new Error(\n `Could not read theme configuration file from: ${configFilePath}`,\n );\n }\n }\n};\n\n/**\n */\nconst setApplication = (store: ReduxStore) => {\n try {\n const locale = getLocale(store.getState());\n const application = new ModularUIRequest(\"/\", {\n locale: locale,\n }).fetchSync();\n\n application.connectKey = `application(/)(${locale})`;\n\n store.dispatch(\n initModels([\n {\n key: `application(/)(${locale})`,\n model: application,\n },\n ]),\n );\n } catch (e) {\n // swallow error, in this case we just don't pre-cache the webapplication,\n // which has not much difference for the end user\n }\n};\n\n/**\n */\nconst handleErrors = (store: ReduxStore) => {\n const state = store.getState();\n\n if (\n state.error &&\n (state.error.shouldThrowOnServer ||\n !has(state.error, \"shouldThrowOnServer\"))\n ) {\n throw state.error;\n }\n};\n\n/**\n */\nconst dehydrate = (store: ReduxStore): string => {\n const state = store.getState();\n\n const modularui: {\n [key: string]: { status: string, lastModification: number, model: ?Object },\n } = {};\n\n for (const key in state.modularui) {\n const { status, model, lastModification } = state.modularui[key];\n\n if (model) {\n modularui[key] = {\n status,\n lastModification,\n model: model.dehydrate(),\n };\n } else {\n modularui[key] = {\n status,\n lastModification,\n model: undefined,\n };\n }\n }\n\n const filteredState = {\n ...state,\n modularui,\n };\n\n return JSON.stringify(filteredState).replace(/</g, \"\\\\u003c\");\n};\n\n/**\n */\nconst createHead = (\n sheet: any,\n UUID: string,\n helmetContext?: Object,\n): Object => {\n const style = sheet.getStyleTags();\n const meta = helmetContext ? [...helmetContext.helmet.meta] : [];\n\n if (helmetContext) {\n return {\n ...helmetContext.helmet,\n style,\n meta,\n };\n }\n\n return {\n style,\n meta,\n };\n};\n\nexport {\n createReduxStore,\n setI18n,\n setApplication,\n setServerPreferences,\n setConfigurationTheme,\n createHead,\n handleErrors,\n dehydrate,\n};\n"],"mappings":";;;;;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,eAAA,GAAAD,sBAAA,CAAAH,OAAA;AAEA,IAAAK,QAAA,GAAAC,uBAAA,CAAAN,OAAA;AAGA,IAAAO,mBAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AAEA,IAAAS,YAAA,GAAAT,OAAA;AASA,IAAAU,SAAA,GAAAV,OAAA;AAEA,IAAAW,WAAA,GAAAX,OAAA;AAEA,IAAAY,MAAA,GAAAZ,OAAA;AACA,IAAAa,KAAA,GAAAb,OAAA;AAEA,IAAAc,iBAAA,GAAAX,sBAAA,CAAAH,OAAA;AAA6D,SAAAM,wBAAA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GAAG;QACfQ,MAAM;QACNC,gBAAgB;QAChBR,KAAK,EAAEA,KAAK,CAACK,SAAS,CAAC;MACzB,CAAC;IACH,CAAC,MAAM;MACLC,SAAS,CAACP,GAAG,CAAC,GAAG;QACfQ,MAAM;QACNC,gBAAgB;QAChBR,KAAK,EAAE7D;MACT,CAAC;IACH;EACF;EAEA,MAAMsE,aAAa,GAAG;IACpB,GAAGP,KAAK;IACRI;EACF,CAAC;EAED,OAAO,IAAAI,UAAA,CAAA/F,OAAA,EAAe8F,aAAa,CAAC,CAACE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC;AAC/D,CAAC;;AAED;AACA;AADA7E,OAAA,CAAAuE,SAAA,GAAAA,SAAA;AAEA,MAAMO,UAAU,GAAGA,CACjBC,KAAU,EACVC,IAAY,EACZC,aAAsB,KACX;EACX,MAAMC,KAAK,GAAGH,KAAK,CAACI,YAAY,CAAC,CAAC;EAClC,MAAMC,IAAI,GAAGH,aAAa,GAAG,CAAC,GAAGA,aAAa,CAACI,MAAM,CAACD,IAAI,CAAC,GAAG,EAAE;EAEhE,IAAIH,aAAa,EAAE;IACjB,OAAO;MACL,GAAGA,aAAa,CAACI,MAAM;MACvBH,KAAK;MACLE;IACF,CAAC;EACH;EAEA,OAAO;IACLF,KAAK;IACLE;EACF,CAAC;AACH,CAAC;AAACpF,OAAA,CAAA8E,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18nActions.js","names":["_ProgressIndicator","require","receiveLocale","locale","type","payload","exports","updateLocale","dispatch","startProgress","finishProgress","setLocales","locales"],"sources":["../../../src/redux/_i18n/I18nActions.js"],"sourcesContent":["// @flow\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\n\nimport type Locales from \"../../i18n/Locales\";\nimport type { SetLocalesAction, UpdateLocaleAction } from \"./types\";\nimport type { ThunkAction } from \"../types\";\n\n/**\n * Update current locale\n */\nexport const receiveLocale = (locale: string): UpdateLocaleAction => ({\n type: \"UPDATE_LOCALE\",\n payload: locale,\n});\n\n/**\n * Change locale of application and redirect\n */\nexport const updateLocale =\n (locale: string): ThunkAction =>\n (dispatch) => {\n dispatch(startProgress());\n dispatch(receiveLocale(locale));\n
|
|
1
|
+
{"version":3,"file":"I18nActions.js","names":["_ProgressIndicator","require","receiveLocale","locale","type","payload","exports","updateLocale","dispatch","startProgress","finishProgress","setLocales","locales"],"sources":["../../../src/redux/_i18n/I18nActions.js"],"sourcesContent":["// @flow\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\n\nimport type Locales from \"../../i18n/Locales\";\nimport type { SetLocalesAction, UpdateLocaleAction } from \"./types\";\nimport type { ThunkAction } from \"../types\";\n\n/**\n * Update current locale\n */\nexport const receiveLocale = (locale: string): UpdateLocaleAction => ({\n type: \"UPDATE_LOCALE\",\n payload: locale,\n});\n\n/**\n * Change locale of application and redirect\n */\nexport const updateLocale =\n (locale: string): ThunkAction =>\n (dispatch) => {\n dispatch(startProgress());\n dispatch(receiveLocale(locale));\n dispatch(finishProgress());\n };\n\n/**\n */\nexport const setLocales = (\n locales: Locales,\n locale: string,\n): SetLocalesAction => ({\n type: \"SET_LOCALES\",\n payload: {\n locales,\n locale,\n },\n});\n"],"mappings":";;;;;;AACA,IAAAA,kBAAA,GAAAC,OAAA;AAMA;AACA;AACA;AACO,MAAMC,aAAa,GAAIC,MAAc,KAA0B;EACpEC,IAAI,EAAE,eAAe;EACrBC,OAAO,EAAEF;AACX,CAAC,CAAC;;AAEF;AACA;AACA;AAFAG,OAAA,CAAAJ,aAAA,GAAAA,aAAA;AAGO,MAAMK,YAAY,GACtBJ,MAAc,IACdK,QAAQ,IAAK;EACZA,QAAQ,CAAC,IAAAC,gCAAa,EAAC,CAAC,CAAC;EACzBD,QAAQ,CAACN,aAAa,CAACC,MAAM,CAAC,CAAC;EAC/BK,QAAQ,CAAC,IAAAE,iCAAc,EAAC,CAAC,CAAC;AAC5B,CAAC;;AAEH;AACA;AADAJ,OAAA,CAAAC,YAAA,GAAAA,YAAA;AAEO,MAAMI,UAAU,GAAGA,CACxBC,OAAgB,EAChBT,MAAc,MACQ;EACtBC,IAAI,EAAE,aAAa;EACnBC,OAAO,EAAE;IACPO,OAAO;IACPT;EACF;AACF,CAAC,CAAC;AAACG,OAAA,CAAAK,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
@@ -12,7 +12,11 @@ var _Locales = _interopRequireDefault(require("../../i18n/Locales"));
|
|
|
12
12
|
*/
|
|
13
13
|
const updateLocale = (state, locale) => {
|
|
14
14
|
// set locale in cookie
|
|
15
|
-
(
|
|
15
|
+
if (state.locales?.length > 1) {
|
|
16
|
+
(0, _Cookies.setCookie)("locale", locale);
|
|
17
|
+
} else {
|
|
18
|
+
(0, _Cookies.clearCookie)("locale");
|
|
19
|
+
}
|
|
16
20
|
|
|
17
21
|
// clear cache because of cached contributions
|
|
18
22
|
_Cache.default.clear();
|
|
@@ -30,7 +34,11 @@ const setLocales = (state, _ref) => {
|
|
|
30
34
|
locales
|
|
31
35
|
} = _ref;
|
|
32
36
|
// set locale in cookie
|
|
33
|
-
(
|
|
37
|
+
if (state.locales.length > 1) {
|
|
38
|
+
(0, _Cookies.setCookie)("locale", locale);
|
|
39
|
+
} else {
|
|
40
|
+
(0, _Cookies.clearCookie)("locale");
|
|
41
|
+
}
|
|
34
42
|
if (locale) {
|
|
35
43
|
return {
|
|
36
44
|
...state,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18nReducer.js","names":["_Cache","_interopRequireDefault","require","_Cookies","_Locales","updateLocale","state","locale","setCookie","Cache","clear","setLocales","_ref","
|
|
1
|
+
{"version":3,"file":"I18nReducer.js","names":["_Cache","_interopRequireDefault","require","_Cookies","_Locales","updateLocale","state","locale","locales","length","setCookie","clearCookie","Cache","clear","setLocales","_ref","getDefaultLocale","navigator","language","split","initialState","Locales","I18nReducer","arguments","undefined","action","type","payload","exports"],"sources":["../../../src/redux/_i18n/I18nReducer.js"],"sourcesContent":["// @flow\nimport Cache from \"../../utils/browser/Cache\";\nimport { setCookie, clearCookie } from \"../../utils/browser/Cookies\";\n\nimport Locales from \"../../i18n/Locales\";\n\nimport type { Reducer } from \"redux\";\nimport type { I18nState } from \"./types\";\nimport type { ReduxAction } from \"../types\";\n\n/**\n */\nconst updateLocale = (state: I18nState, locale: string) => {\n // set locale in cookie\n if (state.locales?.length > 1) {\n setCookie(\"locale\", locale);\n } else {\n clearCookie(\"locale\");\n }\n\n // clear cache because of cached contributions\n Cache.clear();\n\n return {\n ...state,\n locale,\n };\n};\n\n/**\n */\nconst setLocales = (\n state: I18nState,\n { locale, locales }: { locale: string, locales: Locales },\n) => {\n // set locale in cookie\n if (state.locales.length > 1) {\n setCookie(\"locale\", locale);\n } else {\n clearCookie(\"locale\");\n }\n\n if (locale) {\n return {\n ...state,\n locales,\n locale,\n };\n }\n\n return {\n ...state,\n locales,\n };\n};\n\nconst getDefaultLocale = () => {\n if (typeof navigator !== \"undefined\" && navigator?.language) {\n return navigator?.language.split(\"-\")[0] || \"en\";\n }\n return \"en\";\n};\n\n// REDUCER\nconst initialState: I18nState = {\n locales: new Locales(),\n locale: getDefaultLocale(),\n};\n\n/**\n * Form reducer\n */\nexport const I18nReducer: Reducer<I18nState, ReduxAction> = (\n state = initialState,\n action = void 0,\n) => {\n if (!action) {\n return state;\n }\n\n switch (action.type) {\n case \"SET_LOCALES\":\n return setLocales(state, action.payload);\n\n case \"UPDATE_LOCALE\":\n return updateLocale(state, action.payload);\n\n default:\n return state;\n }\n};\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAH,sBAAA,CAAAC,OAAA;AAMA;AACA;AACA,MAAMG,YAAY,GAAGA,CAACC,KAAgB,EAAEC,MAAc,KAAK;EACzD;EACA,IAAID,KAAK,CAACE,OAAO,EAAEC,MAAM,GAAG,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,MAAM,GAAAF,SAAA,CAAAd,MAAA,QAAAc,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,KAAK,CAAC;EAEf,IAAI,CAACE,MAAM,EAAE;IACX,OAAOnB,KAAK;EACd;EAEA,QAAQmB,MAAM,CAACC,IAAI;IACjB,KAAK,aAAa;MAChB,OAAOZ,UAAU,CAACR,KAAK,EAAEmB,MAAM,CAACE,OAAO,CAAC;IAE1C,KAAK,eAAe;MAClB,OAAOtB,YAAY,CAACC,KAAK,EAAEmB,MAAM,CAACE,OAAO,CAAC;IAE5C;MACE,OAAOrB,KAAK;EAChB;AACF,CAAC;AAACsB,OAAA,CAAAN,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -18,6 +18,7 @@ var _PreferencesReducer = _interopRequireDefault(require("./PreferencesReducer")
|
|
|
18
18
|
/**
|
|
19
19
|
*/
|
|
20
20
|
const createReducer = () => ({
|
|
21
|
+
preferences: _PreferencesReducer.default,
|
|
21
22
|
router: _RouterReducer.RouterReducer,
|
|
22
23
|
modularui: _ModularUIReducer.ModularUIReducer,
|
|
23
24
|
i18n: _I18nReducer.I18nReducer,
|
|
@@ -26,8 +27,7 @@ const createReducer = () => ({
|
|
|
26
27
|
modals: _ModalsReducer.default,
|
|
27
28
|
modelcatalog: _ModelCatalogReducer.default,
|
|
28
29
|
notification: _NotificationReducer.default,
|
|
29
|
-
progressindicator: _ProgressIndicatorReducer.default
|
|
30
|
-
preferences: _PreferencesReducer.default
|
|
30
|
+
progressindicator: _ProgressIndicatorReducer.default
|
|
31
31
|
});
|
|
32
32
|
exports.createReducer = createReducer;
|
|
33
33
|
//# sourceMappingURL=createReducer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createReducer.js","names":["_RouterReducer","require","_ModularUIReducer","_I18nReducer","_ModalsReducer","_interopRequireDefault","_AuthReducer","_ErrorReducer","_ModelCatalogReducer","_NotificationReducer","_ProgressIndicatorReducer","_PreferencesReducer","createReducer","router","RouterReducer","modularui","ModularUIReducer","i18n","I18nReducer","auth","AuthReducer","error","ErrorReducer","modals","ModalsReducer","modelcatalog","ModelCatalogReducer","notification","NotificationReducer","progressindicator","ProgressIndicatorReducer","
|
|
1
|
+
{"version":3,"file":"createReducer.js","names":["_RouterReducer","require","_ModularUIReducer","_I18nReducer","_ModalsReducer","_interopRequireDefault","_AuthReducer","_ErrorReducer","_ModelCatalogReducer","_NotificationReducer","_ProgressIndicatorReducer","_PreferencesReducer","createReducer","preferences","PreferencesReducer","router","RouterReducer","modularui","ModularUIReducer","i18n","I18nReducer","auth","AuthReducer","error","ErrorReducer","modals","ModalsReducer","modelcatalog","ModelCatalogReducer","notification","NotificationReducer","progressindicator","ProgressIndicatorReducer","exports"],"sources":["../../../src/redux/reducers/createReducer.js"],"sourcesContent":["// @flow\nimport { RouterReducer } from \"../_router/RouterReducer\";\nimport { ModularUIReducer } from \"../_modularui/ModularUIReducer\";\nimport { I18nReducer } from \"../_i18n/I18nReducer\";\n\nimport ModalsReducer from \"./ModalsReducer\";\nimport AuthReducer from \"./AuthReducer\";\nimport ErrorReducer from \"./ErrorReducer\";\nimport ModelCatalogReducer from \"./ModelCatalogReducer\";\nimport NotificationReducer from \"./NotificationReducer\";\nimport ProgressIndicatorReducer from \"./ProgressIndicatorReducer\";\nimport PreferencesReducer from \"./PreferencesReducer\";\n\nimport type { Reducer } from \"redux\";\nimport type {\n ReduxAction,\n ProgressIndicatorState,\n PreferencesState,\n NotificationState,\n ModalsState,\n ErrorState,\n AuthState,\n ModelCatalogState,\n} from \"../types\";\nimport type { RouterState } from \"../_router/types\";\nimport type { ModularUIState } from \"../_modularui/types\";\nimport type { I18nState } from \"../_i18n/types\";\n\ntype Reducers = {\n auth: Reducer<AuthState, ReduxAction>,\n error: Reducer<ErrorState, ReduxAction>,\n i18n: Reducer<I18nState, ReduxAction>,\n modals: Reducer<ModalsState, ReduxAction>,\n modelcatalog: Reducer<ModelCatalogState, ReduxAction>,\n modularui: Reducer<ModularUIState, ReduxAction>,\n notification: Reducer<NotificationState, ReduxAction>,\n preferences: Reducer<PreferencesState, ReduxAction>,\n progressindicator: Reducer<ProgressIndicatorState, ReduxAction>,\n router: Reducer<RouterState, ReduxAction>,\n};\n\n/**\n */\nexport const createReducer = (): Reducers => ({\n preferences: PreferencesReducer,\n router: RouterReducer,\n modularui: ModularUIReducer,\n i18n: I18nReducer,\n auth: AuthReducer,\n error: ErrorReducer,\n modals: ModalsReducer,\n modelcatalog: ModelCatalogReducer,\n notification: NotificationReducer,\n progressindicator: ProgressIndicatorReducer,\n});\n"],"mappings":";;;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEA,IAAAG,cAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAD,sBAAA,CAAAJ,OAAA;AACA,IAAAM,aAAA,GAAAF,sBAAA,CAAAJ,OAAA;AACA,IAAAO,oBAAA,GAAAH,sBAAA,CAAAJ,OAAA;AACA,IAAAQ,oBAAA,GAAAJ,sBAAA,CAAAJ,OAAA;AACA,IAAAS,yBAAA,GAAAL,sBAAA,CAAAJ,OAAA;AACA,IAAAU,mBAAA,GAAAN,sBAAA,CAAAJ,OAAA;AA8BA;AACA;AACO,MAAMW,aAAa,GAAGA,CAAA,MAAiB;EAC5CC,WAAW,EAAEC,2BAAkB;EAC/BC,MAAM,EAAEC,4BAAa;EACrBC,SAAS,EAAEC,kCAAgB;EAC3BC,IAAI,EAAEC,wBAAW;EACjBC,IAAI,EAAEC,oBAAW;EACjBC,KAAK,EAAEC,qBAAY;EACnBC,MAAM,EAAEC,sBAAa;EACrBC,YAAY,EAAEC,4BAAmB;EACjCC,YAAY,EAAEC,4BAAmB;EACjCC,iBAAiB,EAAEC;AACrB,CAAC,CAAC;AAACC,OAAA,CAAArB,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -11,7 +11,6 @@ var _RouterMiddleware = require("../_router/RouterMiddleware");
|
|
|
11
11
|
var _ModularUIMiddleware = require("../_modularui/ModularUIMiddleware");
|
|
12
12
|
var _createReducer = require("../reducers/createReducer");
|
|
13
13
|
var _RouterActions = require("../_router/RouterActions");
|
|
14
|
-
var _I18nActions = require("../_i18n/I18nActions");
|
|
15
14
|
/**
|
|
16
15
|
*/
|
|
17
16
|
const configureStore = (routerHistory, customReducers, initialState) => {
|
|
@@ -29,10 +28,6 @@ const configureStore = (routerHistory, customReducers, initialState) => {
|
|
|
29
28
|
if (!initialState?.router) {
|
|
30
29
|
store.dispatch((0, _RouterActions.locationChange)(routerHistory.location, "PUSH"));
|
|
31
30
|
}
|
|
32
|
-
const locale = initialState?.i18n.locale;
|
|
33
|
-
if (locale) {
|
|
34
|
-
store.dispatch((0, _I18nActions.updateLocale)(locale));
|
|
35
|
-
}
|
|
36
31
|
return {
|
|
37
32
|
routerHistory,
|
|
38
33
|
store
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configureStore.js","names":["_redux","require","_reduxThunk","_interopRequireDefault","_RouterMiddleware","_ModularUIMiddleware","_createReducer","_RouterActions","
|
|
1
|
+
{"version":3,"file":"configureStore.js","names":["_redux","require","_reduxThunk","_interopRequireDefault","_RouterMiddleware","_ModularUIMiddleware","_createReducer","_RouterActions","configureStore","routerHistory","customReducers","initialState","composeEnhancers","compose","process","env","NODE_ENV","window","__REDUX_DEVTOOLS_EXTENSION_COMPOSE__","combinedReducers","combineReducers","createReducer","middleware","applyMiddleware","modularUIMiddleware","routerMiddleware","thunk","enhancers","store","createReduxStore","router","dispatch","locationChange","location","_default","exports","default"],"sources":["../../../src/redux/store/configureStore.js"],"sourcesContent":["// @flow\nimport {\n applyMiddleware,\n compose,\n combineReducers,\n createStore as createReduxStore,\n} from \"redux\";\nimport thunk from \"redux-thunk\";\n\nimport { routerMiddleware } from \"../_router/RouterMiddleware\";\nimport { modularUIMiddleware } from \"../_modularui/ModularUIMiddleware\";\n\nimport { createReducer } from \"../reducers/createReducer\";\nimport { locationChange } from \"../_router/RouterActions\";\n\nimport type { RouterHistory } from \"react-router\";\nimport type { ReduxAction, ReduxState, ReduxStore } from \"../types\";\nimport type { Reducer } from \"redux\";\n\n/**\n */\nconst configureStore = (\n routerHistory: RouterHistory,\n customReducers?: Object,\n initialState?: $Shape<ReduxState>,\n): { routerHistory: RouterHistory, store: ReduxStore } => {\n let composeEnhancers = compose;\n\n if (process.env.NODE_ENV !== \"production\" && typeof window !== \"undefined\") {\n composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;\n }\n\n const combinedReducers: Reducer<ReduxState, ReduxAction> = combineReducers({\n ...customReducers,\n ...createReducer(),\n });\n\n const middleware = applyMiddleware(\n modularUIMiddleware,\n routerMiddleware(routerHistory),\n thunk,\n );\n\n const enhancers = composeEnhancers(middleware);\n\n const store: ReduxStore = createReduxStore(\n combinedReducers,\n initialState,\n enhancers,\n );\n\n if (!initialState?.router) {\n store.dispatch(locationChange(routerHistory.location, \"PUSH\"));\n }\n\n return { routerHistory, store };\n};\n\nexport default configureStore;\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAMA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,oBAAA,GAAAJ,OAAA;AAEA,IAAAK,cAAA,GAAAL,OAAA;AACA,IAAAM,cAAA,GAAAN,OAAA;AAMA;AACA;AACA,MAAMO,cAAc,GAAGA,CACrBC,aAA4B,EAC5BC,cAAuB,EACvBC,YAAiC,KACuB;EACxD,IAAIC,gBAAgB,GAAGC,cAAO;EAE9B,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IAC1EL,gBAAgB,GAAGK,MAAM,CAACC,oCAAoC,IAAIL,cAAO;EAC3E;EAEA,MAAMM,gBAAkD,GAAG,IAAAC,sBAAe,EAAC;IACzE,GAAGV,cAAc;IACjB,GAAG,IAAAW,4BAAa,EAAC;EACnB,CAAC,CAAC;EAEF,MAAMC,UAAU,GAAG,IAAAC,sBAAe,EAChCC,wCAAmB,EACnB,IAAAC,kCAAgB,EAAChB,aAAa,CAAC,EAC/BiB,mBACF,CAAC;EAED,MAAMC,SAAS,GAAGf,gBAAgB,CAACU,UAAU,CAAC;EAE9C,MAAMM,KAAiB,GAAG,IAAAC,kBAAgB,EACxCV,gBAAgB,EAChBR,YAAY,EACZgB,SACF,CAAC;EAED,IAAI,CAAChB,YAAY,EAAEmB,MAAM,EAAE;IACzBF,KAAK,CAACG,QAAQ,CAAC,IAAAC,6BAAc,EAACvB,aAAa,CAACwB,QAAQ,EAAE,MAAM,CAAC,CAAC;EAChE;EAEA,OAAO;IAAExB,aAAa;IAAEmB;EAAM,CAAC;AACjC,CAAC;AAAC,IAAAM,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa5B,cAAc","ignoreList":[]}
|
|
@@ -105,7 +105,8 @@ class BaseDateTimeUtil {
|
|
|
105
105
|
/**
|
|
106
106
|
*/
|
|
107
107
|
getLocale() {
|
|
108
|
-
const
|
|
108
|
+
const defaultLocale = (0, _constants.getEnabledLocales)()[0];
|
|
109
|
+
const locale = (0, _Cookies.getCookie)("locale") ?? defaultLocale ?? "en";
|
|
109
110
|
if (locale === "nl") {
|
|
110
111
|
return _locale.nl;
|
|
111
112
|
}
|