@beinformed/ui 1.22.0 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/esm/models/attributes/layouthint-rules/DependentAttribute.js +24 -15
- package/esm/models/attributes/layouthint-rules/DependentAttribute.js.map +1 -1
- package/esm/models/error/ErrorResponse.js +1 -1
- package/esm/models/error/ErrorResponse.js.map +1 -1
- package/esm/redux/actions/Error.js +1 -1
- package/esm/redux/actions/Error.js.map +1 -1
- package/lib/models/attributes/layouthint-rules/DependentAttribute.js +27 -18
- package/lib/models/attributes/layouthint-rules/DependentAttribute.js.flow +19 -2
- package/lib/models/attributes/layouthint-rules/DependentAttribute.js.map +1 -1
- package/lib/models/error/ErrorResponse.js +1 -1
- package/lib/models/error/ErrorResponse.js.flow +0 -1
- package/lib/models/error/ErrorResponse.js.map +1 -1
- package/lib/redux/actions/Error.js +1 -1
- package/lib/redux/actions/Error.js.flow +1 -1
- package/lib/redux/actions/Error.js.map +1 -1
- package/package.json +1 -1
- package/src/models/attributes/layouthint-rules/DependentAttribute.js +19 -2
- package/src/models/error/ErrorResponse.js +0 -1
- package/src/redux/actions/Error.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.23.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.22.1...v1.23.0) (2022-09-22)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **DependentAttribute:** DependentAttribute extended to work with empty and not empty attribute value ([73473cf](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/73473cff35ca5c7974a3800df5e49bdb1a9031ea))
|
|
11
|
+
|
|
12
|
+
### [1.22.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.22.0...v1.22.1) (2022-09-07)
|
|
13
|
+
|
|
5
14
|
## [1.22.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.21.7...v1.22.0) (2022-09-05)
|
|
6
15
|
|
|
7
16
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
2
|
+
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
2
3
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
3
4
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
4
5
|
import _trimInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/trim";
|
|
5
|
-
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
6
6
|
import BaseLayoutHintRule from "./BaseLayoutHintRule";
|
|
7
7
|
import { DEPENDENT_ATTRIBUTE_CONTROL, DEPENDENT_ATTRIBUTE } from "../../../constants";
|
|
8
8
|
import ChoiceAttributeModel from "../ChoiceAttributeModel";
|
|
@@ -12,12 +12,29 @@ const EQUALS = "equals";
|
|
|
12
12
|
const INCLUDES = "includes";
|
|
13
13
|
const NOT_EQUALS = "notEquals";
|
|
14
14
|
const NOT_INCLUDES = "notIncludes";
|
|
15
|
+
const NOT_IS_EMPTY = "notIsEmpty";
|
|
16
|
+
const IS_EMPTY = "isEmpty";
|
|
15
17
|
const SHOW = "show";
|
|
16
18
|
const HIDE = "hide";
|
|
19
|
+
/**
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const compareSelectedAttribute = (option, selectedAttribute) => {
|
|
23
|
+
if (option === NOT_IS_EMPTY && (selectedAttribute === null || selectedAttribute === void 0 ? void 0 : selectedAttribute.length) !== 0) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (option === IS_EMPTY && (selectedAttribute === null || selectedAttribute === void 0 ? void 0 : selectedAttribute.length) === 0) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return selectedAttribute === null || selectedAttribute === void 0 ? void 0 : _includesInstanceProperty(selectedAttribute).call(selectedAttribute, option);
|
|
32
|
+
};
|
|
17
33
|
/**
|
|
18
34
|
* Depending attributes hint logic
|
|
19
35
|
*/
|
|
20
36
|
|
|
37
|
+
|
|
21
38
|
class DependentAttribute extends BaseLayoutHintRule {
|
|
22
39
|
constructor() {
|
|
23
40
|
super(...arguments);
|
|
@@ -136,11 +153,7 @@ class DependentAttribute extends BaseLayoutHintRule {
|
|
|
136
153
|
|
|
137
154
|
processEqualsOptions(controlAttribute) {
|
|
138
155
|
if (controlAttribute instanceof ChoiceAttributeModel || controlAttribute instanceof BooleanAttributeModel) {
|
|
139
|
-
return this.options.every(option =>
|
|
140
|
-
var _context8;
|
|
141
|
-
|
|
142
|
-
return _includesInstanceProperty(_context8 = controlAttribute.selected).call(_context8, option);
|
|
143
|
-
});
|
|
156
|
+
return this.options.every(option => compareSelectedAttribute(option, controlAttribute === null || controlAttribute === void 0 ? void 0 : controlAttribute.selected));
|
|
144
157
|
}
|
|
145
158
|
|
|
146
159
|
throw new ConfigurationException("Dependent control in combination with equals operator must be a choice, string or number attribute");
|
|
@@ -151,11 +164,7 @@ class DependentAttribute extends BaseLayoutHintRule {
|
|
|
151
164
|
|
|
152
165
|
processIncludesOptions(controlAttribute) {
|
|
153
166
|
if (controlAttribute instanceof ChoiceAttributeModel) {
|
|
154
|
-
return this.options.some(option =>
|
|
155
|
-
var _context9;
|
|
156
|
-
|
|
157
|
-
return _includesInstanceProperty(_context9 = controlAttribute.selected).call(_context9, option);
|
|
158
|
-
});
|
|
167
|
+
return this.options.some(option => compareSelectedAttribute(option, controlAttribute === null || controlAttribute === void 0 ? void 0 : controlAttribute.selected));
|
|
159
168
|
}
|
|
160
169
|
|
|
161
170
|
throw new ConfigurationException("Dependent control in combination with includes operator must be a choice attribute");
|
|
@@ -187,9 +196,9 @@ class DependentAttribute extends BaseLayoutHintRule {
|
|
|
187
196
|
|
|
188
197
|
|
|
189
198
|
getControlAttribute(attributes) {
|
|
190
|
-
var
|
|
199
|
+
var _context8, _context9;
|
|
191
200
|
|
|
192
|
-
const attribute = attributes.getAttributeByLayoutHint(_concatInstanceProperty(
|
|
201
|
+
const attribute = attributes.getAttributeByLayoutHint(_concatInstanceProperty(_context8 = "".concat(DEPENDENT_ATTRIBUTE_CONTROL, ":")).call(_context8, this.control), _concatInstanceProperty(_context9 = "".concat(DEPENDENT_ATTRIBUTE_CONTROL, ": ")).call(_context9, this.control));
|
|
193
202
|
|
|
194
203
|
if (attribute instanceof ChoiceAttributeModel || attribute instanceof BooleanAttributeModel) {
|
|
195
204
|
return attribute;
|
|
@@ -222,9 +231,9 @@ class DependentAttribute extends BaseLayoutHintRule {
|
|
|
222
231
|
} else if (this.action === HIDE) {
|
|
223
232
|
attribute.isHidden = result;
|
|
224
233
|
} else {
|
|
225
|
-
var
|
|
234
|
+
var _context10;
|
|
226
235
|
|
|
227
|
-
throw new ConfigurationException(_concatInstanceProperty(
|
|
236
|
+
throw new ConfigurationException(_concatInstanceProperty(_context10 = "Unsupported action ".concat(this.action, " for dependent question on attribute: ")).call(_context10, attribute.label));
|
|
228
237
|
}
|
|
229
238
|
}
|
|
230
239
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DependentAttribute.js","names":["BaseLayoutHintRule","DEPENDENT_ATTRIBUTE_CONTROL","DEPENDENT_ATTRIBUTE","ChoiceAttributeModel","BooleanAttributeModel","ConfigurationException","EQUALS","INCLUDES","NOT_EQUALS","NOT_INCLUDES","SHOW","HIDE","DependentAttribute","isApplicableForHint","hint","regex","RegExp","test","getRuleInstance","initHint","rule","OPERATORS","result","match","action","control","operator","options","_action","_control","_operator","_options","split","option","processEqualsOptions","controlAttribute","every","selected","processIncludesOptions","some","handleOperator","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\";\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}`;\n const regex = new RegExp(\n `${DEPENDENT_ATTRIBUTE}\\\\s?(\\\\S*)\\\\swhen ${DEPENDENT_ATTRIBUTE_CONTROL}:\\\\s?(.*?)\\\\s*(${OPERATORS})\\\\s(.*)`,\n \"i\"\n );\n\n const result = hint.match(regex);\n if (result) {\n rule.action = result[1];\n rule.control = result[2];\n rule.operator = result[3];\n rule.options = 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 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) {\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,kBAAP,MAA+B,sBAA/B;AAEA,SACEC,2BADF,EAEEC,mBAFF,QAGO,oBAHP;AAKA,OAAOC,oBAAP,MAAiC,yBAAjC;AACA,OAAOC,qBAAP,MAAkC,0BAAlC;AAEA,SAASC,sBAAT,QAAuC,qBAAvC;AAKA,MAAMC,MAAM,GAAG,QAAf;AACA,MAAMC,QAAQ,GAAG,UAAjB;AACA,MAAMC,UAAU,GAAG,WAAnB;AACA,MAAMC,YAAY,GAAG,aAArB;AAEA,MAAMC,IAAI,GAAG,MAAb;AACA,MAAMC,IAAI,GAAG,MAAb;AAEA;AACA;AACA;;AACA,MAAMC,kBAAN,SAAiCZ,kBAAjC,CAAoD;EAAA;IAAA;;IAAA;;IAAA;;IAAA;;IAAA;EAAA;;EAUlD;AACF;EAC4B,OAAnBa,mBAAmB,CAACC,IAAD,EAAwB;IAAA;;IAChD,MAAMC,KAAK,GAAG,IAAIC,MAAJ,mFACRd,mBADQ,4BACmBQ,IADnB,uBAC2BC,IAD3B,QAEZ,GAFY,CAAd;IAKA,OAAOI,KAAK,CAACE,IAA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["BaseLayoutHintRule","DEPENDENT_ATTRIBUTE_CONTROL","DEPENDENT_ATTRIBUTE","ChoiceAttributeModel","BooleanAttributeModel","ConfigurationException","EQUALS","INCLUDES","NOT_EQUALS","NOT_INCLUDES","NOT_IS_EMPTY","IS_EMPTY","SHOW","HIDE","compareSelectedAttribute","option","selectedAttribute","length","DependentAttribute","isApplicableForHint","hint","regex","RegExp","test","getRuleInstance","initHint","rule","OPERATORS","result","match","action","control","operator","options","_action","_control","_operator","_options","split","processEqualsOptions","controlAttribute","every","selected","processIncludesOptions","some","handleOperator","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 */\nconst compareSelectedAttribute = (\n option: string,\n selectedAttribute: Array<string>\n) => {\n if (option === NOT_IS_EMPTY && selectedAttribute?.length !== 0) {\n return true;\n }\n if (option === IS_EMPTY && selectedAttribute?.length === 0) {\n return true;\n }\n return selectedAttribute?.includes(option);\n};\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}`;\n const regex = new RegExp(\n `${DEPENDENT_ATTRIBUTE}\\\\s?(\\\\S*)\\\\swhen ${DEPENDENT_ATTRIBUTE_CONTROL}:\\\\s?(.*?)\\\\s*(${OPERATORS})\\\\s(.*)`,\n \"i\"\n );\n\n const result = hint.match(regex);\n if (result) {\n rule.action = result[1];\n rule.control = result[2];\n rule.operator = result[3];\n rule.options = 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 compareSelectedAttribute(option, controlAttribute?.selected)\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 compareSelectedAttribute(option, controlAttribute?.selected)\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 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) {\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,kBAAP,MAA+B,sBAA/B;AAEA,SACEC,2BADF,EAEEC,mBAFF,Q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ized() {
|
|
248
248
|
const UNAUTHORIZED_RESPONSE_CODE = 401;
|
|
249
249
|
const hasUnauthorizedStatus = this.status === UNAUTHORIZED_RESPONSE_CODE;
|
|
250
|
-
const hasUnauthorizedErrorId = this.id === "Error.NotAuthorized" || this.id === "Error.Authentication.Required" || this.id === "Error.Authentication.
|
|
250
|
+
const hasUnauthorizedErrorId = this.id === "Error.NotAuthorized" || this.id === "Error.Authentication.Required" || this.id === "Error.Authentication.InvalidCredentials";
|
|
251
251
|
const hasLoginAction = this.error.action ? this.error.action.name === "login" : false;
|
|
252
252
|
return hasUnauthorizedStatus || hasUnauthorizedErrorId || hasLoginAction;
|
|
253
253
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorResponse.js","names":["Href","LayoutHintCollection","ErrorResponse","constructor","data","connectKey","_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.InvalidUsername\" ||\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,IAAP,MAAiB,cAAjB;AAGA,OAAOC,oBAAP,MAAiC,oCAAjC;AAEA;AACA;;AAqBA;AACA;AACA;AACA,eAAe,MAAMC,aAAN,CAAoB;EAIjC;AACF;AACA;EACEC,WAAW,CAACC,IAAD,EAAeC,UAAf,EAAoC;IAAA;;IAAA;;IAC7C,KAAKC,MAAL,GAAcF,IAAd;IACA,KAAKG,WAAL,GAAmBF,UAAnB;EACD;EAED;AACF;;;EACgB,IAAVA,UAAU,CAACG,GAAD,EAAc;IAC1B,KAAKD,WAAL,GAAmBC,GAAnB;EACD;E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KAAKG,SAAhC,IAA6C,CAAC,KAAKF,gBAA1D;EACD;;AAnSgC"}
|
|
1
|
+
{"version":3,"file":"ErrorResponse.js","names":["Href","LayoutHintCollection","ErrorResponse","constructor","data","connectKey","_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,IAAP,MAAiB,cAAjB;AAGA,OAAOC,oBAAP,MAAiC,oCAAjC;AAEA;AACA;;AAqBA;AACA;AACA;AACA,eAAe,MAAMC,aAAN,CAAoB;EAIjC;AACF;AACA;EACEC,WAAW,CAACC,IAAD,EAAeC,UAAf,EAAoC;IAAA;;IAAA;;IAC7C,KAAKC,MAAL,GAAcF,IAAd;IACA,KAAKG,WAAL,GAAmBF,UAAnB;EACD;EAED;AACF;;;EACgB,IAAVA,UAAU,CAACG,GAAD,EAAc;IAC1B,KAAKD,WAAL,GAAmBC,GAAnB;EACD;EAED;AACF;;;EACgB,IAAVH,UAAU,GAAY;IACxB,OAAO,KAAKE,WAAZ;EACD;EAED;AACF;AACA;;;EACW,IAALE,KAAK,GAAW;IAAA;;IAClB,uBAAO,KAAKH,MAAZ,uDAAsB,EAAtB;EACD;EAED;AACF;AACA;;;EACY,IAANI,MAAM,GAAW;IACnB,MAAMC,gBAAgB,GAAG,CAAzB;IACA,MAAMC,aAAa,GAAG,EAAtB;IACA,OAAO,KAAKH,KAAL,CAAWC,MAAX,GACHG,QAAQ,CAAC,KAAKJ,KAAL,CAAWC,MAAZ,EAAoBE,aAApB,CADL,GAEHD,gBAFJ;EAGD;EAED;AACF;AACA;;;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AAL,KAAY,sCAAnB;EACD;EAED;AACF;;;EACoB,IAAdqC,cAAc,GAAY;IAC5B,OAAO,KAAKrC,EAAL,KAAY,kCAAnB;EACD;EAED;AACF;AACA;AACA;;;EAC8B,IAAxBsC,wBAAwB,GAAY;IACtC,OAAO,KAAKtC,EAAL,KAAY,8BAAnB;EACD;EAED;AACF;AACA;;;EACwB,IAAlBuC,kBAAkB,GAAU;IAC9B,OAAO,KAAK5B,UAAL,CAAgBC,QAAhB,GAA2B,IAAI1B,IAAJ,CAAS,KAAKyB,UAAL,CAAgBC,QAAzB,CAA3B,GAAgE,IAAvE;EACD;EAED;AACF;AACA;;;EAC2B,IAArB4B,qBAAqB,GAAY;IACnC,MAAMd,0BAA0B,GAAG,GAAnC;IACA,OACE,KAAKD,cAAL,IACA,KAAK7B,MAAL,KAAgB8B,0BADhB,IAEA,KAAKrB,QAAL,CAAcV,KAAd,KAAwB,iBAH1B;EAKD;EAED;AACF;AACA;;;EACiB,IAAX8C,WAAW,GAAY;IACzB,OACE,KAAKzC,EAAL,KAAY,+BAAZ,IACA,KAAKA,EAAL,KAAY,yCAFd;EAID;EAED;AACF;;;EACyB,IAAnB0C,mBAAmB,GAAY;IACjC,OAAO,CAAC,KAAKX,gBAAN,IAA0B,CAAC,KAAKG,SAAhC,IAA6C,CAAC,KAAKF,gBAA1D;EACD;;AAlSgC"}
|
|
@@ -28,7 +28,7 @@ const defaultErrorResponseHandler = error => dispatch => {
|
|
|
28
28
|
return dispatch(handleUnauthorized(error));
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
if (error.isBlocked || error.isConcurrentUser) {
|
|
31
|
+
if (error.isBlocked || error.isConcurrentUser || error.isInvalidUsername) {
|
|
32
32
|
const LOGOUT_PATH = getSetting("LOGOUT_PATH", "/signout");
|
|
33
33
|
dispatch(push(LOGOUT_PATH));
|
|
34
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Error.js","names":["IS_SERVER","getSetting","ErrorResponse","push","showXHRErrorNotification","resetProgress","changePassword","handleUnauthorized","saveError","error","type","payload","defaultErrorResponseHandler","dispatch","isResourceNotFoundAfterReload","isRemoteServiceException","isUnauthorized","isBlocked","isConcurrentUser","LOGOUT_PATH","isChangePassword","setTimeout","customErrorResponseHandler","errorResponse","defaultHandler","setCustomErrorResponseHandler","handler","handleError"],"sources":["../../../src/redux/actions/Error.js"],"sourcesContent":["// @flow\nimport { IS_SERVER } from \"../../constants/Constants\";\nimport { getSetting } from \"../../constants/Settings\";\n\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\n\nimport { push } from \"../_router/actions\";\nimport { showXHRErrorNotification } from \"./Notification\";\nimport { resetProgress } from \"./ProgressIndicator\";\nimport { changePassword } from \"./SignIn\";\nimport { handleUnauthorized } from \"./Authorization\";\n\nimport type { FetchException } from \"../../exceptions\";\nimport type { Dispatch, SaveErrorAction, ThunkAction } from \"../types\";\n\ntype DefaultErrorResponseHandler = (error: ErrorResponse) => ThunkAction;\ntype CustomErrorResponseHandler = (\n errorResponse: ErrorResponse,\n defaultHandler: DefaultErrorResponseHandler\n) => ThunkAction;\n\n/**\n */\nconst saveError = (error): SaveErrorAction => ({\n type: \"SAVE_ERROR\",\n payload: error,\n});\n\n/**\n */\nconst defaultErrorResponseHandler: DefaultErrorResponseHandler =\n (error: ErrorResponse): ThunkAction =>\n (dispatch: Dispatch) => {\n if (error.isResourceNotFoundAfterReload || error.isRemoteServiceException) {\n return dispatch({ type: \"NO_ACTION\" });\n }\n\n if (error.isUnauthorized) {\n return dispatch(handleUnauthorized(error));\n }\n\n if (error.isBlocked || error.isConcurrentUser) {\n const LOGOUT_PATH = getSetting(\"LOGOUT_PATH\", \"/signout\");\n dispatch(push(LOGOUT_PATH));\n }\n\n if (error.isChangePassword) {\n return dispatch(changePassword());\n }\n\n if (IS_SERVER) {\n return dispatch(saveError(error));\n }\n\n setTimeout(() => {\n throw error;\n });\n\n return dispatch(showXHRErrorNotification(error));\n };\n\n/**\n * Standard Custom error response, acts as a proxy and can be overwritten by {@link setCustomErrorResponseHandler}\n */\nlet customErrorResponseHandler: CustomErrorResponseHandler =\n (errorResponse, defaultHandler) => (dispatch: Dispatch) =>\n dispatch(defaultHandler(errorResponse));\n\n/**\n * Set a custom error response handler,\n * can be used when custom functionality is needed on certain (error) response\n * of the modular ui, for example when custom logic is needed when a user is unauthorized<br>\n * It receives an {@link ErrorResponse} and the {@link defaultErrorResponseHandler}\n */\nexport const setCustomErrorResponseHandler = (\n handler: CustomErrorResponseHandler\n) => {\n customErrorResponseHandler = handler;\n};\n\n/**\n * Handle errors by sending an error notification message\n */\nexport const handleError =\n (error: Error | FetchException): ThunkAction =>\n (dispatch: Dispatch) => {\n dispatch(resetProgress());\n\n const errorResponse = new ErrorResponse(error);\n\n return dispatch(\n customErrorResponseHandler(errorResponse, defaultErrorResponseHandler)\n );\n };\n"],"mappings":"AACA,SAASA,SAAT,QAA0B,2BAA1B;AACA,SAASC,UAAT,QAA2B,0BAA3B;AAEA,OAAOC,aAAP,MAA0B,kCAA1B;AAEA,SAASC,IAAT,QAAqB,oBAArB;AACA,SAASC,wBAAT,QAAyC,gBAAzC;AACA,SAASC,aAAT,QAA8B,qBAA9B;AACA,SAASC,cAAT,QAA+B,UAA/B;AACA,SAASC,kBAAT,QAAmC,iBAAnC;;AAWA;AACA;AACA,MAAMC,SAAS,GAAIC,KAAD,KAA6B;EAC7CC,IAAI,EAAE,YADuC;EAE7CC,OAAO,EAAEF;AAFoC,CAA7B,CAAlB;AAKA;AACA;;;AACA,MAAMG,2BAAwD,GAC3DH,KAAD,IACCI,QAAD,IAAwB;EACtB,IAAIJ,KAAK,CAACK,6BAAN,IAAuCL,KAAK,CAACM,wBAAjD,EAA2E;IACzE,OAAOF,QAAQ,CAAC;MAAEH,IAAI,EAAE;IAAR,CAAD,CAAf;EACD;;EAED,IAAID,KAAK,CAACO,cAAV,EAA0B;IACxB,OAAOH,QAAQ,CAACN,kBAAkB,CAACE,KAAD,CAAnB,CAAf;EACD;;EAED,IAAIA,KAAK,CAACQ,SAAN,IAAmBR,KAAK,CAACS,
|
|
1
|
+
{"version":3,"file":"Error.js","names":["IS_SERVER","getSetting","ErrorResponse","push","showXHRErrorNotification","resetProgress","changePassword","handleUnauthorized","saveError","error","type","payload","defaultErrorResponseHandler","dispatch","isResourceNotFoundAfterReload","isRemoteServiceException","isUnauthorized","isBlocked","isConcurrentUser","isInvalidUsername","LOGOUT_PATH","isChangePassword","setTimeout","customErrorResponseHandler","errorResponse","defaultHandler","setCustomErrorResponseHandler","handler","handleError"],"sources":["../../../src/redux/actions/Error.js"],"sourcesContent":["// @flow\nimport { IS_SERVER } from \"../../constants/Constants\";\nimport { getSetting } from \"../../constants/Settings\";\n\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\n\nimport { push } from \"../_router/actions\";\nimport { showXHRErrorNotification } from \"./Notification\";\nimport { resetProgress } from \"./ProgressIndicator\";\nimport { changePassword } from \"./SignIn\";\nimport { handleUnauthorized } from \"./Authorization\";\n\nimport type { FetchException } from \"../../exceptions\";\nimport type { Dispatch, SaveErrorAction, ThunkAction } from \"../types\";\n\ntype DefaultErrorResponseHandler = (error: ErrorResponse) => ThunkAction;\ntype CustomErrorResponseHandler = (\n errorResponse: ErrorResponse,\n defaultHandler: DefaultErrorResponseHandler\n) => ThunkAction;\n\n/**\n */\nconst saveError = (error): SaveErrorAction => ({\n type: \"SAVE_ERROR\",\n payload: error,\n});\n\n/**\n */\nconst defaultErrorResponseHandler: DefaultErrorResponseHandler =\n (error: ErrorResponse): ThunkAction =>\n (dispatch: Dispatch) => {\n if (error.isResourceNotFoundAfterReload || error.isRemoteServiceException) {\n return dispatch({ type: \"NO_ACTION\" });\n }\n\n if (error.isUnauthorized) {\n return dispatch(handleUnauthorized(error));\n }\n\n if (error.isBlocked || error.isConcurrentUser || error.isInvalidUsername) {\n const LOGOUT_PATH = getSetting(\"LOGOUT_PATH\", \"/signout\");\n dispatch(push(LOGOUT_PATH));\n }\n\n if (error.isChangePassword) {\n return dispatch(changePassword());\n }\n\n if (IS_SERVER) {\n return dispatch(saveError(error));\n }\n\n setTimeout(() => {\n throw error;\n });\n\n return dispatch(showXHRErrorNotification(error));\n };\n\n/**\n * Standard Custom error response, acts as a proxy and can be overwritten by {@link setCustomErrorResponseHandler}\n */\nlet customErrorResponseHandler: CustomErrorResponseHandler =\n (errorResponse, defaultHandler) => (dispatch: Dispatch) =>\n dispatch(defaultHandler(errorResponse));\n\n/**\n * Set a custom error response handler,\n * can be used when custom functionality is needed on certain (error) response\n * of the modular ui, for example when custom logic is needed when a user is unauthorized<br>\n * It receives an {@link ErrorResponse} and the {@link defaultErrorResponseHandler}\n */\nexport const setCustomErrorResponseHandler = (\n handler: CustomErrorResponseHandler\n) => {\n customErrorResponseHandler = handler;\n};\n\n/**\n * Handle errors by sending an error notification message\n */\nexport const handleError =\n (error: Error | FetchException): ThunkAction =>\n (dispatch: Dispatch) => {\n dispatch(resetProgress());\n\n const errorResponse = new ErrorResponse(error);\n\n return dispatch(\n customErrorResponseHandler(errorResponse, defaultErrorResponseHandler)\n );\n };\n"],"mappings":"AACA,SAASA,SAAT,QAA0B,2BAA1B;AACA,SAASC,UAAT,QAA2B,0BAA3B;AAEA,OAAOC,aAAP,MAA0B,kCAA1B;AAEA,SAASC,IAAT,QAAqB,oBAArB;AACA,SAASC,wBAAT,QAAyC,gBAAzC;AACA,SAASC,aAAT,QAA8B,qBAA9B;AACA,SAASC,cAAT,QAA+B,UAA/B;AACA,SAASC,kBAAT,QAAmC,iBAAnC;;AAWA;AACA;AACA,MAAMC,SAAS,GAAIC,KAAD,KAA6B;EAC7CC,IAAI,EAAE,YADuC;EAE7CC,OAAO,EAAEF;AAFoC,CAA7B,CAAlB;AAKA;AACA;;;AACA,MAAMG,2BAAwD,GAC3DH,KAAD,IACCI,QAAD,IAAwB;EACtB,IAAIJ,KAAK,CAACK,6BAAN,IAAuCL,KAAK,CAACM,wBAAjD,EAA2E;IACzE,OAAOF,QAA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@@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
13
|
+
|
|
10
14
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
11
15
|
|
|
12
16
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
13
17
|
|
|
14
18
|
var _trim = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/trim"));
|
|
15
19
|
|
|
16
|
-
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
17
|
-
|
|
18
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
19
|
-
|
|
20
20
|
var _BaseLayoutHintRule = _interopRequireDefault(require("./BaseLayoutHintRule"));
|
|
21
21
|
|
|
22
22
|
var _constants = require("../../../constants");
|
|
@@ -31,12 +31,29 @@ const EQUALS = "equals";
|
|
|
31
31
|
const INCLUDES = "includes";
|
|
32
32
|
const NOT_EQUALS = "notEquals";
|
|
33
33
|
const NOT_INCLUDES = "notIncludes";
|
|
34
|
+
const NOT_IS_EMPTY = "notIsEmpty";
|
|
35
|
+
const IS_EMPTY = "isEmpty";
|
|
34
36
|
const SHOW = "show";
|
|
35
37
|
const HIDE = "hide";
|
|
38
|
+
/**
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
const compareSelectedAttribute = (option, selectedAttribute) => {
|
|
42
|
+
if (option === NOT_IS_EMPTY && (selectedAttribute === null || selectedAttribute === void 0 ? void 0 : selectedAttribute.length) !== 0) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (option === IS_EMPTY && (selectedAttribute === null || selectedAttribute === void 0 ? void 0 : selectedAttribute.length) === 0) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return selectedAttribute === null || selectedAttribute === void 0 ? void 0 : (0, _includes.default)(selectedAttribute).call(selectedAttribute, option);
|
|
51
|
+
};
|
|
36
52
|
/**
|
|
37
53
|
* Depending attributes hint logic
|
|
38
54
|
*/
|
|
39
55
|
|
|
56
|
+
|
|
40
57
|
class DependentAttribute extends _BaseLayoutHintRule.default {
|
|
41
58
|
constructor() {
|
|
42
59
|
super(...arguments);
|
|
@@ -149,11 +166,7 @@ class DependentAttribute extends _BaseLayoutHintRule.default {
|
|
|
149
166
|
|
|
150
167
|
processEqualsOptions(controlAttribute) {
|
|
151
168
|
if (controlAttribute instanceof _ChoiceAttributeModel.default || controlAttribute instanceof _BooleanAttributeModel.default) {
|
|
152
|
-
return this.options.every(option =>
|
|
153
|
-
var _context8;
|
|
154
|
-
|
|
155
|
-
return (0, _includes.default)(_context8 = controlAttribute.selected).call(_context8, option);
|
|
156
|
-
});
|
|
169
|
+
return this.options.every(option => compareSelectedAttribute(option, controlAttribute === null || controlAttribute === void 0 ? void 0 : controlAttribute.selected));
|
|
157
170
|
}
|
|
158
171
|
|
|
159
172
|
throw new _exceptions.ConfigurationException("Dependent control in combination with equals operator must be a choice, string or number attribute");
|
|
@@ -164,11 +177,7 @@ class DependentAttribute extends _BaseLayoutHintRule.default {
|
|
|
164
177
|
|
|
165
178
|
processIncludesOptions(controlAttribute) {
|
|
166
179
|
if (controlAttribute instanceof _ChoiceAttributeModel.default) {
|
|
167
|
-
return this.options.some(option =>
|
|
168
|
-
var _context9;
|
|
169
|
-
|
|
170
|
-
return (0, _includes.default)(_context9 = controlAttribute.selected).call(_context9, option);
|
|
171
|
-
});
|
|
180
|
+
return this.options.some(option => compareSelectedAttribute(option, controlAttribute === null || controlAttribute === void 0 ? void 0 : controlAttribute.selected));
|
|
172
181
|
}
|
|
173
182
|
|
|
174
183
|
throw new _exceptions.ConfigurationException("Dependent control in combination with includes operator must be a choice attribute");
|
|
@@ -200,9 +209,9 @@ class DependentAttribute extends _BaseLayoutHintRule.default {
|
|
|
200
209
|
|
|
201
210
|
|
|
202
211
|
getControlAttribute(attributes) {
|
|
203
|
-
var
|
|
212
|
+
var _context8, _context9;
|
|
204
213
|
|
|
205
|
-
const attribute = attributes.getAttributeByLayoutHint((0, _concat.default)(
|
|
214
|
+
const attribute = attributes.getAttributeByLayoutHint((0, _concat.default)(_context8 = "".concat(_constants.DEPENDENT_ATTRIBUTE_CONTROL, ":")).call(_context8, this.control), (0, _concat.default)(_context9 = "".concat(_constants.DEPENDENT_ATTRIBUTE_CONTROL, ": ")).call(_context9, this.control));
|
|
206
215
|
|
|
207
216
|
if (attribute instanceof _ChoiceAttributeModel.default || attribute instanceof _BooleanAttributeModel.default) {
|
|
208
217
|
return attribute;
|
|
@@ -235,9 +244,9 @@ class DependentAttribute extends _BaseLayoutHintRule.default {
|
|
|
235
244
|
} else if (this.action === HIDE) {
|
|
236
245
|
attribute.isHidden = result;
|
|
237
246
|
} else {
|
|
238
|
-
var
|
|
247
|
+
var _context10;
|
|
239
248
|
|
|
240
|
-
throw new _exceptions.ConfigurationException((0, _concat.default)(
|
|
249
|
+
throw new _exceptions.ConfigurationException((0, _concat.default)(_context10 = "Unsupported action ".concat(this.action, " for dependent question on attribute: ")).call(_context10, attribute.label));
|
|
241
250
|
}
|
|
242
251
|
}
|
|
243
252
|
|
|
@@ -18,10 +18,27 @@ const EQUALS = "equals";
|
|
|
18
18
|
const INCLUDES = "includes";
|
|
19
19
|
const NOT_EQUALS = "notEquals";
|
|
20
20
|
const NOT_INCLUDES = "notIncludes";
|
|
21
|
+
const NOT_IS_EMPTY = "notIsEmpty";
|
|
22
|
+
const IS_EMPTY = "isEmpty";
|
|
21
23
|
|
|
22
24
|
const SHOW = "show";
|
|
23
25
|
const HIDE = "hide";
|
|
24
26
|
|
|
27
|
+
/**
|
|
28
|
+
*/
|
|
29
|
+
const compareSelectedAttribute = (
|
|
30
|
+
option: string,
|
|
31
|
+
selectedAttribute: Array<string>
|
|
32
|
+
) => {
|
|
33
|
+
if (option === NOT_IS_EMPTY && selectedAttribute?.length !== 0) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
if (option === IS_EMPTY && selectedAttribute?.length === 0) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return selectedAttribute?.includes(option);
|
|
40
|
+
};
|
|
41
|
+
|
|
25
42
|
/**
|
|
26
43
|
* Depending attributes hint logic
|
|
27
44
|
*/
|
|
@@ -137,7 +154,7 @@ class DependentAttribute extends BaseLayoutHintRule {
|
|
|
137
154
|
controlAttribute instanceof BooleanAttributeModel
|
|
138
155
|
) {
|
|
139
156
|
return this.options.every((option) =>
|
|
140
|
-
controlAttribute
|
|
157
|
+
compareSelectedAttribute(option, controlAttribute?.selected)
|
|
141
158
|
);
|
|
142
159
|
}
|
|
143
160
|
|
|
@@ -153,7 +170,7 @@ class DependentAttribute extends BaseLayoutHintRule {
|
|
|
153
170
|
): boolean {
|
|
154
171
|
if (controlAttribute instanceof ChoiceAttributeModel) {
|
|
155
172
|
return this.options.some((option) =>
|
|
156
|
-
controlAttribute
|
|
173
|
+
compareSelectedAttribute(option, controlAttribute?.selected)
|
|
157
174
|
);
|
|
158
175
|
}
|
|
159
176
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DependentAttribute.js","names":["EQUALS","INCLUDES","NOT_EQUALS","NOT_INCLUDES","SHOW","HIDE","DependentAttribute","BaseLayoutHintRule","isApplicableForHint","hint","regex","RegExp","DEPENDENT_ATTRIBUTE","test","getRuleInstance","initHint","rule","OPERATORS","DEPENDENT_ATTRIBUTE_CONTROL","result","match","action","control","operator","options","ConfigurationException","_action","_control","_operator","_options","split","option","processEqualsOptions","controlAttribute","ChoiceAttributeModel","BooleanAttributeModel","every","selected","processIncludesOptions","some","handleOperator","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\";\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}`;\n const regex = new RegExp(\n `${DEPENDENT_ATTRIBUTE}\\\\s?(\\\\S*)\\\\swhen ${DEPENDENT_ATTRIBUTE_CONTROL}:\\\\s?(.*?)\\\\s*(${OPERATORS})\\\\s(.*)`,\n \"i\"\n );\n\n const result = hint.match(regex);\n if (result) {\n rule.action = result[1];\n rule.control = result[2];\n rule.operator = result[3];\n rule.options = 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 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) {\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;;AAEA;;AAKA;;AACA;;AAEA;;AAKA,MAAMA,MAAM,GAAG,QAAf;AACA,MAAMC,QAAQ,GAAG,UAAjB;AACA,MAAMC,UAAU,GAAG,WAAnB;AACA,MAAMC,YAAY,GAAG,aAArB;AAEA,MAAMC,IAAI,GAAG,MAAb;AACA,MAAMC,IAAI,GAAG,MAAb;AAEA;AACA;AACA;;AACA,MAAMC,kBAAN,SAAiCC,2BAAjC,CAAoD;EAAA;IAAA;IAAA;IAAA;IAAA;IAAA;EAAA;;EAUlD;AACF;EAC4B,OAAnBC,mBAAmB,CAACC,IAAD,EAAwB;IAAA;;IAChD,MAAMC,KAAK,GAAG,IAAIC,MAAJ,6EACRC,8BADQ,4BACmBR,IADnB,uBAC2BC,IAD3B,QAEZ,GAFY,CAAd;IAKA,OAAOK,KAAK,CAACG,IAAN,CAAWJ,IAAX,CAAP;EACD;EAED;AACF;AACA;;;EACwB,OAAfK,eAAe,GAAuB;IAC3C,OAAO,IAAIR,kBAAJ,EAAP;EACD;EAED;AACF;;;EACiB,OAARS,QAAQ,CAACN,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mBAAmB,CACjBC,UADiB,EAEoC;IAAA;;IACrD,MAAMC,SAAS,GAAGD,UAAU,CAACE,wBAAX,6CACb1B,sCADa,yBACkB,KAAKI,OADvB,+CAEbJ,sCAFa,0BAEmB,KAAKI,OAFxB,EAAlB;;IAKA,IACEqB,SAAS,YAAYT,6BAArB,IACAS,SAAS,YAAYR,8BAFvB,EAGE;MACA,OAAOQ,SAAP;IACD;;IAED,OAAO,IAAP;EACD;EAED;AACF;;;EACEE,OAAO,CAACF,SAAD,EAA4BD,UAA5B,EAA6D;IAClE,MAAMT,gBAAgB,GAAG,KAAKQ,mBAAL,CAAyBC,UAAzB,CAAzB;;IACA,IAAI,CAACT,gBAAL,EAAuB;MACrB;IACD;;IAEDA,gBAAgB,CAACa,sBAAjB,CAAwCJ,UAAxC;;IACA,IAAIT,gBAAgB,CAACc,QAArB,EAA+B;MAC7BJ,SAAS,CAACK,IAAV;MACA;IACD;;IAED,MAAM7B,MAAM,GAAG,KAAKqB,cAAL,CAAoBP,gBAApB,CAAf;;IACA,IAAI,KAAKZ,MAAL,KAAgBjB,IAApB,EAA0B;MACxBuC,SAAS,CAACI,QAAV,GAAqB,CAAC5B,MAAtB;IACD,CAFD,MAEO,IAAI,KAAKE,MAAL,KAAgBhB,IAApB,EAA0B;MAC/BsC,SAAS,CAACI,QAAV,GAAqB5B,MAArB;IACD,CAFM,MAEA;MAAA;;MACL,MAAM,IAAIM,kCAAJ,gEACkB,KAAKJ,MADvB,8DACsEsB,SAAS,CAACM,KADhF,EAAN;IAGD;EACF;;AA1MiD;;8BAA9C3C,kB,4BAQqC,I;eAqM5BA,kB"}
|
|
1
|
+
{"version":3,"file":"DependentAttribute.js","names":["EQUALS","INCLUDES","NOT_EQUALS","NOT_INCLUDES","NOT_IS_EMPTY","IS_EMPTY","SHOW","HIDE","compareSelectedAttribute","option","selectedAttribute","length","DependentAttribute","BaseLayoutHintRule","isApplicableForHint","hint","regex","RegExp","DEPENDENT_ATTRIBUTE","test","getRuleInstance","initHint","rule","OPERATORS","DEPENDENT_ATTRIBUTE_CONTROL","result","match","action","control","operator","options","ConfigurationException","_action","_control","_operator","_options","split","processEqualsOptions","controlAttribute","ChoiceAttributeModel","BooleanAttributeModel","every","selected","processIncludesOptions","some","handleOperator","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 */\nconst compareSelectedAttribute = (\n option: string,\n selectedAttribute: Array<string>\n) => {\n if (option === NOT_IS_EMPTY && selectedAttribute?.length !== 0) {\n return true;\n }\n if (option === IS_EMPTY && selectedAttribute?.length === 0) {\n return true;\n }\n return selectedAttribute?.includes(option);\n};\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}`;\n const regex = new RegExp(\n `${DEPENDENT_ATTRIBUTE}\\\\s?(\\\\S*)\\\\swhen ${DEPENDENT_ATTRIBUTE_CONTROL}:\\\\s?(.*?)\\\\s*(${OPERATORS})\\\\s(.*)`,\n \"i\"\n );\n\n const result = hint.match(regex);\n if (result) {\n rule.action = result[1];\n rule.control = result[2];\n rule.operator = result[3];\n rule.options = 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 compareSelectedAttribute(option, controlAttribute?.selected)\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 compareSelectedAttribute(option, controlAttribute?.selected)\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 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) {\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;;AAEA;;AAKA;;AACA;;AAEA;;AAKA,MAAMA,MAAM,GAAG,QAAf;AACA,MAAMC,QAAQ,GAAG,UAAjB;AACA,MAAMC,UAAU,GAAG,WAAnB;AACA,MAAMC,YAAY,GAAG,aAArB;AACA,MAAMC,YAAY,GAAG,YAArB;AACA,MAAMC,QAAQ,GAAG,SAAjB;AAEA,MAAMC,IAAI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AS,YAAYR,8BAFvB,EAGE;MACA,OAAOQ,SAAP;IACD;;IAED,OAAO,IAAP;EACD;EAED;AACF;;;EACEE,OAAO,CAACF,SAAD,EAA4BD,UAA5B,EAA6D;IAClE,MAAMT,gBAAgB,GAAG,KAAKQ,mBAAL,CAAyBC,UAAzB,CAAzB;;IACA,IAAI,CAACT,gBAAL,EAAuB;MACrB;IACD;;IAEDA,gBAAgB,CAACa,sBAAjB,CAAwCJ,UAAxC;;IACA,IAAIT,gBAAgB,CAACc,QAArB,EAA+B;MAC7BJ,SAAS,CAACK,IAAV;MACA;IACD;;IAED,MAAM5B,MAAM,GAAG,KAAKoB,cAAL,CAAoBP,gBAApB,CAAf;;IACA,IAAI,KAAKX,MAAL,KAAgBrB,IAApB,EAA0B;MACxB0C,SAAS,CAACI,QAAV,GAAqB,CAAC3B,MAAtB;IACD,CAFD,MAEO,IAAI,KAAKE,MAAL,KAAgBpB,IAApB,EAA0B;MAC/ByC,SAAS,CAACI,QAAV,GAAqB3B,MAArB;IACD,CAFM,MAEA;MAAA;;MACL,MAAM,IAAIM,kCAAJ,gEACkB,KAAKJ,MADvB,8DACsEqB,SAAS,CAACM,KADhF,EAAN;IAGD;EACF;;AA1MiD;;8BAA9C1C,kB,4BAQqC,I;eAqM5BA,kB"}
|
|
@@ -254,7 +254,7 @@ class ErrorResponse {
|
|
|
254
254
|
get isUnauthorized() {
|
|
255
255
|
const UNAUTHORIZED_RESPONSE_CODE = 401;
|
|
256
256
|
const hasUnauthorizedStatus = this.status === UNAUTHORIZED_RESPONSE_CODE;
|
|
257
|
-
const hasUnauthorizedErrorId = this.id === "Error.NotAuthorized" || this.id === "Error.Authentication.Required" || this.id === "Error.Authentication.
|
|
257
|
+
const hasUnauthorizedErrorId = this.id === "Error.NotAuthorized" || this.id === "Error.Authentication.Required" || this.id === "Error.Authentication.InvalidCredentials";
|
|
258
258
|
const hasLoginAction = this.error.action ? this.error.action.name === "login" : false;
|
|
259
259
|
return hasUnauthorizedStatus || hasUnauthorizedErrorId || hasLoginAction;
|
|
260
260
|
}
|
|
@@ -222,7 +222,6 @@ export default class ErrorResponse {
|
|
|
222
222
|
const hasUnauthorizedErrorId =
|
|
223
223
|
this.id === "Error.NotAuthorized" ||
|
|
224
224
|
this.id === "Error.Authentication.Required" ||
|
|
225
|
-
this.id === "Error.Authentication.InvalidUsername" ||
|
|
226
225
|
this.id === "Error.Authentication.InvalidCredentials";
|
|
227
226
|
|
|
228
227
|
const hasLoginAction = this.error.action
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorResponse.js","names":["ErrorResponse","constructor","data","connectKey","_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","Href","layouthint","LayoutHintCollection","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.InvalidUsername\" ||\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;;AAGA;;AAwBA;AACA;AACA;AACe,MAAMA,aAAN,CAAoB;EAIjC;AACF;AACA;EACEC,WAAW,CAACC,IAAD,EAAeC,UAAf,EAAoC;IAAA;IAAA;IAC7C,KAAKC,MAAL,GAAcF,IAAd;IACA,KAAKG,WAAL,GAAmBF,UAAnB;EACD;EAED;AACF;;;EACgB,IAAVA,UAAU,CAACG,GAAD,EAAc;IAC1B,KAAKD,WAAL,GAAmBC,GAAnB;EACD;EAED;AACF;;;EACgB,IAAVH,UAAU,GAAY;IACxB,OAAO,KAAKE,WAAZ;EACD;EAED;AACF;AACA;;;EACW,IAALE,KAAK,GAAW;IAAA;;IAClB,uBAAO,KAAKH,MAAZ,uDAAsB,EAAtB;EACD;EAED;AACF;AAC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KAAKA,EAAL,KAAY,mCAJd;EAMD;EAED;AACF;;;EACe,IAAToC,SAAS,GAAY;IACvB,OAAO,KAAKpC,EAAL,KAAY,kCAAnB;EACD;EAED;AACF;;;EAC0B,IAApBqC,oBAAoB,GAAY;IAClC,OAAO,KAAKrC,EAAL,KAAY,yCAAnB;EACD;EAED;AACF;;;EACuB,IAAjBsC,iBAAiB,GAAY;IAC/B,OAAO,KAAKtC,EAAL,KAAY,sCAAnB;EACD;EAED;AACF;;;EACoB,IAAduC,cAAc,GAAY;IAC5B,OAAO,KAAKvC,EAAL,KAAY,kCAAnB;EACD;EAED;AACF;AACA;AACA;;;EAC8B,IAAxBwC,wBAAwB,GAAY;IACtC,OAAO,KAAKxC,EAAL,KAAY,8BAAnB;EACD;EAED;AACF;AACA;;;EACwB,IAAlByC,kBAAkB,GAAU;IAC9B,OAAO,KAAK9B,UAAL,CAAgBC,QAAhB,GAA2B,IAAIQ,aAAJ,CAAS,KAAKT,UAAL,CAAgBC,QAAzB,CAA3B,GAAgE,IAAvE;EACD;EAED;AACF;AACA;;;EAC2B,IAArB8B,qBAAqB,GAAY;IACnC,MAAMd,0BAA0B,GAAG,GAAnC;IACA,OACE,KAAKD,cAAL,IACA,KAAK/B,MAAL,KAAgBgC,0BADhB,IAEA,KAAKvB,QAAL,CAAcV,KAAd,KAAwB,iBAH1B;EAKD;EAED;AACF;AACA;;;EACiB,IAAXgD,WAAW,GAAY;IACzB,OACE,KAAK3C,EAAL,KAAY,+BAAZ,IACA,KAAKA,EAAL,KAAY,yCAFd;EAID;EAED;AACF;;;EACyB,IAAnB4C,mBAAmB,GAAY;IACjC,OAAO,CAAC,KAAKX,gBAAN,IAA0B,CAAC,KAAKG,SAAhC,IAA6C,CAAC,KAAKF,gBAA1D;EACD;;AAnSgC"}
|
|
1
|
+
{"version":3,"file":"ErrorResponse.js","names":["ErrorResponse","constructor","data","connectKey","_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","Href","layouthint","LayoutHintCollection","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;;AAGA;;AAwBA;AACA;AACA;AACe,MAAMA,aAAN,CAAoB;EAIjC;AACF;AACA;EACEC,WAAW,CAACC,IAAD,EAAeC,UAAf,EAAoC;IAAA;IAAA;IAC7C,KAAKC,MAAL,GAAcF,IAAd;IACA,KAAKG,WAAL,GAAmBF,UAAnB;EACD;EAED;AACF;;;EACgB,IAAVA,UAAU,CAACG,GAAD,EAAc;IAC1B,KAAKD,WAAL,GAAmBC,GAAnB;EACD;EAED;AACF;;;EACgB,IAAVH,UAAU,GAAY;IACxB,OAAO,KAAKE,WAAZ;EACD;EAED;AACF;AACA;;;EACW,IAALE,KAAK,GAAW;IAAA;;IAClB,uBAAO,KAAKH,MAAZ,uDAAsB,EAAtB;EACD;EAED;AACF;AACA;;;EACY,IAANI,MAAM,GAAW;IACnB,MAAMC,gBAAgB,GAAG,CAAzB;IACA,MAAMC,aAAa,GAAG,EAAtB;IACA,OAAO,KAAKH,KAAL,CAAWC,MAAX,GACHG,QAAQ,CAAC,KAAKJ,KAAL,CAAWC,MAAZ,EAAoBE,aAApB,CADL,GAEHD,gBAFJ;EAGD;EAED;AACF;AACA;;;EACQ,IAAFG,EAAE,GAAW;IACf,IAAI,KAAKC,kBAAL,IAA2B,KAAKN,KAAL,CAAWK,EAAX,KAAkB,qBAAjD,EAAwE;MACtE,OAAO,wBAAP;IACD;;IAED,OAAO,KAAKL,KAAL,CAAWK,EAAX,IAAiB,KAAKL,KAAL,CAAWO,IAA5B,IAAoC,oBAA3C;EACD;EAED;AACF;;;EACa,IAA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AU;IAC9B,OAAO,KAAK9B,UAAL,CAAgBC,QAAhB,GAA2B,IAAIQ,aAAJ,CAAS,KAAKT,UAAL,CAAgBC,QAAzB,CAA3B,GAAgE,IAAvE;EACD;EAED;AACF;AACA;;;EAC2B,IAArB8B,qBAAqB,GAAY;IACnC,MAAMd,0BAA0B,GAAG,GAAnC;IACA,OACE,KAAKD,cAAL,IACA,KAAK/B,MAAL,KAAgBgC,0BADhB,IAEA,KAAKvB,QAAL,CAAcV,KAAd,KAAwB,iBAH1B;EAKD;EAED;AACF;AACA;;;EACiB,IAAXgD,WAAW,GAAY;IACzB,OACE,KAAK3C,EAAL,KAAY,+BAAZ,IACA,KAAKA,EAAL,KAAY,yCAFd;EAID;EAED;AACF;;;EACyB,IAAnB4C,mBAAmB,GAAY;IACjC,OAAO,CAAC,KAAKX,gBAAN,IAA0B,CAAC,KAAKG,SAAhC,IAA6C,CAAC,KAAKF,gBAA1D;EACD;;AAlSgC"}
|
|
@@ -44,7 +44,7 @@ const defaultErrorResponseHandler = error => dispatch => {
|
|
|
44
44
|
return dispatch((0, _Authorization.handleUnauthorized)(error));
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
if (error.isBlocked || error.isConcurrentUser) {
|
|
47
|
+
if (error.isBlocked || error.isConcurrentUser || error.isInvalidUsername) {
|
|
48
48
|
const LOGOUT_PATH = (0, _Settings.getSetting)("LOGOUT_PATH", "/signout");
|
|
49
49
|
dispatch((0, _actions.push)(LOGOUT_PATH));
|
|
50
50
|
}
|
|
@@ -39,7 +39,7 @@ const defaultErrorResponseHandler: DefaultErrorResponseHandler =
|
|
|
39
39
|
return dispatch(handleUnauthorized(error));
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
if (error.isBlocked || error.isConcurrentUser) {
|
|
42
|
+
if (error.isBlocked || error.isConcurrentUser || error.isInvalidUsername) {
|
|
43
43
|
const LOGOUT_PATH = getSetting("LOGOUT_PATH", "/signout");
|
|
44
44
|
dispatch(push(LOGOUT_PATH));
|
|
45
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Error.js","names":["saveError","error","type","payload","defaultErrorResponseHandler","dispatch","isResourceNotFoundAfterReload","isRemoteServiceException","isUnauthorized","handleUnauthorized","isBlocked","isConcurrentUser","LOGOUT_PATH","getSetting","push","isChangePassword","changePassword","IS_SERVER","setTimeout","showXHRErrorNotification","customErrorResponseHandler","errorResponse","defaultHandler","setCustomErrorResponseHandler","handler","handleError","resetProgress","ErrorResponse"],"sources":["../../../src/redux/actions/Error.js"],"sourcesContent":["// @flow\nimport { IS_SERVER } from \"../../constants/Constants\";\nimport { getSetting } from \"../../constants/Settings\";\n\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\n\nimport { push } from \"../_router/actions\";\nimport { showXHRErrorNotification } from \"./Notification\";\nimport { resetProgress } from \"./ProgressIndicator\";\nimport { changePassword } from \"./SignIn\";\nimport { handleUnauthorized } from \"./Authorization\";\n\nimport type { FetchException } from \"../../exceptions\";\nimport type { Dispatch, SaveErrorAction, ThunkAction } from \"../types\";\n\ntype DefaultErrorResponseHandler = (error: ErrorResponse) => ThunkAction;\ntype CustomErrorResponseHandler = (\n errorResponse: ErrorResponse,\n defaultHandler: DefaultErrorResponseHandler\n) => ThunkAction;\n\n/**\n */\nconst saveError = (error): SaveErrorAction => ({\n type: \"SAVE_ERROR\",\n payload: error,\n});\n\n/**\n */\nconst defaultErrorResponseHandler: DefaultErrorResponseHandler =\n (error: ErrorResponse): ThunkAction =>\n (dispatch: Dispatch) => {\n if (error.isResourceNotFoundAfterReload || error.isRemoteServiceException) {\n return dispatch({ type: \"NO_ACTION\" });\n }\n\n if (error.isUnauthorized) {\n return dispatch(handleUnauthorized(error));\n }\n\n if (error.isBlocked || error.isConcurrentUser) {\n const LOGOUT_PATH = getSetting(\"LOGOUT_PATH\", \"/signout\");\n dispatch(push(LOGOUT_PATH));\n }\n\n if (error.isChangePassword) {\n return dispatch(changePassword());\n }\n\n if (IS_SERVER) {\n return dispatch(saveError(error));\n }\n\n setTimeout(() => {\n throw error;\n });\n\n return dispatch(showXHRErrorNotification(error));\n };\n\n/**\n * Standard Custom error response, acts as a proxy and can be overwritten by {@link setCustomErrorResponseHandler}\n */\nlet customErrorResponseHandler: CustomErrorResponseHandler =\n (errorResponse, defaultHandler) => (dispatch: Dispatch) =>\n dispatch(defaultHandler(errorResponse));\n\n/**\n * Set a custom error response handler,\n * can be used when custom functionality is needed on certain (error) response\n * of the modular ui, for example when custom logic is needed when a user is unauthorized<br>\n * It receives an {@link ErrorResponse} and the {@link defaultErrorResponseHandler}\n */\nexport const setCustomErrorResponseHandler = (\n handler: CustomErrorResponseHandler\n) => {\n customErrorResponseHandler = handler;\n};\n\n/**\n * Handle errors by sending an error notification message\n */\nexport const handleError =\n (error: Error | FetchException): ThunkAction =>\n (dispatch: Dispatch) => {\n dispatch(resetProgress());\n\n const errorResponse = new ErrorResponse(error);\n\n return dispatch(\n customErrorResponseHandler(errorResponse, defaultErrorResponseHandler)\n );\n };\n"],"mappings":";;;;;;;;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAWA;AACA;AACA,MAAMA,SAAS,GAAIC,KAAD,KAA6B;EAC7CC,IAAI,EAAE,YADuC;EAE7CC,OAAO,EAAEF;AAFoC,CAA7B,CAAlB;AAKA;AACA;;;AACA,MAAMG,2BAAwD,GAC3DH,KAAD,IACCI,QAAD,IAAwB;EACtB,IAAIJ,KAAK,CAACK,6BAAN,IAAuCL,KAAK,CAACM,wBAAjD,EAA2E;IACzE,OAAOF,QAAQ,CAAC;MAAEH,IAAI,EAAE;IAAR,CAAD,CAAf;EACD;;EAED,IAAID,KAAK,CAACO,cAAV,EAA0B;IACxB,OAAOH,QAAQ,CAAC,IAAAI,iCAAA,EAAmBR,KAAnB,CAAD,CAAf;EACD;;EAED,IAAIA,KAAK,CAACS,SAAN,IAAmBT,KAAK,CAACU,
|
|
1
|
+
{"version":3,"file":"Error.js","names":["saveError","error","type","payload","defaultErrorResponseHandler","dispatch","isResourceNotFoundAfterReload","isRemoteServiceException","isUnauthorized","handleUnauthorized","isBlocked","isConcurrentUser","isInvalidUsername","LOGOUT_PATH","getSetting","push","isChangePassword","changePassword","IS_SERVER","setTimeout","showXHRErrorNotification","customErrorResponseHandler","errorResponse","defaultHandler","setCustomErrorResponseHandler","handler","handleError","resetProgress","ErrorResponse"],"sources":["../../../src/redux/actions/Error.js"],"sourcesContent":["// @flow\nimport { IS_SERVER } from \"../../constants/Constants\";\nimport { getSetting } from \"../../constants/Settings\";\n\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\n\nimport { push } from \"../_router/actions\";\nimport { showXHRErrorNotification } from \"./Notification\";\nimport { resetProgress } from \"./ProgressIndicator\";\nimport { changePassword } from \"./SignIn\";\nimport { handleUnauthorized } from \"./Authorization\";\n\nimport type { FetchException } from \"../../exceptions\";\nimport type { Dispatch, SaveErrorAction, ThunkAction } from \"../types\";\n\ntype DefaultErrorResponseHandler = (error: ErrorResponse) => ThunkAction;\ntype CustomErrorResponseHandler = (\n errorResponse: ErrorResponse,\n defaultHandler: DefaultErrorResponseHandler\n) => ThunkAction;\n\n/**\n */\nconst saveError = (error): SaveErrorAction => ({\n type: \"SAVE_ERROR\",\n payload: error,\n});\n\n/**\n */\nconst defaultErrorResponseHandler: DefaultErrorResponseHandler =\n (error: ErrorResponse): ThunkAction =>\n (dispatch: Dispatch) => {\n if (error.isResourceNotFoundAfterReload || error.isRemoteServiceException) {\n return dispatch({ type: \"NO_ACTION\" });\n }\n\n if (error.isUnauthorized) {\n return dispatch(handleUnauthorized(error));\n }\n\n if (error.isBlocked || error.isConcurrentUser || error.isInvalidUsername) {\n const LOGOUT_PATH = getSetting(\"LOGOUT_PATH\", \"/signout\");\n dispatch(push(LOGOUT_PATH));\n }\n\n if (error.isChangePassword) {\n return dispatch(changePassword());\n }\n\n if (IS_SERVER) {\n return dispatch(saveError(error));\n }\n\n setTimeout(() => {\n throw error;\n });\n\n return dispatch(showXHRErrorNotification(error));\n };\n\n/**\n * Standard Custom error response, acts as a proxy and can be overwritten by {@link setCustomErrorResponseHandler}\n */\nlet customErrorResponseHandler: CustomErrorResponseHandler =\n (errorResponse, defaultHandler) => (dispatch: Dispatch) =>\n dispatch(defaultHandler(errorResponse));\n\n/**\n * Set a custom error response handler,\n * can be used when custom functionality is needed on certain (error) response\n * of the modular ui, for example when custom logic is needed when a user is unauthorized<br>\n * It receives an {@link ErrorResponse} and the {@link defaultErrorResponseHandler}\n */\nexport const setCustomErrorResponseHandler = (\n handler: CustomErrorResponseHandler\n) => {\n customErrorResponseHandler = handler;\n};\n\n/**\n * Handle errors by sending an error notification message\n */\nexport const handleError =\n (error: Error | FetchException): ThunkAction =>\n (dispatch: Dispatch) => {\n dispatch(resetProgress());\n\n const errorResponse = new ErrorResponse(error);\n\n return dispatch(\n customErrorResponseHandler(errorResponse, defaultErrorResponseHandler)\n );\n };\n"],"mappings":";;;;;;;;;AACA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAWA;AACA;AACA,MAAMA,SAAS,GAAIC,KAAD,KAA6B;EAC7CC,IAAI,EAAE,YADuC;EAE7CC,OAAO,EAAEF;AAFoC,CAA7B,CAAlB;AAKA;AACA;;;AACA,MAAMG,2BAAwD,GAC3DH,KAAD,IACCI,QAAD,IAAwB;EACtB,IAAIJ,KAAK,CAACK,6BAAN,IAAuCL,KAAK,CAACM,wBAAjD,EAA2E;IACzE,OAAOF,QAAQ,CAAC;MAAEH,IAAI,EAAE;IAAR,CAAD,CAAf;EACD;;EAED,IAAID,KAAK,CAACO,cAAV,EAA0B;IACxB,OAAOH,QAAQ,CAAC,IAAAI,iCAAA,EAAmBR,KAAnB,CAAD,CAAf;EACD;;EAED,IAAIA,KAAK,CAACS,SAAN,IAAmBT,KAAK,CAACU,gBAAzB,IAA6CV,KAAK,CAACW,iBAAvD,EAA0E;IACxE,MAAMC,WAAW,GAAG,IAAAC,oBAAA,EAAW,aAAX,EAA0B,UAA1B,CAApB;IACAT,QAAQ,CAAC,IAAAU,aAAA,EAAKF,WAAL,CAAD,CAAR;EACD;;EAED,IAAIZ,KAAK,CAACe,gBAAV,EAA4B;IAC1B,OAAOX,QAAQ,CAAC,IAAAY,sBAAA,GAAD,CAAf;EACD;;EAED,IAAIC,oBAAJ,EAAe;IACb,OAAOb,QAAQ,CAACL,SAAS,CAACC,KAAD,CAAV,CAAf;EACD;;EAEDkB,UAAU,CAAC,MAAM;IACf,MAAMlB,KAAN;EACD,CAFS,CAAV;EAIA,OAAOI,QAAQ,CAAC,IAAAe,sCAAA,EAAyBnB,KAAzB,CAAD,CAAf;AACD,CA7BH;AA+BA;AACA;AACA;;;AACA,IAAIoB,0BAAsD,GACxD,CAACC,aAAD,EAAgBC,cAAhB,KAAoClB,QAAD,IACjCA,QAAQ,CAACkB,cAAc,CAACD,aAAD,CAAf,CAFZ;AAIA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAME,6BAA6B,GACxCC,OAD2C,IAExC;EACHJ,0BAA0B,GAAGI,OAA7B;AACD,CAJM;AAMP;AACA;AACA;;;;;AACO,MAAMC,WAAW,GACrBzB,KAAD,IACCI,QAAD,IAAwB;EACtBA,QAAQ,CAAC,IAAAsB,gCAAA,GAAD,CAAR;EAEA,MAAML,aAAa,GAAG,IAAIM,sBAAJ,CAAkB3B,KAAlB,CAAtB;EAEA,OAAOI,QAAQ,CACbgB,0BAA0B,CAACC,aAAD,EAAgBlB,2BAAhB,CADb,CAAf;AAGD,CAVI"}
|
package/package.json
CHANGED
|
@@ -18,10 +18,27 @@ const EQUALS = "equals";
|
|
|
18
18
|
const INCLUDES = "includes";
|
|
19
19
|
const NOT_EQUALS = "notEquals";
|
|
20
20
|
const NOT_INCLUDES = "notIncludes";
|
|
21
|
+
const NOT_IS_EMPTY = "notIsEmpty";
|
|
22
|
+
const IS_EMPTY = "isEmpty";
|
|
21
23
|
|
|
22
24
|
const SHOW = "show";
|
|
23
25
|
const HIDE = "hide";
|
|
24
26
|
|
|
27
|
+
/**
|
|
28
|
+
*/
|
|
29
|
+
const compareSelectedAttribute = (
|
|
30
|
+
option: string,
|
|
31
|
+
selectedAttribute: Array<string>
|
|
32
|
+
) => {
|
|
33
|
+
if (option === NOT_IS_EMPTY && selectedAttribute?.length !== 0) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
if (option === IS_EMPTY && selectedAttribute?.length === 0) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return selectedAttribute?.includes(option);
|
|
40
|
+
};
|
|
41
|
+
|
|
25
42
|
/**
|
|
26
43
|
* Depending attributes hint logic
|
|
27
44
|
*/
|
|
@@ -137,7 +154,7 @@ class DependentAttribute extends BaseLayoutHintRule {
|
|
|
137
154
|
controlAttribute instanceof BooleanAttributeModel
|
|
138
155
|
) {
|
|
139
156
|
return this.options.every((option) =>
|
|
140
|
-
controlAttribute
|
|
157
|
+
compareSelectedAttribute(option, controlAttribute?.selected)
|
|
141
158
|
);
|
|
142
159
|
}
|
|
143
160
|
|
|
@@ -153,7 +170,7 @@ class DependentAttribute extends BaseLayoutHintRule {
|
|
|
153
170
|
): boolean {
|
|
154
171
|
if (controlAttribute instanceof ChoiceAttributeModel) {
|
|
155
172
|
return this.options.some((option) =>
|
|
156
|
-
controlAttribute
|
|
173
|
+
compareSelectedAttribute(option, controlAttribute?.selected)
|
|
157
174
|
);
|
|
158
175
|
}
|
|
159
176
|
|
|
@@ -222,7 +222,6 @@ export default class ErrorResponse {
|
|
|
222
222
|
const hasUnauthorizedErrorId =
|
|
223
223
|
this.id === "Error.NotAuthorized" ||
|
|
224
224
|
this.id === "Error.Authentication.Required" ||
|
|
225
|
-
this.id === "Error.Authentication.InvalidUsername" ||
|
|
226
225
|
this.id === "Error.Authentication.InvalidCredentials";
|
|
227
226
|
|
|
228
227
|
const hasLoginAction = this.error.action
|
|
@@ -39,7 +39,7 @@ const defaultErrorResponseHandler: DefaultErrorResponseHandler =
|
|
|
39
39
|
return dispatch(handleUnauthorized(error));
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
if (error.isBlocked || error.isConcurrentUser) {
|
|
42
|
+
if (error.isBlocked || error.isConcurrentUser || error.isInvalidUsername) {
|
|
43
43
|
const LOGOUT_PATH = getSetting("LOGOUT_PATH", "/signout");
|
|
44
44
|
dispatch(push(LOGOUT_PATH));
|
|
45
45
|
}
|