@beinformed/ui 1.27.5 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -1
- package/esm/constants/LayoutHintConfig.js +0 -9
- package/esm/constants/LayoutHintConfig.js.map +1 -1
- package/esm/constants/LayoutHints.js +0 -4
- package/esm/constants/LayoutHints.js.map +1 -1
- package/esm/constants/Settings.js +0 -4
- package/esm/constants/Settings.js.map +1 -1
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeModel.js +1 -0
- package/esm/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeOptionModel.js +2 -2
- package/esm/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/esm/models/attributes/DatetimeAttributeModel.js +3 -29
- package/esm/models/attributes/DatetimeAttributeModel.js.map +1 -1
- package/esm/react-client/Init.js +2 -2
- package/esm/react-client/Init.js.map +1 -1
- package/esm/react-client/client.js +80 -52
- package/esm/react-client/client.js.map +1 -1
- package/esm/redux/_modularui/ModularUIActions.js +7 -0
- package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
- package/esm/redux/_modularui/ModularUIReducer.js +1 -0
- package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/esm/redux/_modularui/types.js.map +1 -1
- package/esm/redux/actions/Form.js +2 -2
- package/esm/redux/actions/Form.js.map +1 -1
- package/esm/redux/actions/FormAttributeSet.js +2 -2
- package/esm/redux/actions/FormAttributeSet.js.map +1 -1
- package/esm/redux/actions/FormAttributeSetRepeatable.js +4 -4
- package/esm/redux/actions/FormAttributeSetRepeatable.js.map +1 -1
- package/esm/redux/actions/FormAutosave.js +2 -2
- package/esm/redux/actions/FormAutosave.js.map +1 -1
- package/esm/redux/actions/FormValidations.js +2 -2
- package/esm/redux/actions/FormValidations.js.map +1 -1
- package/esm/redux/connectors/Form.js.map +1 -1
- package/esm/redux/connectors/FormAttributeSet.js.map +1 -1
- package/esm/redux/store/configureStore.js +4 -4
- package/esm/redux/store/configureStore.js.map +1 -1
- package/esm/redux/types.js.map +1 -1
- package/lib/constants/LayoutHintConfig.js +0 -9
- package/lib/constants/LayoutHintConfig.js.flow +0 -9
- package/lib/constants/LayoutHintConfig.js.map +1 -1
- package/lib/constants/LayoutHints.js +2 -7
- package/lib/constants/LayoutHints.js.flow +0 -4
- package/lib/constants/LayoutHints.js.map +1 -1
- package/lib/constants/Settings.js +0 -4
- package/lib/constants/Settings.js.flow +0 -6
- package/lib/constants/Settings.js.map +1 -1
- package/lib/hooks/__tests__/useForm.spec.js.flow +4 -4
- package/lib/hooks/useForm.js.flow +5 -5
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeModel.js +1 -0
- package/lib/models/attributes/ChoiceAttributeModel.js.flow +1 -0
- package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeOptionModel.js +2 -2
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.flow +2 -2
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/lib/models/attributes/DatetimeAttributeModel.js +3 -29
- package/lib/models/attributes/DatetimeAttributeModel.js.flow +7 -41
- package/lib/models/attributes/DatetimeAttributeModel.js.map +1 -1
- package/lib/models/attributes/__tests__/DateAttributeModel.spec.js.flow +1 -35
- package/lib/models/attributes/__tests__/DatetimeAttributeModel.spec.js.flow +158 -216
- package/lib/models/attributes/__tests__/TimestampModel.spec.js.flow +0 -5
- package/lib/react-client/Init.js +2 -2
- package/lib/react-client/Init.js.flow +3 -3
- package/lib/react-client/Init.js.map +1 -1
- package/lib/react-client/client.js +83 -53
- package/lib/react-client/client.js.flow +106 -67
- package/lib/react-client/client.js.map +1 -1
- package/lib/redux/_modularui/ModularUIActions.js +9 -1
- package/lib/redux/_modularui/ModularUIActions.js.flow +8 -0
- package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
- package/lib/redux/_modularui/ModularUIReducer.js +1 -0
- package/lib/redux/_modularui/ModularUIReducer.js.flow +1 -0
- package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/lib/redux/_modularui/types.js.flow +5 -0
- package/lib/redux/_modularui/types.js.map +1 -1
- package/lib/redux/actions/Form.js +1 -1
- package/lib/redux/actions/Form.js.flow +4 -4
- package/lib/redux/actions/Form.js.map +1 -1
- package/lib/redux/actions/FormAttributeSet.js +1 -1
- package/lib/redux/actions/FormAttributeSet.js.flow +3 -2
- package/lib/redux/actions/FormAttributeSet.js.map +1 -1
- package/lib/redux/actions/FormAttributeSetRepeatable.js +3 -3
- package/lib/redux/actions/FormAttributeSetRepeatable.js.flow +8 -8
- package/lib/redux/actions/FormAttributeSetRepeatable.js.map +1 -1
- package/lib/redux/actions/FormAutosave.js +1 -1
- package/lib/redux/actions/FormAutosave.js.flow +2 -2
- package/lib/redux/actions/FormAutosave.js.map +1 -1
- package/lib/redux/actions/FormValidations.js +1 -1
- package/lib/redux/actions/FormValidations.js.flow +2 -2
- package/lib/redux/actions/FormValidations.js.map +1 -1
- package/lib/redux/actions/__tests__/Form.spec.js.flow +1 -1
- package/lib/redux/connectors/Form.js.flow +2 -5
- package/lib/redux/connectors/Form.js.map +1 -1
- package/lib/redux/connectors/FormAttributeSet.js.flow +5 -5
- package/lib/redux/connectors/FormAttributeSet.js.map +1 -1
- package/lib/redux/store/configureStore.js +4 -4
- package/lib/redux/store/configureStore.js.flow +5 -5
- package/lib/redux/store/configureStore.js.map +1 -1
- package/lib/redux/types.js.flow +2 -0
- package/lib/redux/types.js.map +1 -1
- package/package.json +17 -19
- package/src/constants/LayoutHintConfig.js +0 -9
- package/src/constants/LayoutHints.js +0 -4
- package/src/constants/Settings.js +0 -6
- package/src/hooks/__tests__/useForm.spec.js +4 -4
- package/src/hooks/useForm.js +5 -5
- package/src/models/attributes/ChoiceAttributeModel.js +1 -0
- package/src/models/attributes/ChoiceAttributeOptionModel.js +2 -2
- package/src/models/attributes/DatetimeAttributeModel.js +7 -41
- package/src/models/attributes/__tests__/DateAttributeModel.spec.js +1 -35
- package/src/models/attributes/__tests__/DatetimeAttributeModel.spec.js +158 -216
- package/src/models/attributes/__tests__/TimestampModel.spec.js +0 -5
- package/src/react-client/Init.js +3 -3
- package/src/react-client/client.js +106 -67
- package/src/redux/_modularui/ModularUIActions.js +8 -0
- package/src/redux/_modularui/ModularUIReducer.js +1 -0
- package/src/redux/_modularui/types.js +5 -0
- package/src/redux/actions/Form.js +4 -4
- package/src/redux/actions/FormAttributeSet.js +3 -2
- package/src/redux/actions/FormAttributeSetRepeatable.js +8 -8
- package/src/redux/actions/FormAutosave.js +2 -2
- package/src/redux/actions/FormValidations.js +2 -2
- package/src/redux/actions/__tests__/Form.spec.js +1 -1
- package/src/redux/connectors/Form.js +2 -5
- package/src/redux/connectors/FormAttributeSet.js +5 -5
- package/src/redux/store/configureStore.js +5 -5
- package/src/redux/types.js +2 -0
- package/types/constants/LayoutHintConfig.d.ts +8 -23
- package/types/constants/LayoutHints.d.ts +0 -4
- package/types/models/actions/ActionCollection.d.ts +1 -1
- package/types/models/attributes/DatetimeAttributeModel.d.ts +8 -2
- package/types/redux/_modularui/types.d.ts +4 -0
- package/types/redux/types.d.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatetimeAttributeModel.js","names":["has","DateUtil","DateTimeUtil","TimeUtil","TimestampUtil","StringAttributeModel","ConstraintCollection","DateTimeDateFormatConstraint","DateTimeTimeFormatConstraint","DatetimeFormatConstraint","DateBoundaryConstraint","ATTRIBUTE_WIDTH","ISO_DATE_FORMAT","getSetting","IGNORE_FORMAT_SETTING","PRODUCT_DEFAULT_DATE_FORMAT","DatetimeAttributeModel","constructor","attribute","attributeContributions","updateInitValue","isApplicableModel","contributions","type","formatUtil","getInitValue","value","data","length","split","hasTime","getTimeValue","timeValue","timeInputFormat","toLowerCase","setHour","setMinute","setSecond","setMilliseconds","_initvalue","_inputvalue","getInitialInputValue","_value","initValue","toFormat","inputFormat","getContribution","getInputValue","toString","inputvalue","validate","toISO","format","convertFormat","operator","hasDate","formatLabel","dateInputFormat","ignoreFormatSetting","layouthint","dateInputFormatSetting","dateFormat","replace","dateReadonlyFormat","readonlyFormatSetting","placeholder","_placeholder","timeFormatParts","push","timeFormat","join","timeReadonlyFormat","dateInputValue","timeInputValue","formatValue","hasFormat","dateTimeReadonlyFormat","readonlyvalue","mindate","maxdate","addServerError","error","id","message","properties","_errorCollection","getFormatConstraint","addConstraints","constraints","add","readonlyWidth","SMALL","MEDIUM"],"sources":["../../../src/models/attributes/DatetimeAttributeModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport {\n DateUtil,\n DateTimeUtil,\n TimeUtil,\n TimestampUtil,\n} from \"../../utils/datetime/DateTimeUtil\";\n\nimport StringAttributeModel from \"./StringAttributeModel\";\n\nimport ConstraintCollection from \"./input-constraints/ConstraintCollection\";\nimport DateTimeDateFormatConstraint from \"./input-constraints/DateTimeDateFormatConstraint\";\nimport DateTimeTimeFormatConstraint from \"./input-constraints/DateTimeTimeFormatConstraint\";\nimport DatetimeFormatConstraint from \"./input-constraints/DatetimeFormatConstraint\";\nimport DateBoundaryConstraint from \"./input-constraints/DateBoundaryConstraint\";\n\nimport { ATTRIBUTE_WIDTH, ISO_DATE_FORMAT } from \"../../constants\";\nimport { getSetting } from \"../../constants/Settings\";\nimport { IGNORE_FORMAT_SETTING } from \"../../constants/LayoutHints\";\n\nimport type { FormErrorAnchor, IConstraintModel } from \"../types\";\n\n// date format of default\nconst PRODUCT_DEFAULT_DATE_FORMAT = \"dd-MM-yyyy\";\n\n/**\n */\nclass DatetimeAttributeModel extends StringAttributeModel {\n /**\n */\n constructor(attribute: Object, attributeContributions: Object) {\n super(attribute, attributeContributions);\n\n this.updateInitValue();\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return [\"date\", \"time\", \"datetime\", \"timestamp\"].includes(\n contributions.type\n );\n }\n\n /**\n */\n get formatUtil():\n | typeof TimeUtil\n | typeof TimestampUtil\n | typeof DateTimeUtil\n | typeof DateUtil {\n switch (this.type) {\n case \"time\":\n return TimeUtil;\n case \"timestamp\":\n return TimestampUtil;\n case \"datetime\":\n return DateTimeUtil;\n default:\n return DateUtil;\n }\n }\n\n /**\n */\n getInitValue(): string | null {\n let value = this.data.value;\n if (value != null) {\n if (this.type === \"time\" && value.length === 5) {\n value = `${value}:00`;\n }\n\n // handle old datetime values, which contained ms\n if (this.type === \"datetime\" && value.includes(\".\")) {\n value = value.split(\".\")[0];\n }\n\n if (this.hasTime) {\n value = this.getTimeValue(value);\n }\n }\n\n return value;\n }\n\n /**\n */\n getTimeValue(value: string): string {\n let timeValue = value;\n if (!this.timeInputFormat.toLowerCase().includes(\"h\")) {\n timeValue = this.formatUtil.setHour(value, 0);\n }\n if (!this.timeInputFormat.includes(\"m\")) {\n timeValue = this.formatUtil.setMinute(value, 0);\n }\n if (!this.timeInputFormat.includes(\"s\")) {\n timeValue = this.formatUtil.setSecond(value, 0);\n }\n if (this.type === \"timestamp\" && !this.timeInputFormat.includes(\"S\")) {\n timeValue = this.formatUtil.setMilliseconds(value, 0);\n }\n return timeValue;\n }\n\n /**\n * Set time in the correct value based on available elements in the time format\n */\n updateInitValue() {\n const value = this.getInitValue();\n if (value != null) {\n this._initvalue = value;\n this._inputvalue = this.getInitialInputValue(value);\n this._value = value;\n }\n }\n\n /**\n * Get initial user input value\n */\n getInitialInputValue(value?: string): string {\n if (!value) {\n return \"\";\n }\n\n let initValue = value;\n if (this.type === \"time\" && value.length === 5) {\n initValue = `${value}:00`;\n }\n\n return this.formatUtil.toFormat(initValue, this.inputFormat);\n }\n\n /**\n * Set type to date\n */\n get type(): string {\n return this.getContribution(\"type\", \"date\");\n }\n\n /**\n * Returns the value as entered by the user. This can differ from the internal iso value that is stored\n */\n getInputValue(): string {\n return this._inputvalue ? this._inputvalue.toString() : \"\";\n }\n\n /**\n * Get input value\n */\n get inputvalue(): string {\n return this.getInputValue();\n }\n\n /**\n * Sets the input value to the value entered by the user\n */\n set inputvalue(value: string) {\n this.validate(value);\n\n this._inputvalue = value;\n\n this.value =\n value !== null && value !== \"\"\n ? this.formatUtil.toISO(value, this.inputFormat)\n : null;\n }\n\n /**\n * Get date format\n */\n get format(): string {\n const format = this.getContribution(\"format\", \"\");\n return this.formatUtil.convertFormat(format);\n }\n\n /**\n */\n get operator(): string {\n return this.getContribution(\"operator\", \"\");\n }\n\n /**\n */\n get hasDate(): boolean {\n return (\n this.type === \"date\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get hasTime(): boolean {\n return (\n this.type === \"time\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get formatLabel(): string {\n switch (this.type) {\n case \"date\":\n return this.dateInputFormat.toLowerCase();\n case \"time\":\n return this.timeInputFormat.toLowerCase();\n default:\n return this.format.toLowerCase();\n }\n }\n\n /**\n */\n get inputFormat(): string {\n if (this.hasDate && this.hasTime) {\n return `${this.dateInputFormat} ${this.timeInputFormat}`.trim();\n }\n\n if (this.hasDate) {\n return this.dateInputFormat;\n }\n\n if (this.hasTime) {\n return this.timeInputFormat;\n }\n\n return \"\";\n }\n\n /**\n */\n get dateInputFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n // setting for date input\n const ignoreFormatSetting = this.layouthint.has(IGNORE_FORMAT_SETTING);\n if (!ignoreFormatSetting) {\n const dateInputFormatSetting = getSetting(\"DATE_INPUT_FORMAT\", \"\");\n if (dateInputFormatSetting) {\n return dateInputFormatSetting;\n }\n }\n\n let format = this.format;\n\n let dateFormat = this.hasTime\n ? format.replace(this.timeInputFormat, \"\").trim()\n : format;\n\n return dateFormat;\n }\n\n /**\n */\n get dateReadonlyFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n let format = this.format;\n\n let dateFormat = this.hasTime\n ? format.replace(this.timeInputFormat, \"\").trim()\n : format;\n\n const readonlyFormatSetting = getSetting(\"DATE_READONLY_FORMAT\", \"\");\n\n if (dateFormat === PRODUCT_DEFAULT_DATE_FORMAT && readonlyFormatSetting) {\n dateFormat = readonlyFormatSetting;\n }\n\n return dateFormat;\n }\n\n /**\n * return attribute placeholder or, if DATE_INPUT_FORMAT setting is used, lowercased setting, otherwise return formatlabel without time input format from contributions\n */\n get placeholder(): string {\n if (this._placeholder !== \"\") {\n return this._placeholder;\n }\n\n const dateInputFormatSetting = getSetting(\"DATE_INPUT_FORMAT\", \"\");\n\n if (dateInputFormatSetting) {\n return dateInputFormatSetting.toLowerCase();\n }\n\n const formatLabel = this.getContribution(\"formatlabel\", \"\");\n\n if (this.hasDate && this.hasTime && formatLabel.includes(\" \")) {\n // return first part of formatlabel to keep placeholder matching date input\n return formatLabel.split(\" \")[0];\n }\n\n return formatLabel;\n }\n\n /**\n * Set placeholder text\n */\n set placeholder(placeholder: string) {\n this._placeholder = placeholder;\n }\n\n /**\n */\n get timeInputFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n const format = this.format;\n\n let timeFormatParts = [];\n if (format.includes(\"H\")) {\n timeFormatParts.push(\"HH\");\n } else if (format.includes(\"h\")) {\n timeFormatParts.push(\"hh\");\n }\n if (format.includes(\"m\")) {\n timeFormatParts.push(\"mm\");\n }\n if (format.includes(\"s\")) {\n timeFormatParts.push(\"ss\");\n }\n\n let timeFormat = timeFormatParts.join(\":\");\n if (format.includes(\"S\")) {\n timeFormat = `${timeFormat}.SSS`;\n }\n if (format.includes(\"a\")) {\n return `${timeFormat} a`;\n }\n return timeFormat;\n }\n\n /**\n */\n get timeReadonlyFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n return this.timeInputFormat;\n }\n\n /**\n */\n get dateInputValue(): string {\n return typeof this.value === \"string\" && this.dateInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.dateInputFormat)\n : \"\";\n }\n\n /**\n */\n get timeInputValue(): string {\n return typeof this.value === \"string\" && this.timeInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.timeInputFormat)\n : \"\";\n }\n\n // format value in readonly rendering\n /**\n */\n formatValue(value: ?string): string {\n if (value == null || value.toString() === \"\") {\n return \"\";\n }\n\n // when the value is exactly an iso date, render as date\n if (\n (this.type === \"datetime\" || this.type === \"timestamp\") &&\n DateUtil.hasFormat(value, ISO_DATE_FORMAT)\n ) {\n return DateUtil.toFormat(value, this.dateReadonlyFormat);\n }\n\n if (this.hasDate && this.hasTime) {\n const dateTimeReadonlyFormat = `${this.dateReadonlyFormat} ${this.timeReadonlyFormat}`;\n return this.formatUtil.toFormat(value, dateTimeReadonlyFormat);\n }\n\n if (this.type === \"date\") {\n return this.formatUtil.toFormat(value, this.dateReadonlyFormat);\n }\n\n return this.formatUtil.toFormat(value, this.format);\n }\n\n /**\n * Retrieve readonly value, the date in the configurated format\n */\n get readonlyvalue(): string {\n if (typeof this.value === \"string\") {\n return this.formatValue(this.value.toString());\n }\n\n return \"\";\n }\n\n /**\n * Get minimum date\n */\n get mindate(): string | null {\n return this.getContribution(\"mindate\");\n }\n\n /**\n * Get maximum date\n */\n get maxdate(): string | null {\n return this.getContribution(\"maxdate\");\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n const { id, message, properties, layouthint } = error;\n if (properties && has(properties, \"format\") && this.formatLabel) {\n properties.format = this.formatLabel;\n }\n\n this._errorCollection.addServerError(id, message, properties, layouthint);\n }\n\n /**\n */\n getFormatConstraint(): IConstraintModel {\n switch (this.type) {\n case \"date\":\n return new DateTimeDateFormatConstraint(\n this.dateInputFormat,\n this.formatLabel\n );\n case \"time\":\n return new DateTimeTimeFormatConstraint(\n this.timeInputFormat,\n this.formatLabel\n );\n default:\n return new DatetimeFormatConstraint(\n this.type,\n this.inputFormat,\n this.formatLabel\n );\n }\n }\n\n /**\n * Add Date constraints for attribute\n */\n addConstraints(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n\n constraints.add(this.getFormatConstraint());\n\n if (this.mindate || this.maxdate) {\n constraints.add(\n new DateBoundaryConstraint(\n this.type,\n this.mindate,\n this.maxdate,\n this.inputFormat\n )\n );\n }\n\n return constraints;\n }\n\n /**\n */\n get readonlyWidth(): $Keys<typeof ATTRIBUTE_WIDTH> {\n if (this.type === \"date\" || this.type === \"time\") {\n return ATTRIBUTE_WIDTH.SMALL;\n }\n\n return ATTRIBUTE_WIDTH.MEDIUM;\n }\n}\n\nexport default DatetimeAttributeModel;\n"],"mappings":";;AACA,SAASA,GAAG,QAAQ,6BAA6B;AAEjD,SACEC,QAAQ,EACRC,YAAY,EACZC,QAAQ,EACRC,aAAa,QACR,mCAAmC;AAE1C,OAAOC,oBAAoB,MAAM,wBAAwB;AAEzD,OAAOC,oBAAoB,MAAM,0CAA0C;AAC3E,OAAOC,4BAA4B,MAAM,kDAAkD;AAC3F,OAAOC,4BAA4B,MAAM,kDAAkD;AAC3F,OAAOC,wBAAwB,MAAM,8CAA8C;AACnF,OAAOC,sBAAsB,MAAM,4CAA4C;AAE/E,SAASC,eAAe,EAAEC,eAAe,QAAQ,iBAAiB;AAClE,SAASC,UAAU,QAAQ,0BAA0B;AACrD,SAASC,qBAAqB,QAAQ,6BAA6B;AAInE;AACA,MAAMC,2BAA2B,GAAG,YAAY;;AAEhD;AACA;AACA,MAAMC,sBAAsB,SAASX,oBAAoB,CAAC;EACxD;AACF;EACEY,WAAW,CAACC,SAAiB,EAAEC,sBAA8B,EAAE;IAC7D,KAAK,CAACD,SAAS,EAAEC,sBAAsB,CAAC;IAExC,IAAI,CAACC,eAAe,EAAE;EACxB;;EAEA;AACF;EACE,OAAOC,iBAAiB,CAACC,aAAqB,EAAW;IAAA;IACvD,OAAO,sCAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,iBAC9CA,aAAa,CAACC,IAAI,CACnB;EACH;;EAEA;AACF;EACE,IAAIC,UAAU,GAIM;IAClB,QAAQ,IAAI,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I,IAAI,CAACnE,IAAI,KAAK,MAAM,IAAI,IAAI,CAACA,IAAI,KAAK,MAAM,EAAE;MAChD,OAAOZ,eAAe,CAACgF,KAAK;IAC9B;IAEA,OAAOhF,eAAe,CAACiF,MAAM;EAC/B;AACF;AAEA,eAAe5E,sBAAsB"}
|
|
1
|
+
{"version":3,"file":"DatetimeAttributeModel.js","names":["has","DateUtil","DateTimeUtil","TimeUtil","TimestampUtil","StringAttributeModel","ConstraintCollection","DateTimeDateFormatConstraint","DateTimeTimeFormatConstraint","DatetimeFormatConstraint","DateBoundaryConstraint","ATTRIBUTE_WIDTH","ISO_DATE_FORMAT","DatetimeAttributeModel","constructor","attribute","attributeContributions","updateInitValue","isApplicableModel","contributions","type","formatUtil","getInitValue","value","data","length","split","hasTime","getTimeValue","timeValue","timeInputFormat","toLowerCase","setHour","setMinute","setSecond","setMilliseconds","_initvalue","_inputvalue","getInitialInputValue","_value","initValue","toFormat","inputFormat","getContribution","getInputValue","toString","inputvalue","validate","toISO","format","convertFormat","operator","hasDate","formatLabel","dateInputFormat","replace","dateReadonlyFormat","placeholder","_placeholder","timeFormatParts","push","timeFormat","join","timeReadonlyFormat","dateInputValue","timeInputValue","formatValue","hasFormat","dateTimeReadonlyFormat","readonlyvalue","mindate","maxdate","addServerError","error","id","message","properties","layouthint","_errorCollection","getFormatConstraint","addConstraints","constraints","add","readonlyWidth","SMALL","MEDIUM"],"sources":["../../../src/models/attributes/DatetimeAttributeModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport {\n DateUtil,\n DateTimeUtil,\n TimeUtil,\n TimestampUtil,\n} from \"../../utils/datetime/DateTimeUtil\";\n\nimport StringAttributeModel from \"./StringAttributeModel\";\n\nimport ConstraintCollection from \"./input-constraints/ConstraintCollection\";\nimport DateTimeDateFormatConstraint from \"./input-constraints/DateTimeDateFormatConstraint\";\nimport DateTimeTimeFormatConstraint from \"./input-constraints/DateTimeTimeFormatConstraint\";\nimport DatetimeFormatConstraint from \"./input-constraints/DatetimeFormatConstraint\";\nimport DateBoundaryConstraint from \"./input-constraints/DateBoundaryConstraint\";\n\nimport { ATTRIBUTE_WIDTH, ISO_DATE_FORMAT } from \"../../constants\";\n\nimport type { FormErrorAnchor, IConstraintModel } from \"../types\";\n\n/**\n */\nclass DatetimeAttributeModel extends StringAttributeModel {\n /**\n */\n constructor(attribute: Object, attributeContributions: Object) {\n super(attribute, attributeContributions);\n\n this.updateInitValue();\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return [\"date\", \"time\", \"datetime\", \"timestamp\"].includes(\n contributions.type\n );\n }\n\n /**\n */\n get formatUtil():\n | typeof TimeUtil\n | typeof TimestampUtil\n | typeof DateTimeUtil\n | typeof DateUtil {\n switch (this.type) {\n case \"time\":\n return TimeUtil;\n case \"timestamp\":\n return TimestampUtil;\n case \"datetime\":\n return DateTimeUtil;\n default:\n return DateUtil;\n }\n }\n\n /**\n */\n getInitValue(): string | null {\n let value = this.data.value;\n if (value != null) {\n if (this.type === \"time\" && value.length === 5) {\n value = `${value}:00`;\n }\n\n // handle old datetime values, which contained ms\n if (this.type === \"datetime\" && value.includes(\".\")) {\n value = value.split(\".\")[0];\n }\n\n if (this.hasTime) {\n value = this.getTimeValue(value);\n }\n }\n\n return value;\n }\n\n /**\n */\n getTimeValue(value: string): string {\n let timeValue = value;\n if (!this.timeInputFormat.toLowerCase().includes(\"h\")) {\n timeValue = this.formatUtil.setHour(value, 0);\n }\n if (!this.timeInputFormat.includes(\"m\")) {\n timeValue = this.formatUtil.setMinute(value, 0);\n }\n if (!this.timeInputFormat.includes(\"s\")) {\n timeValue = this.formatUtil.setSecond(value, 0);\n }\n if (this.type === \"timestamp\" && !this.timeInputFormat.includes(\"S\")) {\n timeValue = this.formatUtil.setMilliseconds(value, 0);\n }\n return timeValue;\n }\n\n /**\n * Set time in the correct value based on available elements in the time format\n */\n updateInitValue() {\n const value = this.getInitValue();\n if (value != null) {\n this._initvalue = value;\n this._inputvalue = this.getInitialInputValue(value);\n this._value = value;\n }\n }\n\n /**\n * Get initial user input value\n */\n getInitialInputValue(value?: string): string {\n if (!value) {\n return \"\";\n }\n\n let initValue = value;\n if (this.type === \"time\" && value.length === 5) {\n initValue = `${value}:00`;\n }\n\n return this.formatUtil.toFormat(initValue, this.inputFormat);\n }\n\n /**\n * Set type to date\n */\n get type(): string {\n return this.getContribution(\"type\", \"date\");\n }\n\n /**\n * Returns the value as entered by the user. This can differ from the internal iso value that is stored\n */\n getInputValue(): string {\n return this._inputvalue ? this._inputvalue.toString() : \"\";\n }\n\n /**\n * Get input value\n */\n get inputvalue(): string {\n return this.getInputValue();\n }\n\n /**\n * Sets the input value to the value entered by the user\n */\n set inputvalue(value: string) {\n this.validate(value);\n\n this._inputvalue = value;\n\n this.value =\n value !== null && value !== \"\"\n ? this.formatUtil.toISO(value, this.inputFormat)\n : null;\n }\n\n /**\n * Get date format\n */\n get format(): string {\n const format = this.getContribution(\"format\", \"\");\n return this.formatUtil.convertFormat(format);\n }\n\n /**\n */\n get operator(): string {\n return this.getContribution(\"operator\", \"\");\n }\n\n /**\n */\n get hasDate(): boolean {\n return (\n this.type === \"date\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get hasTime(): boolean {\n return (\n this.type === \"time\" ||\n this.type === \"datetime\" ||\n this.type === \"timestamp\"\n );\n }\n\n /**\n */\n get formatLabel(): string {\n switch (this.type) {\n case \"date\":\n return this.dateInputFormat.toLowerCase();\n case \"time\":\n return this.timeInputFormat.toLowerCase();\n default:\n return this.format.toLowerCase();\n }\n }\n\n /**\n */\n get inputFormat(): string {\n if (this.hasDate && this.hasTime) {\n return `${this.dateInputFormat} ${this.timeInputFormat}`.trim();\n }\n\n if (this.hasDate) {\n return this.dateInputFormat;\n }\n\n if (this.hasTime) {\n return this.timeInputFormat;\n }\n\n return \"\";\n }\n\n /**\n */\n get dateInputFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n return this.hasTime\n ? this.format.replace(this.timeInputFormat, \"\").trim()\n : this.format;\n }\n\n /**\n */\n get dateReadonlyFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n return this.hasTime\n ? this.format.replace(this.timeInputFormat, \"\").trim()\n : this.format;\n }\n\n /**\n * return attribute placeholder or return formatlabel without time input format from contributions\n */\n get placeholder(): string {\n if (this._placeholder !== \"\") {\n return this._placeholder;\n }\n\n const formatLabel = this.getContribution(\"formatlabel\", \"\");\n\n if (this.hasDate && this.hasTime && formatLabel.includes(\" \")) {\n // return first part of formatlabel to keep placeholder matching date input\n return formatLabel.split(\" \")[0];\n }\n\n return formatLabel;\n }\n\n /**\n * Set placeholder text\n */\n set placeholder(placeholder: string) {\n this._placeholder = placeholder;\n }\n\n /**\n */\n get timeInputFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n const format = this.format;\n\n let timeFormatParts = [];\n if (format.includes(\"H\")) {\n timeFormatParts.push(\"HH\");\n } else if (format.includes(\"h\")) {\n timeFormatParts.push(\"hh\");\n }\n if (format.includes(\"m\")) {\n timeFormatParts.push(\"mm\");\n }\n if (format.includes(\"s\")) {\n timeFormatParts.push(\"ss\");\n }\n\n let timeFormat = timeFormatParts.join(\":\");\n if (format.includes(\"S\")) {\n timeFormat = `${timeFormat}.SSS`;\n }\n if (format.includes(\"a\")) {\n return `${timeFormat} a`;\n }\n return timeFormat;\n }\n\n /**\n */\n get timeReadonlyFormat(): string {\n if (!this.hasTime) {\n return \"\";\n }\n\n return this.timeInputFormat;\n }\n\n /**\n */\n get dateInputValue(): string {\n return typeof this.value === \"string\" && this.dateInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.dateInputFormat)\n : \"\";\n }\n\n /**\n */\n get timeInputValue(): string {\n return typeof this.value === \"string\" && this.timeInputFormat !== \"\"\n ? this.formatUtil.toFormat(this.value, this.timeInputFormat)\n : \"\";\n }\n\n // format value in readonly rendering\n /**\n */\n formatValue(value: ?string): string {\n if (value == null || value.toString() === \"\") {\n return \"\";\n }\n\n // when the value is exactly an iso date, render as date\n if (\n (this.type === \"datetime\" || this.type === \"timestamp\") &&\n DateUtil.hasFormat(value, ISO_DATE_FORMAT)\n ) {\n return DateUtil.toFormat(value, this.dateReadonlyFormat);\n }\n\n if (this.hasDate && this.hasTime) {\n const dateTimeReadonlyFormat = `${this.dateReadonlyFormat} ${this.timeReadonlyFormat}`;\n return this.formatUtil.toFormat(value, dateTimeReadonlyFormat);\n }\n\n if (this.type === \"date\") {\n return this.formatUtil.toFormat(value, this.dateReadonlyFormat);\n }\n\n return this.formatUtil.toFormat(value, this.format);\n }\n\n /**\n * Retrieve readonly value, the date in the configurated format\n */\n get readonlyvalue(): string {\n if (typeof this.value === \"string\") {\n return this.formatValue(this.value.toString());\n }\n\n return \"\";\n }\n\n /**\n * Get minimum date\n */\n get mindate(): string | null {\n return this.getContribution(\"mindate\");\n }\n\n /**\n * Get maximum date\n */\n get maxdate(): string | null {\n return this.getContribution(\"maxdate\");\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n const { id, message, properties, layouthint } = error;\n if (properties && has(properties, \"format\") && this.formatLabel) {\n properties.format = this.formatLabel;\n }\n\n this._errorCollection.addServerError(id, message, properties, layouthint);\n }\n\n /**\n */\n getFormatConstraint(): IConstraintModel {\n switch (this.type) {\n case \"date\":\n return new DateTimeDateFormatConstraint(\n this.dateInputFormat,\n this.formatLabel\n );\n case \"time\":\n return new DateTimeTimeFormatConstraint(\n this.timeInputFormat,\n this.formatLabel\n );\n default:\n return new DatetimeFormatConstraint(\n this.type,\n this.inputFormat,\n this.formatLabel\n );\n }\n }\n\n /**\n * Add Date constraints for attribute\n */\n addConstraints(): ConstraintCollection {\n const constraints = new ConstraintCollection();\n\n constraints.add(this.getFormatConstraint());\n\n if (this.mindate || this.maxdate) {\n constraints.add(\n new DateBoundaryConstraint(\n this.type,\n this.mindate,\n this.maxdate,\n this.inputFormat\n )\n );\n }\n\n return constraints;\n }\n\n /**\n */\n get readonlyWidth(): $Keys<typeof ATTRIBUTE_WIDTH> {\n if (this.type === \"date\" || this.type === \"time\") {\n return ATTRIBUTE_WIDTH.SMALL;\n }\n\n return ATTRIBUTE_WIDTH.MEDIUM;\n }\n}\n\nexport default DatetimeAttributeModel;\n"],"mappings":";;AACA,SAASA,GAAG,QAAQ,6BAA6B;AAEjD,SACEC,QAAQ,EACRC,YAAY,EACZC,QAAQ,EACRC,aAAa,QACR,mCAAmC;AAE1C,OAAOC,oBAAoB,MAAM,wBAAwB;AAEzD,OAAOC,oBAAoB,MAAM,0CAA0C;AAC3E,OAAOC,4BAA4B,MAAM,kDAAkD;AAC3F,OAAOC,4BAA4B,MAAM,kDAAkD;AAC3F,OAAOC,wBAAwB,MAAM,8CAA8C;AACnF,OAAOC,sBAAsB,MAAM,4CAA4C;AAE/E,SAASC,eAAe,EAAEC,eAAe,QAAQ,iBAAiB;AAIlE;AACA;AACA,MAAMC,sBAAsB,SAASR,oBAAoB,CAAC;EACxD;AACF;EACES,WAAW,CAACC,SAAiB,EAAEC,sBAA8B,EAAE;IAC7D,KAAK,CAACD,SAAS,EAAEC,sBAAsB,CAAC;IAExC,IAAI,CAACC,eAAe,EAAE;EACxB;;EAEA;AACF;EACE,OAAOC,iBAAiB,CAACC,aAAqB,EAAW;IAAA;IACvD,OAAO,sCAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,iBAC9CA,aAAa,CAACC,IAAI,CACnB;EACH;;EAEA;AACF;EACE,IAAIC,UAAU,GAIM;IAClB,QAAQ,IAAI,CAACD,IAAI;MACf,KAAK,MAAM;QACT,OAAOjB,QAAQ;MACjB,KAAK,WAAW;QACd,OAAOC,aAAa;MACtB,KAAK,UAAU;QACb,OAAOF,YAAY;MACrB;QACE,OAAOD,QAAQ;IAAC;EAEtB;;EAEA;AACF;EACEqB,YAAY,GAAkB;IAC5B,IAAIC,KAAK,GAAG,IAAI,CAACC,IAAI,CAACD,K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AAI,IAAI,CAACT,OAAO,IAAI,IAAI,CAACC,OAAO,EAAE;MAChCU,WAAW,CAACC,GAAG,CACb,IAAIxE,sBAAsB,CACxB,IAAI,CAACU,IAAI,EACT,IAAI,CAACkD,OAAO,EACZ,IAAI,CAACC,OAAO,EACZ,IAAI,CAAC7B,WAAW,CACjB,CACF;IACH;IAEA,OAAOuC,WAAW;EACpB;;EAEA;AACF;EACE,IAAIE,aAAa,GAAkC;IACjD,IAAI,IAAI,CAAC/D,IAAI,KAAK,MAAM,IAAI,IAAI,CAACA,IAAI,KAAK,MAAM,EAAE;MAChD,OAAOT,eAAe,CAACyE,KAAK;IAC9B;IAEA,OAAOzE,eAAe,CAAC0E,MAAM;EAC/B;AACF;AAEA,eAAexE,sBAAsB"}
|
package/esm/react-client/Init.js
CHANGED
|
@@ -9,7 +9,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
9
9
|
const Init = _ref => {
|
|
10
10
|
let {
|
|
11
11
|
store,
|
|
12
|
-
|
|
12
|
+
routerHistory,
|
|
13
13
|
contextPath,
|
|
14
14
|
theme,
|
|
15
15
|
children,
|
|
@@ -23,7 +23,7 @@ const Init = _ref => {
|
|
|
23
23
|
children: /*#__PURE__*/_jsx(ErrorBoundary, {
|
|
24
24
|
FallbackComponent: ErrorFallbackComponent,
|
|
25
25
|
children: /*#__PURE__*/_jsx(Router, {
|
|
26
|
-
history:
|
|
26
|
+
history: routerHistory,
|
|
27
27
|
basename: contextPath,
|
|
28
28
|
children: children
|
|
29
29
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Init.js","names":["Provider","HelmetProvider","Router","ThemeProvider","ErrorBoundary","Init","store","
|
|
1
|
+
{"version":3,"file":"Init.js","names":["Provider","HelmetProvider","Router","ThemeProvider","ErrorBoundary","Init","store","routerHistory","contextPath","theme","children","ErrorFallbackComponent","displayName"],"sources":["../../src/react-client/Init.js"],"sourcesContent":["// @flow\nimport { Provider } from \"react-redux\";\nimport { HelmetProvider } from \"react-helmet-async\";\nimport { Router } from \"react-router\";\n\nimport ThemeProvider from \"../react-theme/ThemeProvider\";\nimport ErrorBoundary from \"../react/ErrorBoundary\";\n\nimport type { ComponentType, Node } from \"react\";\nimport type { RouterHistory } from \"react-router\";\nimport type { Theme } from \"../react-theme/types\";\nimport type { ReduxStore } from \"../redux/types\";\nimport type { Props as FallbackProps } from \"../react/ErrorBoundaryFallback\";\n\nexport type Props = {\n +store: ReduxStore,\n +routerHistory: RouterHistory,\n +contextPath: string,\n +theme?: Theme | Array<Theme>,\n +children: ?Node,\n +ErrorFallbackComponent?: ComponentType<FallbackProps>,\n};\n\n/**\n */\nconst Init = ({\n store,\n routerHistory,\n contextPath,\n theme,\n children,\n ErrorFallbackComponent,\n}: Props): Node => (\n <Provider store={store}>\n <ThemeProvider theme={theme}>\n <HelmetProvider>\n <ErrorBoundary FallbackComponent={ErrorFallbackComponent}>\n <Router history={routerHistory} basename={contextPath}>\n {children}\n </Router>\n </ErrorBoundary>\n </HelmetProvider>\n </ThemeProvider>\n </Provider>\n);\n\nInit.displayName = \"BI.Init\";\n\nexport default Init;\n"],"mappings":"AACA,SAASA,QAAQ,QAAQ,aAAa;AACtC,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,MAAM,QAAQ,cAAc;AAErC,OAAOC,aAAa,MAAM,8BAA8B;AACxD,OAAOC,aAAa,MAAM,wBAAwB;AAAC;AAiBnD;AACA;AACA,MAAMC,IAAI,GAAG;EAAA,IAAC;IACZC,KAAK;IACLC,aAAa;IACbC,WAAW;IACXC,KAAK;IACLC,QAAQ;IACRC;EACK,CAAC;EAAA,oBACN,KAAC,QAAQ;IAAC,KAAK,EAAEL,KAAM;IAAA,uBACrB,KAAC,aAAa;MAAC,KAAK,EAAEG,KAAM;MAAA,uBAC1B,KAAC,cAAc;QAAA,uBACb,KAAC,aAAa;UAAC,iBAAiB,EAAEE,sBAAuB;UAAA,uBACvD,KAAC,MAAM;YAAC,OAAO,EAAEJ,aAAc;YAAC,QAAQ,EAAEC,WAAY;YAAA,UACnDE;UAAQ;QACF;MACK;IACD;EACH,EACP;AAAA,CACZ;AAEDL,IAAI,CAACO,WAAW,GAAG,SAAS;AAE5B,eAAeP,IAAI"}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import _trimInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/trim";
|
|
2
|
-
|
|
3
|
-
import elementClosest from "element-closest";
|
|
4
|
-
elementClosest(window);
|
|
5
|
-
|
|
6
|
-
/* polyfill for focus-visible */
|
|
7
|
-
import "focus-visible";
|
|
8
|
-
import { hydrate, render as reactRender } from "react-dom";
|
|
2
|
+
import { hydrate, render } from "react-dom";
|
|
9
3
|
import { has } from "../utils/helpers/objects";
|
|
10
4
|
import setImmediate from "setimmediate";
|
|
11
5
|
import Cache from "../utils/browser/Cache";
|
|
@@ -25,8 +19,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
25
19
|
/*
|
|
26
20
|
* deserialize serialized data from the server to provide a smooth dehydration.
|
|
27
21
|
*/
|
|
28
|
-
/**
|
|
29
|
-
*/
|
|
30
22
|
const parseDataToJSON = data => {
|
|
31
23
|
try {
|
|
32
24
|
return JSON.parse(data);
|
|
@@ -34,22 +26,41 @@ const parseDataToJSON = data => {
|
|
|
34
26
|
throw new JsonParseException(`Error parsing content ${data}`);
|
|
35
27
|
}
|
|
36
28
|
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Mount the webapplication to the DOM, used client side when JavaScript is enabled.
|
|
40
|
-
*/
|
|
41
|
-
const client = props => {
|
|
29
|
+
const getDataFromServer = () => {
|
|
42
30
|
var _context;
|
|
43
|
-
if (typeof window.contextPath === "undefined") {
|
|
44
|
-
throw new Error("Missing contextPath on window object");
|
|
45
|
-
}
|
|
46
31
|
const dataElement = document.querySelector('script[type="application/json"][data-app-state="app-json"]');
|
|
47
32
|
if (!dataElement) {
|
|
48
33
|
throw new Error("Error loading state, json not found");
|
|
49
34
|
} else if (_trimInstanceProperty(_context = dataElement.textContent).call(_context) === "") {
|
|
50
|
-
return;
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
return parseDataToJSON(dataElement.textContent);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
*/
|
|
42
|
+
export const setUnhandledRejectionEvent = store => {
|
|
43
|
+
window.onunhandledrejection = event => {
|
|
44
|
+
if (event.detail) {
|
|
45
|
+
return setImmediate(() => {
|
|
46
|
+
const errorMessage = event.detail.reason.message.toString();
|
|
47
|
+
store.dispatch(showXHRErrorNotification(errorMessage));
|
|
48
|
+
throw event.detail.reason;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return event;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
*/
|
|
57
|
+
export const setupClient = function () {
|
|
58
|
+
let customReducers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
59
|
+
let beforeRenderHooks = arguments.length > 1 ? arguments[1] : undefined;
|
|
60
|
+
if (typeof window.contextPath === "undefined") {
|
|
61
|
+
throw new Error("Missing contextPath on window object");
|
|
51
62
|
}
|
|
52
|
-
const data =
|
|
63
|
+
const data = getDataFromServer();
|
|
53
64
|
|
|
54
65
|
// remove all resources from cache
|
|
55
66
|
Cache.clear("^res:");
|
|
@@ -59,9 +70,9 @@ const client = props => {
|
|
|
59
70
|
basename: getBasePath()
|
|
60
71
|
});
|
|
61
72
|
const {
|
|
62
|
-
|
|
73
|
+
routerHistory,
|
|
63
74
|
store
|
|
64
|
-
} = configureStore(browserHistory,
|
|
75
|
+
} = configureStore(browserHistory, customReducers, rehydrate(data));
|
|
65
76
|
setAllContentInDataSetting(store.getState());
|
|
66
77
|
setLoginPreferences(store.getState());
|
|
67
78
|
|
|
@@ -72,7 +83,7 @@ const client = props => {
|
|
|
72
83
|
}
|
|
73
84
|
});
|
|
74
85
|
if (has(data, "error.name")) {
|
|
75
|
-
const error = new FetchException(data
|
|
86
|
+
const error = new FetchException(data?.error?.response);
|
|
76
87
|
store.dispatch(handleError(error));
|
|
77
88
|
}
|
|
78
89
|
if (Cache.getItem("auth")) {
|
|
@@ -80,53 +91,70 @@ const client = props => {
|
|
|
80
91
|
}
|
|
81
92
|
|
|
82
93
|
// listen to history change and update the redux router store
|
|
83
|
-
|
|
94
|
+
routerHistory.listen((location, action) => {
|
|
84
95
|
store.dispatch(locationChange(location, action));
|
|
85
96
|
});
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
*/
|
|
89
|
-
window.onunhandledrejection = event => {
|
|
90
|
-
if (event.detail) {
|
|
91
|
-
return setImmediate(() => {
|
|
92
|
-
const errorMessage = event.detail.reason.message.toString();
|
|
93
|
-
store.dispatch(showXHRErrorNotification(errorMessage));
|
|
94
|
-
throw event.detail.reason;
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
return event;
|
|
98
|
-
};
|
|
97
|
+
setUnhandledRejectionEvent(store);
|
|
99
98
|
if (document.body) {
|
|
100
99
|
document.body.className = "js";
|
|
101
100
|
}
|
|
102
|
-
if (
|
|
103
|
-
handleBeforeRenderHooks(
|
|
101
|
+
if (beforeRenderHooks) {
|
|
102
|
+
handleBeforeRenderHooks(beforeRenderHooks, {
|
|
104
103
|
store
|
|
105
104
|
});
|
|
106
105
|
}
|
|
107
|
-
|
|
106
|
+
return {
|
|
107
|
+
store,
|
|
108
|
+
routerHistory
|
|
109
|
+
};
|
|
108
110
|
};
|
|
109
111
|
|
|
110
112
|
/**
|
|
111
113
|
*/
|
|
112
|
-
const addContentLoadedEvent = (store,
|
|
114
|
+
export const addContentLoadedEvent = (store, routerHistory, theme, render, ErrorFallbackComponent, mount) => {
|
|
113
115
|
window.addEventListener("DOMContentLoaded", () => {
|
|
114
116
|
const applicationNode = document.querySelector("#application");
|
|
115
|
-
if (applicationNode) {
|
|
116
|
-
const isSSR = applicationNode.querySelector(".application");
|
|
117
|
-
const mount = isSSR ? hydrate : reactRender;
|
|
118
|
-
mount( /*#__PURE__*/_jsx(Init, {
|
|
119
|
-
store: store,
|
|
120
|
-
history: history,
|
|
121
|
-
contextPath: window.contextPath,
|
|
122
|
-
theme: theme,
|
|
123
|
-
ErrorFallbackComponent: ErrorFallbackComponent,
|
|
124
|
-
children: render()
|
|
125
|
-
}), applicationNode);
|
|
126
|
-
} else {
|
|
117
|
+
if (!applicationNode) {
|
|
127
118
|
throw new Error("No DOM element with id application found to attach client to");
|
|
128
119
|
}
|
|
120
|
+
mount(applicationNode, /*#__PURE__*/_jsx(Init, {
|
|
121
|
+
store: store,
|
|
122
|
+
routerHistory: routerHistory,
|
|
123
|
+
contextPath: window.contextPath,
|
|
124
|
+
theme: theme,
|
|
125
|
+
ErrorFallbackComponent: ErrorFallbackComponent,
|
|
126
|
+
children: render()
|
|
127
|
+
}));
|
|
129
128
|
});
|
|
130
129
|
};
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
*/
|
|
133
|
+
const mountClient = (applicationNode, initComponent) => {
|
|
134
|
+
const isSSR = applicationNode.querySelector(".application");
|
|
135
|
+
if (isSSR) {
|
|
136
|
+
hydrate(initComponent, applicationNode);
|
|
137
|
+
} else {
|
|
138
|
+
render(initComponent, applicationNode);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Mount the webapplication to the DOM, setup redux store and caches, add unhandledRejectionEvent, used client side when JavaScript is enabled.
|
|
144
|
+
*/
|
|
145
|
+
const client = _ref => {
|
|
146
|
+
let {
|
|
147
|
+
customReducers,
|
|
148
|
+
theme,
|
|
149
|
+
render,
|
|
150
|
+
beforeRenderHooks,
|
|
151
|
+
ErrorFallbackComponent
|
|
152
|
+
} = _ref;
|
|
153
|
+
const {
|
|
154
|
+
store,
|
|
155
|
+
routerHistory
|
|
156
|
+
} = setupClient(customReducers, beforeRenderHooks);
|
|
157
|
+
addContentLoadedEvent(store, routerHistory, theme, render, ErrorFallbackComponent, mountClient);
|
|
158
|
+
};
|
|
131
159
|
export default client;
|
|
132
160
|
//# sourceMappingURL=client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":["elementClosest","window","hydrate","render","reactRender","has","setImmediate","Cache","createBrowserHistory","configureStore","rehydrate","getBasePath","setAllContentInDataSetting","setLoginPreferences","showXHRErrorNotification","handleError","loginSuccess","locationChange","JsonParseException","FetchException","Init","handleBeforeRenderHooks","parseDataToJSON","data","JSON","parse","error","client","props","contextPath","Error","dataElement","document","querySelector","textContent","clear","browserHistory","basename","history","store","customReducers","getState","loadOtherBrowserTabs","getItem","dispatch","response","listen","location","action","onunhandledrejection","event","detail","errorMessage","reason","message","toString","body","className","beforeRenderHooks","addContentLoadedEvent","theme","ErrorFallbackComponent","addEventListener","applicationNode","isSSR","mount"],"sources":["../../src/react-client/client.js"],"sourcesContent":["// @flow\n/* polyfills needed for ie11 */\nimport elementClosest from \"element-closest\";\nelementClosest(window);\n\n/* polyfill for focus-visible */\nimport \"focus-visible\";\n\nimport { hydrate, render as reactRender } from \"react-dom\";\n\nimport { has } from \"../utils/helpers/objects\";\nimport setImmediate from \"setimmediate\";\n\nimport Cache from \"../utils/browser/Cache\";\n\nimport { createBrowserHistory } from \"history\";\nimport configureStore from \"../redux/store/configureStore\";\n\nimport rehydrate from \"./rehydrate\";\nimport { getBasePath } from \"../constants/Settings\";\n\nimport {\n setAllContentInDataSetting,\n setLoginPreferences,\n} from \"../redux/actions/Preferences\";\nimport { showXHRErrorNotification } from \"../redux/actions/Notification\";\n\nimport { handleError } from \"../redux/actions/Error\";\nimport { loginSuccess } from \"../redux/actions/SignIn\";\n\nimport { locationChange } 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 { ComponentType } 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\";\nexport type Props = {\n customReducers?: CustomReducers,\n theme?: Theme | Array<Theme>,\n render: Function,\n beforeRenderHooks?: Array<BeforeRenderHook>,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n};\n\n/*\n * deserialize serialized data from the server to provide a smooth dehydration.\n */\n/**\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\n/**\n * Mount the webapplication to the DOM, used client side when JavaScript is enabled.\n */\nconst client = (props: Props) => {\n if (typeof window.contextPath === \"undefined\") {\n throw new Error(\"Missing contextPath on window object\");\n }\n\n const dataElement = document.querySelector(\n 'script[type=\"application/json\"][data-app-state=\"app-json\"]'\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 const data = parseDataToJSON(dataElement.textContent);\n\n // remove all resources from cache\n Cache.clear(\"^res:\");\n\n // $FlowExpectedError\n const browserHistory: RouterHistory = createBrowserHistory({\n basename: getBasePath(),\n });\n const { history, store } = configureStore(\n browserHistory,\n props.customReducers ?? {},\n rehydrate(data)\n );\n\n setAllContentInDataSetting(store.getState());\n setLoginPreferences(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 history.listen((location, action) => {\n store.dispatch(locationChange(location, action));\n });\n\n /**\n */\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 if (document.body) {\n document.body.className = \"js\";\n }\n\n if (props.beforeRenderHooks) {\n handleBeforeRenderHooks(props.beforeRenderHooks, { store });\n }\n\n addContentLoadedEvent(\n store,\n history,\n props.theme,\n props.render,\n props.ErrorFallbackComponent\n );\n};\n\n/**\n */\nconst addContentLoadedEvent = (\n store: ReduxStore,\n history: RouterHistory,\n theme?: Theme | Array<Theme>,\n render: Function,\n ErrorFallbackComponent?: ComponentType<FallbackProps>\n) => {\n window.addEventListener(\"DOMContentLoaded\", () => {\n const applicationNode = document.querySelector(\"#application\");\n if (applicationNode) {\n const isSSR = applicationNode.querySelector(\".application\");\n const mount = isSSR ? hydrate : reactRender;\n mount(\n <Init\n store={store}\n history={history}\n contextPath={window.contextPath}\n theme={theme}\n ErrorFallbackComponent={ErrorFallbackComponent}\n >\n {render()}\n </Init>,\n applicationNode\n );\n } else {\n throw new Error(\n \"No DOM element with id application found to attach client to\"\n );\n }\n });\n};\n\nexport default client;\n"],"mappings":";AACA;AACA,OAAOA,cAAc,MAAM,iBAAiB;AAC5CA,cAAc,CAACC,MAAM,CAAC;;AAEtB;AACA,OAAO,eAAe;AAEtB,SAASC,OAAO,EAAEC,MAAM,IAAIC,WAAW,QAAQ,WAAW;AAE1D,SAASC,GAAG,QAAQ,0BAA0B;AAC9C,OAAOC,YAAY,MAAM,cAAc;AAEvC,OAAOC,KAAK,MAAM,wBAAwB;AAE1C,SAASC,oBAAoB,QAAQ,SAAS;AAC9C,OAAOC,cAAc,MAAM,+BAA+B;AAE1D,OAAOC,SAAS,MAAM,aAAa;AACnC,SAASC,WAAW,QAAQ,uBAAuB;AAEnD,SACEC,0BAA0B,EAC1BC,mBAAmB,QACd,8BAA8B;AACrC,SAASC,wBAAwB,QAAQ,+BAA+B;AAExE,SAASC,WAAW,QAAQ,wBAAwB;AACpD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AAG,IAAI;EAChC;EAEA,IAAI7B,KAAK,CAAC8B,iBAAiB,EAAE;IAC3BrC,uBAAuB,CAACO,KAAK,CAAC8B,iBAAiB,EAAE;MAAEnB;IAAM,CAAC,CAAC;EAC7D;EAEAoB,qBAAqB,CACnBpB,KAAK,EACLD,OAAO,EACPV,KAAK,CAACgC,KAAK,EACXhC,KAAK,CAACzB,MAAM,EACZyB,KAAK,CAACiC,sBAAsB,CAC7B;AACH,CAAC;;AAED;AACA;AACA,MAAMF,qBAAqB,GAAG,CAC5BpB,KAAiB,EACjBD,OAAsB,EACtBsB,KAA4B,EAC5BzD,MAAgB,EAChB0D,sBAAqD,KAClD;EACH5D,MAAM,CAAC6D,gBAAgB,CAAC,kBAAkB,EAAE,MAAM;IAChD,MAAMC,eAAe,GAAG/B,QAAQ,CAACC,aAAa,CAAC,cAAc,CAAC;IAC9D,IAAI8B,eAAe,EAAE;MACnB,MAAMC,KAAK,GAAGD,eAAe,CAAC9B,aAAa,CAAC,cAAc,CAAC;MAC3D,MAAMgC,KAAK,GAAGD,KAAK,GAAG9D,OAAO,GAAGE,WAAW;MAC3C6D,KAAK,eACH,KAAC,IAAI;QACH,KAAK,EAAE1B,KAAM;QACb,OAAO,EAAED,OAAQ;QACjB,WAAW,EAAErC,MAAM,CAAC4B,WAAY;QAChC,KAAK,EAAE+B,KAAM;QACb,sBAAsB,EAAEC,sBAAuB;QAAA,UAE9C1D,MAAM;MAAE,EACJ,EACP4D,eAAe,CAChB;IACH,CAAC,MAAM;MACL,MAAM,IAAIjC,KAAK,CACb,8DAA8D,CAC/D;IACH;EACF,CAAC,CAAC;AACJ,CAAC;AAED,eAAeH,MAAM"}
|
|
1
|
+
{"version":3,"file":"client.js","names":["hydrate","render","has","setImmediate","Cache","createBrowserHistory","configureStore","rehydrate","getBasePath","setAllContentInDataSetting","setLoginPreferences","showXHRErrorNotification","handleError","loginSuccess","locationChange","JsonParseException","FetchException","Init","handleBeforeRenderHooks","parseDataToJSON","data","JSON","parse","error","getDataFromServer","dataElement","document","querySelector","Error","textContent","setUnhandledRejectionEvent","store","window","onunhandledrejection","event","detail","errorMessage","reason","message","toString","dispatch","setupClient","customReducers","beforeRenderHooks","contextPath","clear","browserHistory","basename","routerHistory","getState","loadOtherBrowserTabs","getItem","response","listen","location","action","body","className","addContentLoadedEvent","theme","ErrorFallbackComponent","mount","addEventListener","applicationNode","mountClient","initComponent","isSSR","client"],"sources":["../../src/react-client/client.js"],"sourcesContent":["// @flow\nimport { hydrate, render } from \"react-dom\";\n\nimport { has } from \"../utils/helpers/objects\";\nimport setImmediate from \"setimmediate\";\n\nimport Cache from \"../utils/browser/Cache\";\n\nimport { createBrowserHistory } from \"history\";\nimport configureStore from \"../redux/store/configureStore\";\n\nimport rehydrate from \"./rehydrate\";\nimport { getBasePath } from \"../constants/Settings\";\n\nimport {\n setAllContentInDataSetting,\n setLoginPreferences,\n} from \"../redux/actions/Preferences\";\nimport { showXHRErrorNotification } from \"../redux/actions/Notification\";\n\nimport { handleError } from \"../redux/actions/Error\";\nimport { loginSuccess } from \"../redux/actions/SignIn\";\n\nimport { locationChange } 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\nexport type Props = {\n customReducers?: CustomReducers,\n theme?: Theme | Array<Theme>,\n render: Function,\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 */\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: getBasePath(),\n });\n const { routerHistory, store } = configureStore(\n browserHistory,\n customReducers,\n rehydrate(data)\n );\n\n setAllContentInDataSetting(store.getState());\n setLoginPreferences(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: Function,\n ErrorFallbackComponent?: ComponentType<FallbackProps>,\n mount: Function\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 initComponent: ReactElement<ElementType>\n) => {\n const isSSR = applicationNode.querySelector(\".application\");\n if (isSSR) {\n hydrate(initComponent, applicationNode);\n } else {\n render(initComponent, 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 */\nconst client = ({\n customReducers,\n theme,\n render,\n beforeRenderHooks,\n ErrorFallbackComponent,\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 mountClient\n );\n};\n\nexport default client;\n"],"mappings":";AACA,SAASA,OAAO,EAAEC,MAAM,QAAQ,WAAW;AAE3C,SAASC,GAAG,QAAQ,0BAA0B;AAC9C,OAAOC,YAAY,MAAM,cAAc;AAEvC,OAAOC,KAAK,MAAM,wBAAwB;AAE1C,SAASC,oBAAoB,QAAQ,SAAS;AAC9C,OAAOC,cAAc,MAAM,+BAA+B;AAE1D,OAAOC,SAAS,MAAM,aAAa;AACnC,SAASC,WAAW,QAAQ,uBAAuB;AAEnD,SACEC,0BAA0B,EAC1BC,mBAAmB,QACd,8BAA8B;AACrC,SAASC,wBAAwB,QAAQ,+BAA+B;A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C,CAAC,MAAM;IACL9D,MAAM,CAACgE,aAAa,EAAEF,eAAe,CAAC;EACxC;AACF,CAAC;;AAED;AACA;AACA;AACA,MAAMI,MAAM,GAAG,QAMF;EAAA,IANG;IACdzB,cAAc;IACdiB,KAAK;IACL1D,MAAM;IACN0C,iBAAiB;IACjBiB;EACK,CAAC;EACN,MAAM;IAAE7B,KAAK;IAAEiB;EAAc,CAAC,GAAGP,WAAW,CAC1CC,cAAc,EACdC,iBAAiB,CAClB;EAEDe,qBAAqB,CACnB3B,KAAK,EACLiB,aAAa,EACbW,KAAK,EACL1D,MAAM,EACN2D,sBAAsB,EACtBI,WAAW,CACZ;AACH,CAAC;AAED,eAAeG,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUIActions.js","names":["HTTP_METHODS","MODULARUI_STATUS","Href","ErrorResponse","finishProgress","startProgress","handleError","setModel","key","model","connectKey","type","payload","initModels","models","updateModel","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","modelToUpdate","clonedModel","clone","update","Error","loadModel","href","options","method","GET","data","locale","childmodels","targetModel","forceTargetModel","successAction","errorAction","error","errorResponse","isChangePassword","isResourceNotFoundAfterReload","ERROR","loadModularUI","dispatch","LOADING","loadModelPromise","resolve","then","response","FINISHED","catch","reloadModel","selfhref","isReload"],"sources":["../../../src/redux/_modularui/ModularUIActions.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\nimport Href from \"../../models/href/Href\";\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\nimport { finishProgress, startProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { Dispatch, ThunkAction } from \"../types\";\nimport type {\n ModularUIAction,\n SetModelAction,\n InitModelAction,\n UpdateModelAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n UpdateStatusAction,\n} from \"./types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\n/**\n */\nexport const setModel = (\n key: string,\n model: ModularUIModel\n): SetModelAction => {\n // set key on model for later reference\n model.connectKey = key;\n return {\n type: \"MODULARUI/SET\",\n payload: {\n key,\n model,\n },\n };\n};\n\n/**\n */\nexport const initModels = (\n models: Array<{ key: string, model: ModularUIModel }>\n): InitModelAction => ({\n type: \"MODULARUI/INIT\",\n payload: models,\n});\n\n/**\n */\nexport const updateModel = (model: ModularUIModel): UpdateModelAction => ({\n type: \"MODULARUI/UPDATE\",\n payload: model,\n});\n\n/**\n */\nexport const removeModelByKey = (key: string): RemoveModelByKeyAction => ({\n type: \"MODULARUI/REMOVE_KEY\",\n payload: key,\n});\n\n/**\n * Removes all models except the application model from the modular ui reducer\n */\nexport const resetModularUI = (): ResetModularUIAction => ({\n type: \"MODULARUI/RESET\",\n});\n\n/**\n */\nexport const updateStatus = (\n key: string,\n status: $Keys<typeof MODULARUI_STATUS>\n): UpdateStatusAction => ({\n type: \"MODULARUI/STATUS\",\n payload: { key, status },\n});\n\n/**\n */\nconst loadModelSuccessAction = (\n key: string,\n model: ModularUIModel,\n modelToUpdate: ?ModularUIModel\n): UpdateModelAction | SetModelAction => {\n if (modelToUpdate) {\n // $FlowFixMe[prop-missing]\n if (typeof modelToUpdate[\"update\"] === \"function\") {\n const clonedModel = modelToUpdate.clone();\n clonedModel.update(model);\n\n return updateModel(clonedModel);\n }\n\n throw new Error(\n `loadModel action: updateModel is set as option for ${key}, but the model is missing an update methode`\n );\n }\n\n return setModel(key, model);\n};\n\n/**\n * This action is handled by the modularui middleware\n */\nexport const loadModel = (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions\n): ModularUIAction => ({\n type: \"MODULARUI/FETCH\",\n payload: {\n href: href instanceof Href ? href : new Href(href),\n method: options?.method ?? HTTP_METHODS.GET,\n data: options?.data,\n locale: options?.locale ?? \"en\",\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateModel),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key);\n if (errorResponse.isChangePassword) {\n return {\n type: \"NO_ACTION\",\n };\n } else if (errorResponse.isResourceNotFoundAfterReload) {\n return removeModelByKey(key);\n }\n\n return updateStatus(key, MODULARUI_STATUS.ERROR);\n },\n },\n});\n\n/**\n */\nexport const loadModularUI =\n (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));\n dispatch(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then((response) => {\n if (response?.type === \"FINISH_PROGRESS\") {\n dispatch(updateStatus(key, MODULARUI_STATUS.FINISHED));\n }\n\n return dispatch(finishProgress());\n })\n .catch((error) => dispatch(handleError(error)));\n };\n\n/**\n */\nexport const reloadModel = (\n model: ModularUIModel,\n options?: RequestModularUIOptions\n): ThunkAction =>\n loadModularUI(model.connectKey, model.selfhref, {\n ...options,\n isReload: true,\n });\n"],"mappings":";AACA,SAASA,YAAY,EAAEC,gBAAgB,QAAQ,2BAA2B;AAC1E,OAAOC,IAAI,MAAM,wBAAwB;AACzC,OAAOC,aAAa,MAAM,kCAAkC;AAC5D,SAASC,cAAc,EAAEC,aAAa,QAAQ,8BAA8B;AAC5E,SAASC,WAAW,QAAQ,kBAAkB;
|
|
1
|
+
{"version":3,"file":"ModularUIActions.js","names":["HTTP_METHODS","MODULARUI_STATUS","Href","ErrorResponse","finishProgress","startProgress","handleError","setModel","key","model","connectKey","type","payload","initModels","models","updateModel","updateForm","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","modelToUpdate","clonedModel","clone","update","Error","loadModel","href","options","method","GET","data","locale","childmodels","targetModel","forceTargetModel","successAction","errorAction","error","errorResponse","isChangePassword","isResourceNotFoundAfterReload","ERROR","loadModularUI","dispatch","LOADING","loadModelPromise","resolve","then","response","FINISHED","catch","reloadModel","selfhref","isReload"],"sources":["../../../src/redux/_modularui/ModularUIActions.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\nimport Href from \"../../models/href/Href\";\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\nimport { finishProgress, startProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { Dispatch, ThunkAction } from \"../types\";\nimport type {\n ModularUIAction,\n SetModelAction,\n InitModelAction,\n UpdateModelAction,\n UpdateFormAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n UpdateStatusAction,\n} from \"./types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\n/**\n */\nexport const setModel = (\n key: string,\n model: ModularUIModel\n): SetModelAction => {\n // set key on model for later reference\n model.connectKey = key;\n return {\n type: \"MODULARUI/SET\",\n payload: {\n key,\n model,\n },\n };\n};\n\n/**\n */\nexport const initModels = (\n models: Array<{ key: string, model: ModularUIModel }>\n): InitModelAction => ({\n type: \"MODULARUI/INIT\",\n payload: models,\n});\n\n/**\n */\nexport const updateModel = (model: ModularUIModel): UpdateModelAction => ({\n type: \"MODULARUI/UPDATE\",\n payload: model,\n});\n\n/**\n */\nexport const updateForm = (model: ModularUIModel): UpdateFormAction => ({\n type: \"MODULARUI/UPDATE_FORM\",\n payload: model,\n});\n\n/**\n */\nexport const removeModelByKey = (key: string): RemoveModelByKeyAction => ({\n type: \"MODULARUI/REMOVE_KEY\",\n payload: key,\n});\n\n/**\n * Removes all models except the application model from the modular ui reducer\n */\nexport const resetModularUI = (): ResetModularUIAction => ({\n type: \"MODULARUI/RESET\",\n});\n\n/**\n */\nexport const updateStatus = (\n key: string,\n status: $Keys<typeof MODULARUI_STATUS>\n): UpdateStatusAction => ({\n type: \"MODULARUI/STATUS\",\n payload: { key, status },\n});\n\n/**\n */\nconst loadModelSuccessAction = (\n key: string,\n model: ModularUIModel,\n modelToUpdate: ?ModularUIModel\n): UpdateModelAction | SetModelAction => {\n if (modelToUpdate) {\n // $FlowFixMe[prop-missing]\n if (typeof modelToUpdate[\"update\"] === \"function\") {\n const clonedModel = modelToUpdate.clone();\n clonedModel.update(model);\n\n return updateModel(clonedModel);\n }\n\n throw new Error(\n `loadModel action: updateModel is set as option for ${key}, but the model is missing an update methode`\n );\n }\n\n return setModel(key, model);\n};\n\n/**\n * This action is handled by the modularui middleware\n */\nexport const loadModel = (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions\n): ModularUIAction => ({\n type: \"MODULARUI/FETCH\",\n payload: {\n href: href instanceof Href ? href : new Href(href),\n method: options?.method ?? HTTP_METHODS.GET,\n data: options?.data,\n locale: options?.locale ?? \"en\",\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateModel),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key);\n if (errorResponse.isChangePassword) {\n return {\n type: \"NO_ACTION\",\n };\n } else if (errorResponse.isResourceNotFoundAfterReload) {\n return removeModelByKey(key);\n }\n\n return updateStatus(key, MODULARUI_STATUS.ERROR);\n },\n },\n});\n\n/**\n */\nexport const loadModularUI =\n (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));\n dispatch(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then((response) => {\n if (response?.type === \"FINISH_PROGRESS\") {\n dispatch(updateStatus(key, MODULARUI_STATUS.FINISHED));\n }\n\n return dispatch(finishProgress());\n })\n .catch((error) => dispatch(handleError(error)));\n };\n\n/**\n */\nexport const reloadModel = (\n model: ModularUIModel,\n options?: RequestModularUIOptions\n): ThunkAction =>\n loadModularUI(model.connectKey, model.selfhref, {\n ...options,\n isReload: true,\n });\n"],"mappings":";AACA,SAASA,YAAY,EAAEC,gBAAgB,QAAQ,2BAA2B;AAC1E,OAAOC,IAAI,MAAM,wBAAwB;AACzC,OAAOC,aAAa,MAAM,kCAAkC;AAC5D,SAASC,cAAc,EAAEC,aAAa,QAAQ,8BAA8B;AAC5E,SAASC,WAAW,QAAQ,kBAAkB;AAgB9C;AACA;AACA,OAAO,MAAMC,QAAQ,GAAG,CACtBC,GAAW,EACXC,KAAqB,KACF;EACnB;EACAA,KAAK,CAACC,UAAU,GAAGF,GAAG;EACtB,OAAO;IACLG,IAAI,EAAE,eAAe;IACrBC,OAAO,EAAE;MACPJ,GAAG;MACHC;IACF;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA,OAAO,MAAMI,UAAU,GACrBC,MAAqD,KAChC;EACrBH,IAAI,EAAE,gBAAgB;EACtBC,OAAO,EAAEE;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMC,WAAW,GAAIN,KAAqB,KAAyB;EACxEE,IAAI,EAAE,kBAAkB;EACxBC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMO,UAAU,GAAIP,KAAqB,KAAwB;EACtEE,IAAI,EAAE,uBAAuB;EAC7BC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMQ,gBAAgB,GAAIT,GAAW,KAA8B;EACxEG,IAAI,EAAE,sBAAsB;EAC5BC,OAAO,EAAEJ;AACX,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,MAAMU,cAAc,GAAG,OAA6B;EACzDP,IAAI,EAAE;AACR,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMQ,YAAY,GAAG,CAC1BX,GAAW,EACXY,MAAsC,MACd;EACxBT,IAAI,EAAE,kBAAkB;EACxBC,OAAO,EAAE;IAAEJ,GAAG;IAAEY;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 @@ export const ModularUIReducer = function () {
|
|
|
132
132
|
case "MODULARUI/SET":
|
|
133
133
|
return setModel(state, action.payload);
|
|
134
134
|
case "MODULARUI/UPDATE":
|
|
135
|
+
case "MODULARUI/UPDATE_FORM":
|
|
135
136
|
return updateModel(state, action.payload);
|
|
136
137
|
case "MODULARUI/REMOVE_KEY":
|
|
137
138
|
return removeKey(action.payload, state);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUIReducer.js","names":["IllegalArgumentException","MODULARUI_STATUS","ApplicationModel","updateStatus","state","key","status","LOADING","lastModification","Date","now","setModel","model","initModularUI","models","newState","forEach","FINISHED","getModelKey","connectKey","updateModel","modelKey","Error","removeKey","resetModularUI","initialState","ModularUIReducer","action","type","payload"],"sources":["../../../src/redux/_modularui/ModularUIReducer.js"],"sourcesContent":["// @flow\nimport { IllegalArgumentException } from \"../../exceptions\";\nimport { MODULARUI_STATUS } from \"../../constants/Constants\";\nimport { ApplicationModel } from \"../../models\";\n\nimport type { Reducer } from \"redux\";\nimport type { ReduxAction } from \"../types\";\nimport type { ModularUIState } from \"./types\";\nimport type { ModularUIModel } from \"../../models\";\n\n/**\n */\nconst updateStatus = (\n state: ModularUIState,\n { key, status }: { key: string, status: $Keys<typeof MODULARUI_STATUS> }\n) => {\n // model should always be available when status is not loading\n if (status !== MODULARUI_STATUS.LOADING && !state[key]) {\n return state;\n }\n\n return {\n ...state,\n [key]: {\n ...state[key],\n status,\n lastModification: Date.now(),\n },\n };\n};\n\n/**\n */\nconst setModel = (\n state: ModularUIState,\n { key, model }: { key: string, model: ?ModularUIModel }\n) => {\n if (!state[key]) {\n return state;\n }\n\n if (model) {\n return {\n ...state,\n [key]: {\n ...state[key],\n model,\n lastModification: Date.now(),\n },\n };\n }\n\n throw new IllegalArgumentException(\"No model for setModel\");\n};\n\n/**\n */\nconst initModularUI = (\n state: ModularUIState,\n models: Array<{ key: string, model: ModularUIModel }>\n) => {\n const newState = Object.assign({}, state);\n\n models.forEach(({ key, model }) => {\n newState[key] = {\n status: MODULARUI_STATUS.FINISHED,\n lastModification: Date.now(),\n model,\n };\n });\n\n return newState;\n};\n\n/**\n */\nconst getModelKey = (state: ModularUIState, model: ModularUIModel) =>\n Object.keys(state).find((key) => {\n const connectKey = state[key]?.model?.connectKey ?? \"\";\n return connectKey === model.connectKey;\n });\n\n/**\n */\nconst updateModel = (state: ModularUIState, model: ModularUIModel) => {\n const modelKey = getModelKey(state, model);\n\n if (modelKey) {\n return setModel(state, { key: modelKey, model });\n }\n\n throw new Error(\n `ModularUIReducer: Cannot update model with key ${model.connectKey}`\n );\n};\n\n/**\n */\nconst removeKey = (modelKey: string, state: ModularUIState): ModularUIState => {\n const newState = Object.assign({}, state);\n delete newState[modelKey];\n return newState;\n};\n\n/**\n * Remove all but application models\n */\nconst resetModularUI = (state: ModularUIState) => {\n const newState: ModularUIState = {};\n\n for (const key in state) {\n if (state[key].model instanceof ApplicationModel) {\n newState[key] = { ...state[key] };\n }\n }\n\n return newState;\n};\n\nconst initialState: ModularUIState = {};\n\n/**\n * Modular UI Reducer\n */\nexport const ModularUIReducer: Reducer<ModularUIState, ReduxAction> = (\n state = initialState,\n action\n) => {\n if (!action) {\n return state;\n }\n\n switch (action.type) {\n case \"MODULARUI/INIT\":\n return initModularUI(state, action.payload);\n\n case \"MODULARUI/RESET\":\n return resetModularUI(state);\n\n case \"MODULARUI/STATUS\":\n return updateStatus(state, action.payload);\n\n case \"MODULARUI/SET\":\n return setModel(state, action.payload);\n\n case \"MODULARUI/UPDATE\":\n return updateModel(state, action.payload);\n\n case \"MODULARUI/REMOVE_KEY\":\n return removeKey(action.payload, state);\n\n default:\n return state;\n }\n};\n"],"mappings":";;;AACA,SAASA,wBAAwB,QAAQ,kBAAkB;AAC3D,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,SAASC,gBAAgB,QAAQ,cAAc;AAO/C;AACA;AACA,MAAMC,YAAY,GAAG,CACnBC,KAAqB,WAElB;EAAA,IADH;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AA,IACpBE,MAAM;EAEN,IAAI,CAACA,MAAM,EAAE;IACX,OAAOvB,KAAK;EACd;EAEA,QAAQuB,MAAM,CAACC,IAAI;IACjB,KAAK,gBAAgB;MACnB,OAAOf,aAAa,CAACT,KAAK,EAAEuB,MAAM,CAACE,OAAO,CAAC;IAE7C,KAAK,iBAAiB;MACpB,OAAOL,cAAc,CAACpB,KAAK,CAAC;IAE9B,KAAK,kBAAkB;MACrB,OAAOD,YAAY,CAACC,KAAK,EAAEuB,MAAM,CAACE,OAAO,CAAC;IAE5C,KAAK,eAAe;MAClB,OAAOlB,QAAQ,CAACP,KAAK,EAAEuB,MAAM,CAACE,OAAO,CAAC;IAExC,KAAK,kBAAkB;
|
|
1
|
+
{"version":3,"file":"ModularUIReducer.js","names":["IllegalArgumentException","MODULARUI_STATUS","ApplicationModel","updateStatus","state","key","status","LOADING","lastModification","Date","now","setModel","model","initModularUI","models","newState","forEach","FINISHED","getModelKey","connectKey","updateModel","modelKey","Error","removeKey","resetModularUI","initialState","ModularUIReducer","action","type","payload"],"sources":["../../../src/redux/_modularui/ModularUIReducer.js"],"sourcesContent":["// @flow\nimport { IllegalArgumentException } from \"../../exceptions\";\nimport { MODULARUI_STATUS } from \"../../constants/Constants\";\nimport { ApplicationModel } from \"../../models\";\n\nimport type { Reducer } from \"redux\";\nimport type { ReduxAction } from \"../types\";\nimport type { ModularUIState } from \"./types\";\nimport type { ModularUIModel } from \"../../models\";\n\n/**\n */\nconst updateStatus = (\n state: ModularUIState,\n { key, status }: { key: string, status: $Keys<typeof MODULARUI_STATUS> }\n) => {\n // model should always be available when status is not loading\n if (status !== MODULARUI_STATUS.LOADING && !state[key]) {\n return state;\n }\n\n return {\n ...state,\n [key]: {\n ...state[key],\n status,\n lastModification: Date.now(),\n },\n };\n};\n\n/**\n */\nconst setModel = (\n state: ModularUIState,\n { key, model }: { key: string, model: ?ModularUIModel }\n) => {\n if (!state[key]) {\n return state;\n }\n\n if (model) {\n return {\n ...state,\n [key]: {\n ...state[key],\n model,\n lastModification: Date.now(),\n },\n };\n }\n\n throw new IllegalArgumentException(\"No model for setModel\");\n};\n\n/**\n */\nconst initModularUI = (\n state: ModularUIState,\n models: Array<{ key: string, model: ModularUIModel }>\n) => {\n const newState = Object.assign({}, state);\n\n models.forEach(({ key, model }) => {\n newState[key] = {\n status: MODULARUI_STATUS.FINISHED,\n lastModification: Date.now(),\n model,\n };\n });\n\n return newState;\n};\n\n/**\n */\nconst getModelKey = (state: ModularUIState, model: ModularUIModel) =>\n Object.keys(state).find((key) => {\n const connectKey = state[key]?.model?.connectKey ?? \"\";\n return connectKey === model.connectKey;\n });\n\n/**\n */\nconst updateModel = (state: ModularUIState, model: ModularUIModel) => {\n const modelKey = getModelKey(state, model);\n\n if (modelKey) {\n return setModel(state, { key: modelKey, model });\n }\n\n throw new Error(\n `ModularUIReducer: Cannot update model with key ${model.connectKey}`\n );\n};\n\n/**\n */\nconst removeKey = (modelKey: string, state: ModularUIState): ModularUIState => {\n const newState = Object.assign({}, state);\n delete newState[modelKey];\n return newState;\n};\n\n/**\n * Remove all but application models\n */\nconst resetModularUI = (state: ModularUIState) => {\n const newState: ModularUIState = {};\n\n for (const key in state) {\n if (state[key].model instanceof ApplicationModel) {\n newState[key] = { ...state[key] };\n }\n }\n\n return newState;\n};\n\nconst initialState: ModularUIState = {};\n\n/**\n * Modular UI Reducer\n */\nexport const ModularUIReducer: Reducer<ModularUIState, ReduxAction> = (\n state = initialState,\n action\n) => {\n if (!action) {\n return state;\n }\n\n switch (action.type) {\n case \"MODULARUI/INIT\":\n return initModularUI(state, action.payload);\n\n case \"MODULARUI/RESET\":\n return resetModularUI(state);\n\n case \"MODULARUI/STATUS\":\n return updateStatus(state, action.payload);\n\n case \"MODULARUI/SET\":\n return setModel(state, action.payload);\n\n case \"MODULARUI/UPDATE\":\n case \"MODULARUI/UPDATE_FORM\":\n return updateModel(state, action.payload);\n\n case \"MODULARUI/REMOVE_KEY\":\n return removeKey(action.payload, state);\n\n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AK,CAACC,GAAG;MAAE,CAAC;IACnC;EACF;EAEA,OAAOU,QAAQ;AACjB,CAAC;AAED,MAAMU,YAA4B,GAAG,CAAC,CAAC;;AAEvC;AACA;AACA;AACA,OAAO,MAAMC,gBAAsD,GAAG,YAGjE;EAAA,IAFHtB,KAAK,uEAAGqB,YAAY;EAAA,IACpBE,MAAM;EAEN,IAAI,CAACA,MAAM,EAAE;IACX,OAAOvB,KAAK;EACd;EAEA,QAAQuB,MAAM,CAACC,IAAI;IACjB,KAAK,gBAAgB;MACnB,OAAOf,aAAa,CAACT,KAAK,EAAEuB,MAAM,CAACE,OAAO,CAAC;IAE7C,KAAK,iBAAiB;MACpB,OAAOL,cAAc,CAACpB,KAAK,CAAC;IAE9B,KAAK,kBAAkB;MACrB,OAAOD,YAAY,CAACC,KAAK,EAAEuB,MAAM,CAACE,OAAO,CAAC;IAE5C,KAAK,eAAe;MAClB,OAAOlB,QAAQ,CAACP,KAAK,EAAEuB,MAAM,CAACE,OAAO,CAAC;IAExC,KAAK,kBAAkB;IACvB,KAAK,uBAAuB;MAC1B,OAAOT,WAAW,CAAChB,KAAK,EAAEuB,MAAM,CAACE,OAAO,CAAC;IAE3C,KAAK,sBAAsB;MACzB,OAAON,SAAS,CAACI,MAAM,CAACE,OAAO,EAAEzB,KAAK,CAAC;IAEzC;MACE,OAAOA,KAAK;EAAC;AAEnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/redux/_modularui/types.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { FetchException } from \"../../exceptions\";\nimport type { NoAction } from \"../types\";\nimport typeof {\n HTTP_METHODS,\n MODULARUI_STATUS,\n} from \"../../constants/Constants\";\nimport type { ComponentType } from \"react\";\nimport type { TargetModel } from \"../../modularui/types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\nexport type ModularUIOptions = {\n propName?: string,\n removeOnUnmount?: boolean,\n ...RequestModularUIOptions,\n};\n\nexport type ModelEntry = {\n +status: string,\n +model: ModularUIModel,\n +lastModification: number,\n};\n\nexport type ModularUIState = {\n [string]: ModelEntry,\n ...\n};\n\nexport type SetModelAction = {\n type: \"MODULARUI/SET\",\n payload: {\n key: string,\n model: ?ModularUIModel,\n },\n};\n\nexport type InitModelAction = {\n type: \"MODULARUI/INIT\",\n payload: Array<{\n key: string,\n model: ModularUIModel,\n }>,\n};\n\nexport type UpdateModelAction = {\n type: \"MODULARUI/UPDATE\",\n payload: ModularUIModel,\n};\n\nexport type SuccessAction = (\n model: ModularUIModel\n) => UpdateModelAction | SetModelAction;\n\nexport type ErrorAction = (\n error: FetchException\n) => UpdateStatusAction | RemoveModelByKeyAction | NoAction;\n\nexport type ModularUIAction = {\n type: \"MODULARUI/FETCH\",\n payload: {\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n successAction: (\n model: ModularUIModel\n ) => UpdateModelAction | SetModelAction,\n errorAction?: ErrorAction,\n },\n};\n\nexport type RemoveModelByKeyAction = {\n type: \"MODULARUI/REMOVE_KEY\",\n payload: string,\n};\n\nexport type ResetModularUIAction = {\n type: \"MODULARUI/RESET\",\n};\n\nexport type UpdateStatusAction = {\n type: \"MODULARUI/STATUS\",\n payload: {\n key: string,\n status: $Keys<MODULARUI_STATUS>,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>\n) => ComponentType<any>;\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/redux/_modularui/types.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { FetchException } from \"../../exceptions\";\nimport type { NoAction } from \"../types\";\nimport typeof {\n HTTP_METHODS,\n MODULARUI_STATUS,\n} from \"../../constants/Constants\";\nimport type { ComponentType } from \"react\";\nimport type { TargetModel } from \"../../modularui/types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\nexport type ModularUIOptions = {\n propName?: string,\n removeOnUnmount?: boolean,\n ...RequestModularUIOptions,\n};\n\nexport type ModelEntry = {\n +status: string,\n +model: ModularUIModel,\n +lastModification: number,\n};\n\nexport type ModularUIState = {\n [string]: ModelEntry,\n ...\n};\n\nexport type SetModelAction = {\n type: \"MODULARUI/SET\",\n payload: {\n key: string,\n model: ?ModularUIModel,\n },\n};\n\nexport type InitModelAction = {\n type: \"MODULARUI/INIT\",\n payload: Array<{\n key: string,\n model: ModularUIModel,\n }>,\n};\n\nexport type UpdateModelAction = {\n type: \"MODULARUI/UPDATE\",\n payload: ModularUIModel,\n};\n\nexport type UpdateFormAction = {\n type: \"MODULARUI/UPDATE_FORM\",\n payload: ModularUIModel,\n};\n\nexport type SuccessAction = (\n model: ModularUIModel\n) => UpdateModelAction | SetModelAction;\n\nexport type ErrorAction = (\n error: FetchException\n) => UpdateStatusAction | RemoveModelByKeyAction | NoAction;\n\nexport type ModularUIAction = {\n type: \"MODULARUI/FETCH\",\n payload: {\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n data?: any,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n successAction: (\n model: ModularUIModel\n ) => UpdateModelAction | SetModelAction,\n errorAction?: ErrorAction,\n },\n};\n\nexport type RemoveModelByKeyAction = {\n type: \"MODULARUI/REMOVE_KEY\",\n payload: string,\n};\n\nexport type ResetModularUIAction = {\n type: \"MODULARUI/RESET\",\n};\n\nexport type UpdateStatusAction = {\n type: \"MODULARUI/STATUS\",\n payload: {\n key: string,\n status: $Keys<MODULARUI_STATUS>,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>\n) => ComponentType<any>;\n"],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { goBack } from "../_router/RouterActions";
|
|
2
|
-
import {
|
|
2
|
+
import { updateForm } from "../_modularui/ModularUIActions";
|
|
3
3
|
import { logoutSuccess } from "./SignOut";
|
|
4
4
|
import { reloadApplication } from "./Application";
|
|
5
5
|
import { startProgress, finishProgress } from "./ProgressIndicator";
|
|
@@ -10,7 +10,7 @@ import Authenticate from "../../modularui/Authenticate";
|
|
|
10
10
|
export const previousObject = form => {
|
|
11
11
|
const newForm = form.clone();
|
|
12
12
|
newForm.setPreviousObject();
|
|
13
|
-
return
|
|
13
|
+
return updateForm(newForm);
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.js","names":["goBack","
|
|
1
|
+
{"version":3,"file":"Form.js","names":["goBack","updateForm","logoutSuccess","reloadApplication","startProgress","finishProgress","Authenticate","previousObject","form","newForm","clone","setPreviousObject","cancelForm","dispatch","getState","key","auth","mustChangePassword","logout","then"],"sources":["../../../src/redux/actions/Form.js"],"sourcesContent":["// @flow\nimport { goBack } from \"../_router/RouterActions\";\nimport { updateForm } from \"../_modularui/ModularUIActions\";\nimport { logoutSuccess } from \"./SignOut\";\nimport { reloadApplication } from \"./Application\";\nimport { startProgress, finishProgress } from \"./ProgressIndicator\";\n\nimport Authenticate from \"../../modularui/Authenticate\";\n\nimport type { Dispatch, GetState, ThunkAction } from \"../types\";\nimport type FormModel from \"../../models/form/FormModel\";\nimport type { UpdateFormAction } from \"../_modularui/types\";\n\n/**\n * Go back to previous object (back button on form)\n */\nexport const previousObject = (form: FormModel): UpdateFormAction => {\n const newForm = form.clone();\n\n newForm.setPreviousObject();\n\n return updateForm(newForm);\n};\n\n/**\n */\nexport const cancelForm =\n (form: FormModel): ThunkAction =>\n (dispatch: Dispatch, getState: GetState) => {\n if (form.key === \"ChangePassword\" && getState().auth.mustChangePassword) {\n dispatch(startProgress());\n return new Authenticate().logout().then(() => {\n dispatch(logoutSuccess());\n dispatch(reloadApplication());\n dispatch(finishProgress());\n\n return dispatch(goBack());\n });\n }\n\n return dispatch(goBack());\n };\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,0BAA0B;AACjD,SAASC,UAAU,QAAQ,gCAAgC;AAC3D,SAASC,aAAa,QAAQ,WAAW;AACzC,SAASC,iBAAiB,QAAQ,eAAe;AACjD,SAASC,aAAa,EAAEC,cAAc,QAAQ,qBAAqB;AAEnE,OAAOC,YAAY,MAAM,8BAA8B;AAMvD;AACA;AACA;AACA,OAAO,MAAMC,cAAc,GAAIC,IAAe,IAAuB;EACnE,MAAMC,OAAO,GAAGD,IAAI,CAACE,KAAK,EAAE;EAE5BD,OAAO,CAACE,iBAAiB,EAAE;EAE3B,OAAOV,UAAU,CAACQ,OAAO,CAAC;AAC5B,CAAC;;AAED;AACA;AACA,OAAO,MAAMG,UAAU,GACpBJ,IAAe,IAChB,CAACK,QAAkB,EAAEC,QAAkB,KAAK;EAC1C,IAAIN,IAAI,CAACO,GAAG,KAAK,gBAAgB,IAAID,QAAQ,EAAE,CAACE,IAAI,CAACC,kBAAkB,EAAE;IACvEJ,QAAQ,CAACT,aAAa,EAAE,CAAC;IACzB,OAAO,IAAIE,YAAY,EAAE,CAACY,MAAM,EAAE,CAACC,IAAI,CAAC,MAAM;MAC5CN,QAAQ,CAACX,aAAa,EAAE,CAAC;MACzBW,QAAQ,CAACV,iBAAiB,EAAE,CAAC;MAC7BU,QAAQ,CAACR,cAAc,EAAE,CAAC;MAE1B,OAAOQ,QAAQ,CAACb,MAAM,EAAE,CAAC;IAC3B,CAAC,CAAC;EACJ;EAEA,OAAOa,QAAQ,CAACb,MAAM,EAAE,CAAC;AAC3B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { updateForm } from "../_modularui/ModularUIActions";
|
|
2
2
|
import { getSetting } from "../../constants/Settings";
|
|
3
3
|
import { validateFormObject } from "./FormValidations";
|
|
4
4
|
import { autosaveFormObject } from "./FormAutosave";
|
|
@@ -40,7 +40,7 @@ export const updateFormAttribute = function (form, formObject, attribute, inputv
|
|
|
40
40
|
// server form validations happens async, don't wait for the form to return
|
|
41
41
|
dispatch(validateFormObject(newForm));
|
|
42
42
|
}
|
|
43
|
-
return dispatch(
|
|
43
|
+
return dispatch(updateForm(newForm));
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
46
|
//# sourceMappingURL=FormAttributeSet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormAttributeSet.js","names":["
|
|
1
|
+
{"version":3,"file":"FormAttributeSet.js","names":["updateForm","getSetting","validateFormObject","autosaveFormObject","autosubmitFormObject","updateFormAttribute","form","formObject","attribute","inputvalue","options","autosubmit","autosave","forceUpdate","validate","dispatch","newForm","clone","undefined","currentFormObject","equals","updateAttribute","completedFormObjects","forEach","completeObject","isValid","autosubmitAction","isChanged","hasDynamicValidations"],"sources":["../../../src/redux/actions/FormAttributeSet.js"],"sourcesContent":["// @flow\nimport { updateForm } from \"../_modularui/ModularUIActions\";\n\nimport { getSetting } from \"../../constants/Settings\";\n\nimport { validateFormObject } from \"./FormValidations\";\nimport { autosaveFormObject } from \"./FormAutosave\";\nimport { autosubmitFormObject } from \"./FormAutosubmit\";\n\nimport type { Dispatch, ThunkAction, UpdateFormOptions } from \"../types\";\nimport type { AttributeType } from \"../../models/types\";\nimport type FormModel from \"../../models/form/FormModel\";\nimport type FormObjectModel from \"../../models/form/FormObjectModel\";\n\n/**\n * Update an attribute on a form\n */\nexport const updateFormAttribute =\n (\n form: FormModel,\n formObject: FormObjectModel,\n attribute: AttributeType,\n inputvalue: string,\n options: UpdateFormOptions = {\n autosubmit: false,\n autosave: false,\n forceUpdate: false,\n validate: true,\n }\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n const newForm = form.clone();\n\n if (options.validate === undefined) {\n options.validate = true;\n }\n\n if (newForm.currentFormObject?.equals(formObject)) {\n newForm.currentFormObject.updateAttribute(attribute, inputvalue);\n } else {\n newForm.completedFormObjects.forEach((completeObject) => {\n if (completeObject.equals(formObject)) {\n completeObject.updateAttribute(attribute, inputvalue);\n }\n });\n }\n\n if (options.autosubmit && newForm.isValid) {\n const autosubmitAction = autosubmitFormObject(\n newForm,\n attribute,\n options.forceUpdate\n );\n if (autosubmitAction) {\n return dispatch(autosubmitAction);\n }\n }\n\n if (options.autosave && newForm.isValid && newForm.isChanged()) {\n dispatch(autosaveFormObject(newForm));\n }\n\n if (\n options.validate &&\n newForm.currentFormObject?.hasDynamicValidations &&\n getSetting(\"USE_INSTANT_SERVER_VALIDATION\")\n ) {\n // server form validations happens async, don't wait for the form to return\n dispatch(validateFormObject(newForm));\n }\n\n return dispatch(updateForm(newForm));\n };\n"],"mappings":"AACA,SAASA,UAAU,QAAQ,gCAAgC;AAE3D,SAASC,UAAU,QAAQ,0BAA0B;AAErD,SAASC,kBAAkB,QAAQ,mBAAmB;AACtD,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,oBAAoB,QAAQ,kBAAkB;AAOvD;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,GAC9B,UACEC,IAAe,EACfC,UAA2B,EAC3BC,SAAwB,EACxBC,UAAkB;EAAA,IAClBC,OAA0B,uEAAG;IAC3BC,UAAU,EAAE,KAAK;IACjBC,QAAQ,EAAE,KAAK;IACfC,WAAW,EAAE,KAAK;IAClBC,QAAQ,EAAE;EACZ,CAAC;EAAA,OAEFC,QAAkB,IAAK;IACtB,MAAMC,OAAO,GAAGV,IAAI,CAACW,KAAK,EAAE;IAE5B,IAAIP,OAAO,CAACI,QAAQ,KAAKI,SAAS,EAAE;MAClCR,OAAO,CAACI,QAAQ,GAAG,IAAI;IACzB;IAEA,IAAIE,OAAO,CAACG,iBAAiB,EAAEC,MAAM,CAACb,UAAU,CAAC,EAAE;MACjDS,OAAO,CAACG,iBAAiB,CAACE,eAAe,CAACb,SAAS,EAAEC,UAAU,CAAC;IAClE,CAAC,MAAM;MACLO,OAAO,CAACM,oBAAoB,CAACC,OAAO,CAAEC,cAAc,I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