@beinformed/ui 1.59.6 → 1.59.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 +15 -0
- package/esm/models/attributes/DatetimeAttributeModel.js +25 -19
- package/esm/models/attributes/DatetimeAttributeModel.js.map +1 -1
- package/esm/redux/_modularui/ModularUIActions.js +1 -8
- package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
- package/esm/redux/_modularui/ModularUIReducer.js +8 -3
- package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/lib/models/attributes/DatetimeAttributeModel.js +25 -19
- package/lib/models/attributes/DatetimeAttributeModel.js.flow +27 -21
- package/lib/models/attributes/DatetimeAttributeModel.js.map +1 -1
- package/lib/redux/_modularui/ModularUIActions.js +1 -8
- package/lib/redux/_modularui/ModularUIActions.js.flow +1 -12
- package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
- package/lib/redux/_modularui/ModularUIReducer.js +8 -3
- package/lib/redux/_modularui/ModularUIReducer.js.flow +6 -3
- package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/lib/redux/_modularui/__tests__/reducer.spec.js.flow +3 -3
- package/package.json +1 -1
- package/src/models/attributes/DatetimeAttributeModel.js +27 -21
- package/src/redux/_modularui/ModularUIActions.js +1 -12
- package/src/redux/_modularui/ModularUIReducer.js +6 -3
- package/src/redux/_modularui/__tests__/reducer.spec.js +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.59.8](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.59.7...v1.59.8) (2024-12-12)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **modularui:** log message in stead of exceptions ([9962997](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/9962997e3efc18b658a2c9fb49c0440b350010c5))
|
|
11
|
+
* **modularui:** log message in stead of exceptions ([771a38c](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/771a38c6d57882c4b609c55d443eef2f3ca53099))
|
|
12
|
+
|
|
13
|
+
## [1.59.7](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.59.6...v1.59.7) (2024-12-12)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **load-model:** allow duplicate request, fixes jmeter test ([8d1a630](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/8d1a630e20c1a0db392770e1ed0af54802bf11cd))
|
|
19
|
+
|
|
5
20
|
## [1.59.6](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.59.5...v1.59.6) (2024-12-11)
|
|
6
21
|
|
|
7
22
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
2
2
|
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
3
3
|
import _trimInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/trim";
|
|
4
|
+
import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
|
4
5
|
import { has } from "../../utils/helpers/objects";
|
|
5
6
|
import { DateUtil, DateTimeUtil, TimeUtil, TimestampUtil } from "../../utils/datetime/DateTimeUtil";
|
|
6
7
|
import StringAttributeModel from "./StringAttributeModel";
|
|
@@ -208,35 +209,40 @@ class DatetimeAttributeModel extends StringAttributeModel {
|
|
|
208
209
|
|
|
209
210
|
/**
|
|
210
211
|
*/
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
if (this._dateInputFormat) {
|
|
216
|
-
return this._dateInputFormat;
|
|
217
|
-
}
|
|
218
|
-
const dateEraChars = "yMLdQDEewGu";
|
|
219
|
-
const timeOffsetChars = "HhaKmsSZzXxO";
|
|
212
|
+
extractDateInputFormat() {
|
|
213
|
+
const dateEraChars = new _Set("yMLdQDEewGu");
|
|
214
|
+
const timeOffsetChars = new _Set("HhaKmsSZzXxO");
|
|
220
215
|
const format = this.format;
|
|
221
216
|
let inputFormat = "";
|
|
222
217
|
let isInQuotes = false;
|
|
223
|
-
let
|
|
218
|
+
let keep = false;
|
|
224
219
|
for (let i = 0; i < format.length; i++) {
|
|
220
|
+
const prevChar = i > 0 ? format[i - 1] : "";
|
|
221
|
+
const nextChar = i < format.length ? format[i + 1] : "";
|
|
225
222
|
const char = format[i];
|
|
226
223
|
if (char === "'") {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
} else if (!isInQuotes &&
|
|
231
|
-
|
|
232
|
-
} else if (!isInQuotes && _includesInstanceProperty(timeOffsetChars).call(timeOffsetChars, char)) {
|
|
233
|
-
isInDate = false;
|
|
224
|
+
isInQuotes = prevChar === "'" || nextChar === "'" || !isInQuotes;
|
|
225
|
+
} else if (!isInQuotes && dateEraChars.has(char)) {
|
|
226
|
+
keep = true;
|
|
227
|
+
} else if (!isInQuotes && timeOffsetChars.has(char)) {
|
|
228
|
+
keep = false;
|
|
234
229
|
}
|
|
235
|
-
if (
|
|
230
|
+
if (keep) {
|
|
236
231
|
inputFormat += char;
|
|
237
232
|
}
|
|
238
233
|
}
|
|
239
|
-
|
|
234
|
+
return _trimInstanceProperty(inputFormat).call(inputFormat);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
*/
|
|
239
|
+
get dateInputFormat() {
|
|
240
|
+
if (!this.hasDate) {
|
|
241
|
+
return "";
|
|
242
|
+
}
|
|
243
|
+
if (!this._dateInputFormat) {
|
|
244
|
+
this._dateInputFormat = this.extractDateInputFormat();
|
|
245
|
+
}
|
|
240
246
|
return this._dateInputFormat;
|
|
241
247
|
}
|
|
242
248
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatetimeAttributeModel.js","names":["has","DateUtil","DateTimeUtil","TimeUtil","TimestampUtil","StringAttributeModel","ConstraintCollection","DateTimeDateFormatConstraint","DateTimeTimeFormatConstraint","DatetimeFormatConstraint","DateBoundaryConstraint","isIncludeTimeOffsetInDateTimes","ATTRIBUTE_WIDTH","DATETIME_OFFSET_FORMAT","ISO_DATE_FORMAT","DatetimeAttributeModel","constructor","attribute","attributeContributions","modelOptions","_defineProperty","updateInitValue","isApplicableModel","contributions","_context","_includesInstanceProperty","call","type","formatUtil","getInitValue","value","data","length","toFormat","getIsoFormat","toISO","hasTime","getTimeValue","_context2","_context3","_context4","_context5","timeValue","timeInputFormat","toLowerCase","setHour","setMinute","setSecond","setMilliseconds","oldOffset","newOffset","replace","_initvalue","_inputvalue","getInitialInputValue","_value","initValue","inputFormat","getContribution","getInputValue","toString","inputvalue","validate","format","convertFormat","hasDate","formatLabel","dateInputFormat","inputFormatWithoutOffset","_context6","_trimInstanceProperty","_dateInputFormat","dateEraChars","timeOffsetChars","isInQuotes","isInDate","i","char","prevChar","nextChar","dateReadonlyFormat","_context7","placeholder","_placeholder","split","_timeInputFormat","timeFormatParts","push","timeFormat","join","timeReadonlyFormat","dateInputValue","timeInputValue","formatValue","hasFormat","readonlyvalue","isAmbiguous","offset","getOffset","mindate","maxdate","addServerError","error","id","message","properties","layouthint","_errorCollection","getFormatConstraint","addConstraints","constraints","add","readonlyWidth","SMALL","MEDIUM","updateByAttribute","otherAttribute","reset","otherValue","inputValue","update","console"],"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 {\n isIncludeTimeOffsetInDateTimes,\n ATTRIBUTE_WIDTH,\n DATETIME_OFFSET_FORMAT,\n ISO_DATE_FORMAT,\n} from \"../../constants\";\n\nimport type {\n FormErrorAnchor,\n IConstraintModel,\n AttributeType,\n ModelOptions,\n} from \"../types\";\nimport type { OffsetInfo } from \"../../utils/datetime/DateTimeUtil\";\n\n/**\n */\nclass DatetimeAttributeModel extends StringAttributeModel {\n _dateInputFormat: ?string;\n _timeInputFormat: ?string;\n\n /**\n */\n constructor(\n attribute: Object,\n attributeContributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(attribute, attributeContributions, modelOptions);\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 = TimestampUtil.toFormat(value, DateTimeUtil.getIsoFormat());\n } else {\n value = this.formatUtil.toISO(value);\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\n if (isIncludeTimeOffsetInDateTimes()) {\n // https://github.com/date-fns/date-fns/issues/3579\n const oldOffset = this.formatUtil.toFormat(value, DATETIME_OFFSET_FORMAT);\n const newOffset = this.formatUtil.toFormat(\n timeValue,\n DATETIME_OFFSET_FORMAT,\n );\n timeValue = timeValue.replace(newOffset, oldOffset);\n }\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 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 inputFormatWithoutOffset(): 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 inputFormat(): string {\n if (\n isIncludeTimeOffsetInDateTimes() &&\n this.dateInputFormat !== \"\" &&\n this.timeInputFormat !== \"\"\n ) {\n return `${this.inputFormatWithoutOffset} ${DATETIME_OFFSET_FORMAT}`;\n }\n return this.inputFormatWithoutOffset;\n }\n\n /**\n */\n get dateInputFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n if (this._dateInputFormat) {\n return this._dateInputFormat;\n }\n\n const dateEraChars = \"yMLdQDEewGu\";\n const timeOffsetChars = \"HhaKmsSZzXxO\";\n\n const format = this.format;\n let inputFormat = \"\";\n\n let isInQuotes = false;\n let isInDate = false;\n\n for (let i = 0; i < format.length; i++) {\n const char = format[i];\n if (char === \"'\") {\n const prevChar = i > 0 ? format[i - 1] : \"\";\n const nextChar = format[i + 1];\n isInQuotes = prevChar === \"'\" || nextChar === \"'\" ? true : !isInQuotes;\n } else if (!isInQuotes && dateEraChars.includes(char)) {\n isInDate = true;\n } else if (!isInQuotes && timeOffsetChars.includes(char)) {\n isInDate = false;\n }\n\n if (isInDate) {\n inputFormat += char;\n }\n }\n\n this._dateInputFormat = inputFormat.trim();\n return this._dateInputFormat;\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 if (this._timeInputFormat) {\n return this._timeInputFormat;\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 timeFormat = `${timeFormat} a`;\n }\n\n this._timeInputFormat = timeFormat;\n return this._timeInputFormat;\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 /**\n * format value in readonly rendering\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 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 */\n get isAmbiguous(): boolean {\n if (typeof this.value === \"string\") {\n return this.formatUtil.isAmbiguous(this.value);\n }\n return false;\n }\n\n /**\n */\n get offset(): OffsetInfo | null {\n if (typeof this.value === \"string\") {\n return this.formatUtil.getOffset(this.value);\n }\n return null;\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 /**\n */\n updateByAttribute(otherAttribute: AttributeType): void {\n this.reset();\n if (otherAttribute instanceof DatetimeAttributeModel) {\n const otherValue = otherAttribute.value;\n if (otherValue != null) {\n const inputValue = this.formatUtil.toFormat(\n otherValue,\n this.inputFormat,\n );\n this.update(inputValue);\n }\n } else {\n console.error(\n `update of datetime attribute with ${otherAttribute.type} not supported`,\n );\n }\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,SACEC,8BAA8B,EAC9BC,eAAe,EACfC,sBAAsB,EACtBC,eAAe,QACV,iBAAiB;AAUxB;AACA;AACA,MAAMC,sBAAsB,SAASV,oBAAoB,CAAC;EAIxD;AACF;EACEW,WAAWA,CACTC,SAAiB,EACjBC,sBAA8B,EAC9BC,YAA2B,EAC3B;IACA,KAAK,CAACF,SAAS,EAAEC,sBAAsB,EAAEC,YAAY,CAAC;IAACC,eAAA;IAAAA,eAAA;IAEvD,IAAI,CAACC,eAAe,CAAC,CAAC;EACxB;;EAEA;AACF;EACE,OAAOC,iBAAiBA,CAACC,aAAqB,EAAW;IAAA,IAAAC,QAAA;IACvD,OAAOC,yBAAA,CAAAD,QAAA,IAAC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AAMC,UAAU,GAAG,IAAI,CAAC3F,UAAU,CAACK,QAAQ,CACzCqF,UAAU,EACV,IAAI,CAAC7D,WACP,CAAC;QACD,IAAI,CAAC+D,MAAM,CAACD,UAAU,CAAC;MACzB;IACF,CAAC,MAAM;MACLE,OAAO,CAACnB,KAAK,CACX,qCAAqCc,cAAc,CAACzF,IAAI,gBAC1D,CAAC;IACH;EACF;AACF;AAEA,eAAeZ,sBAAsB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"DatetimeAttributeModel.js","names":["has","DateUtil","DateTimeUtil","TimeUtil","TimestampUtil","StringAttributeModel","ConstraintCollection","DateTimeDateFormatConstraint","DateTimeTimeFormatConstraint","DatetimeFormatConstraint","DateBoundaryConstraint","isIncludeTimeOffsetInDateTimes","ATTRIBUTE_WIDTH","DATETIME_OFFSET_FORMAT","ISO_DATE_FORMAT","DatetimeAttributeModel","constructor","attribute","attributeContributions","modelOptions","_defineProperty","updateInitValue","isApplicableModel","contributions","_context","_includesInstanceProperty","call","type","formatUtil","getInitValue","value","data","length","toFormat","getIsoFormat","toISO","hasTime","getTimeValue","_context2","_context3","_context4","_context5","timeValue","timeInputFormat","toLowerCase","setHour","setMinute","setSecond","setMilliseconds","oldOffset","newOffset","replace","_initvalue","_inputvalue","getInitialInputValue","_value","initValue","inputFormat","getContribution","getInputValue","toString","inputvalue","validate","format","convertFormat","hasDate","formatLabel","dateInputFormat","inputFormatWithoutOffset","_context6","_trimInstanceProperty","extractDateInputFormat","dateEraChars","_Set","timeOffsetChars","isInQuotes","keep","i","prevChar","nextChar","char","_dateInputFormat","dateReadonlyFormat","_context7","placeholder","_placeholder","split","_timeInputFormat","timeFormatParts","push","timeFormat","join","timeReadonlyFormat","dateInputValue","timeInputValue","formatValue","hasFormat","readonlyvalue","isAmbiguous","offset","getOffset","mindate","maxdate","addServerError","error","id","message","properties","layouthint","_errorCollection","getFormatConstraint","addConstraints","constraints","add","readonlyWidth","SMALL","MEDIUM","updateByAttribute","otherAttribute","reset","otherValue","inputValue","update","console"],"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 {\n isIncludeTimeOffsetInDateTimes,\n ATTRIBUTE_WIDTH,\n DATETIME_OFFSET_FORMAT,\n ISO_DATE_FORMAT,\n} from \"../../constants\";\n\nimport type {\n FormErrorAnchor,\n IConstraintModel,\n AttributeType,\n ModelOptions,\n} from \"../types\";\nimport type { OffsetInfo } from \"../../utils/datetime/DateTimeUtil\";\n\n/**\n */\nclass DatetimeAttributeModel extends StringAttributeModel {\n _dateInputFormat: ?string;\n _timeInputFormat: ?string;\n\n /**\n */\n constructor(\n attribute: Object,\n attributeContributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(attribute, attributeContributions, modelOptions);\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 = TimestampUtil.toFormat(value, DateTimeUtil.getIsoFormat());\n } else {\n value = this.formatUtil.toISO(value);\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\n if (isIncludeTimeOffsetInDateTimes()) {\n // https://github.com/date-fns/date-fns/issues/3579\n const oldOffset = this.formatUtil.toFormat(value, DATETIME_OFFSET_FORMAT);\n const newOffset = this.formatUtil.toFormat(\n timeValue,\n DATETIME_OFFSET_FORMAT,\n );\n timeValue = timeValue.replace(newOffset, oldOffset);\n }\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 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 inputFormatWithoutOffset(): 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 inputFormat(): string {\n if (\n isIncludeTimeOffsetInDateTimes() &&\n this.dateInputFormat !== \"\" &&\n this.timeInputFormat !== \"\"\n ) {\n return `${this.inputFormatWithoutOffset} ${DATETIME_OFFSET_FORMAT}`;\n }\n return this.inputFormatWithoutOffset;\n }\n\n /**\n */\n extractDateInputFormat(): string {\n const dateEraChars = new Set(\"yMLdQDEewGu\");\n const timeOffsetChars = new Set(\"HhaKmsSZzXxO\");\n\n const format = this.format;\n let inputFormat = \"\";\n\n let isInQuotes = false;\n let keep = false;\n\n for (let i = 0; i < format.length; i++) {\n const prevChar = i > 0 ? format[i - 1] : \"\";\n const nextChar = i < format.length ? format[i + 1] : \"\";\n const char = format[i];\n\n if (char === \"'\") {\n isInQuotes = prevChar === \"'\" || nextChar === \"'\" || !isInQuotes;\n } else if (!isInQuotes && dateEraChars.has(char)) {\n keep = true;\n } else if (!isInQuotes && timeOffsetChars.has(char)) {\n keep = false;\n }\n\n if (keep) {\n inputFormat += char;\n }\n }\n\n return inputFormat.trim();\n }\n\n /**\n */\n get dateInputFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n if (!this._dateInputFormat) {\n this._dateInputFormat = this.extractDateInputFormat();\n }\n\n return this._dateInputFormat;\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 if (this._timeInputFormat) {\n return this._timeInputFormat;\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 timeFormat = `${timeFormat} a`;\n }\n\n this._timeInputFormat = timeFormat;\n return this._timeInputFormat;\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 /**\n * format value in readonly rendering\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 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 */\n get isAmbiguous(): boolean {\n if (typeof this.value === \"string\") {\n return this.formatUtil.isAmbiguous(this.value);\n }\n return false;\n }\n\n /**\n */\n get offset(): OffsetInfo | null {\n if (typeof this.value === \"string\") {\n return this.formatUtil.getOffset(this.value);\n }\n return null;\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 /**\n */\n updateByAttribute(otherAttribute: AttributeType): void {\n this.reset();\n if (otherAttribute instanceof DatetimeAttributeModel) {\n const otherValue = otherAttribute.value;\n if (otherValue != null) {\n const inputValue = this.formatUtil.toFormat(\n otherValue,\n this.inputFormat,\n );\n this.update(inputValue);\n }\n } else {\n console.error(\n `update of datetime attribute with ${otherAttribute.type} not supported`,\n );\n }\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,SACEC,8BAA8B,EAC9BC,eAAe,EACfC,sBAAsB,EACtBC,eAAe,QACV,iBAAiB;AAUxB;AACA;AACA,MAAMC,sBAAsB,SAASV,oBAAoB,CAAC;EAIxD;AACF;E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AA,EAAkC;IACjD,IAAI,IAAI,CAACvF,IAAI,KAAK,MAAM,IAAI,IAAI,CAACA,IAAI,KAAK,MAAM,EAAE;MAChD,OAAOf,eAAe,CAACuG,KAAK;IAC9B;IAEA,OAAOvG,eAAe,CAACwG,MAAM;EAC/B;;EAEA;AACF;EACEC,iBAAiBA,CAACC,cAA6B,EAAQ;IACrD,IAAI,CAACC,KAAK,CAAC,CAAC;IACZ,IAAID,cAAc,YAAYvG,sBAAsB,EAAE;MACpD,MAAMyG,UAAU,GAAGF,cAAc,CAACxF,KAAK;MACvC,IAAI0F,UAAU,IAAI,IAAI,EAAE;QACtB,MAAMC,UAAU,GAAG,IAAI,CAAC7F,UAAU,CAACK,QAAQ,CACzCuF,UAAU,EACV,IAAI,CAAC/D,WACP,CAAC;QACD,IAAI,CAACiE,MAAM,CAACD,UAAU,CAAC;MACzB;IACF,CAAC,MAAM;MACLE,OAAO,CAACnB,KAAK,CACX,qCAAqCc,cAAc,CAAC3F,IAAI,gBAC1D,CAAC;IACH;EACF;AACF;AAEA,eAAeZ,sBAAsB","ignoreList":[]}
|
|
@@ -116,14 +116,7 @@ export const loadModel = (key, href, options) => ({
|
|
|
116
116
|
|
|
117
117
|
/**
|
|
118
118
|
*/
|
|
119
|
-
export const loadModularUI = (key, href, options) =>
|
|
120
|
-
const modularuiStore = getState()?.modularui;
|
|
121
|
-
if (modularuiStore && modularuiStore[key]?.status === MODULARUI_STATUS.LOADING) {
|
|
122
|
-
// don't create duplicate requests during loading
|
|
123
|
-
return dispatch({
|
|
124
|
-
type: "NO_ACTION"
|
|
125
|
-
});
|
|
126
|
-
}
|
|
119
|
+
export const loadModularUI = (key, href, options) => dispatch => {
|
|
127
120
|
dispatch(startProgress());
|
|
128
121
|
const loadModelPromise = dispatch(loadModel(key, href, options));
|
|
129
122
|
return _Promise.resolve(loadModelPromise).then(() => dispatch(finishProgress())).catch(error => dispatch(handleError(error)));
|
|
@@ -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","updateForm","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","updateHandler","loadModel","href","options","origin","contextPath","method","GET","data","locale","childmodels","targetModel","forceTargetModel","cache","successAction","errorAction","error","errorResponse","isChangePassword","isResourceNotFoundAfterReload","ERROR","loadModularUI","dispatch","
|
|
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","updateHandler","loadModel","href","options","origin","contextPath","method","GET","data","locale","childmodels","targetModel","forceTargetModel","cache","successAction","errorAction","error","errorResponse","isChangePassword","isResourceNotFoundAfterReload","ERROR","loadModularUI","dispatch","loadModelPromise","_Promise","resolve","then","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 {\n RequestModularUIOptions,\n UpdateHandler,\n} 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 updateHandler: UpdateHandler | void,\n): UpdateModelAction | SetModelAction => {\n if (updateHandler) {\n return updateModel(updateHandler(model));\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 key,\n origin: options?.origin,\n contextPath: options?.contextPath,\n href:\n href instanceof Href\n ? href\n : new Href(href, \"\", {\n origin: options?.origin,\n contextPath: options?.contextPath,\n }),\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 cache: options?.cache,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateHandler),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key, {\n origin: options?.origin,\n contextPath: options?.contextPath,\n });\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(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then(() => dispatch(finishProgress()))\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;AAmB9C;AACA;AACA,OAAO,MAAMC,QAAQ,GAAGA,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,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C6C,KAAK,CAAEX,KAAK,IAAKM,QAAQ,CAACtC,WAAW,CAACgC,KAAK,CAAC,CAAC,CAAC;AACnD,CAAC;;AAEH;AACA;AACA,OAAO,MAAMY,WAAW,GAAGA,CACzBzC,KAAqB,EACrBgB,OAAiC,KAEjCkB,aAAa,CAAClC,KAAK,CAACC,UAAU,EAAED,KAAK,CAAC0C,QAAQ,EAAE;EAC9C,GAAG1B,OAAO;EACV2B,QAAQ,EAAE;AACZ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
2
2
|
import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
|
|
3
3
|
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
4
|
-
import { IllegalArgumentException } from "../../exceptions";
|
|
5
4
|
import { MODULARUI_STATUS } from "../../constants/Constants";
|
|
6
5
|
import { ApplicationModel } from "../../models";
|
|
7
6
|
/**
|
|
@@ -46,7 +45,10 @@ const setModel = (state, _ref2) => {
|
|
|
46
45
|
}
|
|
47
46
|
};
|
|
48
47
|
}
|
|
49
|
-
|
|
48
|
+
|
|
49
|
+
// eslint-disable-next-line no-console
|
|
50
|
+
console.debug("No model for setModel");
|
|
51
|
+
return state;
|
|
50
52
|
};
|
|
51
53
|
|
|
52
54
|
/**
|
|
@@ -87,7 +89,10 @@ const updateModel = (state, model) => {
|
|
|
87
89
|
model
|
|
88
90
|
});
|
|
89
91
|
}
|
|
90
|
-
|
|
92
|
+
|
|
93
|
+
// eslint-disable-next-line no-console
|
|
94
|
+
console.debug(`ModularUIReducer: Cannot update model with key ${model.connectKey}`);
|
|
95
|
+
return state;
|
|
91
96
|
};
|
|
92
97
|
|
|
93
98
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUIReducer.js","names":["
|
|
1
|
+
{"version":3,"file":"ModularUIReducer.js","names":["MODULARUI_STATUS","ApplicationModel","updateStatus","state","_ref","key","status","LOADING","lastModification","Date","now","setModel","_ref2","model","FINISHED","console","debug","initModularUI","models","newState","_Object$assign","forEach","_ref3","getModelKey","_context","_findInstanceProperty","_Object$keys","call","connectKey","updateModel","modelKey","removeKey","resetModularUI","initialState","ModularUIReducer","arguments","length","undefined","action","type","payload"],"sources":["../../../src/redux/_modularui/ModularUIReducer.js"],"sourcesContent":["// @flow\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 status: MODULARUI_STATUS.FINISHED,\n },\n };\n }\n\n // eslint-disable-next-line no-console\n console.debug(\"No model for setModel\");\n return state;\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 // eslint-disable-next-line no-console\n console.debug(\n `ModularUIReducer: Cannot update model with key ${model.connectKey}`,\n );\n return state;\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 default:\n return state;\n }\n};\n"],"mappings":";;;AACA,SAASA,gBAAgB,QAAQ,2BAA2B;AAC5D,SAASC,gBAAgB,QAAQ,cAAc;AAO/C;AACA;AACA,MAAMC,YAAY,GAAGA,CACnBC,KAAqB,EAAAC,IAAA,KAElB;EAAA,IADH;IAAEC,GAAG;IAAEC;EAAgE,CAAC,GAAAF,IAAA;EAExE;EACA,IAAIE,MAAM,KAAKN,gBAAgB,CAACO,OAAO,IAAI,CAACJ,KAAK,CAACE,GAAG,CAAC,EAAE;IACtD,OAAOF,KAAK;EACd;EAEA,OAAO;IACL,GAAGA,KAAK;IACR,CAACE,GAAG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,OAAO,MAAMC,gBAAsD,GAAG,SAAAA,CAAA,EAGjE;EAAA,IAFH/B,KAAK,GAAAgC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGF,YAAY;EAAA,IACpBK,MAAM,GAAAH,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAEN,IAAI,CAACC,MAAM,EAAE;IACX,OAAOnC,KAAK;EACd;EAEA,QAAQmC,MAAM,CAACC,IAAI;IACjB,KAAK,gBAAgB;MACnB,OAAOtB,aAAa,CAACd,KAAK,EAAEmC,MAAM,CAACE,OAAO,CAAC;IAE7C,KAAK,iBAAiB;MACpB,OAAOR,cAAc,CAAC7B,KAAK,CAAC;IAE9B,KAAK,kBAAkB;MACrB,OAAOD,YAAY,CAACC,KAAK,EAAEmC,MAAM,CAACE,OAAO,CAAC;IAE5C,KAAK,eAAe;MAClB,OAAO7B,QAAQ,CAACR,KAAK,EAAEmC,MAAM,CAACE,OAAO,CAAC;IAExC,KAAK,kBAAkB;IACvB,KAAK,uBAAuB;MAC1B,OAAOX,WAAW,CAAC1B,KAAK,EAAEmC,MAAM,CAACE,OAAO,CAAC;IAE3C,KAAK,sBAAsB;MACzB,OAAOT,SAAS,CAACO,MAAM,CAACE,OAAO,EAAErC,KAAK,CAAC;IAEzC;MACE,OAAOA,KAAK;EAChB;AACF,CAAC","ignoreList":[]}
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
9
9
|
var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
|
|
10
|
+
var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set"));
|
|
10
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
11
12
|
var _objects = require("../../utils/helpers/objects");
|
|
12
13
|
var _DateTimeUtil = require("../../utils/datetime/DateTimeUtil");
|
|
@@ -215,35 +216,40 @@ class DatetimeAttributeModel extends _StringAttributeModel.default {
|
|
|
215
216
|
|
|
216
217
|
/**
|
|
217
218
|
*/
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
if (this._dateInputFormat) {
|
|
223
|
-
return this._dateInputFormat;
|
|
224
|
-
}
|
|
225
|
-
const dateEraChars = "yMLdQDEewGu";
|
|
226
|
-
const timeOffsetChars = "HhaKmsSZzXxO";
|
|
219
|
+
extractDateInputFormat() {
|
|
220
|
+
const dateEraChars = new _set.default("yMLdQDEewGu");
|
|
221
|
+
const timeOffsetChars = new _set.default("HhaKmsSZzXxO");
|
|
227
222
|
const format = this.format;
|
|
228
223
|
let inputFormat = "";
|
|
229
224
|
let isInQuotes = false;
|
|
230
|
-
let
|
|
225
|
+
let keep = false;
|
|
231
226
|
for (let i = 0; i < format.length; i++) {
|
|
227
|
+
const prevChar = i > 0 ? format[i - 1] : "";
|
|
228
|
+
const nextChar = i < format.length ? format[i + 1] : "";
|
|
232
229
|
const char = format[i];
|
|
233
230
|
if (char === "'") {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
} else if (!isInQuotes &&
|
|
238
|
-
|
|
239
|
-
} else if (!isInQuotes && (0, _includes.default)(timeOffsetChars).call(timeOffsetChars, char)) {
|
|
240
|
-
isInDate = false;
|
|
231
|
+
isInQuotes = prevChar === "'" || nextChar === "'" || !isInQuotes;
|
|
232
|
+
} else if (!isInQuotes && dateEraChars.has(char)) {
|
|
233
|
+
keep = true;
|
|
234
|
+
} else if (!isInQuotes && timeOffsetChars.has(char)) {
|
|
235
|
+
keep = false;
|
|
241
236
|
}
|
|
242
|
-
if (
|
|
237
|
+
if (keep) {
|
|
243
238
|
inputFormat += char;
|
|
244
239
|
}
|
|
245
240
|
}
|
|
246
|
-
|
|
241
|
+
return (0, _trim.default)(inputFormat).call(inputFormat);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
*/
|
|
246
|
+
get dateInputFormat() {
|
|
247
|
+
if (!this.hasDate) {
|
|
248
|
+
return "";
|
|
249
|
+
}
|
|
250
|
+
if (!this._dateInputFormat) {
|
|
251
|
+
this._dateInputFormat = this.extractDateInputFormat();
|
|
252
|
+
}
|
|
247
253
|
return this._dateInputFormat;
|
|
248
254
|
}
|
|
249
255
|
|
|
@@ -267,42 +267,48 @@ class DatetimeAttributeModel extends StringAttributeModel {
|
|
|
267
267
|
|
|
268
268
|
/**
|
|
269
269
|
*/
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
if (this._dateInputFormat) {
|
|
276
|
-
return this._dateInputFormat;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const dateEraChars = "yMLdQDEewGu";
|
|
280
|
-
const timeOffsetChars = "HhaKmsSZzXxO";
|
|
270
|
+
extractDateInputFormat(): string {
|
|
271
|
+
const dateEraChars = new Set("yMLdQDEewGu");
|
|
272
|
+
const timeOffsetChars = new Set("HhaKmsSZzXxO");
|
|
281
273
|
|
|
282
274
|
const format = this.format;
|
|
283
275
|
let inputFormat = "";
|
|
284
276
|
|
|
285
277
|
let isInQuotes = false;
|
|
286
|
-
let
|
|
278
|
+
let keep = false;
|
|
287
279
|
|
|
288
280
|
for (let i = 0; i < format.length; i++) {
|
|
281
|
+
const prevChar = i > 0 ? format[i - 1] : "";
|
|
282
|
+
const nextChar = i < format.length ? format[i + 1] : "";
|
|
289
283
|
const char = format[i];
|
|
284
|
+
|
|
290
285
|
if (char === "'") {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
} else if (!isInQuotes &&
|
|
295
|
-
|
|
296
|
-
} else if (!isInQuotes && timeOffsetChars.includes(char)) {
|
|
297
|
-
isInDate = false;
|
|
286
|
+
isInQuotes = prevChar === "'" || nextChar === "'" || !isInQuotes;
|
|
287
|
+
} else if (!isInQuotes && dateEraChars.has(char)) {
|
|
288
|
+
keep = true;
|
|
289
|
+
} else if (!isInQuotes && timeOffsetChars.has(char)) {
|
|
290
|
+
keep = false;
|
|
298
291
|
}
|
|
299
292
|
|
|
300
|
-
if (
|
|
293
|
+
if (keep) {
|
|
301
294
|
inputFormat += char;
|
|
302
295
|
}
|
|
303
296
|
}
|
|
304
297
|
|
|
305
|
-
|
|
298
|
+
return inputFormat.trim();
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
*/
|
|
303
|
+
get dateInputFormat(): string {
|
|
304
|
+
if (!this.hasDate) {
|
|
305
|
+
return "";
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (!this._dateInputFormat) {
|
|
309
|
+
this._dateInputFormat = this.extractDateInputFormat();
|
|
310
|
+
}
|
|
311
|
+
|
|
306
312
|
return this._dateInputFormat;
|
|
307
313
|
}
|
|
308
314
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatetimeAttributeModel.js","names":["_objects","require","_DateTimeUtil","_StringAttributeModel","_interopRequireDefault","_ConstraintCollection","_DateTimeDateFormatConstraint","_DateTimeTimeFormatConstraint","_DatetimeFormatConstraint","_DateBoundaryConstraint","_constants","DatetimeAttributeModel","StringAttributeModel","constructor","attribute","attributeContributions","modelOptions","_defineProperty2","default","updateInitValue","isApplicableModel","contributions","_context","_includes","call","type","formatUtil","TimeUtil","TimestampUtil","DateTimeUtil","DateUtil","getInitValue","value","data","length","toFormat","getIsoFormat","toISO","hasTime","getTimeValue","_context2","_context3","_context4","_context5","timeValue","timeInputFormat","toLowerCase","setHour","setMinute","setSecond","setMilliseconds","isIncludeTimeOffsetInDateTimes","oldOffset","DATETIME_OFFSET_FORMAT","newOffset","replace","_initvalue","_inputvalue","getInitialInputValue","_value","initValue","inputFormat","getContribution","getInputValue","toString","inputvalue","validate","format","convertFormat","hasDate","formatLabel","dateInputFormat","inputFormatWithoutOffset","_context6","_trim","_dateInputFormat","dateEraChars","timeOffsetChars","isInQuotes","isInDate","i","char","prevChar","nextChar","dateReadonlyFormat","_context7","placeholder","_placeholder","split","_timeInputFormat","timeFormatParts","push","timeFormat","join","timeReadonlyFormat","dateInputValue","timeInputValue","formatValue","hasFormat","ISO_DATE_FORMAT","readonlyvalue","isAmbiguous","offset","getOffset","mindate","maxdate","addServerError","error","id","message","properties","layouthint","has","_errorCollection","getFormatConstraint","DateTimeDateFormatConstraint","DateTimeTimeFormatConstraint","DatetimeFormatConstraint","addConstraints","constraints","ConstraintCollection","add","DateBoundaryConstraint","readonlyWidth","ATTRIBUTE_WIDTH","SMALL","MEDIUM","updateByAttribute","otherAttribute","reset","otherValue","inputValue","update","console","_default","exports"],"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 {\n isIncludeTimeOffsetInDateTimes,\n ATTRIBUTE_WIDTH,\n DATETIME_OFFSET_FORMAT,\n ISO_DATE_FORMAT,\n} from \"../../constants\";\n\nimport type {\n FormErrorAnchor,\n IConstraintModel,\n AttributeType,\n ModelOptions,\n} from \"../types\";\nimport type { OffsetInfo } from \"../../utils/datetime/DateTimeUtil\";\n\n/**\n */\nclass DatetimeAttributeModel extends StringAttributeModel {\n _dateInputFormat: ?string;\n _timeInputFormat: ?string;\n\n /**\n */\n constructor(\n attribute: Object,\n attributeContributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(attribute, attributeContributions, modelOptions);\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 = TimestampUtil.toFormat(value, DateTimeUtil.getIsoFormat());\n } else {\n value = this.formatUtil.toISO(value);\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\n if (isIncludeTimeOffsetInDateTimes()) {\n // https://github.com/date-fns/date-fns/issues/3579\n const oldOffset = this.formatUtil.toFormat(value, DATETIME_OFFSET_FORMAT);\n const newOffset = this.formatUtil.toFormat(\n timeValue,\n DATETIME_OFFSET_FORMAT,\n );\n timeValue = timeValue.replace(newOffset, oldOffset);\n }\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 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 inputFormatWithoutOffset(): 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 inputFormat(): string {\n if (\n isIncludeTimeOffsetInDateTimes() &&\n this.dateInputFormat !== \"\" &&\n this.timeInputFormat !== \"\"\n ) {\n return `${this.inputFormatWithoutOffset} ${DATETIME_OFFSET_FORMAT}`;\n }\n return this.inputFormatWithoutOffset;\n }\n\n /**\n */\n get dateInputFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n if (this._dateInputFormat) {\n return this._dateInputFormat;\n }\n\n const dateEraChars = \"yMLdQDEewGu\";\n const timeOffsetChars = \"HhaKmsSZzXxO\";\n\n const format = this.format;\n let inputFormat = \"\";\n\n let isInQuotes = false;\n let isInDate = false;\n\n for (let i = 0; i < format.length; i++) {\n const char = format[i];\n if (char === \"'\") {\n const prevChar = i > 0 ? format[i - 1] : \"\";\n const nextChar = format[i + 1];\n isInQuotes = prevChar === \"'\" || nextChar === \"'\" ? true : !isInQuotes;\n } else if (!isInQuotes && dateEraChars.includes(char)) {\n isInDate = true;\n } else if (!isInQuotes && timeOffsetChars.includes(char)) {\n isInDate = false;\n }\n\n if (isInDate) {\n inputFormat += char;\n }\n }\n\n this._dateInputFormat = inputFormat.trim();\n return this._dateInputFormat;\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 if (this._timeInputFormat) {\n return this._timeInputFormat;\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 timeFormat = `${timeFormat} a`;\n }\n\n this._timeInputFormat = timeFormat;\n return this._timeInputFormat;\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 /**\n * format value in readonly rendering\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 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 */\n get isAmbiguous(): boolean {\n if (typeof this.value === \"string\") {\n return this.formatUtil.isAmbiguous(this.value);\n }\n return false;\n }\n\n /**\n */\n get offset(): OffsetInfo | null {\n if (typeof this.value === \"string\") {\n return this.formatUtil.getOffset(this.value);\n }\n return null;\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 /**\n */\n updateByAttribute(otherAttribute: AttributeType): void {\n this.reset();\n if (otherAttribute instanceof DatetimeAttributeModel) {\n const otherValue = otherAttribute.value;\n if (otherValue != null) {\n const inputValue = this.formatUtil.toFormat(\n otherValue,\n this.inputFormat,\n );\n this.update(inputValue);\n }\n } else {\n console.error(\n `update of datetime attribute with ${otherAttribute.type} not supported`,\n );\n }\n }\n}\n\nexport default DatetimeAttributeModel;\n"],"mappings":";;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC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AM,CAACD,UAAU,CAAC;MACzB;IACF,CAAC,MAAM;MACLE,OAAO,CAAC1B,KAAK,CACX,qCAAqCqB,cAAc,CAACvG,IAAI,gBAC1D,CAAC;IACH;EACF;AACF;AAAC,IAAA6G,QAAA,GAAAC,OAAA,CAAArH,OAAA,GAEcP,sBAAsB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"DatetimeAttributeModel.js","names":["_objects","require","_DateTimeUtil","_StringAttributeModel","_interopRequireDefault","_ConstraintCollection","_DateTimeDateFormatConstraint","_DateTimeTimeFormatConstraint","_DatetimeFormatConstraint","_DateBoundaryConstraint","_constants","DatetimeAttributeModel","StringAttributeModel","constructor","attribute","attributeContributions","modelOptions","_defineProperty2","default","updateInitValue","isApplicableModel","contributions","_context","_includes","call","type","formatUtil","TimeUtil","TimestampUtil","DateTimeUtil","DateUtil","getInitValue","value","data","length","toFormat","getIsoFormat","toISO","hasTime","getTimeValue","_context2","_context3","_context4","_context5","timeValue","timeInputFormat","toLowerCase","setHour","setMinute","setSecond","setMilliseconds","isIncludeTimeOffsetInDateTimes","oldOffset","DATETIME_OFFSET_FORMAT","newOffset","replace","_initvalue","_inputvalue","getInitialInputValue","_value","initValue","inputFormat","getContribution","getInputValue","toString","inputvalue","validate","format","convertFormat","hasDate","formatLabel","dateInputFormat","inputFormatWithoutOffset","_context6","_trim","extractDateInputFormat","dateEraChars","_set","timeOffsetChars","isInQuotes","keep","i","prevChar","nextChar","char","has","_dateInputFormat","dateReadonlyFormat","_context7","placeholder","_placeholder","split","_timeInputFormat","timeFormatParts","push","timeFormat","join","timeReadonlyFormat","dateInputValue","timeInputValue","formatValue","hasFormat","ISO_DATE_FORMAT","readonlyvalue","isAmbiguous","offset","getOffset","mindate","maxdate","addServerError","error","id","message","properties","layouthint","_errorCollection","getFormatConstraint","DateTimeDateFormatConstraint","DateTimeTimeFormatConstraint","DatetimeFormatConstraint","addConstraints","constraints","ConstraintCollection","add","DateBoundaryConstraint","readonlyWidth","ATTRIBUTE_WIDTH","SMALL","MEDIUM","updateByAttribute","otherAttribute","reset","otherValue","inputValue","update","console","_default","exports"],"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 {\n isIncludeTimeOffsetInDateTimes,\n ATTRIBUTE_WIDTH,\n DATETIME_OFFSET_FORMAT,\n ISO_DATE_FORMAT,\n} from \"../../constants\";\n\nimport type {\n FormErrorAnchor,\n IConstraintModel,\n AttributeType,\n ModelOptions,\n} from \"../types\";\nimport type { OffsetInfo } from \"../../utils/datetime/DateTimeUtil\";\n\n/**\n */\nclass DatetimeAttributeModel extends StringAttributeModel {\n _dateInputFormat: ?string;\n _timeInputFormat: ?string;\n\n /**\n */\n constructor(\n attribute: Object,\n attributeContributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(attribute, attributeContributions, modelOptions);\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 = TimestampUtil.toFormat(value, DateTimeUtil.getIsoFormat());\n } else {\n value = this.formatUtil.toISO(value);\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\n if (isIncludeTimeOffsetInDateTimes()) {\n // https://github.com/date-fns/date-fns/issues/3579\n const oldOffset = this.formatUtil.toFormat(value, DATETIME_OFFSET_FORMAT);\n const newOffset = this.formatUtil.toFormat(\n timeValue,\n DATETIME_OFFSET_FORMAT,\n );\n timeValue = timeValue.replace(newOffset, oldOffset);\n }\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 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 inputFormatWithoutOffset(): 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 inputFormat(): string {\n if (\n isIncludeTimeOffsetInDateTimes() &&\n this.dateInputFormat !== \"\" &&\n this.timeInputFormat !== \"\"\n ) {\n return `${this.inputFormatWithoutOffset} ${DATETIME_OFFSET_FORMAT}`;\n }\n return this.inputFormatWithoutOffset;\n }\n\n /**\n */\n extractDateInputFormat(): string {\n const dateEraChars = new Set(\"yMLdQDEewGu\");\n const timeOffsetChars = new Set(\"HhaKmsSZzXxO\");\n\n const format = this.format;\n let inputFormat = \"\";\n\n let isInQuotes = false;\n let keep = false;\n\n for (let i = 0; i < format.length; i++) {\n const prevChar = i > 0 ? format[i - 1] : \"\";\n const nextChar = i < format.length ? format[i + 1] : \"\";\n const char = format[i];\n\n if (char === \"'\") {\n isInQuotes = prevChar === \"'\" || nextChar === \"'\" || !isInQuotes;\n } else if (!isInQuotes && dateEraChars.has(char)) {\n keep = true;\n } else if (!isInQuotes && timeOffsetChars.has(char)) {\n keep = false;\n }\n\n if (keep) {\n inputFormat += char;\n }\n }\n\n return inputFormat.trim();\n }\n\n /**\n */\n get dateInputFormat(): string {\n if (!this.hasDate) {\n return \"\";\n }\n\n if (!this._dateInputFormat) {\n this._dateInputFormat = this.extractDateInputFormat();\n }\n\n return this._dateInputFormat;\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 if (this._timeInputFormat) {\n return this._timeInputFormat;\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 timeFormat = `${timeFormat} a`;\n }\n\n this._timeInputFormat = timeFormat;\n return this._timeInputFormat;\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 /**\n * format value in readonly rendering\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 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 */\n get isAmbiguous(): boolean {\n if (typeof this.value === \"string\") {\n return this.formatUtil.isAmbiguous(this.value);\n }\n return false;\n }\n\n /**\n */\n get offset(): OffsetInfo | null {\n if (typeof this.value === \"string\") {\n return this.formatUtil.getOffset(this.value);\n }\n return null;\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 /**\n */\n updateByAttribute(otherAttribute: AttributeType): void {\n this.reset();\n if (otherAttribute instanceof DatetimeAttributeModel) {\n const otherValue = otherAttribute.value;\n if (otherValue != null) {\n const inputValue = this.formatUtil.toFormat(\n otherValue,\n this.inputFormat,\n );\n this.update(inputValue);\n }\n } else {\n console.error(\n `update of datetime attribute with ${otherAttribute.type} not supported`,\n );\n }\n }\n}\n\nexport default DatetimeAttributeModel;\n"],"mappings":";;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AAOA,IAAAE,qBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,qBAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,6BAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,6BAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,yBAAA,GAAAJ,sBAAA,CAAAH,OAAA;AACA,IAAAQ,uBAAA,GAAAL,sBAAA,CAAAH,OAAA;AAEA,IAAAS,UAAA,GAAAT,OAAA;AAeA;AACA;AACA,MAAMU,sBAAs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
|
|
132
132
|
*/
|
|
133
133
|
exports.loadModel = loadModel;
|
|
134
|
-
const loadModularUI = (key, href, options) =>
|
|
135
|
-
const modularuiStore = getState()?.modularui;
|
|
136
|
-
if (modularuiStore && modularuiStore[key]?.status === _Constants.MODULARUI_STATUS.LOADING) {
|
|
137
|
-
// don't create duplicate requests during loading
|
|
138
|
-
return dispatch({
|
|
139
|
-
type: "NO_ACTION"
|
|
140
|
-
});
|
|
141
|
-
}
|
|
134
|
+
const loadModularUI = (key, href, options) => dispatch => {
|
|
142
135
|
dispatch((0, _ProgressIndicator.startProgress)());
|
|
143
136
|
const loadModelPromise = dispatch(loadModel(key, href, options));
|
|
144
137
|
return _promise.default.resolve(loadModelPromise).then(() => dispatch((0, _ProgressIndicator.finishProgress)())).catch(error => dispatch((0, _Error.handleError)(error)));
|
|
@@ -158,18 +158,7 @@ export const loadModularUI =
|
|
|
158
158
|
href: Href | string,
|
|
159
159
|
options?: RequestModularUIOptions,
|
|
160
160
|
): ThunkAction =>
|
|
161
|
-
(dispatch: Dispatch
|
|
162
|
-
const modularuiStore = getState()?.modularui;
|
|
163
|
-
if (
|
|
164
|
-
modularuiStore &&
|
|
165
|
-
modularuiStore[key]?.status === MODULARUI_STATUS.LOADING
|
|
166
|
-
) {
|
|
167
|
-
// don't create duplicate requests during loading
|
|
168
|
-
return dispatch({
|
|
169
|
-
type: "NO_ACTION",
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
|
|
161
|
+
(dispatch: Dispatch) => {
|
|
173
162
|
dispatch(startProgress());
|
|
174
163
|
|
|
175
164
|
const loadModelPromise = dispatch(loadModel(key, href, options));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUIActions.js","names":["_Constants","require","_Href","_interopRequireDefault","_ErrorResponse","_ProgressIndicator","_Error","setModel","key","model","connectKey","type","payload","exports","initModels","models","updateModel","updateForm","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","updateHandler","loadModel","href","options","origin","contextPath","Href","method","HTTP_METHODS","GET","data","locale","childmodels","targetModel","forceTargetModel","cache","successAction","errorAction","error","errorResponse","ErrorResponse","isChangePassword","isResourceNotFoundAfterReload","MODULARUI_STATUS","ERROR","loadModularUI","dispatch","
|
|
1
|
+
{"version":3,"file":"ModularUIActions.js","names":["_Constants","require","_Href","_interopRequireDefault","_ErrorResponse","_ProgressIndicator","_Error","setModel","key","model","connectKey","type","payload","exports","initModels","models","updateModel","updateForm","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","updateHandler","loadModel","href","options","origin","contextPath","Href","method","HTTP_METHODS","GET","data","locale","childmodels","targetModel","forceTargetModel","cache","successAction","errorAction","error","errorResponse","ErrorResponse","isChangePassword","isResourceNotFoundAfterReload","MODULARUI_STATUS","ERROR","loadModularUI","dispatch","startProgress","loadModelPromise","_promise","default","resolve","then","finishProgress","catch","handleError","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 {\n RequestModularUIOptions,\n UpdateHandler,\n} 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 updateHandler: UpdateHandler | void,\n): UpdateModelAction | SetModelAction => {\n if (updateHandler) {\n return updateModel(updateHandler(model));\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 key,\n origin: options?.origin,\n contextPath: options?.contextPath,\n href:\n href instanceof Href\n ? href\n : new Href(href, \"\", {\n origin: options?.origin,\n contextPath: options?.contextPath,\n }),\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 cache: options?.cache,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateHandler),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key, {\n origin: options?.origin,\n contextPath: options?.contextPath,\n });\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(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then(() => dispatch(finishProgress()))\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,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,cAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAmBA;AACA;AACO,MAAMM,QAAQ,GAAGA,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;AADAI,OAAA,CAAAN,QAAA,GAAAA,QAAA;AAEO,MAAMO,UAAU,GACrBC,MAAqD,KAChC;EACrBJ,IAAI,EAAE,gBAAgB;EACtBC,OAAO,EAAEG;AACX,CAAC,CAAC;;AAEF;AACA;AADAF,OAAA,CAAAC,UAAA,GAAAA,UAAA;AAEO,MAAME,WAAW,GAAIP,KAAqB,KAAyB;EACxEE,IAAI,EAAE,kBAAkB;EACxBC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;AACA;AADAI,OAAA,CAAAG,WAAA,GAAAA,WAAA;AAE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AS,CAAChB,GAAG,EAAEiB,IAAI,EAAEC,OAAO,CAAC,CAAC;EAEhE,OAAO0B,QAAA,CAAAC,OAAA,CAAQC,OAAO,CAACH,gBAAgB,CAAC,CACrCI,IAAI,CAAC,MAAMN,QAAQ,CAAC,IAAAO,iCAAc,EAAC,CAAC,CAAC,CAAC,CACtCC,KAAK,CAAEhB,KAAK,IAAKQ,QAAQ,CAAC,IAAAS,kBAAW,EAACjB,KAAK,CAAC,CAAC,CAAC;AACnD,CAAC;;AAEH;AACA;AADA5B,OAAA,CAAAmC,aAAA,GAAAA,aAAA;AAEO,MAAMW,WAAW,GAAGA,CACzBlD,KAAqB,EACrBiB,OAAiC,KAEjCsB,aAAa,CAACvC,KAAK,CAACC,UAAU,EAAED,KAAK,CAACmD,QAAQ,EAAE;EAC9C,GAAGlC,OAAO;EACVmC,QAAQ,EAAE;AACZ,CAAC,CAAC;AAAChD,OAAA,CAAA8C,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -8,7 +8,6 @@ exports.ModularUIReducer = void 0;
|
|
|
8
8
|
var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
|
|
9
9
|
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
10
10
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
11
|
-
var _exceptions = require("../../exceptions");
|
|
12
11
|
var _Constants = require("../../constants/Constants");
|
|
13
12
|
var _models = require("../../models");
|
|
14
13
|
/**
|
|
@@ -53,7 +52,10 @@ const setModel = (state, _ref2) => {
|
|
|
53
52
|
}
|
|
54
53
|
};
|
|
55
54
|
}
|
|
56
|
-
|
|
55
|
+
|
|
56
|
+
// eslint-disable-next-line no-console
|
|
57
|
+
console.debug("No model for setModel");
|
|
58
|
+
return state;
|
|
57
59
|
};
|
|
58
60
|
|
|
59
61
|
/**
|
|
@@ -94,7 +96,10 @@ const updateModel = (state, model) => {
|
|
|
94
96
|
model
|
|
95
97
|
});
|
|
96
98
|
}
|
|
97
|
-
|
|
99
|
+
|
|
100
|
+
// eslint-disable-next-line no-console
|
|
101
|
+
console.debug(`ModularUIReducer: Cannot update model with key ${model.connectKey}`);
|
|
102
|
+
return state;
|
|
98
103
|
};
|
|
99
104
|
|
|
100
105
|
/**
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import { IllegalArgumentException } from "../../exceptions";
|
|
3
2
|
import { MODULARUI_STATUS } from "../../constants/Constants";
|
|
4
3
|
import { ApplicationModel } from "../../models";
|
|
5
4
|
|
|
@@ -51,7 +50,9 @@ const setModel = (
|
|
|
51
50
|
};
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
// eslint-disable-next-line no-console
|
|
54
|
+
console.debug("No model for setModel");
|
|
55
|
+
return state;
|
|
55
56
|
};
|
|
56
57
|
|
|
57
58
|
/**
|
|
@@ -90,9 +91,11 @@ const updateModel = (state: ModularUIState, model: ModularUIModel) => {
|
|
|
90
91
|
return setModel(state, { key: modelKey, model });
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
|
|
94
|
+
// eslint-disable-next-line no-console
|
|
95
|
+
console.debug(
|
|
94
96
|
`ModularUIReducer: Cannot update model with key ${model.connectKey}`,
|
|
95
97
|
);
|
|
98
|
+
return state;
|
|
96
99
|
};
|
|
97
100
|
|
|
98
101
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUIReducer.js","names":["
|
|
1
|
+
{"version":3,"file":"ModularUIReducer.js","names":["_Constants","require","_models","updateStatus","state","_ref","key","status","MODULARUI_STATUS","LOADING","lastModification","Date","now","setModel","_ref2","model","FINISHED","console","debug","initModularUI","models","newState","_assign","default","forEach","_ref3","getModelKey","_context","_find","_keys","call","connectKey","updateModel","modelKey","removeKey","resetModularUI","ApplicationModel","initialState","ModularUIReducer","arguments","length","undefined","action","type","payload","exports"],"sources":["../../../src/redux/_modularui/ModularUIReducer.js"],"sourcesContent":["// @flow\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 status: MODULARUI_STATUS.FINISHED,\n },\n };\n }\n\n // eslint-disable-next-line no-console\n console.debug(\"No model for setModel\");\n return state;\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 // eslint-disable-next-line no-console\n console.debug(\n `ModularUIReducer: Cannot update model with key ${model.connectKey}`,\n );\n return state;\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 default:\n return state;\n }\n};\n"],"mappings":";;;;;;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAOA;AACA;AACA,MAAME,YAAY,GAAGA,CACnBC,KAAqB,EAAAC,IAAA,KAElB;EAAA,IADH;IAAEC,GAAG;IAAEC;EAAgE,CAAC,GAAAF,IAAA;EAExE;EACA,IAAIE,MAAM,KAAKC,2BAAgB,CAACC,OAAO,IAAI,CAACL,KAAK,CAACE,GAAG,CAAC,EAAE;IACtD,OAAOF,KAAK;EACd;EAEA,OAAO;IACL,GAAGA,KAAK;IACR,CAACE,GAAG,GAAG;MACL,GAAGF,KAAK,CAACE,GAAG,CAAC;MACbC,MAAM;MACNG,gBAAgB,EAAEC,IAAI,CAACC,GAAG,CAAC;IAC7B;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA,MAAMC,QAAQ,GAAGA,CACfT,KAAqB,EAAAU,KAAA,KAElB;EAAA,IADH;IAAER,GAAG;IAAES;EAA+C,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AH,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAEN,IAAI,CAACC,MAAM,EAAE;IACX,OAAOtC,KAAK;EACd;EAEA,QAAQsC,MAAM,CAACC,IAAI;IACjB,KAAK,gBAAgB;MACnB,OAAOxB,aAAa,CAACf,KAAK,EAAEsC,MAAM,CAACE,OAAO,CAAC;IAE7C,KAAK,iBAAiB;MACpB,OAAOT,cAAc,CAAC/B,KAAK,CAAC;IAE9B,KAAK,kBAAkB;MACrB,OAAOD,YAAY,CAACC,KAAK,EAAEsC,MAAM,CAACE,OAAO,CAAC;IAE5C,KAAK,eAAe;MAClB,OAAO/B,QAAQ,CAACT,KAAK,EAAEsC,MAAM,CAACE,OAAO,CAAC;IAExC,KAAK,kBAAkB;IACvB,KAAK,uBAAuB;MAC1B,OAAOZ,WAAW,CAAC5B,KAAK,EAAEsC,MAAM,CAACE,OAAO,CAAC;IAE3C,KAAK,sBAAsB;MACzB,OAAOV,SAAS,CAACQ,MAAM,CAACE,OAAO,EAAExC,KAAK,CAAC;IAEzC;MACE,OAAOA,KAAK;EAChB;AACF,CAAC;AAACyC,OAAA,CAAAP,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -107,15 +107,15 @@ describe("modularui reducer", () => {
|
|
|
107
107
|
|
|
108
108
|
it("should handle MODULARUI/UPDATE without existing model", () => {
|
|
109
109
|
application.connectKey = "modelKey";
|
|
110
|
-
expect(
|
|
110
|
+
expect(
|
|
111
111
|
ModularUIReducer(
|
|
112
112
|
{},
|
|
113
113
|
{
|
|
114
114
|
type: "MODULARUI/UPDATE",
|
|
115
115
|
payload: application,
|
|
116
116
|
},
|
|
117
|
-
)
|
|
118
|
-
|
|
117
|
+
),
|
|
118
|
+
).toStrictEqual({});
|
|
119
119
|
});
|
|
120
120
|
|
|
121
121
|
it("should handle MODULARUI/REMOVE_KEY", () => {
|
package/package.json
CHANGED
|
@@ -267,42 +267,48 @@ class DatetimeAttributeModel extends StringAttributeModel {
|
|
|
267
267
|
|
|
268
268
|
/**
|
|
269
269
|
*/
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
if (this._dateInputFormat) {
|
|
276
|
-
return this._dateInputFormat;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const dateEraChars = "yMLdQDEewGu";
|
|
280
|
-
const timeOffsetChars = "HhaKmsSZzXxO";
|
|
270
|
+
extractDateInputFormat(): string {
|
|
271
|
+
const dateEraChars = new Set("yMLdQDEewGu");
|
|
272
|
+
const timeOffsetChars = new Set("HhaKmsSZzXxO");
|
|
281
273
|
|
|
282
274
|
const format = this.format;
|
|
283
275
|
let inputFormat = "";
|
|
284
276
|
|
|
285
277
|
let isInQuotes = false;
|
|
286
|
-
let
|
|
278
|
+
let keep = false;
|
|
287
279
|
|
|
288
280
|
for (let i = 0; i < format.length; i++) {
|
|
281
|
+
const prevChar = i > 0 ? format[i - 1] : "";
|
|
282
|
+
const nextChar = i < format.length ? format[i + 1] : "";
|
|
289
283
|
const char = format[i];
|
|
284
|
+
|
|
290
285
|
if (char === "'") {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
} else if (!isInQuotes &&
|
|
295
|
-
|
|
296
|
-
} else if (!isInQuotes && timeOffsetChars.includes(char)) {
|
|
297
|
-
isInDate = false;
|
|
286
|
+
isInQuotes = prevChar === "'" || nextChar === "'" || !isInQuotes;
|
|
287
|
+
} else if (!isInQuotes && dateEraChars.has(char)) {
|
|
288
|
+
keep = true;
|
|
289
|
+
} else if (!isInQuotes && timeOffsetChars.has(char)) {
|
|
290
|
+
keep = false;
|
|
298
291
|
}
|
|
299
292
|
|
|
300
|
-
if (
|
|
293
|
+
if (keep) {
|
|
301
294
|
inputFormat += char;
|
|
302
295
|
}
|
|
303
296
|
}
|
|
304
297
|
|
|
305
|
-
|
|
298
|
+
return inputFormat.trim();
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
*/
|
|
303
|
+
get dateInputFormat(): string {
|
|
304
|
+
if (!this.hasDate) {
|
|
305
|
+
return "";
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (!this._dateInputFormat) {
|
|
309
|
+
this._dateInputFormat = this.extractDateInputFormat();
|
|
310
|
+
}
|
|
311
|
+
|
|
306
312
|
return this._dateInputFormat;
|
|
307
313
|
}
|
|
308
314
|
|
|
@@ -158,18 +158,7 @@ export const loadModularUI =
|
|
|
158
158
|
href: Href | string,
|
|
159
159
|
options?: RequestModularUIOptions,
|
|
160
160
|
): ThunkAction =>
|
|
161
|
-
(dispatch: Dispatch
|
|
162
|
-
const modularuiStore = getState()?.modularui;
|
|
163
|
-
if (
|
|
164
|
-
modularuiStore &&
|
|
165
|
-
modularuiStore[key]?.status === MODULARUI_STATUS.LOADING
|
|
166
|
-
) {
|
|
167
|
-
// don't create duplicate requests during loading
|
|
168
|
-
return dispatch({
|
|
169
|
-
type: "NO_ACTION",
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
|
|
161
|
+
(dispatch: Dispatch) => {
|
|
173
162
|
dispatch(startProgress());
|
|
174
163
|
|
|
175
164
|
const loadModelPromise = dispatch(loadModel(key, href, options));
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import { IllegalArgumentException } from "../../exceptions";
|
|
3
2
|
import { MODULARUI_STATUS } from "../../constants/Constants";
|
|
4
3
|
import { ApplicationModel } from "../../models";
|
|
5
4
|
|
|
@@ -51,7 +50,9 @@ const setModel = (
|
|
|
51
50
|
};
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
// eslint-disable-next-line no-console
|
|
54
|
+
console.debug("No model for setModel");
|
|
55
|
+
return state;
|
|
55
56
|
};
|
|
56
57
|
|
|
57
58
|
/**
|
|
@@ -90,9 +91,11 @@ const updateModel = (state: ModularUIState, model: ModularUIModel) => {
|
|
|
90
91
|
return setModel(state, { key: modelKey, model });
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
|
|
94
|
+
// eslint-disable-next-line no-console
|
|
95
|
+
console.debug(
|
|
94
96
|
`ModularUIReducer: Cannot update model with key ${model.connectKey}`,
|
|
95
97
|
);
|
|
98
|
+
return state;
|
|
96
99
|
};
|
|
97
100
|
|
|
98
101
|
/**
|
|
@@ -107,15 +107,15 @@ describe("modularui reducer", () => {
|
|
|
107
107
|
|
|
108
108
|
it("should handle MODULARUI/UPDATE without existing model", () => {
|
|
109
109
|
application.connectKey = "modelKey";
|
|
110
|
-
expect(
|
|
110
|
+
expect(
|
|
111
111
|
ModularUIReducer(
|
|
112
112
|
{},
|
|
113
113
|
{
|
|
114
114
|
type: "MODULARUI/UPDATE",
|
|
115
115
|
payload: application,
|
|
116
116
|
},
|
|
117
|
-
)
|
|
118
|
-
|
|
117
|
+
),
|
|
118
|
+
).toStrictEqual({});
|
|
119
119
|
});
|
|
120
120
|
|
|
121
121
|
it("should handle MODULARUI/REMOVE_KEY", () => {
|