neo.mjs 5.5.10 → 5.5.11
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/apps/ServiceWorker.mjs +2 -2
- package/apps/form/Overwrites.mjs +0 -4
- package/apps/form/view/pages/Page11.mjs +26 -8
- package/examples/ServiceWorker.mjs +2 -2
- package/package.json +1 -1
- package/src/DefaultConfig.mjs +2 -2
- package/src/container/Base.mjs +13 -5
- package/src/form/field/ZipCode.mjs +83 -1
package/apps/ServiceWorker.mjs
CHANGED
package/apps/form/Overwrites.mjs
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import FormPageContainer from '../FormPageContainer.mjs';
|
2
|
+
import SelectField from '../../../../src/form/field/Select.mjs';
|
2
3
|
import ZipCodeField from '../../../../src/form/field/ZipCode.mjs';
|
3
4
|
|
4
5
|
/**
|
@@ -16,15 +17,32 @@ class Page11 extends FormPageContainer {
|
|
16
17
|
* @member {Object[]} items
|
17
18
|
*/
|
18
19
|
items: [{
|
19
|
-
module
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
module : SelectField,
|
21
|
+
editable : false,
|
22
|
+
forceSelection: true,
|
23
|
+
labelText : 'Country',
|
24
|
+
name : 'page11.countryfield',
|
25
|
+
reference : 'country',
|
26
|
+
value : 'DE',
|
27
|
+
|
28
|
+
store: {
|
29
|
+
data: [
|
30
|
+
{id: 'DE', name: 'Germany'},
|
31
|
+
{id: 'Others', name: 'Others'}
|
32
|
+
]
|
33
|
+
}
|
34
|
+
}, {
|
35
|
+
module : ZipCodeField,
|
36
|
+
countryField: 'country',
|
37
|
+
labelText : 'Munich',
|
38
|
+
name : 'page11.field1',
|
39
|
+
required : true,
|
40
|
+
value : '80796'
|
24
41
|
}, {
|
25
|
-
module
|
26
|
-
|
27
|
-
|
42
|
+
module : ZipCodeField,
|
43
|
+
countryField: 'country',
|
44
|
+
labelText : 'Page 11 Field 2',
|
45
|
+
name : 'page11.field2'
|
28
46
|
}]
|
29
47
|
}
|
30
48
|
}
|
package/package.json
CHANGED
package/src/DefaultConfig.mjs
CHANGED
@@ -236,12 +236,12 @@ const DefaultConfig = {
|
|
236
236
|
useVdomWorker: true,
|
237
237
|
/**
|
238
238
|
* buildScripts/injectPackageVersion.mjs will update this value
|
239
|
-
* @default '5.5.
|
239
|
+
* @default '5.5.11'
|
240
240
|
* @memberOf! module:Neo
|
241
241
|
* @name config.version
|
242
242
|
* @type String
|
243
243
|
*/
|
244
|
-
version: '5.5.
|
244
|
+
version: '5.5.11'
|
245
245
|
};
|
246
246
|
|
247
247
|
Object.assign(DefaultConfig, {
|
package/src/container/Base.mjs
CHANGED
@@ -507,18 +507,26 @@ class Base extends Component {
|
|
507
507
|
|
508
508
|
/**
|
509
509
|
* Clears the item array
|
510
|
-
* @param {Boolean}
|
511
|
-
* @param {Boolean}
|
510
|
+
* @param {Boolean} destroyItems=true
|
511
|
+
* @param {Boolean} silent=false
|
512
512
|
*/
|
513
|
-
removeAll(
|
513
|
+
removeAll(destroyItems=true, silent=false) {
|
514
514
|
let me = this;
|
515
515
|
|
516
|
+
me.items.forEach(item => {
|
517
|
+
if (destroyItems) {
|
518
|
+
item.destroy(true, true)
|
519
|
+
} else {
|
520
|
+
item.mounted = false
|
521
|
+
}
|
522
|
+
});
|
523
|
+
|
516
524
|
me.items = [];
|
517
525
|
|
518
526
|
me.getVdomItemsRoot().cn = [];
|
519
527
|
|
520
|
-
if (!silent ||
|
521
|
-
me.update()
|
528
|
+
if (!silent || destroyItems) {
|
529
|
+
me.update()
|
522
530
|
}
|
523
531
|
}
|
524
532
|
|
@@ -7,6 +7,15 @@ import Text from './Text.mjs';
|
|
7
7
|
* @extends Neo.form.field.Text
|
8
8
|
*/
|
9
9
|
class ZipCode extends Text {
|
10
|
+
/**
|
11
|
+
* @member {Object} countryCodes
|
12
|
+
* @protected
|
13
|
+
* @static
|
14
|
+
*/
|
15
|
+
static countryCodes = {
|
16
|
+
DE: /^(?!01000|99999)(0[1-9]\d{3}|[1-9]\d{4})$/
|
17
|
+
}
|
18
|
+
|
10
19
|
static config = {
|
11
20
|
/**
|
12
21
|
* @member {String} className='Neo.form.field.ZipCode'
|
@@ -17,7 +26,80 @@ class ZipCode extends Text {
|
|
17
26
|
* @member {String} ntype='zipcodefield'
|
18
27
|
* @protected
|
19
28
|
*/
|
20
|
-
ntype: 'zipcodefield'
|
29
|
+
ntype: 'zipcodefield',
|
30
|
+
/**
|
31
|
+
* @member {String} countryCode_=null
|
32
|
+
*/
|
33
|
+
countryCode_: null,
|
34
|
+
/**
|
35
|
+
* You can either pass a field instance or a field reference
|
36
|
+
* @member {Neo.form.field.Base|String|null} countryField_=null
|
37
|
+
*/
|
38
|
+
countryField_: null,
|
39
|
+
/**
|
40
|
+
* data passes inputPattern, maxLength, minLength & valueLength properties
|
41
|
+
* @member {Function} errorTextInputPattern=data=>`Input pattern violation: ${data.inputPattern}`
|
42
|
+
*/
|
43
|
+
errorTextInputPattern: data => `Not a valid zip code`
|
44
|
+
}
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Triggered after the countryCode config got changed
|
48
|
+
* @param {String|null} value
|
49
|
+
* @param {String|null} oldValue
|
50
|
+
* @protected
|
51
|
+
*/
|
52
|
+
afterSetCountryCode(value, oldValue) {
|
53
|
+
let me = this;
|
54
|
+
|
55
|
+
me.inputPattern = ZipCode.countryCodes[value] || null;
|
56
|
+
|
57
|
+
!me.clean && me.validate(false);
|
58
|
+
}
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Triggered after the countryField config got changed
|
62
|
+
* @param {Neo.form.field.Base|null} value
|
63
|
+
* @param {Neo.form.field.Base|null} oldValue
|
64
|
+
* @protected
|
65
|
+
*/
|
66
|
+
afterSetCountryField(value, oldValue) {
|
67
|
+
if (value) {
|
68
|
+
let me = this;
|
69
|
+
|
70
|
+
value.on({
|
71
|
+
change: me.onCountryFieldChange,
|
72
|
+
scope : me
|
73
|
+
});
|
74
|
+
|
75
|
+
value.value && me.onCountryFieldChange({
|
76
|
+
component: value,
|
77
|
+
record : value.record,
|
78
|
+
value : value.value
|
79
|
+
})
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Triggered before the countryField config gets changed
|
85
|
+
* @param {Neo.form.field.Base|String|null} value
|
86
|
+
* @param {Neo.form.field.Base|String|null} oldValue
|
87
|
+
* @returns {Neo.form.field.Base|null}
|
88
|
+
* @protected
|
89
|
+
*/
|
90
|
+
beforeSetCountryField(value, oldValue) {
|
91
|
+
if (Neo.isString(value)) {
|
92
|
+
return this.up().getReference(value)
|
93
|
+
}
|
94
|
+
|
95
|
+
return value;
|
96
|
+
}
|
97
|
+
|
98
|
+
/**
|
99
|
+
* @param {Object} data
|
100
|
+
*/
|
101
|
+
onCountryFieldChange(data) {
|
102
|
+
this.countryCode = data.record?.[data.component.valueField];
|
21
103
|
}
|
22
104
|
}
|
23
105
|
|