neo.mjs 5.1.15 → 5.1.17
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 +2 -1
- package/apps/form/view/FormContainer.mjs +19 -22
- package/apps/form/view/Viewport.mjs +3 -2
- package/apps/form/view/ViewportController.mjs +11 -0
- package/examples/ServiceWorker.mjs +2 -2
- package/package.json +1 -1
- package/src/DefaultConfig.mjs +2 -2
- package/src/component/Base.mjs +2 -0
- package/src/core/Base.mjs +1 -1
- package/src/form/Container.mjs +32 -4
- package/src/form/field/Text.mjs +5 -3
- package/src/layout/Card.mjs +48 -20
- package/src/vdom/Helper.mjs +0 -1
package/apps/ServiceWorker.mjs
CHANGED
package/apps/form/Overwrites.mjs
CHANGED
@@ -38,8 +38,14 @@ class FormContainer extends BaseFormContainer {
|
|
38
38
|
cls : ['form-header-label'],
|
39
39
|
flex : 'none'
|
40
40
|
}, '->', {
|
41
|
+
iconCls: ['fas', 'fa-file'],
|
41
42
|
handler: 'onValidatePageButtonClick',
|
42
|
-
text : 'Validate
|
43
|
+
text : 'Validate page'
|
44
|
+
}, {
|
45
|
+
iconCls: ['fas', 'fa-layer-group'],
|
46
|
+
handler: 'onValidateAllPagesButtonClick',
|
47
|
+
style : {marginLeft: '1em'},
|
48
|
+
text : 'Validate all pages'
|
43
49
|
}]
|
44
50
|
}, {
|
45
51
|
module : Container,
|
@@ -50,27 +56,18 @@ class FormContainer extends BaseFormContainer {
|
|
50
56
|
bind : {activeIndex: data => data.activeIndex}
|
51
57
|
},
|
52
58
|
|
53
|
-
items: [
|
54
|
-
module: () => import('./pages/Page1.mjs')
|
55
|
-
|
56
|
-
module: () => import('./pages/
|
57
|
-
|
58
|
-
module: () => import('./pages/
|
59
|
-
|
60
|
-
module: () => import('./pages/
|
61
|
-
|
62
|
-
module: () => import('./pages/
|
63
|
-
|
64
|
-
|
65
|
-
}, {
|
66
|
-
module: () => import('./pages/Page7.mjs')
|
67
|
-
}, {
|
68
|
-
module: () => import('./pages/Page8.mjs')
|
69
|
-
}, {
|
70
|
-
module: () => import('./pages/Page9.mjs')
|
71
|
-
}, {
|
72
|
-
module: () => import('./pages/Page10.mjs')
|
73
|
-
}]
|
59
|
+
items: [
|
60
|
+
{module: () => import('./pages/Page1.mjs')},
|
61
|
+
{module: () => import('./pages/Page2.mjs')},
|
62
|
+
{module: () => import('./pages/Page3.mjs')},
|
63
|
+
{module: () => import('./pages/Page4.mjs')},
|
64
|
+
{module: () => import('./pages/Page5.mjs')},
|
65
|
+
{module: () => import('./pages/Page6.mjs')},
|
66
|
+
{module: () => import('./pages/Page7.mjs')},
|
67
|
+
{module: () => import('./pages/Page8.mjs')},
|
68
|
+
{module: () => import('./pages/Page9.mjs')},
|
69
|
+
{module: () => import('./pages/Page10.mjs')}
|
70
|
+
]
|
74
71
|
}, {
|
75
72
|
module: Toolbar,
|
76
73
|
cls : ['form-footer'],
|
@@ -40,8 +40,9 @@ class Viewport extends BaseViewport {
|
|
40
40
|
}
|
41
41
|
}]
|
42
42
|
}, {
|
43
|
-
module: FormContainer,
|
44
|
-
|
43
|
+
module : FormContainer,
|
44
|
+
reference: 'main-form',
|
45
|
+
style : {margin: '20px'}
|
45
46
|
}],
|
46
47
|
/**
|
47
48
|
* @member {Object} layout={ntype:'hbox',align:'stretch'}
|
@@ -13,6 +13,17 @@ class ViewportController extends Component {
|
|
13
13
|
className: 'Form.view.ViewportController'
|
14
14
|
}
|
15
15
|
|
16
|
+
/**
|
17
|
+
* @param {Object} data
|
18
|
+
*/
|
19
|
+
onValidateAllPagesButtonClick(data) {
|
20
|
+
let me = this,
|
21
|
+
form = me.getReference('main-form'),
|
22
|
+
isValid = form.validate();
|
23
|
+
|
24
|
+
console.log('Form values', form.getValues());
|
25
|
+
}
|
26
|
+
|
16
27
|
/**
|
17
28
|
* @param {Object} data
|
18
29
|
*/
|
package/package.json
CHANGED
package/src/DefaultConfig.mjs
CHANGED
@@ -237,12 +237,12 @@ const DefaultConfig = {
|
|
237
237
|
useVdomWorker: true,
|
238
238
|
/**
|
239
239
|
* buildScripts/injectPackageVersion.mjs will update this value
|
240
|
-
* @default '5.1.
|
240
|
+
* @default '5.1.17'
|
241
241
|
* @memberOf! module:Neo
|
242
242
|
* @name config.version
|
243
243
|
* @type String
|
244
244
|
*/
|
245
|
-
version: '5.1.
|
245
|
+
version: '5.1.17'
|
246
246
|
};
|
247
247
|
|
248
248
|
Object.assign(DefaultConfig, {
|
package/src/component/Base.mjs
CHANGED
package/src/core/Base.mjs
CHANGED
@@ -378,7 +378,7 @@ class Base {
|
|
378
378
|
nsKey = nsArray.pop();
|
379
379
|
ns = Neo.ns(nsArray, false, me);
|
380
380
|
|
381
|
-
if (
|
381
|
+
if (ns[nsKey] === undefined) {
|
382
382
|
console.error('The used @config does not exist:', nsKey, nsArray.join('.'));
|
383
383
|
} else {
|
384
384
|
symbolNs = Neo.ns(nsArray, false, me[configSymbol]);
|
package/src/form/Container.mjs
CHANGED
@@ -30,6 +30,25 @@ class Container extends BaseContainer {
|
|
30
30
|
{tag: 'form', cn: [], onsubmit: 'return false;'}
|
31
31
|
}
|
32
32
|
|
33
|
+
/**
|
34
|
+
* @returns {Object[]}
|
35
|
+
*/
|
36
|
+
findNotLoadedModules(container=this) {
|
37
|
+
let modules = [];
|
38
|
+
|
39
|
+
container.items.forEach(item => {
|
40
|
+
if (Neo.typeOf(item.module) === 'Function') {
|
41
|
+
modules.push(item)
|
42
|
+
} else {
|
43
|
+
item.items && this.findNotLoadedModules(item);
|
44
|
+
}
|
45
|
+
});
|
46
|
+
|
47
|
+
console.log(modules);
|
48
|
+
|
49
|
+
return modules;
|
50
|
+
}
|
51
|
+
|
33
52
|
/**
|
34
53
|
* Either pass a field id or name
|
35
54
|
* @param {String} name
|
@@ -56,6 +75,8 @@ class Container extends BaseContainer {
|
|
56
75
|
getFields() {
|
57
76
|
let fields = [];
|
58
77
|
|
78
|
+
this.findNotLoadedModules();
|
79
|
+
|
59
80
|
ComponentManager.getChildComponents(this).forEach(item => {
|
60
81
|
item instanceof BaseField && fields.push(item);
|
61
82
|
});
|
@@ -149,16 +170,23 @@ class Container extends BaseContainer {
|
|
149
170
|
}
|
150
171
|
|
151
172
|
/**
|
152
|
-
* Updates the invalid state for all fields
|
153
|
-
* This can be useful for create
|
173
|
+
* Updates the invalid state for all fields which have validate() implemented.
|
174
|
+
* This can be useful for create-entity forms which show up "clean" until pressing a submit button.
|
154
175
|
* @returns {Boolean}
|
155
176
|
*/
|
156
177
|
validate() {
|
178
|
+
let isValid = true,
|
179
|
+
validField;
|
180
|
+
|
157
181
|
this.getFields().forEach(item => {
|
158
|
-
item.validate?.(false);
|
182
|
+
validField = item.validate?.(false);
|
183
|
+
|
184
|
+
if (!validField) {
|
185
|
+
isValid = false;
|
186
|
+
}
|
159
187
|
});
|
160
188
|
|
161
|
-
return
|
189
|
+
return isValid;
|
162
190
|
}
|
163
191
|
}
|
164
192
|
|
package/src/form/field/Text.mjs
CHANGED
@@ -570,7 +570,7 @@ class Text extends Base {
|
|
570
570
|
|
571
571
|
me.validate(); // silent
|
572
572
|
me.changeInputElKey('required', value ? value : null, true); // silent update
|
573
|
-
me.labelText = me.labelText;
|
573
|
+
me.labelText = me.labelText; // triggers a vdom update
|
574
574
|
}
|
575
575
|
|
576
576
|
/**
|
@@ -786,8 +786,10 @@ class Text extends Base {
|
|
786
786
|
labelOptionalText = me.labelOptionalText,
|
787
787
|
hasOptionalText = value.endsWith(labelOptionalText);
|
788
788
|
|
789
|
-
if (me.showOptionalText && !me.required
|
790
|
-
|
789
|
+
if (me.showOptionalText && !me.required) {
|
790
|
+
if (!hasOptionalText) {
|
791
|
+
value += labelOptionalText;
|
792
|
+
}
|
791
793
|
} else if (value && hasOptionalText) {
|
792
794
|
value = value.replace(labelOptionalText, '');
|
793
795
|
}
|
package/src/layout/Card.mjs
CHANGED
@@ -65,11 +65,10 @@ class Card extends Base {
|
|
65
65
|
sCfg = me.constructor,
|
66
66
|
needsUpdate = false,
|
67
67
|
removeInactiveCards = me.removeInactiveCards,
|
68
|
-
i, isActiveIndex, item, items, len, module,
|
68
|
+
i, isActiveIndex, item, items, len, module, wrapperCls;
|
69
69
|
|
70
70
|
if (Neo.isNumber(value) && container) {
|
71
71
|
items = container.items;
|
72
|
-
vdom = container.vdom;
|
73
72
|
len = items.length;
|
74
73
|
|
75
74
|
if (!items[value]) {
|
@@ -80,7 +79,7 @@ class Card extends Base {
|
|
80
79
|
for (i=0; i < len; i++) {
|
81
80
|
module = items[i].module;
|
82
81
|
|
83
|
-
if (i === value &&
|
82
|
+
if (i === value && Neo.typeOf(module) === 'Function') {
|
84
83
|
needsUpdate = true;
|
85
84
|
break;
|
86
85
|
}
|
@@ -91,23 +90,8 @@ class Card extends Base {
|
|
91
90
|
item = items[i];
|
92
91
|
module = item.module;
|
93
92
|
|
94
|
-
if (isActiveIndex &&
|
95
|
-
|
96
|
-
module = module.default;
|
97
|
-
proto = module.prototype;
|
98
|
-
wrapperCls = item.wrapperCls || proto.constructor.config.wrapperCls || [];
|
99
|
-
|
100
|
-
item.className = proto.className;
|
101
|
-
item.wrapperCls = [...wrapperCls, sCfg.itemCls];
|
102
|
-
item.module = module;
|
103
|
-
|
104
|
-
delete item.vdom;
|
105
|
-
|
106
|
-
items[i] = item = Neo.create(item);
|
107
|
-
|
108
|
-
container.fire('cardLoaded', {item});
|
109
|
-
|
110
|
-
vdom.cn[i] = item.vdom;
|
93
|
+
if (isActiveIndex && Neo.typeOf(module) === 'Function') {
|
94
|
+
item = await me.loadModule(item, i);
|
111
95
|
}
|
112
96
|
|
113
97
|
if (item instanceof Neo.core.Base) {
|
@@ -180,6 +164,50 @@ class Card extends Base {
|
|
180
164
|
container.wrapperCls = wrapperCls;
|
181
165
|
}
|
182
166
|
|
167
|
+
/**
|
168
|
+
* Loads a component.Base module which is defined via module: () => import('...')
|
169
|
+
* @param {Object} item
|
170
|
+
* @param {Number} [index]
|
171
|
+
* @returns {Neo.component.Base}
|
172
|
+
*/
|
173
|
+
async loadModule(item, index) {
|
174
|
+
let me = this,
|
175
|
+
containerId = me.containerId,
|
176
|
+
container = Neo.getComponent(containerId) || Neo.get(containerId), // the instance might not be registered yet
|
177
|
+
items = container.items,
|
178
|
+
sCfg = me.constructor,
|
179
|
+
vdom = container.vdom,
|
180
|
+
module = item.module,
|
181
|
+
proto, wrapperCls;
|
182
|
+
|
183
|
+
if (!Neo.isNumber(index)) {
|
184
|
+
index = items.indexOf(item);
|
185
|
+
}
|
186
|
+
|
187
|
+
module = await module();
|
188
|
+
module = module.default;
|
189
|
+
proto = module.prototype;
|
190
|
+
wrapperCls = item.wrapperCls || proto.constructor.config.wrapperCls || [];
|
191
|
+
|
192
|
+
item.className = proto.className;
|
193
|
+
item.wrapperCls = [...wrapperCls, sCfg.itemCls];
|
194
|
+
item.module = module;
|
195
|
+
|
196
|
+
delete item.vdom;
|
197
|
+
|
198
|
+
items[index] = item = Neo.create(item);
|
199
|
+
|
200
|
+
if (me.removeInactiveCards) {
|
201
|
+
item.vdom.removeDom = true;
|
202
|
+
}
|
203
|
+
|
204
|
+
container.fire('cardLoaded', {item});
|
205
|
+
|
206
|
+
vdom.cn[index] = item.vdom;
|
207
|
+
|
208
|
+
return item;
|
209
|
+
}
|
210
|
+
|
183
211
|
/**
|
184
212
|
* Removes all CSS rules from the container this layout is bound to.
|
185
213
|
* Gets called when switching to a different layout.
|