@beinformed/ui 1.33.0-beta.5 → 1.33.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/esm/models/filters/StringFilterModel.js +32 -1
- package/esm/models/filters/StringFilterModel.js.map +1 -1
- package/lib/models/filters/StringFilterModel.js +32 -1
- package/lib/models/filters/StringFilterModel.js.flow +37 -1
- package/lib/models/filters/StringFilterModel.js.map +1 -1
- package/lib/models/filters/__tests__/ZipcodeFilter.spec.js.flow +46 -12
- package/package.json +1 -1
- package/src/models/filters/StringFilterModel.js +37 -1
- package/src/models/filters/__tests__/ZipcodeFilter.spec.js +46 -12
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.33.0-beta.7](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.33.0-beta.6...v1.33.0-beta.7) (2023-08-28)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **validation:** set isvalid to true before update ([d0f2e4f](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/d0f2e4f4b301b90aa86b1ecc512903114649fed4))
|
|
11
|
+
|
|
12
|
+
## [1.33.0-beta.6](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.33.0-beta.5...v1.33.0-beta.6) (2023-08-28)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **formatting:** remove formatting on exactly and not ([b80518d](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/b80518d5d74a1f54943e1e835a708f193555b85b))
|
|
18
|
+
|
|
5
19
|
## [1.33.0-beta.5](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.33.0-beta.4...v1.33.0-beta.5) (2023-08-28)
|
|
6
20
|
|
|
7
21
|
## [1.33.0-beta.4](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.33.0-beta.3...v1.33.0-beta.4) (2023-08-28)
|
|
@@ -28,7 +28,7 @@ export default class StringFilterModel extends BaseFilterModel {
|
|
|
28
28
|
}
|
|
29
29
|
return [{
|
|
30
30
|
name: this.param,
|
|
31
|
-
value: this.value
|
|
31
|
+
value: this.removeFormat(this.value)
|
|
32
32
|
}];
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -64,6 +64,7 @@ export default class StringFilterModel extends BaseFilterModel {
|
|
|
64
64
|
* Update this filter with input name and value
|
|
65
65
|
*/
|
|
66
66
|
update(attribute, value) {
|
|
67
|
+
this._isValid = true;
|
|
67
68
|
this._inputvalue = typeof value !== "string" ? value.toString() : value;
|
|
68
69
|
if (this.operator === "exactly" || this.operator === "isNot") {
|
|
69
70
|
var _context, _context2;
|
|
@@ -98,5 +99,35 @@ export default class StringFilterModel extends BaseFilterModel {
|
|
|
98
99
|
}
|
|
99
100
|
return value;
|
|
100
101
|
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
*/
|
|
105
|
+
isBSN() {
|
|
106
|
+
return this.layouthint.has("bsn");
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
*/
|
|
111
|
+
isIBAN() {
|
|
112
|
+
return this.layouthint.has("iban");
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
*/
|
|
117
|
+
isZipcode() {
|
|
118
|
+
return this.layouthint.has("zipcode");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
*/
|
|
123
|
+
removeFormat(value) {
|
|
124
|
+
if (value == null || value.toString() === "") {
|
|
125
|
+
return "";
|
|
126
|
+
}
|
|
127
|
+
if ((this.operator === "exactly" || this.operator === "isNot") && (this.isIBAN() || this.isZipcode() || this.isBSN())) {
|
|
128
|
+
return value.replace(/[^a-z0-9,]/gi, "");
|
|
129
|
+
}
|
|
130
|
+
return value;
|
|
131
|
+
}
|
|
101
132
|
}
|
|
102
133
|
//# sourceMappingURL=StringFilterModel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StringFilterModel.js","names":["BaseFilterModel","StringFilterModel","constructor","data","contributions","_defineProperty","update","attribute","value","_inputvalue","_value","params","param","name","inputvalue","reset","isValid","_isValid","toString","operator","_context","_context2","values","isMultiple","_mapInstanceProperty","split","call","val","_trimInstanceProperty","outputValues","formattedValue","formatValue","push","validate","join","getContribution"],"sources":["../../../src/models/filters/StringFilterModel.js"],"sourcesContent":["// @flow\nimport BaseFilterModel from \"./BaseFilterModel\";\n\nimport type { AttributeType, FilterType } from \"../types\";\n\n/**\n * StringFilterModel can handle string filters with multiple setting\n */\nexport default class StringFilterModel extends BaseFilterModel {\n _isValid: boolean = true;\n _value: string | null;\n _inputvalue: string;\n\n /**\n */\n constructor(data: Object, contributions: Object) {\n super(data, contributions);\n\n this.update(this.attribute, data.value ?? \"\");\n\n // when formatted value set this to initial input value\n this._inputvalue = this._value ?? \"\";\n }\n\n /**\n * Retrieve the parameters with its value for this filter\n */\n get params(): Array<{ name: string, value: ?string }> {\n if (!this.param) {\n return [];\n }\n\n return [\n {\n name: this.param,\n value: this.value,\n },\n ];\n }\n\n /**\n * Getting the value of the filter\n */\n get value(): string | null {\n return this._value;\n }\n\n /**\n */\n get inputvalue(): string {\n return this._inputvalue;\n }\n\n /**\n * Reset the value of this filter to undefined\n */\n reset(): FilterType {\n this._inputvalue = \"\";\n this._value = null;\n\n return this;\n }\n\n /**\n */\n get isValid(): boolean {\n return this._isValid;\n }\n\n /**\n * Update this filter with input name and value\n */\n update(attribute: AttributeType, value: string) {\n this._inputvalue = typeof value !== \"string\" ? value.toString() : value;\n\n if (this.operator === \"exactly\" || this.operator === \"isNot\") {\n const values = this.isMultiple\n ? this._inputvalue.split(\",\").map((val) => val.trim())\n : [this._inputvalue.trim()];\n\n const outputValues = [];\n for (const val of values) {\n const formattedValue = this.formatValue(val);\n if (formattedValue !== \"\") {\n outputValues.push(formattedValue);\n\n if (!this.attribute.validate(formattedValue)) {\n this._isValid = false;\n }\n }\n }\n\n this._value = outputValues.join(\",\");\n } else {\n this._value = value;\n }\n }\n\n /**\n */\n get operator(): string {\n return this.getContribution(\"operator\", \"\");\n }\n\n /**\n */\n formatValue(value: string): string {\n if (this.operator === \"exactly\" || this.operator === \"isNot\") {\n return this.attribute.formatValue(value);\n }\n return value;\n }\n}\n"],"mappings":";;;AACA,OAAOA,eAAe,MAAM,mBAAmB;AAI/C;AACA;AACA;AACA,eAAe,MAAMC,iBAAiB,SAASD,eAAe,CAAC;EAK7D;AACF;EACEE,WAAWA,CAACC,IAAY,EAAEC,aAAqB,EAAE;IAC/C,KAAK,CAACD,IAAI,EAAEC,aAAa,CAAC;IAACC,eAAA,mBAPT,IAAI;IAAAA,eAAA;IAAAA,eAAA;IAStB,IAAI,CAACC,MAAM,CAAC,IAAI,CAACC,SAAS,EAAEJ,IAAI,CAACK,KAAK,IAAI,EAAE,CAAC;;IAE7C;IACA,IAAI,CAACC,WAAW,GAAG,IAAI,CAACC,MAAM,IAAI,EAAE;EACtC;;EAEA;AACF;AACA;EACE,IAAIC,MAAMA,CAAA,EAA4C;IACpD,IAAI,CAAC,IAAI,CAACC,KAAK,EAAE;MACf,OAAO,EAAE;IACX;IAEA,OAAO,CACL;MACEC,IAAI,EAAE,IAAI,CAACD,KAAK;MAChBJ,KAAK,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"StringFilterModel.js","names":["BaseFilterModel","StringFilterModel","constructor","data","contributions","_defineProperty","update","attribute","value","_inputvalue","_value","params","param","name","removeFormat","inputvalue","reset","isValid","_isValid","toString","operator","_context","_context2","values","isMultiple","_mapInstanceProperty","split","call","val","_trimInstanceProperty","outputValues","formattedValue","formatValue","push","validate","join","getContribution","isBSN","layouthint","has","isIBAN","isZipcode","replace"],"sources":["../../../src/models/filters/StringFilterModel.js"],"sourcesContent":["// @flow\nimport BaseFilterModel from \"./BaseFilterModel\";\n\nimport type { AttributeType, FilterType } from \"../types\";\n\n/**\n * StringFilterModel can handle string filters with multiple setting\n */\nexport default class StringFilterModel extends BaseFilterModel {\n _isValid: boolean = true;\n _value: string | null;\n _inputvalue: string;\n\n /**\n */\n constructor(data: Object, contributions: Object) {\n super(data, contributions);\n\n this.update(this.attribute, data.value ?? \"\");\n\n // when formatted value set this to initial input value\n this._inputvalue = this._value ?? \"\";\n }\n\n /**\n * Retrieve the parameters with its value for this filter\n */\n get params(): Array<{ name: string, value: ?string }> {\n if (!this.param) {\n return [];\n }\n\n return [\n {\n name: this.param,\n value: this.removeFormat(this.value),\n },\n ];\n }\n\n /**\n * Getting the value of the filter\n */\n get value(): string | null {\n return this._value;\n }\n\n /**\n */\n get inputvalue(): string {\n return this._inputvalue;\n }\n\n /**\n * Reset the value of this filter to undefined\n */\n reset(): FilterType {\n this._inputvalue = \"\";\n this._value = null;\n\n return this;\n }\n\n /**\n */\n get isValid(): boolean {\n return this._isValid;\n }\n\n /**\n * Update this filter with input name and value\n */\n update(attribute: AttributeType, value: string) {\n this._isValid = true;\n this._inputvalue = typeof value !== \"string\" ? value.toString() : value;\n\n if (this.operator === \"exactly\" || this.operator === \"isNot\") {\n const values = this.isMultiple\n ? this._inputvalue.split(\",\").map((val) => val.trim())\n : [this._inputvalue.trim()];\n\n const outputValues = [];\n for (const val of values) {\n const formattedValue = this.formatValue(val);\n if (formattedValue !== \"\") {\n outputValues.push(formattedValue);\n\n if (!this.attribute.validate(formattedValue)) {\n this._isValid = false;\n }\n }\n }\n\n this._value = outputValues.join(\",\");\n } else {\n this._value = value;\n }\n }\n\n /**\n */\n get operator(): string {\n return this.getContribution(\"operator\", \"\");\n }\n\n /**\n */\n formatValue(value: string): string {\n if (this.operator === \"exactly\" || this.operator === \"isNot\") {\n return this.attribute.formatValue(value);\n }\n return value;\n }\n\n /**\n */\n isBSN(): boolean {\n return this.layouthint.has(\"bsn\");\n }\n\n /**\n */\n isIBAN(): boolean {\n return this.layouthint.has(\"iban\");\n }\n\n /**\n */\n isZipcode(): boolean {\n return this.layouthint.has(\"zipcode\");\n }\n\n /**\n */\n removeFormat(value: ?string): string {\n if (value == null || value.toString() === \"\") {\n return \"\";\n }\n\n if (\n (this.operator === \"exactly\" || this.operator === \"isNot\") &&\n (this.isIBAN() || this.isZipcode() || this.isBSN())\n ) {\n return value.replace(/[^a-z0-9,]/gi, \"\");\n }\n\n return value;\n }\n}\n"],"mappings":";;;AACA,OAAOA,eAAe,MAAM,mBAAmB;AAI/C;AACA;AACA;AACA,eAAe,MAAMC,iBAAiB,SAASD,eAAe,CAAC;EAK7D;AACF;EACEE,WAAWA,CAACC,IAAY,EAAEC,aAAqB,EAAE;IAC/C,KAAK,CAACD,IAAI,EAAEC,aAAa,CAAC;IAACC,eAAA,mBAPT,IAAI;IAAAA,eAAA;IAAAA,eAAA;IAStB,IAAI,CAACC,MAAM,CAAC,IAAI,CAACC,SAAS,EAAEJ,IAAI,CAACK,KAAK,IAAI,EAAE,CAAC;;IAE7C;IACA,IAAI,CAACC,WAAW,GAAG,IAAI,CAACC,MAAM,IAAI,EAAE;EACtC;;EAEA;AACF;AACA;EACE,IAAIC,MAAMA,CAAA,EAA4C;IACpD,IAAI,CAAC,IAAI,CAACC,KAAK,EAAE;MACf,OAAO,EAAE;IACX;IAEA,OAAO,CACL;MACEC,IAAI,EAAE,IAAI,CAACD,KAAK;MAChBJ,KAAK,EAAE,IAAI,CAACM,YAAY,CAAC,IAAI,CAACN,KAAK;IACrC,CAAC,CACF;EACH;;EAEA;AACF;AACA;EACE,IAAIA,KAAKA,CAAA,EAAkB;IACzB,OAAO,IAAI,CAACE,MAAM;EACpB;;EAEA;AACF;EACE,IAAIK,UAAUA,CAAA,EAAW;IACvB,OAAO,IAAI,CAACN,W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lC,KAAK;EACd;AACF"}
|
|
@@ -35,7 +35,7 @@ class StringFilterModel extends _BaseFilterModel.default {
|
|
|
35
35
|
}
|
|
36
36
|
return [{
|
|
37
37
|
name: this.param,
|
|
38
|
-
value: this.value
|
|
38
|
+
value: this.removeFormat(this.value)
|
|
39
39
|
}];
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -71,6 +71,7 @@ class StringFilterModel extends _BaseFilterModel.default {
|
|
|
71
71
|
* Update this filter with input name and value
|
|
72
72
|
*/
|
|
73
73
|
update(attribute, value) {
|
|
74
|
+
this._isValid = true;
|
|
74
75
|
this._inputvalue = typeof value !== "string" ? value.toString() : value;
|
|
75
76
|
if (this.operator === "exactly" || this.operator === "isNot") {
|
|
76
77
|
var _context, _context2;
|
|
@@ -105,6 +106,36 @@ class StringFilterModel extends _BaseFilterModel.default {
|
|
|
105
106
|
}
|
|
106
107
|
return value;
|
|
107
108
|
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
*/
|
|
112
|
+
isBSN() {
|
|
113
|
+
return this.layouthint.has("bsn");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
*/
|
|
118
|
+
isIBAN() {
|
|
119
|
+
return this.layouthint.has("iban");
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
*/
|
|
124
|
+
isZipcode() {
|
|
125
|
+
return this.layouthint.has("zipcode");
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
*/
|
|
130
|
+
removeFormat(value) {
|
|
131
|
+
if (value == null || value.toString() === "") {
|
|
132
|
+
return "";
|
|
133
|
+
}
|
|
134
|
+
if ((this.operator === "exactly" || this.operator === "isNot") && (this.isIBAN() || this.isZipcode() || this.isBSN())) {
|
|
135
|
+
return value.replace(/[^a-z0-9,]/gi, "");
|
|
136
|
+
}
|
|
137
|
+
return value;
|
|
138
|
+
}
|
|
108
139
|
}
|
|
109
140
|
exports.default = StringFilterModel;
|
|
110
141
|
//# sourceMappingURL=StringFilterModel.js.map
|
|
@@ -33,7 +33,7 @@ export default class StringFilterModel extends BaseFilterModel {
|
|
|
33
33
|
return [
|
|
34
34
|
{
|
|
35
35
|
name: this.param,
|
|
36
|
-
value: this.value,
|
|
36
|
+
value: this.removeFormat(this.value),
|
|
37
37
|
},
|
|
38
38
|
];
|
|
39
39
|
}
|
|
@@ -71,6 +71,7 @@ export default class StringFilterModel extends BaseFilterModel {
|
|
|
71
71
|
* Update this filter with input name and value
|
|
72
72
|
*/
|
|
73
73
|
update(attribute: AttributeType, value: string) {
|
|
74
|
+
this._isValid = true;
|
|
74
75
|
this._inputvalue = typeof value !== "string" ? value.toString() : value;
|
|
75
76
|
|
|
76
77
|
if (this.operator === "exactly" || this.operator === "isNot") {
|
|
@@ -110,4 +111,39 @@ export default class StringFilterModel extends BaseFilterModel {
|
|
|
110
111
|
}
|
|
111
112
|
return value;
|
|
112
113
|
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
*/
|
|
117
|
+
isBSN(): boolean {
|
|
118
|
+
return this.layouthint.has("bsn");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
*/
|
|
123
|
+
isIBAN(): boolean {
|
|
124
|
+
return this.layouthint.has("iban");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
*/
|
|
129
|
+
isZipcode(): boolean {
|
|
130
|
+
return this.layouthint.has("zipcode");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
*/
|
|
135
|
+
removeFormat(value: ?string): string {
|
|
136
|
+
if (value == null || value.toString() === "") {
|
|
137
|
+
return "";
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (
|
|
141
|
+
(this.operator === "exactly" || this.operator === "isNot") &&
|
|
142
|
+
(this.isIBAN() || this.isZipcode() || this.isBSN())
|
|
143
|
+
) {
|
|
144
|
+
return value.replace(/[^a-z0-9,]/gi, "");
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return value;
|
|
148
|
+
}
|
|
113
149
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StringFilterModel.js","names":["_BaseFilterModel","_interopRequireDefault","require","StringFilterModel","BaseFilterModel","constructor","data","contributions","_defineProperty2","default","update","attribute","value","_inputvalue","_value","params","param","name","inputvalue","reset","isValid","_isValid","toString","operator","_context","_context2","values","isMultiple","_map","split","call","val","_trim","outputValues","formattedValue","formatValue","push","validate","join","getContribution","exports"],"sources":["../../../src/models/filters/StringFilterModel.js"],"sourcesContent":["// @flow\nimport BaseFilterModel from \"./BaseFilterModel\";\n\nimport type { AttributeType, FilterType } from \"../types\";\n\n/**\n * StringFilterModel can handle string filters with multiple setting\n */\nexport default class StringFilterModel extends BaseFilterModel {\n _isValid: boolean = true;\n _value: string | null;\n _inputvalue: string;\n\n /**\n */\n constructor(data: Object, contributions: Object) {\n super(data, contributions);\n\n this.update(this.attribute, data.value ?? \"\");\n\n // when formatted value set this to initial input value\n this._inputvalue = this._value ?? \"\";\n }\n\n /**\n * Retrieve the parameters with its value for this filter\n */\n get params(): Array<{ name: string, value: ?string }> {\n if (!this.param) {\n return [];\n }\n\n return [\n {\n name: this.param,\n value: this.value,\n },\n ];\n }\n\n /**\n * Getting the value of the filter\n */\n get value(): string | null {\n return this._value;\n }\n\n /**\n */\n get inputvalue(): string {\n return this._inputvalue;\n }\n\n /**\n * Reset the value of this filter to undefined\n */\n reset(): FilterType {\n this._inputvalue = \"\";\n this._value = null;\n\n return this;\n }\n\n /**\n */\n get isValid(): boolean {\n return this._isValid;\n }\n\n /**\n * Update this filter with input name and value\n */\n update(attribute: AttributeType, value: string) {\n this._inputvalue = typeof value !== \"string\" ? value.toString() : value;\n\n if (this.operator === \"exactly\" || this.operator === \"isNot\") {\n const values = this.isMultiple\n ? this._inputvalue.split(\",\").map((val) => val.trim())\n : [this._inputvalue.trim()];\n\n const outputValues = [];\n for (const val of values) {\n const formattedValue = this.formatValue(val);\n if (formattedValue !== \"\") {\n outputValues.push(formattedValue);\n\n if (!this.attribute.validate(formattedValue)) {\n this._isValid = false;\n }\n }\n }\n\n this._value = outputValues.join(\",\");\n } else {\n this._value = value;\n }\n }\n\n /**\n */\n get operator(): string {\n return this.getContribution(\"operator\", \"\");\n }\n\n /**\n */\n formatValue(value: string): string {\n if (this.operator === \"exactly\" || this.operator === \"isNot\") {\n return this.attribute.formatValue(value);\n }\n return value;\n }\n}\n"],"mappings":";;;;;;;;;;AACA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA;AACA;AACA;AACe,MAAMC,iBAAiB,SAASC,wBAAe,CAAC;EAK7D;AACF;EACEC,WAAWA,CAACC,IAAY,EAAEC,aAAqB,EAAE;IAC/C,KAAK,CAACD,IAAI,EAAEC,aAAa,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA,oBAPT,IAAI;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAStB,IAAI,CAACC,MAAM,CAAC,IAAI,CAACC,SAAS,EAAEL,IAAI,CAACM,KAAK,IAAI,EAAE,CAAC;;IAE7C;IACA,IAAI,CAACC,WAAW,GAAG,IAAI,CAACC,MAAM,IAAI,EAAE;EACtC;;EAEA;AACF;AACA;EACE,IAAIC,MAAMA,CAAA,EAA4C;IACpD,IAAI,CAAC,IAAI,CAACC,KAAK,EAAE;MACf,OAAO,EAAE;IACX;IAEA,OAAO,CACL;MACEC,IAAI,EAAE,IAAI,CAACD,KAAK;MAChBJ,KAAK,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"StringFilterModel.js","names":["_BaseFilterModel","_interopRequireDefault","require","StringFilterModel","BaseFilterModel","constructor","data","contributions","_defineProperty2","default","update","attribute","value","_inputvalue","_value","params","param","name","removeFormat","inputvalue","reset","isValid","_isValid","toString","operator","_context","_context2","values","isMultiple","_map","split","call","val","_trim","outputValues","formattedValue","formatValue","push","validate","join","getContribution","isBSN","layouthint","has","isIBAN","isZipcode","replace","exports"],"sources":["../../../src/models/filters/StringFilterModel.js"],"sourcesContent":["// @flow\nimport BaseFilterModel from \"./BaseFilterModel\";\n\nimport type { AttributeType, FilterType } from \"../types\";\n\n/**\n * StringFilterModel can handle string filters with multiple setting\n */\nexport default class StringFilterModel extends BaseFilterModel {\n _isValid: boolean = true;\n _value: string | null;\n _inputvalue: string;\n\n /**\n */\n constructor(data: Object, contributions: Object) {\n super(data, contributions);\n\n this.update(this.attribute, data.value ?? \"\");\n\n // when formatted value set this to initial input value\n this._inputvalue = this._value ?? \"\";\n }\n\n /**\n * Retrieve the parameters with its value for this filter\n */\n get params(): Array<{ name: string, value: ?string }> {\n if (!this.param) {\n return [];\n }\n\n return [\n {\n name: this.param,\n value: this.removeFormat(this.value),\n },\n ];\n }\n\n /**\n * Getting the value of the filter\n */\n get value(): string | null {\n return this._value;\n }\n\n /**\n */\n get inputvalue(): string {\n return this._inputvalue;\n }\n\n /**\n * Reset the value of this filter to undefined\n */\n reset(): FilterType {\n this._inputvalue = \"\";\n this._value = null;\n\n return this;\n }\n\n /**\n */\n get isValid(): boolean {\n return this._isValid;\n }\n\n /**\n * Update this filter with input name and value\n */\n update(attribute: AttributeType, value: string) {\n this._isValid = true;\n this._inputvalue = typeof value !== \"string\" ? value.toString() : value;\n\n if (this.operator === \"exactly\" || this.operator === \"isNot\") {\n const values = this.isMultiple\n ? this._inputvalue.split(\",\").map((val) => val.trim())\n : [this._inputvalue.trim()];\n\n const outputValues = [];\n for (const val of values) {\n const formattedValue = this.formatValue(val);\n if (formattedValue !== \"\") {\n outputValues.push(formattedValue);\n\n if (!this.attribute.validate(formattedValue)) {\n this._isValid = false;\n }\n }\n }\n\n this._value = outputValues.join(\",\");\n } else {\n this._value = value;\n }\n }\n\n /**\n */\n get operator(): string {\n return this.getContribution(\"operator\", \"\");\n }\n\n /**\n */\n formatValue(value: string): string {\n if (this.operator === \"exactly\" || this.operator === \"isNot\") {\n return this.attribute.formatValue(value);\n }\n return value;\n }\n\n /**\n */\n isBSN(): boolean {\n return this.layouthint.has(\"bsn\");\n }\n\n /**\n */\n isIBAN(): boolean {\n return this.layouthint.has(\"iban\");\n }\n\n /**\n */\n isZipcode(): boolean {\n return this.layouthint.has(\"zipcode\");\n }\n\n /**\n */\n removeFormat(value: ?string): string {\n if (value == null || value.toString() === \"\") {\n return \"\";\n }\n\n if (\n (this.operator === \"exactly\" || this.operator === \"isNot\") &&\n (this.isIBAN() || this.isZipcode() || this.isBSN())\n ) {\n return value.replace(/[^a-z0-9,]/gi, \"\");\n }\n\n return value;\n }\n}\n"],"mappings":";;;;;;;;;;AACA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA;AACA;AACA;AACe,MAAMC,iBAAiB,SAASC,wBAAe,CAAC;EAK7D;AACF;EACEC,WAAWA,CAACC,IAAY,EAAEC,aAAqB,EAAE;IAC/C,KAAK,CAACD,IAAI,EAAEC,aAAa,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA,oBAPT,IAAI;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAStB,IAAI,CAACC,MAAM,CAAC,IAAI,CAACC,SAAS,EAAEL,IAAI,CAACM,KAAK,IAAI,EAAE,CAAC;;IAE7C;IACA,IAAI,CAACC,WAAW,GAAG,IAAI,CAACC,MAAM,IAAI,EAAE;EACtC;;EAEA;AACF;AACA;EACE,IAAIC,MAAMA,CAAA,EAA4C;IACpD,IAAI,CAAC,IAAI,CAACC,KAAK,EAAE;MACf,OAAO,EAAE;IACX;IAEA,OAAO,CACL;MACEC,IAAI,EAAE,IAAI,CAACD,KAAK;MAChBJ,KAAK,EAAE,IAAI,CAACM,YAAY,CAAC,IAAI,CAACN,KAAK;IACrC,CAAC,CACF;EACH;;EAEA;AACF;AACA;EACE,IAAIA,KAAKA,CAAA,EAAkB;IACzB,OAAO,IAAI,CAACE,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AAC,CAAC,IAAI,IAAI,CAACJ,KAAK,CAAC,CAAC,CAAC,EACnD;MACA,OAAO7B,KAAK,CAACkC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;IAC1C;IAEA,OAAOlC,KAAK;EACd;AACF;AAACmC,OAAA,CAAAtC,OAAA,GAAAN,iBAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import StringFilterModel from "../
|
|
1
|
+
import StringFilterModel from "../StringFilterModel";
|
|
2
2
|
|
|
3
3
|
describe("Zipcode Filter", () => {
|
|
4
4
|
let data;
|
|
@@ -25,7 +25,7 @@ describe("Zipcode Filter", () => {
|
|
|
25
25
|
expect(filter).toBeInstanceOf(StringFilterModel);
|
|
26
26
|
expect(filter.label).toBe("zipfilter");
|
|
27
27
|
expect(filter.name).toBe("zipfilter");
|
|
28
|
-
expect(filter.value).
|
|
28
|
+
expect(filter.value).toBe("");
|
|
29
29
|
expect(filter.inputvalue).toBe("");
|
|
30
30
|
expect(filter.type).toBe("string");
|
|
31
31
|
});
|
|
@@ -38,8 +38,8 @@ describe("Zipcode Filter", () => {
|
|
|
38
38
|
const filter = new StringFilterModel(stringFilterWithValue, contributions);
|
|
39
39
|
|
|
40
40
|
expect(filter).toBeInstanceOf(StringFilterModel);
|
|
41
|
-
expect(filter.
|
|
42
|
-
expect(filter.
|
|
41
|
+
expect(filter.value).toBe("1234 AB");
|
|
42
|
+
expect(filter.inputvalue).toBe("1234 AB");
|
|
43
43
|
expect(filter.params).toStrictEqual([
|
|
44
44
|
{
|
|
45
45
|
name: "zipfilter",
|
|
@@ -48,8 +48,8 @@ describe("Zipcode Filter", () => {
|
|
|
48
48
|
]);
|
|
49
49
|
|
|
50
50
|
filter.reset();
|
|
51
|
-
expect(filter.
|
|
52
|
-
expect(filter.
|
|
51
|
+
expect(filter.inputvalue).toBe("");
|
|
52
|
+
expect(filter.value).toBeNull();
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
it("modular ui input, zipcode space", () => {
|
|
@@ -58,8 +58,29 @@ describe("Zipcode Filter", () => {
|
|
|
58
58
|
filter.update(filter.attribute, "1234 AB");
|
|
59
59
|
|
|
60
60
|
expect(filter).toBeInstanceOf(StringFilterModel);
|
|
61
|
-
expect(filter.
|
|
62
|
-
expect(filter.
|
|
61
|
+
expect(filter.value).toBe("1234 AB");
|
|
62
|
+
expect(filter.inputvalue).toBe("1234 AB");
|
|
63
|
+
expect(filter.params).toStrictEqual([
|
|
64
|
+
{
|
|
65
|
+
name: "zipfilter",
|
|
66
|
+
value: "1234AB",
|
|
67
|
+
},
|
|
68
|
+
]);
|
|
69
|
+
|
|
70
|
+
expect(filter.isValid).toBe(true);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("modular ui input, exact", () => {
|
|
74
|
+
const filter = new StringFilterModel(data, {
|
|
75
|
+
...contributions,
|
|
76
|
+
multiplechoice: true,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
filter.update(filter.attribute, "1234 AB");
|
|
80
|
+
|
|
81
|
+
expect(filter).toBeInstanceOf(StringFilterModel);
|
|
82
|
+
expect(filter.value).toBe("1234 AB");
|
|
83
|
+
expect(filter.inputvalue).toBe("1234 AB");
|
|
63
84
|
expect(filter.params).toStrictEqual([
|
|
64
85
|
{
|
|
65
86
|
name: "zipfilter",
|
|
@@ -68,6 +89,19 @@ describe("Zipcode Filter", () => {
|
|
|
68
89
|
]);
|
|
69
90
|
|
|
70
91
|
expect(filter.isValid).toBe(true);
|
|
92
|
+
|
|
93
|
+
filter.update(filter.attribute, "1234 AB, 2345 CD");
|
|
94
|
+
|
|
95
|
+
expect(filter.isValid).toBe(true);
|
|
96
|
+
|
|
97
|
+
expect(filter.value).toBe("1234 AB,2345 CD");
|
|
98
|
+
expect(filter.inputvalue).toBe("1234 AB, 2345 CD");
|
|
99
|
+
expect(filter.params).toStrictEqual([
|
|
100
|
+
{
|
|
101
|
+
name: "zipfilter",
|
|
102
|
+
value: "1234AB,2345CD",
|
|
103
|
+
},
|
|
104
|
+
]);
|
|
71
105
|
});
|
|
72
106
|
|
|
73
107
|
it("modular ui input, wrong zipcode", () => {
|
|
@@ -76,8 +110,8 @@ describe("Zipcode Filter", () => {
|
|
|
76
110
|
filter.update(filter.attribute, "123");
|
|
77
111
|
|
|
78
112
|
expect(filter).toBeInstanceOf(StringFilterModel);
|
|
79
|
-
expect(filter.
|
|
80
|
-
expect(filter.
|
|
113
|
+
expect(filter.value).toBe("123");
|
|
114
|
+
expect(filter.inputvalue).toBe("123");
|
|
81
115
|
expect(filter.params).toStrictEqual([
|
|
82
116
|
{
|
|
83
117
|
name: "zipfilter",
|
|
@@ -97,8 +131,8 @@ describe("Zipcode Filter", () => {
|
|
|
97
131
|
filter.update(filter.attribute, "123");
|
|
98
132
|
|
|
99
133
|
expect(filter).toBeInstanceOf(StringFilterModel);
|
|
100
|
-
expect(filter.
|
|
101
|
-
expect(filter.
|
|
134
|
+
expect(filter.value).toBe("123");
|
|
135
|
+
expect(filter.inputvalue).toBe("123");
|
|
102
136
|
expect(filter.params).toStrictEqual([
|
|
103
137
|
{
|
|
104
138
|
name: "zipfilter",
|
package/package.json
CHANGED
|
@@ -33,7 +33,7 @@ export default class StringFilterModel extends BaseFilterModel {
|
|
|
33
33
|
return [
|
|
34
34
|
{
|
|
35
35
|
name: this.param,
|
|
36
|
-
value: this.value,
|
|
36
|
+
value: this.removeFormat(this.value),
|
|
37
37
|
},
|
|
38
38
|
];
|
|
39
39
|
}
|
|
@@ -71,6 +71,7 @@ export default class StringFilterModel extends BaseFilterModel {
|
|
|
71
71
|
* Update this filter with input name and value
|
|
72
72
|
*/
|
|
73
73
|
update(attribute: AttributeType, value: string) {
|
|
74
|
+
this._isValid = true;
|
|
74
75
|
this._inputvalue = typeof value !== "string" ? value.toString() : value;
|
|
75
76
|
|
|
76
77
|
if (this.operator === "exactly" || this.operator === "isNot") {
|
|
@@ -110,4 +111,39 @@ export default class StringFilterModel extends BaseFilterModel {
|
|
|
110
111
|
}
|
|
111
112
|
return value;
|
|
112
113
|
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
*/
|
|
117
|
+
isBSN(): boolean {
|
|
118
|
+
return this.layouthint.has("bsn");
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
*/
|
|
123
|
+
isIBAN(): boolean {
|
|
124
|
+
return this.layouthint.has("iban");
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
*/
|
|
129
|
+
isZipcode(): boolean {
|
|
130
|
+
return this.layouthint.has("zipcode");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
*/
|
|
135
|
+
removeFormat(value: ?string): string {
|
|
136
|
+
if (value == null || value.toString() === "") {
|
|
137
|
+
return "";
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (
|
|
141
|
+
(this.operator === "exactly" || this.operator === "isNot") &&
|
|
142
|
+
(this.isIBAN() || this.isZipcode() || this.isBSN())
|
|
143
|
+
) {
|
|
144
|
+
return value.replace(/[^a-z0-9,]/gi, "");
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return value;
|
|
148
|
+
}
|
|
113
149
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import StringFilterModel from "../
|
|
1
|
+
import StringFilterModel from "../StringFilterModel";
|
|
2
2
|
|
|
3
3
|
describe("Zipcode Filter", () => {
|
|
4
4
|
let data;
|
|
@@ -25,7 +25,7 @@ describe("Zipcode Filter", () => {
|
|
|
25
25
|
expect(filter).toBeInstanceOf(StringFilterModel);
|
|
26
26
|
expect(filter.label).toBe("zipfilter");
|
|
27
27
|
expect(filter.name).toBe("zipfilter");
|
|
28
|
-
expect(filter.value).
|
|
28
|
+
expect(filter.value).toBe("");
|
|
29
29
|
expect(filter.inputvalue).toBe("");
|
|
30
30
|
expect(filter.type).toBe("string");
|
|
31
31
|
});
|
|
@@ -38,8 +38,8 @@ describe("Zipcode Filter", () => {
|
|
|
38
38
|
const filter = new StringFilterModel(stringFilterWithValue, contributions);
|
|
39
39
|
|
|
40
40
|
expect(filter).toBeInstanceOf(StringFilterModel);
|
|
41
|
-
expect(filter.
|
|
42
|
-
expect(filter.
|
|
41
|
+
expect(filter.value).toBe("1234 AB");
|
|
42
|
+
expect(filter.inputvalue).toBe("1234 AB");
|
|
43
43
|
expect(filter.params).toStrictEqual([
|
|
44
44
|
{
|
|
45
45
|
name: "zipfilter",
|
|
@@ -48,8 +48,8 @@ describe("Zipcode Filter", () => {
|
|
|
48
48
|
]);
|
|
49
49
|
|
|
50
50
|
filter.reset();
|
|
51
|
-
expect(filter.
|
|
52
|
-
expect(filter.
|
|
51
|
+
expect(filter.inputvalue).toBe("");
|
|
52
|
+
expect(filter.value).toBeNull();
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
it("modular ui input, zipcode space", () => {
|
|
@@ -58,8 +58,29 @@ describe("Zipcode Filter", () => {
|
|
|
58
58
|
filter.update(filter.attribute, "1234 AB");
|
|
59
59
|
|
|
60
60
|
expect(filter).toBeInstanceOf(StringFilterModel);
|
|
61
|
-
expect(filter.
|
|
62
|
-
expect(filter.
|
|
61
|
+
expect(filter.value).toBe("1234 AB");
|
|
62
|
+
expect(filter.inputvalue).toBe("1234 AB");
|
|
63
|
+
expect(filter.params).toStrictEqual([
|
|
64
|
+
{
|
|
65
|
+
name: "zipfilter",
|
|
66
|
+
value: "1234AB",
|
|
67
|
+
},
|
|
68
|
+
]);
|
|
69
|
+
|
|
70
|
+
expect(filter.isValid).toBe(true);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("modular ui input, exact", () => {
|
|
74
|
+
const filter = new StringFilterModel(data, {
|
|
75
|
+
...contributions,
|
|
76
|
+
multiplechoice: true,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
filter.update(filter.attribute, "1234 AB");
|
|
80
|
+
|
|
81
|
+
expect(filter).toBeInstanceOf(StringFilterModel);
|
|
82
|
+
expect(filter.value).toBe("1234 AB");
|
|
83
|
+
expect(filter.inputvalue).toBe("1234 AB");
|
|
63
84
|
expect(filter.params).toStrictEqual([
|
|
64
85
|
{
|
|
65
86
|
name: "zipfilter",
|
|
@@ -68,6 +89,19 @@ describe("Zipcode Filter", () => {
|
|
|
68
89
|
]);
|
|
69
90
|
|
|
70
91
|
expect(filter.isValid).toBe(true);
|
|
92
|
+
|
|
93
|
+
filter.update(filter.attribute, "1234 AB, 2345 CD");
|
|
94
|
+
|
|
95
|
+
expect(filter.isValid).toBe(true);
|
|
96
|
+
|
|
97
|
+
expect(filter.value).toBe("1234 AB,2345 CD");
|
|
98
|
+
expect(filter.inputvalue).toBe("1234 AB, 2345 CD");
|
|
99
|
+
expect(filter.params).toStrictEqual([
|
|
100
|
+
{
|
|
101
|
+
name: "zipfilter",
|
|
102
|
+
value: "1234AB,2345CD",
|
|
103
|
+
},
|
|
104
|
+
]);
|
|
71
105
|
});
|
|
72
106
|
|
|
73
107
|
it("modular ui input, wrong zipcode", () => {
|
|
@@ -76,8 +110,8 @@ describe("Zipcode Filter", () => {
|
|
|
76
110
|
filter.update(filter.attribute, "123");
|
|
77
111
|
|
|
78
112
|
expect(filter).toBeInstanceOf(StringFilterModel);
|
|
79
|
-
expect(filter.
|
|
80
|
-
expect(filter.
|
|
113
|
+
expect(filter.value).toBe("123");
|
|
114
|
+
expect(filter.inputvalue).toBe("123");
|
|
81
115
|
expect(filter.params).toStrictEqual([
|
|
82
116
|
{
|
|
83
117
|
name: "zipfilter",
|
|
@@ -97,8 +131,8 @@ describe("Zipcode Filter", () => {
|
|
|
97
131
|
filter.update(filter.attribute, "123");
|
|
98
132
|
|
|
99
133
|
expect(filter).toBeInstanceOf(StringFilterModel);
|
|
100
|
-
expect(filter.
|
|
101
|
-
expect(filter.
|
|
134
|
+
expect(filter.value).toBe("123");
|
|
135
|
+
expect(filter.inputvalue).toBe("123");
|
|
102
136
|
expect(filter.params).toStrictEqual([
|
|
103
137
|
{
|
|
104
138
|
name: "zipfilter",
|