@beinformed/ui 1.29.0 → 1.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -2
- package/esm/models/attributes/BooleanAttributeModel.js +1 -1
- package/esm/models/attributes/BooleanAttributeModel.js.map +1 -1
- package/esm/models/attributes/layouthint-rules/BaseLayoutHintRule.js +5 -6
- package/esm/models/attributes/layouthint-rules/BaseLayoutHintRule.js.map +1 -1
- package/esm/models/attributes/layouthint-rules/DependentAttribute.js +2 -0
- package/esm/models/attributes/layouthint-rules/DependentAttribute.js.map +1 -1
- package/esm/models/error/ErrorResponse.js +6 -0
- package/esm/models/error/ErrorResponse.js.map +1 -1
- package/esm/models/form/FormModel.js +45 -3
- package/esm/models/form/FormModel.js.map +1 -1
- package/esm/utils/number/DecimalFormat.js +4 -8
- package/esm/utils/number/DecimalFormat.js.map +1 -1
- package/lib/models/attributes/BooleanAttributeModel.js +1 -1
- package/lib/models/attributes/BooleanAttributeModel.js.flow +1 -1
- package/lib/models/attributes/BooleanAttributeModel.js.map +1 -1
- package/lib/models/attributes/__tests__/BooleanAttributeModel.spec.js.flow +14 -0
- package/lib/models/attributes/layouthint-rules/BaseLayoutHintRule.js +5 -6
- package/lib/models/attributes/layouthint-rules/BaseLayoutHintRule.js.map +1 -1
- package/lib/models/attributes/layouthint-rules/DependentAttribute.js +2 -0
- package/lib/models/attributes/layouthint-rules/DependentAttribute.js.map +1 -1
- package/lib/models/error/ErrorResponse.js +6 -0
- package/lib/models/error/ErrorResponse.js.map +1 -1
- package/lib/models/form/FormModel.js +45 -3
- package/lib/models/form/FormModel.js.flow +58 -4
- package/lib/models/form/FormModel.js.map +1 -1
- package/lib/models/form/__tests__/FormModel.spec.js.flow +4 -0
- package/lib/models/form/__tests__/FormResultData.spec.js.flow +86 -0
- package/lib/utils/number/DecimalFormat.js +4 -8
- package/lib/utils/number/DecimalFormat.js.map +1 -1
- package/package.json +17 -17
- package/src/models/attributes/BooleanAttributeModel.js +1 -1
- package/src/models/attributes/__tests__/BooleanAttributeModel.spec.js +14 -0
- package/src/models/form/FormModel.js +58 -4
- package/src/models/form/__tests__/FormModel.spec.js +4 -0
- package/src/models/form/__tests__/FormResultData.spec.js +86 -0
- package/types/constants/Constants.d.ts +145 -145
- package/types/constants/LayoutHintConfig.d.ts +226 -226
- package/types/constants/LayoutHints.d.ts +74 -74
- package/types/constants/Settings.d.ts +29 -29
- package/types/constants/index.d.ts +3 -3
- package/types/exceptions/ConfigurationException.d.ts +6 -6
- package/types/exceptions/FetchException.d.ts +31 -31
- package/types/exceptions/IllegalArgumentException.d.ts +6 -6
- package/types/exceptions/IllegalReturnException.d.ts +5 -5
- package/types/exceptions/IllegalStateException.d.ts +6 -6
- package/types/exceptions/JsonParseException.d.ts +6 -6
- package/types/exceptions/MissingPropertyException.d.ts +6 -6
- package/types/exceptions/NetworkException.d.ts +9 -9
- package/types/exceptions/NotAllowedUriException.d.ts +6 -6
- package/types/exceptions/NotFoundException.d.ts +10 -10
- package/types/exceptions/ServerRequestException.d.ts +6 -6
- package/types/exceptions/ThemePropertyException.d.ts +6 -6
- package/types/exceptions/TimeoutException.d.ts +7 -7
- package/types/exceptions/UnauthorizedException.d.ts +11 -11
- package/types/exceptions/UnsupportedOperationException.d.ts +6 -6
- package/types/exceptions/index.d.ts +15 -15
- package/types/hooks/useI18n.d.ts +9 -9
- package/types/i18n/Locale.d.ts +53 -53
- package/types/i18n/Locales.d.ts +55 -55
- package/types/i18n/Message.d.ts +6 -6
- package/types/i18n/index.d.ts +5 -5
- package/types/i18n/languages.d.ts +215 -215
- package/types/i18n/translations/beinformed_error_messages_en.nl.d.ts +97 -97
- package/types/i18n/translations/beinformed_error_messages_nl.nl.d.ts +97 -97
- package/types/i18n/types.d.ts +11 -11
- package/types/i18n/withMessage.d.ts +3 -3
- package/types/index.d.ts +6 -6
- package/types/models/actions/ActionCollection.d.ts +29 -29
- package/types/models/actions/ActionModel.d.ts +84 -84
- package/types/models/application/ApplicationModel.d.ts +41 -41
- package/types/models/attributes/AttributeCollection.d.ts +96 -96
- package/types/models/attributes/AttributeContent.d.ts +64 -64
- package/types/models/attributes/AttributeDataHelper.d.ts +67 -67
- package/types/models/attributes/AttributeModel.d.ts +395 -395
- package/types/models/attributes/AttributeSetModel.d.ts +28 -28
- package/types/models/attributes/BooleanAttributeModel.d.ts +65 -65
- package/types/models/attributes/CaptchaAttributeModel.d.ts +19 -19
- package/types/models/attributes/ChoiceAttributeModel.d.ts +76 -76
- package/types/models/attributes/ChoiceAttributeOptionCollection.d.ts +79 -79
- package/types/models/attributes/ChoiceAttributeOptionModel.d.ts +133 -133
- package/types/models/attributes/CompositeAttributeChildCollection.d.ts +56 -56
- package/types/models/attributes/CompositeAttributeModel.d.ts +44 -44
- package/types/models/attributes/DatetimeAttributeModel.d.ts +117 -117
- package/types/models/attributes/HelptextAttributeModel.d.ts +16 -16
- package/types/models/attributes/LabelAttributeModel.d.ts +12 -12
- package/types/models/attributes/MemoAttributeModel.d.ts +14 -14
- package/types/models/attributes/MoneyAttributeModel.d.ts +14 -14
- package/types/models/attributes/NumberAttributeModel.d.ts +49 -49
- package/types/models/attributes/PasswordAttributeModel.d.ts +62 -62
- package/types/models/attributes/StringAttributeModel.d.ts +62 -62
- package/types/models/attributes/UploadAttributeModel.d.ts +60 -60
- package/types/models/attributes/XMLAttributeModel.d.ts +10 -10
- package/types/models/attributes/_createAttribute.d.ts +6 -6
- package/types/models/attributes/input-constraints/BSNConstraint.d.ts +26 -26
- package/types/models/attributes/input-constraints/ConstraintCollection.d.ts +24 -24
- package/types/models/attributes/input-constraints/ConstraintModel.d.ts +34 -34
- package/types/models/attributes/input-constraints/DateBoundaryConstraint.d.ts +109 -109
- package/types/models/attributes/input-constraints/DateTimeDateFormatConstraint.d.ts +36 -36
- package/types/models/attributes/input-constraints/DateTimeTimeFormatConstraint.d.ts +36 -36
- package/types/models/attributes/input-constraints/DatetimeFormatConstraint.d.ts +92 -92
- package/types/models/attributes/input-constraints/FileExtensionConstraint.d.ts +33 -33
- package/types/models/attributes/input-constraints/FileSizeConstraint.d.ts +42 -42
- package/types/models/attributes/input-constraints/IBANConstraint.d.ts +23 -23
- package/types/models/attributes/input-constraints/MandatoryConstraint.d.ts +23 -23
- package/types/models/attributes/input-constraints/MandatoryRangeConstraint.d.ts +36 -36
- package/types/models/attributes/input-constraints/NumberBoundaryConstraint.d.ts +61 -61
- package/types/models/attributes/input-constraints/NumberFormatConstraint.d.ts +52 -52
- package/types/models/attributes/input-constraints/NumberGroupingConstraint.d.ts +46 -46
- package/types/models/attributes/input-constraints/PasswordConfirmConstraint.d.ts +36 -36
- package/types/models/attributes/input-constraints/PasswordLowerAndUpperCaseConstraint.d.ts +23 -23
- package/types/models/attributes/input-constraints/PasswordMinNumericCharactersConstraint.d.ts +32 -32
- package/types/models/attributes/input-constraints/PasswordMinSpecialCharactersConstraint.d.ts +32 -32
- package/types/models/attributes/input-constraints/PasswordThreeConsecutiveCharactersNotAllowedConstraint.d.ts +35 -35
- package/types/models/attributes/input-constraints/RangeConstraint.d.ts +97 -97
- package/types/models/attributes/input-constraints/RegexConstraint.d.ts +37 -37
- package/types/models/attributes/input-constraints/StringLengthConstraint.d.ts +46 -46
- package/types/models/attributes/input-constraints/XMLConstraint.d.ts +26 -26
- package/types/models/attributes/layouthint-rules/BaseLayoutHintRule.d.ts +46 -46
- package/types/models/attributes/layouthint-rules/DependentAttribute.d.ts +57 -57
- package/types/models/attributes/layouthint-rules/LayoutHintRuleCollection.d.ts +27 -27
- package/types/models/attributes/layouthint-rules/RemainingTotalUploadSize.d.ts +17 -17
- package/types/models/base/BaseCollection.d.ts +89 -89
- package/types/models/base/BaseModel.d.ts +67 -67
- package/types/models/base/ResourceCollection.d.ts +19 -19
- package/types/models/base/ResourceModel.d.ts +97 -97
- package/types/models/caseview/CaseViewModel.d.ts +45 -45
- package/types/models/concepts/BusinessScenarioModel.d.ts +20 -20
- package/types/models/concepts/ConceptDetailModel.d.ts +69 -69
- package/types/models/concepts/ConceptIndexModel.d.ts +36 -36
- package/types/models/concepts/ConceptLinkModel.d.ts +65 -65
- package/types/models/concepts/ConceptRelationCollection.d.ts +34 -34
- package/types/models/concepts/ConceptRelationModel.d.ts +44 -44
- package/types/models/concepts/ConceptTypeDetailModel.d.ts +39 -39
- package/types/models/concepts/SourceReferenceCollection.d.ts +13 -13
- package/types/models/concepts/SourceReferenceModel.d.ts +30 -30
- package/types/models/content/ContentIndexModel.d.ts +34 -34
- package/types/models/content/ContentLinkModel.d.ts +81 -81
- package/types/models/content/ContentModel.d.ts +74 -74
- package/types/models/content/ContentTOCModel.d.ts +37 -37
- package/types/models/content/ContentTypeModel.d.ts +26 -26
- package/types/models/content/SectionModel.d.ts +75 -75
- package/types/models/content/SubSectionModel.d.ts +64 -64
- package/types/models/contentconfiguration/ContentConfiguration.d.ts +28 -28
- package/types/models/contentconfiguration/ContentConfigurationElements.d.ts +47 -47
- package/types/models/contentconfiguration/ContentConfigurationEndResults.d.ts +16 -16
- package/types/models/contentconfiguration/ContentConfigurationQuestions.d.ts +22 -22
- package/types/models/contentconfiguration/ContentConfigurationResults.d.ts +39 -39
- package/types/models/detail/DetailModel.d.ts +72 -72
- package/types/models/error/ErrorCollection.d.ts +51 -51
- package/types/models/error/ErrorModel.d.ts +41 -41
- package/types/models/error/ErrorResponse.d.ts +148 -148
- package/types/models/filters/AssignmentFilterModel.d.ts +35 -35
- package/types/models/filters/BaseFilterModel.d.ts +85 -85
- package/types/models/filters/ConceptIndexFilterModel.d.ts +6 -6
- package/types/models/filters/FilterCollection.d.ts +48 -48
- package/types/models/filters/FilterModel.d.ts +5 -5
- package/types/models/filters/RangeFilterModel.d.ts +6 -6
- package/types/models/form/FormModel.d.ts +343 -312
- package/types/models/form/FormObjectModel.d.ts +196 -196
- package/types/models/grouping/GroupingModel.d.ts +85 -85
- package/types/models/href/Href.d.ts +196 -196
- package/types/models/href/ListHref.d.ts +64 -64
- package/types/models/index.d.ts +95 -94
- package/types/models/layouthint/LayoutHintCollection.d.ts +43 -43
- package/types/models/links/LinkCollection.d.ts +62 -62
- package/types/models/links/LinkModel.d.ts +92 -92
- package/types/models/links/normalizeLinkJSON.d.ts +9 -9
- package/types/models/list/ListDetailModel.d.ts +69 -69
- package/types/models/list/ListHeaderModel.d.ts +64 -64
- package/types/models/list/ListItemCollection.d.ts +21 -21
- package/types/models/list/ListItemModel.d.ts +34 -34
- package/types/models/list/ListModel.d.ts +135 -135
- package/types/models/lookup/LookupOptionCollection.d.ts +11 -11
- package/types/models/lookup/LookupOptionsModel.d.ts +19 -19
- package/types/models/modelcatalog/ModelCatalogModel.d.ts +18 -18
- package/types/models/paging/PagesizeModel.d.ts +25 -25
- package/types/models/paging/PagingModel.d.ts +49 -49
- package/types/models/panels/GroupingPanelModel.d.ts +39 -39
- package/types/models/parameter/Parameter.d.ts +40 -40
- package/types/models/process/ProcessStatusSettingsModel.d.ts +38 -38
- package/types/models/resolveModel.d.ts +7 -7
- package/types/models/search/CaseSearchModel.d.ts +14 -14
- package/types/models/sorting/SortOptionModel.d.ts +48 -48
- package/types/models/sorting/SortingModel.d.ts +42 -42
- package/types/models/tab/TabModel.d.ts +44 -44
- package/types/models/taskgroup/TaskGroupCollection.d.ts +12 -12
- package/types/models/taskgroup/TaskGroupModel.d.ts +15 -15
- package/types/models/types.d.ts +161 -161
- package/types/models/user/UserModel.d.ts +14 -14
- package/types/models/user/UserProfileModel.d.ts +12 -12
- package/types/models/user/UserServicesModel.d.ts +28 -28
- package/types/modularui/Authenticate.d.ts +49 -49
- package/types/modularui/CaptchaRequest.d.ts +45 -45
- package/types/modularui/ModularUIError.d.ts +10 -10
- package/types/modularui/ModularUIRequest.d.ts +198 -198
- package/types/modularui/ModularUIResponse.d.ts +56 -56
- package/types/modularui/UploadRequest.d.ts +35 -35
- package/types/modularui/index.d.ts +5 -5
- package/types/modularui/types.d.ts +2 -2
- package/types/redux/_i18n/types.d.ts +13 -13
- package/types/redux/_modularui/types.d.ts +61 -61
- package/types/redux/_router/types.d.ts +35 -35
- package/types/redux/selectors/i18n.d.ts +4 -4
- package/types/redux/types.d.ts +105 -105
- package/types/utils/browser/Cache.d.ts +45 -45
- package/types/utils/browser/Cookies.d.ts +9 -9
- package/types/utils/datetime/DateTimeUtil.d.ts +164 -164
- package/types/utils/fetch/serverFetch.d.ts +5 -5
- package/types/utils/fetch/types.d.ts +40 -40
- package/types/utils/fetch/universalFetch.d.ts +7 -7
- package/types/utils/fetch/xhr.d.ts +5 -5
- package/types/utils/helpers/checkResource.d.ts +3 -3
- package/types/utils/helpers/createHash.d.ts +8 -8
- package/types/utils/helpers/createUUID.d.ts +4 -4
- package/types/utils/helpers/index.d.ts +7 -7
- package/types/utils/helpers/objects.d.ts +11 -11
- package/types/utils/helpers/repositoryResource.d.ts +1 -1
- package/types/utils/helpers/sanitizeHtml.d.ts +9 -9
- package/types/utils/helpers/text.d.ts +7 -7
- package/types/utils/index.d.ts +11 -11
- package/types/utils/number/DecimalFormat.d.ts +90 -90
- package/types/utils/number/formatValue.d.ts +4 -4
- package/types/utils/number/parseNumbers.d.ts +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -2,12 +2,24 @@
|
|
|
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.
|
|
5
|
+
## [1.30.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.30.0...v1.30.1) (2023-03-31)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- **boolean-attribute:** allow for boolean as update value ([d20f0fc](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/d20f0fc892efd7ca62eee3f0982d42d8a0a39847))
|
|
10
|
+
- **form:** after previous step, set finished, complete and success state ([ccb5b2a](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/ccb5b2a868e3c8f5d803ebf4453a9f3130f4018e))
|
|
11
|
+
|
|
12
|
+
## [1.30.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.29.0...v1.30.0) (2023-03-17)
|
|
6
13
|
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- **resultdata:** new getResultData method combines resultdata and contributions into attribute sets ([d5a76c6](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/d5a76c69cb2057d502b829f1ee6ed9a0a9438181))
|
|
17
|
+
|
|
18
|
+
## [1.29.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.28.7...v1.29.0) (2023-03-10)
|
|
7
19
|
|
|
8
20
|
### Features
|
|
9
21
|
|
|
10
|
-
|
|
22
|
+
- **LayoutHintCollection:** export LayoutHintCollection ([8f09649](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/8f0964948388a0705b40dd950b792b0071bdb0de))
|
|
11
23
|
|
|
12
24
|
## [1.28.7](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.28.6...v1.28.7) (2023-03-09)
|
|
13
25
|
|
|
@@ -228,7 +228,7 @@ export default class BooleanAttributeModel extends AttributeModel {
|
|
|
228
228
|
} else if (typeof value === "string" && this.isMultiple) {
|
|
229
229
|
values = value.split(",");
|
|
230
230
|
} else {
|
|
231
|
-
values = [value];
|
|
231
|
+
values = [value.toString()];
|
|
232
232
|
}
|
|
233
233
|
values.forEach(val => {
|
|
234
234
|
if (val instanceof ChoiceAttributeOptionModel) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanAttributeModel.js","names":["AttributeModel","DateUtil","ChoiceAttributeOptionCollection","ContentConfigurationElements","ChoiceAttributeOptionModel","RENDER_SECTION_LABEL","ATTRIBUTE_WIDTH","BooleanAttributeModel","constructor","attribute","attributeContributions","_defineProperty","_referenceDate","getData","now","_options","create","referenceDate","isApplicableModel","contributions","type","date","options","choicetype","_context","_findInstanceProperty","call","hint","layouthint","has","isMultiple","isTree","hasContentConfiguration","_hasContentConfiguration","contentConfiguration","_context2","content","optionElements","optionElementConfig","_mapInstanceProperty","optionElement","contentElement","selected","_context3","option","code","readonlyvalue","_context4","label","join","initvalue","Array","isArray","_initvalue","length","getValue","_context5","hasValue","getInputValue","toggleOption","_context6","_includesInstanceProperty","disableOption","enableOption","deselectAll","select","inputvalue","deselect","reset","mergeAttribute","oldAttribute","readonly","concept","isValid","update","value","updateLastModification","values","split","forEach","val","some","toString","getFormData","inError","name","readonlyWidth","hasAlternativeLabel","SMALL","EXTRA_SMALL"],"sources":["../../../src/models/attributes/BooleanAttributeModel.js"],"sourcesContent":["// @flow\nimport AttributeModel from \"./AttributeModel\";\n\nimport { DateUtil } from \"../../utils/datetime/DateTimeUtil\";\n\nimport ChoiceAttributeOptionCollection from \"./ChoiceAttributeOptionCollection\";\nimport ContentConfigurationElements from \"../contentconfiguration/ContentConfigurationElements\";\nimport ChoiceAttributeOptionModel from \"./ChoiceAttributeOptionModel\";\n\nimport { RENDER_SECTION_LABEL } from \"../../constants/LayoutHints\";\nimport { ATTRIBUTE_WIDTH } from \"../../constants\";\n\nimport type { AttributeType } from \"../types\";\n\n/**\n * Model for a boolean attribute\n */\nexport default class BooleanAttributeModel extends AttributeModel {\n _referenceDate: string;\n _options: ChoiceAttributeOptionCollection;\n _hasContentConfiguration: boolean = false;\n\n /**\n */\n constructor(attribute: Object, attributeContributions: Object) {\n super(attribute, attributeContributions);\n\n this._referenceDate = this.getData(\"referenceDate\", DateUtil.now());\n this._options = ChoiceAttributeOptionCollection.create(\n attribute,\n attributeContributions,\n this.referenceDate\n );\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return contributions.type === \"boolean\";\n }\n\n /**\n */\n get type(): string {\n return \"boolean\";\n }\n\n /**\n * Retrieve reference date of attribute which can be used as entryDate for content\n */\n get referenceDate(): string {\n return this._referenceDate;\n }\n\n /**\n * Set reference date for concepts and content\n */\n set referenceDate(date: string) {\n this._referenceDate = date;\n\n this.options.referenceDate = date;\n }\n\n /**\n * Getting the type of choice filter. For instance checkbox, radiobutton, combobox.\n */\n get choicetype(): \"checkbox\" | \"radiobutton\" | \"combobox\" | \"toggle\" {\n return (\n [\"checkbox\", \"radiobutton\", \"combobox\", \"toggle\"].find((hint) =>\n this.layouthint.has(hint)\n ) || \"radiobutton\"\n );\n }\n\n /**\n * Can multiple options be selected\n */\n get isMultiple(): boolean {\n return false;\n }\n\n /**\n * Check if options need to be rendered as tree\n */\n get isTree(): boolean {\n return false;\n }\n\n /**\n */\n set hasContentConfiguration(hasContentConfiguration: boolean) {\n this._hasContentConfiguration =\n this.contentConfiguration !== null || hasContentConfiguration;\n }\n\n /**\n */\n get hasContentConfiguration(): boolean {\n return this._hasContentConfiguration;\n }\n\n /**\n * Get content configuration configured on the attribute.\n * Only applicable for taxonomy element and knowledge codemaps,\n * content configuration for instrument questions is available on the form object\n */\n get contentConfiguration(): ContentConfigurationElements | null {\n if (\n !this.contributions.content ||\n !this.contributions.content.optionElements\n ) {\n return null;\n }\n\n // Add RENDER_SECTION_LABEL to all content configuration to make sure the label of a section is always rendered on taxonomy and knowlege codemaps\n const optionElementConfig = this.contributions.content.optionElements.map(\n (optionElement) => {\n if (\"contentElement\" in optionElement) {\n return {\n contentElement: {\n ...optionElement.contentElement,\n layouthint: [RENDER_SECTION_LABEL],\n },\n };\n }\n\n return optionElement;\n }\n );\n\n return new ContentConfigurationElements(optionElementConfig);\n }\n\n /**\n * Retrieve available choice options\n */\n get options(): ChoiceAttributeOptionCollection {\n return this._options;\n }\n\n /**\n * Getting all enabled options\n */\n get selected(): Array<string> {\n // $FlowFixMe[incompatible-call]\n return this.options.selected.map<string, ChoiceAttributeOptionModel>(\n (option: ChoiceAttributeOptionModel) => option.code\n );\n }\n\n /**\n * Flatten options and filter out the options that are not selected\n */\n get readonlyvalue(): string {\n return this.options.selected.map((option) => option.label).join(\", \");\n }\n\n /**\n */\n get initvalue(): any {\n if (Array.isArray(this._initvalue) && this._initvalue.length === 0) {\n return null;\n }\n\n return this._initvalue;\n }\n\n /**\n * Retrieve list of selected options, joined with comma\n */\n getValue(): string | null {\n return this.options.selected.length > 0\n ? this.options.selected.map((option) => option.code).join(\",\")\n : null;\n }\n\n /**\n */\n hasValue(): boolean {\n return this.options.selected.length > 0;\n }\n\n /**\n * Get input value of attribute\n */\n getInputValue(): string {\n return this.selected.join(\",\");\n }\n\n /**\n * Setting an option selected or unselected based on the current state\n */\n toggleOption(code: string) {\n if (this.selected.includes(code)) {\n this.disableOption(code);\n } else {\n this.enableOption(code);\n }\n }\n\n /**\n * Enable a option\n */\n enableOption(code: string) {\n this.options.deselectAll();\n this.options.select(code);\n this.inputvalue = this.getInputValue();\n }\n\n /**\n * Disable a option\n */\n disableOption(code: string) {\n this.options.deselect(code);\n this.inputvalue = this.getInputValue();\n }\n\n /**\n * Reset boolean attribute to unselected list\n */\n reset() {\n this.options.deselectAll();\n }\n\n /**\n */\n mergeAttribute(oldAttribute: AttributeType) {\n // when attribute is readonly, don't merge the options no modifications necessary\n if (!this.readonly && oldAttribute instanceof BooleanAttributeModel) {\n this.concept = oldAttribute.concept;\n this.options.deselectAll();\n\n if (oldAttribute.isValid && oldAttribute.inputvalue !== null) {\n this.update(oldAttribute.inputvalue);\n }\n }\n }\n\n /**\n * Update attribute by name and value\n */\n update(value: any): BooleanAttributeModel {\n if (this.readonly) {\n return this;\n }\n\n this.updateLastModification();\n\n let values;\n\n if (Array.isArray(value)) {\n values = value;\n } else if (typeof value === \"string\" && this.isMultiple) {\n values = value.split(\",\");\n } else {\n values = [value];\n }\n\n values.forEach((val) => {\n if (val instanceof ChoiceAttributeOptionModel) {\n this.toggleOption(val.code);\n } else if (\n typeof val === \"string\" &&\n this.options.some((option) => option.code.toString() === val)\n ) {\n this.toggleOption(val);\n }\n });\n\n return this;\n }\n\n /**\n */\n getFormData(): { [string]: boolean | null } | null {\n if (this.inError()) {\n return null;\n }\n\n if (!this.hasValue()) {\n // no value for checkbox and toggle is same as a false value\n if (this.choicetype === \"checkbox\" || this.choicetype === \"toggle\") {\n return { [this.name]: false };\n }\n\n return { [this.name]: null };\n }\n\n return { [this.name]: this.value === \"true\" };\n }\n\n /**\n */\n get readonlyWidth(): $Keys<typeof ATTRIBUTE_WIDTH> {\n if (this.options.some((option) => option.hasAlternativeLabel)) {\n return ATTRIBUTE_WIDTH.SMALL;\n }\n\n return ATTRIBUTE_WIDTH.EXTRA_SMALL;\n }\n}\n"],"mappings":";;;;AACA,OAAOA,cAAc,MAAM,kBAAkB;AAE7C,SAASC,QAAQ,QAAQ,mCAAmC;AAE5D,OAAOC,+BAA+B,MAAM,mCAAmC;AAC/E,OAAOC,4BAA4B,MAAM,sDAAsD;AAC/F,OAAOC,0BAA0B,MAAM,8BAA8B;AAErE,SAASC,oBAAoB,QAAQ,6BAA6B;AAClE,SAASC,eAAe,QAAQ,iBAAiB;AAIjD;AACA;AACA;AACA,eAAe,MAAMC,qBAAqB,SAASP,cAAc,CAAC;EAKhE;AACF;EACEQ,WAAWA,CAACC,SAAiB,EAAEC,sBAA8B,EAAE;IAC7D,KAAK,CAACD,SAAS,EAAEC,sBAAsB,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA,mCALP,KAAK;IAOvC,IAAI,CAACC,cAAc,GAAG,IAAI,CAACC,OAAO,CAAC,eAAe,EAAEZ,QAAQ,CAACa,GAAG,EAAE,CAAC;IACnE,IAAI,CAACC,QAAQ,GAAGb,+BAA+B,CAACc,MAAM,CACpDP,SAAS,EACTC,sBAAsB,EACtB,IAAI,CAACO,aAAa,CACnB;EACH;;EAEA;AACF;EACE,OAAOC,iBAAiBA,CAACC,aAAqB,EAAW;IACvD,OAAOA,aAAa,CAACC,IAAI,KAAK,SAAS;EACzC;;EAEA;AACF;EACE,IAAIA,IAAIA,CAAA,EAAW;IACjB,OAAO,SAAS;EAClB;;EAEA;AACF;AACA;EACE,IAAIH,aAAa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,CAAC3B,QAAQ,EAAE,EAAE;MACpB;MACA,IAAI,IAAI,CAAClC,UAAU,KAAK,UAAU,IAAI,IAAI,CAACA,UAAU,KAAK,QAAQ,EAAE;QAClE,OAAO;UAAE,CAAC,IAAI,CAAC8D,IAAI,GAAG;QAAM,CAAC;MAC/B;MAEA,OAAO;QAAE,CAAC,IAAI,CAACA,IAAI,GAAG;MAAK,CAAC;IAC9B;IAEA,OAAO;MAAE,CAAC,IAAI,CAACA,IAAI,GAAG,IAAI,CAACV,KAAK,KAAK;IAAO,CAAC;EAC/C;;EAEA;AACF;EACE,IAAIW,aAAaA,CAAA,EAAkC;IACjD,IAAI,IAAI,CAAChE,OAAO,CAAC2D,IAAI,CAAErC,MAAM,IAAKA,MAAM,CAAC2C,mBAAmB,CAAC,EAAE;MAC7D,OAAOjF,eAAe,CAACkF,KAAK;IAC9B;IAEA,OAAOlF,eAAe,CAACmF,WAAW;EACpC;AACF"}
|
|
1
|
+
{"version":3,"file":"BooleanAttributeModel.js","names":["AttributeModel","DateUtil","ChoiceAttributeOptionCollection","ContentConfigurationElements","ChoiceAttributeOptionModel","RENDER_SECTION_LABEL","ATTRIBUTE_WIDTH","BooleanAttributeModel","constructor","attribute","attributeContributions","_defineProperty","_referenceDate","getData","now","_options","create","referenceDate","isApplicableModel","contributions","type","date","options","choicetype","_context","_findInstanceProperty","call","hint","layouthint","has","isMultiple","isTree","hasContentConfiguration","_hasContentConfiguration","contentConfiguration","_context2","content","optionElements","optionElementConfig","_mapInstanceProperty","optionElement","contentElement","selected","_context3","option","code","readonlyvalue","_context4","label","join","initvalue","Array","isArray","_initvalue","length","getValue","_context5","hasValue","getInputValue","toggleOption","_context6","_includesInstanceProperty","disableOption","enableOption","deselectAll","select","inputvalue","deselect","reset","mergeAttribute","oldAttribute","readonly","concept","isValid","update","value","updateLastModification","values","split","toString","forEach","val","some","getFormData","inError","name","readonlyWidth","hasAlternativeLabel","SMALL","EXTRA_SMALL"],"sources":["../../../src/models/attributes/BooleanAttributeModel.js"],"sourcesContent":["// @flow\nimport AttributeModel from \"./AttributeModel\";\n\nimport { DateUtil } from \"../../utils/datetime/DateTimeUtil\";\n\nimport ChoiceAttributeOptionCollection from \"./ChoiceAttributeOptionCollection\";\nimport ContentConfigurationElements from \"../contentconfiguration/ContentConfigurationElements\";\nimport ChoiceAttributeOptionModel from \"./ChoiceAttributeOptionModel\";\n\nimport { RENDER_SECTION_LABEL } from \"../../constants/LayoutHints\";\nimport { ATTRIBUTE_WIDTH } from \"../../constants\";\n\nimport type { AttributeType } from \"../types\";\n\n/**\n * Model for a boolean attribute\n */\nexport default class BooleanAttributeModel extends AttributeModel {\n _referenceDate: string;\n _options: ChoiceAttributeOptionCollection;\n _hasContentConfiguration: boolean = false;\n\n /**\n */\n constructor(attribute: Object, attributeContributions: Object) {\n super(attribute, attributeContributions);\n\n this._referenceDate = this.getData(\"referenceDate\", DateUtil.now());\n this._options = ChoiceAttributeOptionCollection.create(\n attribute,\n attributeContributions,\n this.referenceDate\n );\n }\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return contributions.type === \"boolean\";\n }\n\n /**\n */\n get type(): string {\n return \"boolean\";\n }\n\n /**\n * Retrieve reference date of attribute which can be used as entryDate for content\n */\n get referenceDate(): string {\n return this._referenceDate;\n }\n\n /**\n * Set reference date for concepts and content\n */\n set referenceDate(date: string) {\n this._referenceDate = date;\n\n this.options.referenceDate = date;\n }\n\n /**\n * Getting the type of choice filter. For instance checkbox, radiobutton, combobox.\n */\n get choicetype(): \"checkbox\" | \"radiobutton\" | \"combobox\" | \"toggle\" {\n return (\n [\"checkbox\", \"radiobutton\", \"combobox\", \"toggle\"].find((hint) =>\n this.layouthint.has(hint)\n ) || \"radiobutton\"\n );\n }\n\n /**\n * Can multiple options be selected\n */\n get isMultiple(): boolean {\n return false;\n }\n\n /**\n * Check if options need to be rendered as tree\n */\n get isTree(): boolean {\n return false;\n }\n\n /**\n */\n set hasContentConfiguration(hasContentConfiguration: boolean) {\n this._hasContentConfiguration =\n this.contentConfiguration !== null || hasContentConfiguration;\n }\n\n /**\n */\n get hasContentConfiguration(): boolean {\n return this._hasContentConfiguration;\n }\n\n /**\n * Get content configuration configured on the attribute.\n * Only applicable for taxonomy element and knowledge codemaps,\n * content configuration for instrument questions is available on the form object\n */\n get contentConfiguration(): ContentConfigurationElements | null {\n if (\n !this.contributions.content ||\n !this.contributions.content.optionElements\n ) {\n return null;\n }\n\n // Add RENDER_SECTION_LABEL to all content configuration to make sure the label of a section is always rendered on taxonomy and knowlege codemaps\n const optionElementConfig = this.contributions.content.optionElements.map(\n (optionElement) => {\n if (\"contentElement\" in optionElement) {\n return {\n contentElement: {\n ...optionElement.contentElement,\n layouthint: [RENDER_SECTION_LABEL],\n },\n };\n }\n\n return optionElement;\n }\n );\n\n return new ContentConfigurationElements(optionElementConfig);\n }\n\n /**\n * Retrieve available choice options\n */\n get options(): ChoiceAttributeOptionCollection {\n return this._options;\n }\n\n /**\n * Getting all enabled options\n */\n get selected(): Array<string> {\n // $FlowFixMe[incompatible-call]\n return this.options.selected.map<string, ChoiceAttributeOptionModel>(\n (option: ChoiceAttributeOptionModel) => option.code\n );\n }\n\n /**\n * Flatten options and filter out the options that are not selected\n */\n get readonlyvalue(): string {\n return this.options.selected.map((option) => option.label).join(\", \");\n }\n\n /**\n */\n get initvalue(): any {\n if (Array.isArray(this._initvalue) && this._initvalue.length === 0) {\n return null;\n }\n\n return this._initvalue;\n }\n\n /**\n * Retrieve list of selected options, joined with comma\n */\n getValue(): string | null {\n return this.options.selected.length > 0\n ? this.options.selected.map((option) => option.code).join(\",\")\n : null;\n }\n\n /**\n */\n hasValue(): boolean {\n return this.options.selected.length > 0;\n }\n\n /**\n * Get input value of attribute\n */\n getInputValue(): string {\n return this.selected.join(\",\");\n }\n\n /**\n * Setting an option selected or unselected based on the current state\n */\n toggleOption(code: string) {\n if (this.selected.includes(code)) {\n this.disableOption(code);\n } else {\n this.enableOption(code);\n }\n }\n\n /**\n * Enable a option\n */\n enableOption(code: string) {\n this.options.deselectAll();\n this.options.select(code);\n this.inputvalue = this.getInputValue();\n }\n\n /**\n * Disable a option\n */\n disableOption(code: string) {\n this.options.deselect(code);\n this.inputvalue = this.getInputValue();\n }\n\n /**\n * Reset boolean attribute to unselected list\n */\n reset() {\n this.options.deselectAll();\n }\n\n /**\n */\n mergeAttribute(oldAttribute: AttributeType) {\n // when attribute is readonly, don't merge the options no modifications necessary\n if (!this.readonly && oldAttribute instanceof BooleanAttributeModel) {\n this.concept = oldAttribute.concept;\n this.options.deselectAll();\n\n if (oldAttribute.isValid && oldAttribute.inputvalue !== null) {\n this.update(oldAttribute.inputvalue);\n }\n }\n }\n\n /**\n * Update attribute by name and value\n */\n update(value: any): BooleanAttributeModel {\n if (this.readonly) {\n return this;\n }\n\n this.updateLastModification();\n\n let values;\n\n if (Array.isArray(value)) {\n values = value;\n } else if (typeof value === \"string\" && this.isMultiple) {\n values = value.split(\",\");\n } else {\n values = [value.toString()];\n }\n\n values.forEach((val) => {\n if (val instanceof ChoiceAttributeOptionModel) {\n this.toggleOption(val.code);\n } else if (\n typeof val === \"string\" &&\n this.options.some((option) => option.code.toString() === val)\n ) {\n this.toggleOption(val);\n }\n });\n\n return this;\n }\n\n /**\n */\n getFormData(): { [string]: boolean | null } | null {\n if (this.inError()) {\n return null;\n }\n\n if (!this.hasValue()) {\n // no value for checkbox and toggle is same as a false value\n if (this.choicetype === \"checkbox\" || this.choicetype === \"toggle\") {\n return { [this.name]: false };\n }\n\n return { [this.name]: null };\n }\n\n return { [this.name]: this.value === \"true\" };\n }\n\n /**\n */\n get readonlyWidth(): $Keys<typeof ATTRIBUTE_WIDTH> {\n if (this.options.some((option) => option.hasAlternativeLabel)) {\n return ATTRIBUTE_WIDTH.SMALL;\n }\n\n return ATTRIBUTE_WIDTH.EXTRA_SMALL;\n }\n}\n"],"mappings":";;;;AACA,OAAOA,cAAc,MAAM,kBAAkB;AAE7C,SAASC,QAAQ,QAAQ,mCAAmC;A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kC;IACjD,IAAI,IAAI,CAAChE,OAAO,CAAC4D,IAAI,CAAEtC,MAAM,IAAKA,MAAM,CAAC2C,mBAAmB,CAAC,EAAE;MAC7D,OAAOjF,eAAe,CAACkF,KAAK;IAC9B;IAEA,OAAOlF,eAAe,CAACmF,WAAW;EACpC;AACF"}
|
|
@@ -6,12 +6,6 @@ import { IllegalStateException } from "../../../exceptions";
|
|
|
6
6
|
* @abstract
|
|
7
7
|
*/
|
|
8
8
|
class BaseLayoutHintRule {
|
|
9
|
-
/**
|
|
10
|
-
* Indicates if the rule implements the isApplicableForHint method
|
|
11
|
-
* @type {boolean}
|
|
12
|
-
* @default false
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
9
|
/**
|
|
16
10
|
* Indicates if the rule instance is applicable for a specific attribute<br>
|
|
17
11
|
* @default true
|
|
@@ -56,6 +50,11 @@ class BaseLayoutHintRule {
|
|
|
56
50
|
throw new IllegalStateException(`Missing process implementation on layout hint rule`);
|
|
57
51
|
}
|
|
58
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Indicates if the rule implements the isApplicableForHint method
|
|
55
|
+
* @type {boolean}
|
|
56
|
+
* @default false
|
|
57
|
+
*/
|
|
59
58
|
_defineProperty(BaseLayoutHintRule, "checkHintApplicability", false);
|
|
60
59
|
export default BaseLayoutHintRule;
|
|
61
60
|
//# sourceMappingURL=BaseLayoutHintRule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseLayoutHintRule.js","names":["IllegalStateException","BaseLayoutHintRule","isApplicableForAttribute","attribute","isApplicableForHint","hint","initAttribute","initHint","process","attributes","_defineProperty"],"sources":["../../../../src/models/attributes/layouthint-rules/BaseLayoutHintRule.js"],"sourcesContent":["// @flow\n/* eslint-disable no-unused-vars */\n\nimport { IllegalStateException } from \"../../../exceptions\";\n\nimport type { ILayoutHintRule, AttributeType } from \"../../types\";\nimport type AttributeCollection from \"../AttributeCollection\";\nimport type AttributeModel from \"../AttributeModel\";\n\n/**\n * Abstract class for layout hint rules\n * @abstract\n */\nclass BaseLayoutHintRule implements ILayoutHintRule {\n /**\n * Indicates if the rule implements the isApplicableForHint method\n * @type {boolean}\n * @default false\n */\n static checkHintApplicability: boolean = false;\n\n /**\n * Indicates if the rule instance is applicable for a specific attribute<br>\n * @default true\n */\n static isApplicableForAttribute(attribute: AttributeType): boolean {\n return true;\n }\n\n /**\n * Indicates if the rule instance is applicable for a specific hint<br>\n * Is required when checkHintApplicability is true\n * @abstract\n */\n static isApplicableForHint(hint: string): boolean {\n throw new IllegalStateException(\n `Missing isApplicableForHint implementation on layout hint rule`\n );\n }\n\n /**\n * Initialize the rule when isApplicableForAttribute is true and checkHintApplicability is false\n * @abstract\n */\n static initAttribute(attribute: AttributeType): ILayoutHintRule {\n throw new IllegalStateException(\n `Missing initAttribute implementation on layout hint rule`\n );\n }\n\n /**\n * Initialize the rule when isApplicableForAttribute and isApplicableForHint are both true,\n * it receives the hint. Allows a rule to be instantiated multiple times for an attribute,\n * but once for each hint entry\n * @abstract\n */\n static initHint(hint: string): ILayoutHintRule {\n throw new IllegalStateException(\n `Missing initHint implementation on layout hint rule`\n );\n }\n\n /**\n * Abstract method, implements process of layout hint rule,\n * use this to enhance the applicable attribute or the attribute collection\n * @abstract\n */\n process(attribute: AttributeModel, attributes: AttributeCollection): void {\n throw new IllegalStateException(\n `Missing process implementation on layout hint rule`\n );\n }\n}\n\nexport default BaseLayoutHintRule;\n"],"mappings":";AACA;AAEA,SAASA,qBAAqB,QAAQ,qBAAqB;AAM3D;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,CAA4B;
|
|
1
|
+
{"version":3,"file":"BaseLayoutHintRule.js","names":["IllegalStateException","BaseLayoutHintRule","isApplicableForAttribute","attribute","isApplicableForHint","hint","initAttribute","initHint","process","attributes","_defineProperty"],"sources":["../../../../src/models/attributes/layouthint-rules/BaseLayoutHintRule.js"],"sourcesContent":["// @flow\n/* eslint-disable no-unused-vars */\n\nimport { IllegalStateException } from \"../../../exceptions\";\n\nimport type { ILayoutHintRule, AttributeType } from \"../../types\";\nimport type AttributeCollection from \"../AttributeCollection\";\nimport type AttributeModel from \"../AttributeModel\";\n\n/**\n * Abstract class for layout hint rules\n * @abstract\n */\nclass BaseLayoutHintRule implements ILayoutHintRule {\n /**\n * Indicates if the rule implements the isApplicableForHint method\n * @type {boolean}\n * @default false\n */\n static checkHintApplicability: boolean = false;\n\n /**\n * Indicates if the rule instance is applicable for a specific attribute<br>\n * @default true\n */\n static isApplicableForAttribute(attribute: AttributeType): boolean {\n return true;\n }\n\n /**\n * Indicates if the rule instance is applicable for a specific hint<br>\n * Is required when checkHintApplicability is true\n * @abstract\n */\n static isApplicableForHint(hint: string): boolean {\n throw new IllegalStateException(\n `Missing isApplicableForHint implementation on layout hint rule`\n );\n }\n\n /**\n * Initialize the rule when isApplicableForAttribute is true and checkHintApplicability is false\n * @abstract\n */\n static initAttribute(attribute: AttributeType): ILayoutHintRule {\n throw new IllegalStateException(\n `Missing initAttribute implementation on layout hint rule`\n );\n }\n\n /**\n * Initialize the rule when isApplicableForAttribute and isApplicableForHint are both true,\n * it receives the hint. Allows a rule to be instantiated multiple times for an attribute,\n * but once for each hint entry\n * @abstract\n */\n static initHint(hint: string): ILayoutHintRule {\n throw new IllegalStateException(\n `Missing initHint implementation on layout hint rule`\n );\n }\n\n /**\n * Abstract method, implements process of layout hint rule,\n * use this to enhance the applicable attribute or the attribute collection\n * @abstract\n */\n process(attribute: AttributeModel, attributes: AttributeCollection): void {\n throw new IllegalStateException(\n `Missing process implementation on layout hint rule`\n );\n }\n}\n\nexport default BaseLayoutHintRule;\n"],"mappings":";AACA;AAEA,SAASA,qBAAqB,QAAQ,qBAAqB;AAM3D;AACA;AACA;AACA;AACA,MAAMC,kBAAkB,CAA4B;EAQlD;AACF;AACA;AACA;EACE,OAAOC,wBAAwBA,CAACC,SAAwB,EAAW;IACjE,OAAO,IAAI;EACb;;EAEA;AACF;AACA;AACA;AACA;EACE,OAAOC,mBAAmBA,CAACC,IAAY,EAAW;IAChD,MAAM,IAAIL,qBAAqB,CAC5B,gEAA+D,CACjE;EACH;;EAEA;AACF;AACA;AACA;EACE,OAAOM,aAAaA,CAACH,SAAwB,EAAmB;IAC9D,MAAM,IAAIH,qBAAqB,CAC5B,0DAAyD,CAC3D;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAOO,QAAQA,CAACF,IAAY,EAAmB;IAC7C,MAAM,IAAIL,qBAAqB,CAC5B,qDAAoD,CACtD;EACH;;EAEA;AACF;AACA;AACA;AACA;EACEQ,OAAOA,CAACL,SAAyB,EAAEM,UAA+B,EAAQ;IACxE,MAAM,IAAIT,qBAAqB,CAC5B,oDAAmD,CACrD;EACH;AACF;AA1DE;AACF;AACA;AACA;AACA;AAJEU,eAAA,CADIT,kBAAkB,4BAMmB,KAAK;AAuDhD,eAAeA,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DependentAttribute.js","names":["BaseLayoutHintRule","DEPENDENT_ATTRIBUTE_CONTROL","DEPENDENT_ATTRIBUTE","ChoiceAttributeModel","BooleanAttributeModel","ConfigurationException","EQUALS","INCLUDES","NOT_EQUALS","NOT_INCLUDES","NOT_IS_EMPTY","IS_EMPTY","SHOW","HIDE","DependentAttribute","constructor","arguments","_defineProperty","isApplicableForHint","hint","regex","RegExp","test","getRuleInstance","initHint","rule","OPERATORS","isEmpyNotIsEmptRegex","result","match","action","control","operator","options","_action","_control","_operator","_options","_context","_mapInstanceProperty","split","call","option","_trimInstanceProperty","processEqualsOptions","controlAttribute","every","_context2","_includesInstanceProperty","selected","processIncludesOptions","some","_context3","handleOperator","length","getControlAttribute","attributes","attribute","getAttributeByLayoutHint","process","processLayoutHintRules","isHidden","hide","label"],"sources":["../../../../src/models/attributes/layouthint-rules/DependentAttribute.js"],"sourcesContent":["// @flow\nimport BaseLayoutHintRule from \"./BaseLayoutHintRule\";\n\nimport {\n DEPENDENT_ATTRIBUTE_CONTROL,\n DEPENDENT_ATTRIBUTE,\n} from \"../../../constants\";\n\nimport ChoiceAttributeModel from \"../ChoiceAttributeModel\";\nimport BooleanAttributeModel from \"../BooleanAttributeModel\";\n\nimport { ConfigurationException } from \"../../../exceptions\";\n\nimport type AttributeCollection from \"../AttributeCollection\";\nimport type AttributeModel from \"../AttributeModel\";\n\nconst EQUALS = \"equals\";\nconst INCLUDES = \"includes\";\nconst NOT_EQUALS = \"notEquals\";\nconst NOT_INCLUDES = \"notIncludes\";\nconst NOT_IS_EMPTY = \"notIsEmpty\";\nconst IS_EMPTY = \"isEmpty\";\n\nconst SHOW = \"show\";\nconst HIDE = \"hide\";\n\n/**\n * Depending attributes hint logic\n */\nclass DependentAttribute extends BaseLayoutHintRule {\n _action: string;\n _control: string;\n _operator: string;\n _options: Array<string>;\n\n /**\n */\n static checkHintApplicability: boolean = true;\n\n /**\n */\n static isApplicableForHint(hint: string): boolean {\n const regex = new RegExp(\n `^${DEPENDENT_ATTRIBUTE}\\\\s?(${SHOW}|${HIDE})`,\n \"i\"\n );\n\n return regex.test(hint);\n }\n\n /**\n * Used on initHint to create an instance of this rule\n */\n static getRuleInstance(): DependentAttribute {\n return new DependentAttribute();\n }\n\n /**\n */\n static initHint(hint: string): any {\n const rule = this.getRuleInstance();\n\n const OPERATORS = `${EQUALS}|${INCLUDES}|${NOT_EQUALS}|${NOT_INCLUDES}|${NOT_IS_EMPTY}|${IS_EMPTY}`;\n const regex = new RegExp(\n `${DEPENDENT_ATTRIBUTE}\\\\s?(\\\\S*)\\\\swhen ${DEPENDENT_ATTRIBUTE_CONTROL}:\\\\s?(.*?)\\\\s*(${OPERATORS})\\\\s(.*)`,\n \"i\"\n );\n const isEmpyNotIsEmptRegex = new RegExp(\n `${DEPENDENT_ATTRIBUTE}\\\\s?(\\\\S*)\\\\swhen ${DEPENDENT_ATTRIBUTE_CONTROL}:\\\\s?(.*?)\\\\s*(${OPERATORS})`,\n \"i\"\n );\n\n const result = hint.match(regex)\n ? hint.match(regex)\n : hint.match(isEmpyNotIsEmptRegex);\n\n if (result) {\n rule.action = result[1];\n rule.control = result[2];\n rule.operator = result[3];\n rule.options = !result[4] ? \"\" : result[4];\n } else {\n throw new ConfigurationException(\n `No dependent information found on layout hint: ${hint}`\n );\n }\n\n return rule;\n }\n\n /**\n */\n get action(): string {\n return this._action;\n }\n\n /**\n */\n set action(action: string) {\n this._action = action;\n }\n\n /**\n */\n get control(): string {\n return this._control;\n }\n\n /**\n */\n set control(control: string) {\n this._control = control;\n }\n\n /**\n */\n get operator(): string {\n return this._operator;\n }\n\n /**\n */\n set operator(operator: string) {\n this._operator = operator;\n }\n\n /**\n */\n get options(): Array<string> {\n return this._options;\n }\n\n /**\n */\n set options(options: string): void {\n this._options = options.split(\"|\").map((option) => option.trim());\n }\n\n /**\n */\n processEqualsOptions(\n controlAttribute: ChoiceAttributeModel | BooleanAttributeModel\n ): boolean {\n if (\n controlAttribute instanceof ChoiceAttributeModel ||\n controlAttribute instanceof BooleanAttributeModel\n ) {\n return this.options.every((option) =>\n controlAttribute.selected.includes(option)\n );\n }\n\n throw new ConfigurationException(\n \"Dependent control in combination with equals operator must be a choice, string or number attribute\"\n );\n }\n\n /**\n */\n processIncludesOptions(\n controlAttribute: ChoiceAttributeModel | BooleanAttributeModel\n ): boolean {\n if (controlAttribute instanceof ChoiceAttributeModel) {\n return this.options.some((option) =>\n controlAttribute.selected.includes(option)\n );\n }\n\n throw new ConfigurationException(\n \"Dependent control in combination with includes operator must be a choice attribute\"\n );\n }\n\n /**\n */\n handleOperator(\n controlAttribute: ChoiceAttributeModel | BooleanAttributeModel\n ): boolean {\n switch (this.operator) {\n case EQUALS:\n return this.processEqualsOptions(controlAttribute);\n case INCLUDES:\n return this.processIncludesOptions(controlAttribute);\n case NOT_EQUALS:\n return !this.processEqualsOptions(controlAttribute);\n case NOT_INCLUDES:\n return !this.processIncludesOptions(controlAttribute);\n case NOT_IS_EMPTY:\n return controlAttribute?.selected.length !== 0;\n case IS_EMPTY:\n return controlAttribute?.selected.length === 0;\n default:\n throw new ConfigurationException(\n `Unsupported operator for dependent question: ${this.operator}`\n );\n }\n }\n\n /**\n */\n getControlAttribute(\n attributes: AttributeCollection\n ): ChoiceAttributeModel | BooleanAttributeModel | null {\n const attribute = attributes.getAttributeByLayoutHint(\n `${DEPENDENT_ATTRIBUTE_CONTROL}:${this.control}`,\n `${DEPENDENT_ATTRIBUTE_CONTROL}: ${this.control}`\n );\n\n if (\n attribute instanceof ChoiceAttributeModel ||\n attribute instanceof BooleanAttributeModel\n ) {\n return attribute;\n }\n\n return null;\n }\n\n /**\n */\n process(attribute: AttributeModel, attributes: AttributeCollection): void {\n const controlAttribute = this.getControlAttribute(attributes);\n if (!controlAttribute) {\n return;\n }\n\n controlAttribute.processLayoutHintRules(attributes);\n if (controlAttribute.isHidden) {\n attribute.hide();\n return;\n }\n\n const result = this.handleOperator(controlAttribute);\n if (this.action === SHOW) {\n attribute.isHidden = !result;\n } else if (this.action === HIDE) {\n attribute.isHidden = result;\n } else {\n throw new ConfigurationException(\n `Unsupported action ${this.action} for dependent question on attribute: ${attribute.label}`\n );\n }\n }\n}\n\nexport default DependentAttribute;\n"],"mappings":";;;;AACA,OAAOA,kBAAkB,MAAM,sBAAsB;AAErD,SACEC,2BAA2B,EAC3BC,mBAAmB,QACd,oBAAoB;AAE3B,OAAOC,oBAAoB,MAAM,yBAAyB;AAC1D,OAAOC,qBAAqB,MAAM,0BAA0B;AAE5D,SAASC,sBAAsB,QAAQ,qBAAqB;AAK5D,MAAMC,MAAM,GAAG,QAAQ;AACvB,MAAMC,QAAQ,GAAG,UAAU;AAC3B,MAAMC,UAAU,GAAG,WAAW;AAC9B,MAAMC,YAAY,GAAG,aAAa;AAClC,MAAMC,YAAY,GAAG,YAAY;AACjC,MAAMC,QAAQ,GAAG,SAAS;AAE1B,MAAMC,IAAI,GAAG,MAAM;AACnB,MAAMC,IAAI,GAAG,MAAM;;AAEnB;AACA;AACA;AACA,MAAMC,k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EPENDENT_ATTRIBUTE","ChoiceAttributeModel","BooleanAttributeModel","ConfigurationException","EQUALS","INCLUDES","NOT_EQUALS","NOT_INCLUDES","NOT_IS_EMPTY","IS_EMPTY","SHOW","HIDE","DependentAttribute","constructor","arguments","_defineProperty","isApplicableForHint","hint","regex","RegExp","test","getRuleInstance","initHint","rule","OPERATORS","isEmpyNotIsEmptRegex","result","match","action","control","operator","options","_action","_control","_operator","_options","_context","_mapInstanceProperty","split","call","option","_trimInstanceProperty","processEqualsOptions","controlAttribute","every","_context2","_includesInstanceProperty","selected","processIncludesOptions","some","_context3","handleOperator","length","getControlAttribute","attributes","attribute","getAttributeByLayoutHint","process","processLayoutHintRules","isHidden","hide","label"],"sources":["../../../../src/models/attributes/layouthint-rules/DependentAttribute.js"],"sourcesContent":["// @flow\nimport BaseLayoutHintRule from \"./BaseLayoutHintRule\";\n\nimport {\n DEPENDENT_ATTRIBUTE_CONTROL,\n DEPENDENT_ATTRIBUTE,\n} from \"../../../constants\";\n\nimport ChoiceAttributeModel from \"../ChoiceAttributeModel\";\nimport BooleanAttributeModel from \"../BooleanAttributeModel\";\n\nimport { ConfigurationException } from \"../../../exceptions\";\n\nimport type AttributeCollection from \"../AttributeCollection\";\nimport type AttributeModel from \"../AttributeModel\";\n\nconst EQUALS = \"equals\";\nconst INCLUDES = \"includes\";\nconst NOT_EQUALS = \"notEquals\";\nconst NOT_INCLUDES = \"notIncludes\";\nconst NOT_IS_EMPTY = \"notIsEmpty\";\nconst IS_EMPTY = \"isEmpty\";\n\nconst SHOW = \"show\";\nconst HIDE = \"hide\";\n\n/**\n * Depending attributes hint logic\n */\nclass DependentAttribute extends BaseLayoutHintRule {\n _action: string;\n _control: string;\n _operator: string;\n _options: Array<string>;\n\n /**\n */\n static checkHintApplicability: boolean = true;\n\n /**\n */\n static isApplicableForHint(hint: string): boolean {\n const regex = new RegExp(\n `^${DEPENDENT_ATTRIBUTE}\\\\s?(${SHOW}|${HIDE})`,\n \"i\"\n );\n\n return regex.test(hint);\n }\n\n /**\n * Used on initHint to create an instance of this rule\n */\n static getRuleInstance(): DependentAttribute {\n return new DependentAttribute();\n }\n\n /**\n */\n static initHint(hint: string): any {\n const rule = this.getRuleInstance();\n\n const OPERATORS = `${EQUALS}|${INCLUDES}|${NOT_EQUALS}|${NOT_INCLUDES}|${NOT_IS_EMPTY}|${IS_EMPTY}`;\n const regex = new RegExp(\n `${DEPENDENT_ATTRIBUTE}\\\\s?(\\\\S*)\\\\swhen ${DEPENDENT_ATTRIBUTE_CONTROL}:\\\\s?(.*?)\\\\s*(${OPERATORS})\\\\s(.*)`,\n \"i\"\n );\n const isEmpyNotIsEmptRegex = new RegExp(\n `${DEPENDENT_ATTRIBUTE}\\\\s?(\\\\S*)\\\\swhen ${DEPENDENT_ATTRIBUTE_CONTROL}:\\\\s?(.*?)\\\\s*(${OPERATORS})`,\n \"i\"\n );\n\n const result = hint.match(regex)\n ? hint.match(regex)\n : hint.match(isEmpyNotIsEmptRegex);\n\n if (result) {\n rule.action = result[1];\n rule.control = result[2];\n rule.operator = result[3];\n rule.options = !result[4] ? \"\" : result[4];\n } else {\n throw new ConfigurationException(\n `No dependent information found on layout hint: ${hint}`\n );\n }\n\n return rule;\n }\n\n /**\n */\n get action(): string {\n return this._action;\n }\n\n /**\n */\n set action(action: string) {\n this._action = action;\n }\n\n /**\n */\n get control(): string {\n return this._control;\n }\n\n /**\n */\n set control(control: string) {\n this._control = control;\n }\n\n /**\n */\n get operator(): string {\n return this._operator;\n }\n\n /**\n */\n set operator(operator: string) {\n this._operator = operator;\n }\n\n /**\n */\n get options(): Array<string> {\n return this._options;\n }\n\n /**\n */\n set options(options: string): void {\n this._options = options.split(\"|\").map((option) => option.trim());\n }\n\n /**\n */\n processEqualsOptions(\n controlAttribute: ChoiceAttributeModel | BooleanAttributeModel\n ): boolean {\n if (\n controlAttribute instanceof ChoiceAttributeModel ||\n controlAttribute instanceof BooleanAttributeModel\n ) {\n return this.options.every((option) =>\n controlAttribute.selected.includes(option)\n );\n }\n\n throw new ConfigurationException(\n \"Dependent control in combination with equals operator must be a choice, string or number attribute\"\n );\n }\n\n /**\n */\n processIncludesOptions(\n controlAttribute: ChoiceAttributeModel | BooleanAttributeModel\n ): boolean {\n if (controlAttribute instanceof ChoiceAttributeModel) {\n return this.options.some((option) =>\n controlAttribute.selected.includes(option)\n );\n }\n\n throw new ConfigurationException(\n \"Dependent control in combination with includes operator must be a choice attribute\"\n );\n }\n\n /**\n */\n handleOperator(\n controlAttribute: ChoiceAttributeModel | BooleanAttributeModel\n ): boolean {\n switch (this.operator) {\n case EQUALS:\n return this.processEqualsOptions(controlAttribute);\n case INCLUDES:\n return this.processIncludesOptions(controlAttribute);\n case NOT_EQUALS:\n return !this.processEqualsOptions(controlAttribute);\n case NOT_INCLUDES:\n return !this.processIncludesOptions(controlAttribute);\n case NOT_IS_EMPTY:\n return controlAttribute?.selected.length !== 0;\n case IS_EMPTY:\n return controlAttribute?.selected.length === 0;\n default:\n throw new ConfigurationException(\n `Unsupported operator for dependent question: ${this.operator}`\n );\n }\n }\n\n /**\n */\n getControlAttribute(\n attributes: AttributeCollection\n ): ChoiceAttributeModel | BooleanAttributeModel | null {\n const attribute = attributes.getAttributeByLayoutHint(\n `${DEPENDENT_ATTRIBUTE_CONTROL}:${this.control}`,\n `${DEPENDENT_ATTRIBUTE_CONTROL}: ${this.control}`\n );\n\n if (\n attribute instanceof ChoiceAttributeModel ||\n attribute instanceof BooleanAttributeModel\n ) {\n return attribute;\n }\n\n return null;\n }\n\n /**\n */\n process(attribute: AttributeModel, attributes: AttributeCollection): void {\n const controlAttribute = this.getControlAttribute(attributes);\n if (!controlAttribute) {\n return;\n }\n\n controlAttribute.processLayoutHintRules(attributes);\n if (controlAttribute.isHidden) {\n attribute.hide();\n return;\n }\n\n const result = this.handleOperator(controlAttribute);\n if (this.action === SHOW) {\n attribute.isHidden = !result;\n } else if (this.action === HIDE) {\n attribute.isHidden = result;\n } else {\n throw new ConfigurationException(\n `Unsupported action ${this.action} for dependent question on attribute: ${attribute.label}`\n );\n }\n }\n}\n\nexport default DependentAttribute;\n"],"mappings":";;;;AACA,OAAOA,kBAAkB,MAAM,sBAAsB;AAErD,SACEC,2BAA2B,EAC3BC,mBAAmB,QACd,oBAAoB;AAE3B,OAAOC,oBAAoB,MAAM,yBAAyB;AAC1D,OAAOC,qBAAqB,MAAM,0BAA0B;AAE5D,SAASC,sBAAsB,QAAQ,qBAAqB;AAK5D,MAAMC,MAAM,GAAG,QAAQ;AACvB,MAAMC,QAAQ,GAAG,UAAU;AAC3B,MAAMC,UAAU,GAAG,WAAW;AAC9B,MAAMC,YAAY,GAAG,aAAa;AAClC,MAAMC,YAAY,GAAG,YAAY;AACjC,MAAMC,QAAQ,GAAG,SAAS;AAE1B,MAAMC,IAAI,GAAG,MAAM;AACnB,MAAMC,IAAI,GAAG,MAAM;;AAEnB;AACA;AACA;AACA,MAAMC,kBAAkB,SAASd,kBAAkB,CAAC;EAAAe,YAAA;IAAA,SAAAC,SAAA;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;EAAA;EAUlD;AACF;EACE,OAAOC,mBAAmBA,CAACC,IAAY,EAAW;IAChD,MAAMC,KAAK,GAAG,IAAIC,MAAM,CACrB,IAAGnB,mBAAoB,QAAOU,IAAK,IAAGC,IAAK,GAAE,EAC9C,GAAG,CACJ;IAED,OAAOO,KAAK,CAACE,IAAI,CAACH,IAAI,CAAC;EACzB;;EAEA;AACF;AACA;EACE,OAAOI,eAAeA,CAAA,EAAuB;IAC3C,OAAO,IAAIT,kBAAkB,EAAE;EACjC;;EAEA;AACF;EACE,OAAOU,QAAQA,CAACL,IAAY,EAAO;IACjC,MAAMM,IAAI,GAAG,IAAI,CAACF,eAAe,EAAE;IAEnC,MAAMG,SAAS,GAAI,GAAEpB,MAAO,IAAGC,QAAS,IAAGC,UAAW,IAAGC,YAAa,IAAGC,YAAa,IAAGC,QAAS,EAAC;IACnG,MAAMS,KAAK,GA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IACF;IAEA,MAAMlC,MAAM,GAAG,IAAI,CAACyB,cAAc,CAACR,gBAAgB,CAAC;IACpD,IAAI,IAAI,CAACf,MAAM,KAAKlB,IAAI,EAAE;MACxB6C,SAAS,CAACI,QAAQ,GAAG,CAACjC,MAAM;IAC9B,CAAC,MAAM,IAAI,IAAI,CAACE,MAAM,KAAKjB,IAAI,EAAE;MAC/B4C,SAAS,CAACI,QAAQ,GAAGjC,MAAM;IAC7B,CAAC,MAAM;MACL,MAAM,IAAIvB,sBAAsB,CAC7B,sBAAqB,IAAI,CAACyB,MAAO,yCAAwC2B,SAAS,CAACM,KAAM,EAAC,CAC5F;IACH;EACF;AACF;AAhNE;AACF;AADE9C,eAAA,CANIH,kBAAkB,4BAQmB,IAAI;AAgN/C,eAAeA,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorResponse.js","names":["Href","LayoutHintCollection","ErrorResponse","constructor","data","connectKey","_defineProperty","_error","_connectKey","key","error","status","NO_RESPONSE_CODE","DECIMAL_RADIX","parseInt","id","isResourceNotFound","name","message","responseMessage","response","title","titleMessage","undefined","titleId","titleProperties","properties","redirect","redirectText","text","redirectTextID","redirectTextProperties","redirectMessage","redirectHref","href","layouthint","parameters","RESOURCE_NOT_FOUND_RESPONSE_CODE","isResourceNotFoundAfterReload","isReload","isUnauthorized","UNAUTHORIZED_RESPONSE_CODE","hasUnauthorizedStatus","hasUnauthorizedErrorId","hasLoginAction","action","isChangePassword","isConcurrentUser","isConcurrentError","isBlocked","isInvalidCredentials","isInvalidUsername","isTimeoutError","isRemoteServiceException","changePasswordHref","isBasicAuthentication","loginFailed","shouldThrowOnServer"],"sources":["../../../src/models/error/ErrorResponse.js"],"sourcesContent":["// @flow\nimport Href from \"../href/Href\";\n\nimport type { MessageParameters } from \"../../i18n/types\";\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\n\n/**\n */\nexport type TitleObject = {\n +id: string,\n +properties?: Object,\n +message?: string,\n};\n/**\n */\nexport type RedirectTextObject = {\n +id: string,\n +properties?: Object,\n +message?: string,\n};\n\n/**\n */\nexport type RedirectObject = {\n +href: Href,\n +text?: RedirectTextObject,\n};\n\n/**\n * Error response model\n */\nexport default class ErrorResponse {\n _error: Object;\n _connectKey: ?string;\n\n /**\n * Construct ErrorResponse\n */\n constructor(data: Object, connectKey?: string) {\n this._error = data;\n this._connectKey = connectKey;\n }\n\n /**\n */\n set connectKey(key: string) {\n this._connectKey = key;\n }\n\n /**\n */\n get connectKey(): ?string {\n return this._connectKey;\n }\n\n /**\n * Return error information\n */\n get error(): Object {\n return this._error ?? {};\n }\n\n /**\n * Get request status code\n */\n get status(): number {\n const NO_RESPONSE_CODE = 0;\n const DECIMAL_RADIX = 10;\n return this.error.status\n ? parseInt(this.error.status, DECIMAL_RADIX)\n : NO_RESPONSE_CODE;\n }\n\n /**\n * Return error type information\n */\n get id(): string {\n if (this.isResourceNotFound && this.error.id !== \"Error.NotAuthorized\") {\n return \"Error.ResourceNotFound\";\n }\n\n return this.error.id || this.error.name || \"Error.GeneralError\";\n }\n\n /**\n */\n get message(): string {\n return this.error.message || this.id;\n }\n\n /**\n * Return response error message\n */\n get responseMessage(): string {\n return this.response.message || null;\n }\n\n /**\n * Return response error title\n */\n get title(): TitleObject {\n return this.response.title || null;\n }\n\n /**\n * Return response error title message\n */\n get titleMessage(): string {\n return this.response.title?.message || undefined;\n }\n\n /**\n * Return response error title Id\n */\n get titleId(): string {\n return this.response.title?.id || undefined;\n }\n\n /**\n * Return response error title properties\n */\n get titleProperties(): Object {\n return this.response.title?.properties || null;\n }\n\n /**\n * Return response error redirect\n */\n get redirect(): RedirectObject {\n return this.response.redirect || null;\n }\n /**\n * Return response error redirect text\n */\n get redirectText(): RedirectTextObject {\n return this.response?.redirect?.text || null;\n }\n\n /**\n * Return response error redirect text id\n */\n get redirectTextID(): string {\n return this.response.redirect?.text?.id || undefined;\n }\n\n /**\n * Return response error redirect text properties\n */\n get redirectTextProperties(): Object {\n return this.response.redirect?.text?.properties || null;\n }\n\n /**\n * Return response error redirect text message\n */\n get redirectMessage(): string {\n return this.response.redirect?.text?.message || undefined;\n }\n\n /**\n * Return response error redirect href\n */\n get redirectHref(): Href {\n if (this.response.redirect?.href) {\n return new Href(this.response.redirect?.href);\n }\n return new Href();\n }\n\n /**\n * Return error response layouthint\n */\n get layouthint(): LayoutHintCollection {\n return new LayoutHintCollection(this.response?.layouthint);\n }\n\n /**\n */\n get response(): Object {\n return this.error?.response?.error || {};\n }\n\n /**\n */\n get properties(): Object {\n const { properties } = this.error;\n if (properties != null && typeof properties == \"object\") {\n return properties;\n }\n\n return {};\n }\n\n /**\n * Return error parameters\n */\n get parameters(): ?MessageParameters {\n return this.error.parameters || null;\n }\n\n /**\n */\n get isResourceNotFound(): boolean {\n const RESOURCE_NOT_FOUND_RESPONSE_CODE = 404;\n\n return this.status === RESOURCE_NOT_FOUND_RESPONSE_CODE;\n }\n\n /**\n */\n get isResourceNotFoundAfterReload(): boolean {\n return this.isResourceNotFound && this.error.isReload;\n }\n\n /**\n * Check if the error message is an authorization error\n */\n get isUnauthorized(): boolean {\n const UNAUTHORIZED_RESPONSE_CODE = 401;\n\n const hasUnauthorizedStatus = this.status === UNAUTHORIZED_RESPONSE_CODE;\n const hasUnauthorizedErrorId =\n this.id === \"Error.NotAuthorized\" ||\n this.id === \"Error.Authentication.Required\" ||\n this.id === \"Error.Authentication.InvalidCredentials\";\n\n const hasLoginAction = this.error.action\n ? this.error.action.name === \"login\"\n : false;\n\n return hasUnauthorizedStatus || hasUnauthorizedErrorId || hasLoginAction;\n }\n\n /**\n */\n get isChangePassword(): boolean {\n return this.id === \"Error.ChangePasswordRequired\";\n }\n\n /**\n */\n get isConcurrentUser(): boolean {\n return this.id === \"Error.Authentication.ConcurrentUser\";\n }\n\n /**\n */\n get isConcurrentError(): boolean {\n return (\n this.id === \"Error.Case.ConcurrentModification\" ||\n this.id === \"Error.DataStore.ConcurrentModification\" ||\n this.id === \"Error.DataStore.RecordAlreadyExists\" ||\n this.id === \"Error.DataStore.RowCannotBeLocked\"\n );\n }\n\n /**\n */\n get isBlocked(): boolean {\n return this.id === \"Error.Authentication.BlockedUser\";\n }\n\n /**\n */\n get isInvalidCredentials(): boolean {\n return this.id === \"Error.Authentication.InvalidCredentials\";\n }\n\n /**\n */\n get isInvalidUsername(): boolean {\n return this.id === \"Error.Authentication.InvalidUsername\";\n }\n\n /**\n */\n get isTimeoutError(): boolean {\n return this.id === \"Error.CodemapLookup.InvalidToken\";\n }\n\n /**\n * A RemoteServiceException occurs when an exception occurs connecting to an external system,\n * for example when using the service list panels\n */\n get isRemoteServiceException(): boolean {\n return this.id === \"Error.RemoteServiceException\";\n }\n\n /**\n * Get response url\n */\n get changePasswordHref(): ?Href {\n return this.properties.redirect ? new Href(this.properties.redirect) : null;\n }\n\n /**\n * When no action information is present in the unauthorized response, for now we assume it is Basic Authentication\n */\n get isBasicAuthentication(): boolean {\n const UNAUTHORIZED_RESPONSE_CODE = 401;\n return (\n this.isUnauthorized &&\n this.status === UNAUTHORIZED_RESPONSE_CODE &&\n this.response.error === \"No responseText\"\n );\n }\n\n /**\n * Retrieve a failed login attempt\n */\n get loginFailed(): boolean {\n return (\n this.id === \"Error.Authentication.Required\" ||\n this.id === \"Error.Authentication.InvalidCredentials\"\n );\n }\n\n /**\n */\n get shouldThrowOnServer(): boolean {\n return !this.isChangePassword && !this.isBlocked && !this.isConcurrentUser;\n }\n}\n"],"mappings":";AACA,OAAOA,IAAI,MAAM,cAAc;AAG/B,OAAOC,oBAAoB,MAAM,oCAAoC;;AAErE;AACA;;AAqBA;AACA;AACA;AACA,eAAe,MAAMC,aAAa,CAAC;EAIjC;AACF;AACA;EACEC,WAAWA,CAACC,IAAY,EAAEC,UAAmB,EAAE;IAAAC,eAAA;IAAAA,eAAA;IAC7C,IAAI,CAACC,MAAM,GAAGH,IAAI;IAClB,IAAI,CAACI,WAAW,GAAGH,UAAU;EAC/B;;EAEA;AACF;EACE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,OACE,IAAI,CAACD,cAAc,IACnB,IAAI,CAAC7B,MAAM,KAAK8B,0BAA0B,IAC1C,IAAI,CAACrB,QAAQ,CAACV,KAAK,KAAK,iBAAiB;EAE7C;;EAEA;AACF;AACA;EACE,IAAI8C,WAAWA,CAAA,EAAY;IACzB,OACE,IAAI,CAACzC,EAAE,KAAK,+BAA+B,IAC3C,IAAI,CAACA,EAAE,KAAK,yCAAyC;EAEzD;;EAEA;AACF;EACE,IAAI0C,mBAAmBA,CAAA,EAAY;IACjC,OAAO,CAAC,IAAI,CAACX,gBAAgB,IAAI,CAAC,IAAI,CAACG,SAAS,IAAI,CAAC,IAAI,CAACF,gBAAgB;EAC5E;AACF"}
|
|
1
|
+
{"version":3,"file":"ErrorResponse.js","names":["Href","LayoutHintCollection","ErrorResponse","constructor","data","connectKey","_defineProperty","_error","_connectKey","key","error","status","NO_RESPONSE_CODE","DECIMAL_RADIX","parseInt","id","isResourceNotFound","name","message","responseMessage","response","title","titleMessage","undefined","titleId","titleProperties","properties","redirect","redirectText","text","redirectTextID","redirectTextProperties","redirectMessage","redirectHref","href","layouthint","parameters","RESOURCE_NOT_FOUND_RESPONSE_CODE","isResourceNotFoundAfterReload","isReload","isUnauthorized","UNAUTHORIZED_RESPONSE_CODE","hasUnauthorizedStatus","hasUnauthorizedErrorId","hasLoginAction","action","isChangePassword","isConcurrentUser","isConcurrentError","isBlocked","isInvalidCredentials","isInvalidUsername","isTimeoutError","isRemoteServiceException","changePasswordHref","isBasicAuthentication","loginFailed","shouldThrowOnServer"],"sources":["../../../src/models/error/ErrorResponse.js"],"sourcesContent":["// @flow\nimport Href from \"../href/Href\";\n\nimport type { MessageParameters } from \"../../i18n/types\";\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\n\n/**\n */\nexport type TitleObject = {\n +id: string,\n +properties?: Object,\n +message?: string,\n};\n/**\n */\nexport type RedirectTextObject = {\n +id: string,\n +properties?: Object,\n +message?: string,\n};\n\n/**\n */\nexport type RedirectObject = {\n +href: Href,\n +text?: RedirectTextObject,\n};\n\n/**\n * Error response model\n */\nexport default class ErrorResponse {\n _error: Object;\n _connectKey: ?string;\n\n /**\n * Construct ErrorResponse\n */\n constructor(data: Object, connectKey?: string) {\n this._error = data;\n this._connectKey = connectKey;\n }\n\n /**\n */\n set connectKey(key: string) {\n this._connectKey = key;\n }\n\n /**\n */\n get connectKey(): ?string {\n return this._connectKey;\n }\n\n /**\n * Return error information\n */\n get error(): Object {\n return this._error ?? {};\n }\n\n /**\n * Get request status code\n */\n get status(): number {\n const NO_RESPONSE_CODE = 0;\n const DECIMAL_RADIX = 10;\n return this.error.status\n ? parseInt(this.error.status, DECIMAL_RADIX)\n : NO_RESPONSE_CODE;\n }\n\n /**\n * Return error type information\n */\n get id(): string {\n if (this.isResourceNotFound && this.error.id !== \"Error.NotAuthorized\") {\n return \"Error.ResourceNotFound\";\n }\n\n return this.error.id || this.error.name || \"Error.GeneralError\";\n }\n\n /**\n */\n get message(): string {\n return this.error.message || this.id;\n }\n\n /**\n * Return response error message\n */\n get responseMessage(): string {\n return this.response.message || null;\n }\n\n /**\n * Return response error title\n */\n get title(): TitleObject {\n return this.response.title || null;\n }\n\n /**\n * Return response error title message\n */\n get titleMessage(): string {\n return this.response.title?.message || undefined;\n }\n\n /**\n * Return response error title Id\n */\n get titleId(): string {\n return this.response.title?.id || undefined;\n }\n\n /**\n * Return response error title properties\n */\n get titleProperties(): Object {\n return this.response.title?.properties || null;\n }\n\n /**\n * Return response error redirect\n */\n get redirect(): RedirectObject {\n return this.response.redirect || null;\n }\n /**\n * Return response error redirect text\n */\n get redirectText(): RedirectTextObject {\n return this.response?.redirect?.text || null;\n }\n\n /**\n * Return response error redirect text id\n */\n get redirectTextID(): string {\n return this.response.redirect?.text?.id || undefined;\n }\n\n /**\n * Return response error redirect text properties\n */\n get redirectTextProperties(): Object {\n return this.response.redirect?.text?.properties || null;\n }\n\n /**\n * Return response error redirect text message\n */\n get redirectMessage(): string {\n return this.response.redirect?.text?.message || undefined;\n }\n\n /**\n * Return response error redirect href\n */\n get redirectHref(): Href {\n if (this.response.redirect?.href) {\n return new Href(this.response.redirect?.href);\n }\n return new Href();\n }\n\n /**\n * Return error response layouthint\n */\n get layouthint(): LayoutHintCollection {\n return new LayoutHintCollection(this.response?.layouthint);\n }\n\n /**\n */\n get response(): Object {\n return this.error?.response?.error || {};\n }\n\n /**\n */\n get properties(): Object {\n const { properties } = this.error;\n if (properties != null && typeof properties == \"object\") {\n return properties;\n }\n\n return {};\n }\n\n /**\n * Return error parameters\n */\n get parameters(): ?MessageParameters {\n return this.error.parameters || null;\n }\n\n /**\n */\n get isResourceNotFound(): boolean {\n const RESOURCE_NOT_FOUND_RESPONSE_CODE = 404;\n\n return this.status === RESOURCE_NOT_FOUND_RESPONSE_CODE;\n }\n\n /**\n */\n get isResourceNotFoundAfterReload(): boolean {\n return this.isResourceNotFound && this.error.isReload;\n }\n\n /**\n * Check if the error message is an authorization error\n */\n get isUnauthorized(): boolean {\n const UNAUTHORIZED_RESPONSE_CODE = 401;\n\n const hasUnauthorizedStatus = this.status === UNAUTHORIZED_RESPONSE_CODE;\n const hasUnauthorizedErrorId =\n this.id === \"Error.NotAuthorized\" ||\n this.id === \"Error.Authentication.Required\" ||\n this.id === \"Error.Authentication.InvalidCredentials\";\n\n const hasLoginAction = this.error.action\n ? this.error.action.name === \"login\"\n : false;\n\n return hasUnauthorizedStatus || hasUnauthorizedErrorId || hasLoginAction;\n }\n\n /**\n */\n get isChangePassword(): boolean {\n return this.id === \"Error.ChangePasswordRequired\";\n }\n\n /**\n */\n get isConcurrentUser(): boolean {\n return this.id === \"Error.Authentication.ConcurrentUser\";\n }\n\n /**\n */\n get isConcurrentError(): boolean {\n return (\n this.id === \"Error.Case.ConcurrentModification\" ||\n this.id === \"Error.DataStore.ConcurrentModification\" ||\n this.id === \"Error.DataStore.RecordAlreadyExists\" ||\n this.id === \"Error.DataStore.RowCannotBeLocked\"\n );\n }\n\n /**\n */\n get isBlocked(): boolean {\n return this.id === \"Error.Authentication.BlockedUser\";\n }\n\n /**\n */\n get isInvalidCredentials(): boolean {\n return this.id === \"Error.Authentication.InvalidCredentials\";\n }\n\n /**\n */\n get isInvalidUsername(): boolean {\n return this.id === \"Error.Authentication.InvalidUsername\";\n }\n\n /**\n */\n get isTimeoutError(): boolean {\n return this.id === \"Error.CodemapLookup.InvalidToken\";\n }\n\n /**\n * A RemoteServiceException occurs when an exception occurs connecting to an external system,\n * for example when using the service list panels\n */\n get isRemoteServiceException(): boolean {\n return this.id === \"Error.RemoteServiceException\";\n }\n\n /**\n * Get response url\n */\n get changePasswordHref(): ?Href {\n return this.properties.redirect ? new Href(this.properties.redirect) : null;\n }\n\n /**\n * When no action information is present in the unauthorized response, for now we assume it is Basic Authentication\n */\n get isBasicAuthentication(): boolean {\n const UNAUTHORIZED_RESPONSE_CODE = 401;\n return (\n this.isUnauthorized &&\n this.status === UNAUTHORIZED_RESPONSE_CODE &&\n this.response.error === \"No responseText\"\n );\n }\n\n /**\n * Retrieve a failed login attempt\n */\n get loginFailed(): boolean {\n return (\n this.id === \"Error.Authentication.Required\" ||\n this.id === \"Error.Authentication.InvalidCredentials\"\n );\n }\n\n /**\n */\n get shouldThrowOnServer(): boolean {\n return !this.isChangePassword && !this.isBlocked && !this.isConcurrentUser;\n }\n}\n"],"mappings":";AACA,OAAOA,IAAI,MAAM,cAAc;AAG/B,OAAOC,oBAAoB,MAAM,oCAAoC;;AAErE;AACA;;AAMA;AACA;;AAOA;AACA;;AAMA;AACA;AACA;AACA,eAAe,MAAMC,aAAa,CAAC;EAIjC;AACF;AACA;EACEC,WAAWA,CAACC,IAAY,EAAEC,UAAmB,EAAE;IAAAC,eAAA;IAAAA,eAAA;IAC7C,IAAI,CAACC,MAAM,GAAGH,IAAI;IAClB,IAAI,CAACI,WAAW,GAAGH,UAAU;EAC/B;;EAEA;AACF;EACE,IAAIA,UAAUA,CAACI,GAAW,EAAE;IAC1B,IAAI,CAACD,WAAW,GA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AA0B,IAC1C,IAAI,CAACrB,QAAQ,CAACV,KAAK,KAAK,iBAAiB;EAE7C;;EAEA;AACF;AACA;EACE,IAAI8C,WAAWA,CAAA,EAAY;IACzB,OACE,IAAI,CAACzC,EAAE,KAAK,+BAA+B,IAC3C,IAAI,CAACA,EAAE,KAAK,yCAAyC;EAEzD;;EAEA;AACF;EACE,IAAI0C,mBAAmBA,CAAA,EAAY;IACjC,OAAO,CAAC,IAAI,CAACX,gBAAgB,IAAI,CAAC,IAAI,CAACG,SAAS,IAAI,CAAC,IAAI,CAACF,gBAAgB;EAC5E;AACF"}
|
|
@@ -20,6 +20,7 @@ import { HTTP_METHODS } from "../../constants/Constants";
|
|
|
20
20
|
import { getSetting } from "../../constants/Settings";
|
|
21
21
|
import { CREATE_ACTION, DELETE_ACTION, UPDATE_ACTION } from "../../constants/LayoutHints";
|
|
22
22
|
import LayoutHintCollection from "../layouthint/LayoutHintCollection";
|
|
23
|
+
import AttributeSetModel from "../attributes/AttributeSetModel";
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
*/
|
|
@@ -41,6 +42,7 @@ class FormModel extends ResourceModel {
|
|
|
41
42
|
_defineProperty(this, "_commit", void 0);
|
|
42
43
|
_defineProperty(this, "_isFinished", void 0);
|
|
43
44
|
_defineProperty(this, "_isComplete", void 0);
|
|
45
|
+
_defineProperty(this, "_success", void 0);
|
|
44
46
|
_defineProperty(this, "_parameters", void 0);
|
|
45
47
|
_defineProperty(this, "_tokens", void 0);
|
|
46
48
|
this.lastUpdate = 0;
|
|
@@ -51,6 +53,7 @@ class FormModel extends ResourceModel {
|
|
|
51
53
|
if (this.data.errors) {
|
|
52
54
|
this.handleRootErrors(this.data.errors);
|
|
53
55
|
}
|
|
56
|
+
this.createSuccess();
|
|
54
57
|
}
|
|
55
58
|
|
|
56
59
|
/**
|
|
@@ -486,7 +489,7 @@ class FormModel extends ResourceModel {
|
|
|
486
489
|
* Inidicates if form is finished: Form is completely entered and committed
|
|
487
490
|
*/
|
|
488
491
|
get isFinished() {
|
|
489
|
-
return this._isFinished ||
|
|
492
|
+
return this._isFinished || this.success != undefined;
|
|
490
493
|
}
|
|
491
494
|
|
|
492
495
|
/**
|
|
@@ -512,7 +515,7 @@ class FormModel extends ResourceModel {
|
|
|
512
515
|
* Handle success redirects
|
|
513
516
|
*/
|
|
514
517
|
get successRedirect() {
|
|
515
|
-
return this.isFinished && this.
|
|
518
|
+
return this.isFinished && this.success ? new Href(this.success.redirect) : null;
|
|
516
519
|
}
|
|
517
520
|
|
|
518
521
|
/**
|
|
@@ -522,9 +525,23 @@ class FormModel extends ResourceModel {
|
|
|
522
525
|
}
|
|
523
526
|
|
|
524
527
|
/**
|
|
528
|
+
* Get the result data as plain json object
|
|
525
529
|
*/
|
|
526
530
|
getSuccessData() {
|
|
527
|
-
return this.
|
|
531
|
+
return this.success?.data;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Retrieve an object where each property is a result data attribute set
|
|
536
|
+
*/
|
|
537
|
+
getResultData() {
|
|
538
|
+
const resultDataKeys = _Object$keys(this.contributions.resultdata) ?? [];
|
|
539
|
+
const successData = this.getSuccessData() ?? {};
|
|
540
|
+
const resultdata = {};
|
|
541
|
+
for (const resultDataKey of resultDataKeys) {
|
|
542
|
+
resultdata[resultDataKey] = new AttributeSetModel(resultDataKey, successData[resultDataKey], this.contributions.resultdata[resultDataKey]);
|
|
543
|
+
}
|
|
544
|
+
return resultdata;
|
|
528
545
|
}
|
|
529
546
|
|
|
530
547
|
/**
|
|
@@ -737,6 +754,8 @@ class FormModel extends ResourceModel {
|
|
|
737
754
|
setPreviousObject() {
|
|
738
755
|
var _context21, _context22, _context23, _context24, _context25;
|
|
739
756
|
this.isComplete = false;
|
|
757
|
+
this.isFinished = false;
|
|
758
|
+
this.success = null;
|
|
740
759
|
const oldCurrentFormObject = this.currentFormObject;
|
|
741
760
|
if (this.currentFormObject !== null) {
|
|
742
761
|
this.previouslyEnteredFormObjects = [this.currentFormObject, ...this.previouslyEnteredFormObjects];
|
|
@@ -797,6 +816,7 @@ class FormModel extends ResourceModel {
|
|
|
797
816
|
this.tokens = receivedForm.tokens;
|
|
798
817
|
this.isComplete = receivedForm.isComplete;
|
|
799
818
|
this.isFinished = receivedForm.isFinished;
|
|
819
|
+
this.success = receivedForm.success;
|
|
800
820
|
const receivedFormData = receivedForm.data ?? {};
|
|
801
821
|
const hasMissing = has(receivedFormData, "missing");
|
|
802
822
|
const hasErrors = has(receivedFormData, "errors");
|
|
@@ -822,6 +842,28 @@ class FormModel extends ResourceModel {
|
|
|
822
842
|
return this;
|
|
823
843
|
}
|
|
824
844
|
|
|
845
|
+
/**
|
|
846
|
+
* Retrieve success information from response
|
|
847
|
+
* @returns {{redirect: string, data: object}}
|
|
848
|
+
*/
|
|
849
|
+
get success() {
|
|
850
|
+
return this._success;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* Set success information, contains redirect and event data
|
|
855
|
+
* @param success
|
|
856
|
+
*/
|
|
857
|
+
set success(success) {
|
|
858
|
+
this._success = success;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
/**
|
|
862
|
+
*/
|
|
863
|
+
createSuccess() {
|
|
864
|
+
this._success = this.data.success;
|
|
865
|
+
}
|
|
866
|
+
|
|
825
867
|
/**
|
|
826
868
|
* Process finished form
|
|
827
869
|
*/
|