neo.mjs 8.4.2 → 8.5.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/apps/ServiceWorker.mjs +2 -2
- package/apps/portal/index.html +1 -1
- package/apps/portal/view/home/FooterContainer.mjs +1 -1
- package/apps/portal/view/learn/ContentComponent.mjs +1 -13
- package/examples/ServiceWorker.mjs +2 -2
- package/examples/grid/bigData/MainStore.mjs +12 -58
- package/examples/grid/cellEditing/MainContainer.mjs +10 -7
- package/examples/grid/container/MainContainer.mjs +26 -11
- package/package.json +2 -2
- package/resources/data/deck/learnneo/pages/tutorials/TodoList.md +1 -1
- package/resources/data/deck/training/pages/2023-02-05T17-44-53-815Z.md +6 -6
- package/resources/scss/src/apps/portal/examples/TabContainer.scss +5 -1
- package/resources/scss/src/grid/View.scss +4 -0
- package/src/DefaultConfig.mjs +2 -2
- package/src/component/Base.mjs +38 -11
- package/src/grid/Container.mjs +0 -40
- package/src/grid/View.mjs +62 -32
- package/src/grid/header/Toolbar.mjs +4 -2
- package/src/selection/Model.mjs +2 -2
- package/src/selection/grid/RowModel.mjs +16 -47
package/apps/ServiceWorker.mjs
CHANGED
package/apps/portal/index.html
CHANGED
@@ -84,18 +84,6 @@ class ContentComponent extends Component {
|
|
84
84
|
|
85
85
|
if (value) {
|
86
86
|
me.timeout(50).then(() => {
|
87
|
-
me.customComponents.forEach(component => {
|
88
|
-
if (!component.mounted && !component.rendering) {
|
89
|
-
component.render(true)
|
90
|
-
}
|
91
|
-
});
|
92
|
-
|
93
|
-
me.livePreviews.forEach(livePreview => {
|
94
|
-
if (!livePreview.mounted && !livePreview.rendering) {
|
95
|
-
livePreview.render(true)
|
96
|
-
}
|
97
|
-
});
|
98
|
-
|
99
87
|
Neo.main.addon.IntersectionObserver.register({
|
100
88
|
callback: 'findTopmostItem',
|
101
89
|
id : me.id,
|
@@ -110,7 +98,7 @@ class ContentComponent extends Component {
|
|
110
98
|
|
111
99
|
me.livePreviews.forEach(livePreview => {
|
112
100
|
livePreview.mounted = false
|
113
|
-
})
|
101
|
+
})
|
114
102
|
}
|
115
103
|
}
|
116
104
|
|
@@ -27,67 +27,21 @@ class MainStore extends Store {
|
|
27
27
|
}
|
28
28
|
|
29
29
|
firstnames = [
|
30
|
-
'Ashley',
|
31
|
-
'
|
32
|
-
'
|
33
|
-
'
|
34
|
-
'
|
35
|
-
'
|
36
|
-
'Jack',
|
37
|
-
'James',
|
38
|
-
'Jennifer',
|
39
|
-
'Jessica',
|
40
|
-
'Joe',
|
41
|
-
'John',
|
42
|
-
'Karen',
|
43
|
-
'Kelly',
|
44
|
-
'Kim',
|
45
|
-
'Linda',
|
46
|
-
'Lisa',
|
47
|
-
'Mary',
|
48
|
-
'Max',
|
49
|
-
'Michael',
|
50
|
-
'Nancy',
|
51
|
-
'Patricia',
|
52
|
-
'Rich',
|
53
|
-
'Robert',
|
54
|
-
'Sam',
|
55
|
-
'Sandra',
|
56
|
-
'Sarah',
|
57
|
-
'Susan',
|
58
|
-
'Thomas',
|
59
|
-
'Tobias'
|
30
|
+
'Amanda', 'Andrew', 'Anthony', 'Ashley', 'Barbara', 'Betty', 'Brian', 'Carol', 'Charles', 'Christopher',
|
31
|
+
'Daniel', 'David', 'Deborah', 'Donna', 'Elizabeth', 'Emily', 'George', 'Jack', 'James', 'Jennifer',
|
32
|
+
'Jessica', 'Joe', 'John', 'Joseph', 'Joshua', 'Karen', 'Kenneth', 'Kelly', 'Kevin', 'Kimberly',
|
33
|
+
'Linda', 'Lisa', 'Margaret', 'Mark', 'Mary', 'Matthew', 'Max', 'Melissa', 'Michael', 'Michelle',
|
34
|
+
'Nancy', 'Patricia', 'Paul', 'Richard', 'Robert', 'Ronald', 'Sam', 'Sandra', 'Sarah', 'Stephanie',
|
35
|
+
'Steven', 'Susan', 'Thomas', 'Timothy', 'Tobias', 'William'
|
60
36
|
]
|
61
37
|
|
62
38
|
lastnames = [
|
63
|
-
'Anderson',
|
64
|
-
'
|
65
|
-
'
|
66
|
-
'
|
67
|
-
'
|
68
|
-
'
|
69
|
-
'Hernandez',
|
70
|
-
'Jackson',
|
71
|
-
'Johnson',
|
72
|
-
'Jones',
|
73
|
-
'Lee',
|
74
|
-
'Lopez',
|
75
|
-
'Martin',
|
76
|
-
'Martinez',
|
77
|
-
'Miller',
|
78
|
-
'Moore',
|
79
|
-
'Perez',
|
80
|
-
'Rahder',
|
81
|
-
'Rodriguez',
|
82
|
-
'Smith',
|
83
|
-
'Taylor',
|
84
|
-
'Thomas',
|
85
|
-
'Thompson',
|
86
|
-
'Uhlig',
|
87
|
-
'Waters',
|
88
|
-
'White',
|
89
|
-
'Williams',
|
90
|
-
'Wilson'
|
39
|
+
'Adams', 'Allen', 'Anderson', 'Baker', 'Brown', 'Campbell', 'Carter', 'Clark', 'Davis', 'Flores',
|
40
|
+
'Garcia', 'Gonzales', 'Green', 'Hall', 'Harris', 'Hernandez', 'Hill', 'Jackson', 'Johnson', 'Jones',
|
41
|
+
'King', 'Lee', 'Lewis', 'Lopez', 'Martin', 'Martinez', 'Miller', 'Mitchell', 'Moore', 'Nelson',
|
42
|
+
'Nguyen', 'Perez', 'Rahder', 'Ramirez', 'Roberts', 'Rivera', 'Robinson', 'Rodriguez', 'Sanchez', 'Scott',
|
43
|
+
'Smith', 'Taylor', 'Thomas', 'Thompson', 'Torres', 'Uhlig', 'Walker', 'Waters', 'White', 'Williams',
|
44
|
+
'Wilson', 'Wright', 'Young'
|
91
45
|
]
|
92
46
|
|
93
47
|
/**
|
@@ -106,12 +106,11 @@ class MainContainer extends ConfigurationViewport {
|
|
106
106
|
*/
|
107
107
|
createExampleComponent() {
|
108
108
|
return {
|
109
|
-
module
|
110
|
-
bind
|
111
|
-
cellEditing
|
112
|
-
parentId
|
113
|
-
|
114
|
-
store : MainStore,
|
109
|
+
module : GridContainer,
|
110
|
+
bind : {store: 'stores.mainStore'},
|
111
|
+
cellEditing: true,
|
112
|
+
parentId : this.id,
|
113
|
+
store : MainStore,
|
115
114
|
|
116
115
|
columnDefaults: {
|
117
116
|
editable: true,
|
@@ -159,7 +158,11 @@ class MainContainer extends ConfigurationViewport {
|
|
159
158
|
dataField: 'githubId',
|
160
159
|
editable : false,
|
161
160
|
text : 'Github Id (Non-editable)'
|
162
|
-
}]
|
161
|
+
}],
|
162
|
+
|
163
|
+
viewConfig: {
|
164
|
+
selectionModel: CellModel
|
165
|
+
}
|
163
166
|
}
|
164
167
|
}
|
165
168
|
|
@@ -25,7 +25,8 @@ class MainContainer extends ConfigurationViewport {
|
|
25
25
|
}
|
26
26
|
|
27
27
|
createConfigurationComponents() {
|
28
|
-
let me
|
28
|
+
let me = this,
|
29
|
+
{view} = me.exampleComponent;
|
29
30
|
|
30
31
|
const selectionModelRadioDefaults = {
|
31
32
|
module : Radio,
|
@@ -45,34 +46,34 @@ class MainContainer extends ConfigurationViewport {
|
|
45
46
|
value : me.exampleComponent.height
|
46
47
|
}, {
|
47
48
|
...selectionModelRadioDefaults,
|
48
|
-
checked :
|
49
|
+
checked : view.selectionModel.ntype === 'selection-grid-cellmodel',
|
49
50
|
labelText : 'selectionModel',
|
50
51
|
listeners : {change: me.onRadioChange.bind(me, 'selectionModel', CellModel)},
|
51
52
|
style : {marginTop: '10px'},
|
52
53
|
valueLabelText: 'Cell'
|
53
54
|
}, {
|
54
55
|
...selectionModelRadioDefaults,
|
55
|
-
checked :
|
56
|
+
checked : view.selectionModel.ntype === 'selection-grid-columnmodel',
|
56
57
|
listeners : {change: me.onRadioChange.bind(me, 'selectionModel', ColumnModel)},
|
57
58
|
valueLabelText: 'Column'
|
58
59
|
}, {
|
59
60
|
...selectionModelRadioDefaults,
|
60
|
-
checked :
|
61
|
+
checked : view.selectionModel.ntype === 'selection-grid-rowmodel',
|
61
62
|
listeners : {change: me.onRadioChange.bind(me, 'selectionModel', RowModel)},
|
62
63
|
valueLabelText: 'Row'
|
63
64
|
}, {
|
64
65
|
...selectionModelRadioDefaults,
|
65
|
-
checked :
|
66
|
+
checked : view.selectionModel.ntype === 'selection-grid-cellcolumnmodel',
|
66
67
|
listeners : {change: me.onRadioChange.bind(me, 'selectionModel', CellColumnModel)},
|
67
68
|
valueLabelText: 'Cell & Column'
|
68
69
|
}, {
|
69
70
|
...selectionModelRadioDefaults,
|
70
|
-
checked :
|
71
|
+
checked : view.selectionModel.ntype === 'selection-grid-cellrowmodel',
|
71
72
|
listeners : {change: me.onRadioChange.bind(me, 'selectionModel', CellRowModel)},
|
72
73
|
valueLabelText: 'Cell & Row'
|
73
74
|
}, {
|
74
75
|
...selectionModelRadioDefaults,
|
75
|
-
checked :
|
76
|
+
checked : view.selectionModel.ntype === 'selection-grid-cellcolumnrowmodel',
|
76
77
|
listeners : {change: me.onRadioChange.bind(me, 'selectionModel', CellColumnRowModel)},
|
77
78
|
valueLabelText: 'Cell & Column & Row'
|
78
79
|
}]
|
@@ -80,9 +81,8 @@ class MainContainer extends ConfigurationViewport {
|
|
80
81
|
|
81
82
|
createExampleComponent() {
|
82
83
|
return {
|
83
|
-
module
|
84
|
-
|
85
|
-
store : MainStore,
|
84
|
+
module: GridContainer,
|
85
|
+
store : MainStore,
|
86
86
|
|
87
87
|
columnDefaults: {
|
88
88
|
width: 200
|
@@ -93,7 +93,22 @@ class MainContainer extends ConfigurationViewport {
|
|
93
93
|
{dataField: 'lastname', text: 'Lastname'},
|
94
94
|
{dataField: 'githubId', text: 'Github Id'},
|
95
95
|
{dataField: 'country', text: 'Country'}
|
96
|
-
]
|
96
|
+
],
|
97
|
+
|
98
|
+
viewConfig: {
|
99
|
+
selectionModel: CellModel
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
/**
|
105
|
+
* @param {String} config
|
106
|
+
* @param {String} value
|
107
|
+
* @param {Object} opts
|
108
|
+
*/
|
109
|
+
onRadioChange(config, value, opts) {
|
110
|
+
if (opts.value === true) { // we only want to listen to check events, not uncheck
|
111
|
+
this.exampleComponent.view[config] = value
|
97
112
|
}
|
98
113
|
}
|
99
114
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "neo.mjs",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.5.0",
|
4
4
|
"description": "The webworkers driven UI framework",
|
5
5
|
"type": "module",
|
6
6
|
"repository": {
|
@@ -52,7 +52,7 @@
|
|
52
52
|
"commander": "^13.0.0",
|
53
53
|
"cssnano": "^7.0.6",
|
54
54
|
"envinfo": "^7.14.0",
|
55
|
-
"fs-extra": "^11.
|
55
|
+
"fs-extra": "^11.3.0",
|
56
56
|
"highlightjs-line-numbers.js": "^2.9.0",
|
57
57
|
"inquirer": "^12.3.2",
|
58
58
|
"marked": "^15.0.6",
|
@@ -91,7 +91,7 @@ class MainComponent extends Component {
|
|
91
91
|
let me = this,
|
92
92
|
cls = ['far', 'fa-square'],
|
93
93
|
oldCls = ['fa', 'fa-check'],
|
94
|
-
node = VdomUtil.
|
94
|
+
node = VdomUtil.find(me.vdom, data.path[0].id).vdom;
|
95
95
|
|
96
96
|
if (data.path[0].cls.includes('fa-square')) {
|
97
97
|
cls = ['fa', 'fa-check'];
|
@@ -77,7 +77,7 @@ Use the utility method, replacing the statement referencing the vdom hierarchy.
|
|
77
77
|
|
78
78
|
<pre>
|
79
79
|
<s>view.vdom.cn[0].innerHTML = business.title;</s>
|
80
|
-
Neo.util.VDom.
|
80
|
+
Neo.util.VDom.find(view.vdom, 'title').vdom.innerHTML = business.title;
|
81
81
|
</pre>
|
82
82
|
|
83
83
|
|
@@ -86,17 +86,17 @@ calling the function.
|
|
86
86
|
|
87
87
|
Code a new class member.
|
88
88
|
|
89
|
-
|
89
|
+
find = Neo.util.VDom.find
|
90
90
|
|
91
91
|
Then use it in the after set method. Here's how that part of the code will look afterwards.
|
92
92
|
|
93
93
|
<pre style="color:gray; padding: 8px; border: thin solid lightgray;">
|
94
|
-
|
94
|
+
find = Neo.util.VDom.find;
|
95
95
|
|
96
96
|
afterSetBusiness(business){
|
97
97
|
if (!business) return;
|
98
98
|
const view = this.getReference('view');
|
99
|
-
this.
|
99
|
+
this.find(view.vdom, 'title').vdom.innerHTML = business.title;
|
100
100
|
view.update();
|
101
101
|
}
|
102
102
|
</pre>
|
@@ -129,7 +129,7 @@ Then back in the details view, update the vdom as follows.
|
|
129
129
|
|
130
130
|
Then modify the `afterSetBusiness()` method to update the element's `src`.
|
131
131
|
|
132
|
-
this.
|
132
|
+
this.find(view.vdom, 'thumbnail').vdom.src = business.imageUrl;
|
133
133
|
|
134
134
|
??Add the address
|
135
135
|
|
@@ -184,7 +184,7 @@ of thought and try it. If you get stuck, that code is given in the next lab step
|
|
184
184
|
|
185
185
|
Here's one way to code it. How does this compare to your solution?
|
186
186
|
|
187
|
-
this.
|
187
|
+
this.find(view.vdom, 'address').vdom.cn = business
|
188
188
|
.address
|
189
189
|
.map(item => ({tag: 'div', innerHTML: item}));
|
190
190
|
|
package/src/DefaultConfig.mjs
CHANGED
@@ -262,12 +262,12 @@ const DefaultConfig = {
|
|
262
262
|
useVdomWorker: true,
|
263
263
|
/**
|
264
264
|
* buildScripts/injectPackageVersion.mjs will update this value
|
265
|
-
* @default '8.
|
265
|
+
* @default '8.5.0'
|
266
266
|
* @memberOf! module:Neo
|
267
267
|
* @name config.version
|
268
268
|
* @type String
|
269
269
|
*/
|
270
|
-
version: '8.
|
270
|
+
version: '8.5.0'
|
271
271
|
};
|
272
272
|
|
273
273
|
Object.assign(DefaultConfig, {
|
package/src/component/Base.mjs
CHANGED
@@ -402,9 +402,12 @@ class Component extends Base {
|
|
402
402
|
}
|
403
403
|
|
404
404
|
/**
|
405
|
-
*
|
405
|
+
* If an update() gets called while a parent is updating, we store the id & distance of the
|
406
|
+
* requesting component inside the childUpdateCache of the parent, to get resolved once the update is done.
|
407
|
+
* e.g. childUpdateCache = {'neo-grid-view-1': {distance: 1, resolve: fn}}
|
408
|
+
* @member {Object} childUpdateCache={}
|
406
409
|
*/
|
407
|
-
childUpdateCache =
|
410
|
+
childUpdateCache = {}
|
408
411
|
/**
|
409
412
|
* Stores the updateDepth while an update is running to enable checks for parent update collisions
|
410
413
|
* @member {Number|null} currentUpdateDepth=null
|
@@ -1954,7 +1957,7 @@ class Component extends Base {
|
|
1954
1957
|
console.warn('vdom parent update conflict with:', parent, 'for:', me)
|
1955
1958
|
}
|
1956
1959
|
|
1957
|
-
|
1960
|
+
parent.childUpdateCache[me.id] = {distance, resolve};
|
1958
1961
|
|
1959
1962
|
// Adding the resolve fn to its own cache, since the parent will trigger
|
1960
1963
|
// a new update() directly on this cmp
|
@@ -2335,22 +2338,46 @@ class Component extends Base {
|
|
2335
2338
|
* @protected
|
2336
2339
|
*/
|
2337
2340
|
resolveVdomUpdate(resolve) {
|
2338
|
-
let me
|
2341
|
+
let me = this,
|
2342
|
+
hasChildUpdateCache = !Neo.isEmpty(me.childUpdateCache),
|
2343
|
+
component;
|
2339
2344
|
|
2340
2345
|
me.doResolveUpdateCache();
|
2341
2346
|
|
2342
2347
|
resolve?.();
|
2343
2348
|
|
2344
2349
|
if (me.needsVdomUpdate) {
|
2345
|
-
|
2346
|
-
|
2350
|
+
if (hasChildUpdateCache) {
|
2351
|
+
Object.entries(me.childUpdateCache).forEach(([key, value]) => {
|
2352
|
+
component = Neo.getComponent(key);
|
2353
|
+
|
2354
|
+
// The component might already got destroyed
|
2355
|
+
if (component) {
|
2356
|
+
// Pass callbacks to the resolver cache => getting executed once the following update is done
|
2357
|
+
value.resolve && NeoArray.add(me.resolveUpdateCache, value.resolve);
|
2358
|
+
|
2359
|
+
// Adjust the updateDepth to include the depth of all merged child updates
|
2360
|
+
if (me.updateDepth !== -1) {
|
2361
|
+
if (component.updateDepth === -1) {
|
2362
|
+
me.updateDepth = -1
|
2363
|
+
} else {
|
2364
|
+
// Since updateDepth is 1-based, we need to subtract 1 level
|
2365
|
+
me.updateDepth = me.updateDepth + value.distance + component.updateDepth - 1
|
2366
|
+
}
|
2367
|
+
}
|
2368
|
+
}
|
2369
|
+
});
|
2370
|
+
|
2371
|
+
me.childUpdateCache = {}
|
2372
|
+
}
|
2347
2373
|
|
2348
2374
|
me.update()
|
2349
|
-
} else if (
|
2350
|
-
|
2351
|
-
Neo.getComponent(
|
2352
|
-
|
2353
|
-
|
2375
|
+
} else if (hasChildUpdateCache) {
|
2376
|
+
Object.keys(me.childUpdateCache).forEach(key => {
|
2377
|
+
Neo.getComponent(key)?.update()
|
2378
|
+
});
|
2379
|
+
|
2380
|
+
me.childUpdateCache = {}
|
2354
2381
|
}
|
2355
2382
|
}
|
2356
2383
|
|
package/src/grid/Container.mjs
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import BaseContainer from '../container/Base.mjs';
|
2
2
|
import ClassSystemUtil from '../util/ClassSystem.mjs';
|
3
3
|
import GridView from './View.mjs';
|
4
|
-
import RowModel from '../selection/grid/RowModel.mjs';
|
5
4
|
import Store from '../data/Store.mjs';
|
6
5
|
import * as header from './header/_export.mjs';
|
7
6
|
|
@@ -58,11 +57,6 @@ class GridContainer extends BaseContainer {
|
|
58
57
|
* @member {String|null} headerToolbarId_=null
|
59
58
|
*/
|
60
59
|
headerToolbarId_: null,
|
61
|
-
/**
|
62
|
-
* Additional used keys for the selection model
|
63
|
-
* @member {Object} keys
|
64
|
-
*/
|
65
|
-
keys: {},
|
66
60
|
/**
|
67
61
|
* @member {String} layout='base'
|
68
62
|
*/
|
@@ -81,10 +75,6 @@ class GridContainer extends BaseContainer {
|
|
81
75
|
* @protected
|
82
76
|
*/
|
83
77
|
scrollbarId_: null,
|
84
|
-
/**
|
85
|
-
* @member {Neo.selection.Model} selectionModel_=null
|
86
|
-
*/
|
87
|
-
selectionModel_: null,
|
88
78
|
/**
|
89
79
|
* @member {Boolean} showHeaderFilters_=false
|
90
80
|
*/
|
@@ -294,16 +284,6 @@ class GridContainer extends BaseContainer {
|
|
294
284
|
}
|
295
285
|
}
|
296
286
|
|
297
|
-
/**
|
298
|
-
* Triggered after the selectionModel config got changed
|
299
|
-
* @param {Neo.selection.Model} value
|
300
|
-
* @param {Neo.selection.Model} oldValue
|
301
|
-
* @protected
|
302
|
-
*/
|
303
|
-
afterSetSelectionModel(value, oldValue) {
|
304
|
-
this.rendered && value.register(this)
|
305
|
-
}
|
306
|
-
|
307
287
|
/**
|
308
288
|
* Triggered after the showHeaderFilters config got changed
|
309
289
|
* @param {Boolean} value
|
@@ -352,18 +332,6 @@ class GridContainer extends BaseContainer {
|
|
352
332
|
return value || oldValue
|
353
333
|
}
|
354
334
|
|
355
|
-
/**
|
356
|
-
* Triggered before the selectionModel config gets changed.
|
357
|
-
* @param {Neo.selection.Model} value
|
358
|
-
* @param {Neo.selection.Model} oldValue
|
359
|
-
* @protected
|
360
|
-
*/
|
361
|
-
beforeSetSelectionModel(value, oldValue) {
|
362
|
-
oldValue?.destroy();
|
363
|
-
|
364
|
-
return ClassSystemUtil.beforeSetInstance(value, RowModel)
|
365
|
-
}
|
366
|
-
|
367
335
|
/**
|
368
336
|
* Triggered before the store config gets changed.
|
369
337
|
* @param {Neo.data.Store} value
|
@@ -534,14 +502,6 @@ class GridContainer extends BaseContainer {
|
|
534
502
|
return `${this.id}__wrapper`
|
535
503
|
}
|
536
504
|
|
537
|
-
/**
|
538
|
-
*
|
539
|
-
*/
|
540
|
-
onConstructed() {
|
541
|
-
super.onConstructed();
|
542
|
-
this.selectionModel?.register(this)
|
543
|
-
}
|
544
|
-
|
545
505
|
/**
|
546
506
|
* @param {Object} data
|
547
507
|
*/
|
package/src/grid/View.mjs
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
import
|
2
|
-
import
|
3
|
-
import
|
1
|
+
import ClassSystemUtil from '../util/ClassSystem.mjs';
|
2
|
+
import Component from '../component/Base.mjs';
|
3
|
+
import NeoArray from '../util/Array.mjs';
|
4
|
+
import RowModel from '../selection/grid/RowModel.mjs';
|
5
|
+
import VDomUtil from '../util/VDom.mjs';
|
4
6
|
|
5
7
|
/**
|
6
8
|
* @class Neo.grid.View
|
@@ -75,9 +77,10 @@ class GridView extends Component {
|
|
75
77
|
*/
|
76
78
|
isScrolling_: false,
|
77
79
|
/**
|
78
|
-
*
|
80
|
+
* Additional used keys for the selection model
|
81
|
+
* @member {Object} keys
|
79
82
|
*/
|
80
|
-
|
83
|
+
keys: {},
|
81
84
|
/**
|
82
85
|
* @member {String} role='rowgroup'
|
83
86
|
*/
|
@@ -91,6 +94,10 @@ class GridView extends Component {
|
|
91
94
|
* @member {Object} scrollPosition_={x:0,y:0}
|
92
95
|
*/
|
93
96
|
scrollPosition_: {x: 0, y: 0},
|
97
|
+
/**
|
98
|
+
* @member {Neo.selection.Model} selectionModel_=null
|
99
|
+
*/
|
100
|
+
selectionModel_: null,
|
94
101
|
/**
|
95
102
|
* @member {String} selectedRecordField='annotations.selected'
|
96
103
|
*/
|
@@ -103,10 +110,6 @@ class GridView extends Component {
|
|
103
110
|
* @member {Neo.data.Store|null} store_=null
|
104
111
|
*/
|
105
112
|
store_: null,
|
106
|
-
/**
|
107
|
-
* @member {Boolean} useRowRecordIds=true
|
108
|
-
*/
|
109
|
-
useRowRecordIds: true,
|
110
113
|
/**
|
111
114
|
* Stores the indexes of the first & last painted columns
|
112
115
|
* @member {Number[]} visibleColumns_=[0,0]
|
@@ -121,7 +124,7 @@ class GridView extends Component {
|
|
121
124
|
* @member {Object} _vdom
|
122
125
|
*/
|
123
126
|
_vdom:
|
124
|
-
{cn: [
|
127
|
+
{tabIndex: '-1', cn: [
|
125
128
|
{cn: []},
|
126
129
|
{cls: 'neo-grid-scrollbar'}
|
127
130
|
]}
|
@@ -143,10 +146,10 @@ class GridView extends Component {
|
|
143
146
|
* @member {String[]} selectedRows
|
144
147
|
*/
|
145
148
|
get selectedRows() {
|
146
|
-
let {
|
149
|
+
let {selectionModel} = this;
|
147
150
|
|
148
|
-
if (
|
149
|
-
return
|
151
|
+
if (selectionModel.ntype === 'selection-grid-rowmodel') {
|
152
|
+
return selectionModel.items
|
150
153
|
}
|
151
154
|
|
152
155
|
return []
|
@@ -319,6 +322,16 @@ class GridView extends Component {
|
|
319
322
|
}
|
320
323
|
}
|
321
324
|
|
325
|
+
/**
|
326
|
+
* Triggered after the selectionModel config got changed
|
327
|
+
* @param {Neo.selection.Model} value
|
328
|
+
* @param {Neo.selection.Model} oldValue
|
329
|
+
* @protected
|
330
|
+
*/
|
331
|
+
afterSetSelectionModel(value, oldValue) {
|
332
|
+
this.rendered && value.register(this)
|
333
|
+
}
|
334
|
+
|
322
335
|
/**
|
323
336
|
* Triggered after the startIndex config got changed
|
324
337
|
* @param {Number} value
|
@@ -428,8 +441,7 @@ class GridView extends Component {
|
|
428
441
|
id : cellId,
|
429
442
|
cls : cellCls,
|
430
443
|
role : 'gridcell',
|
431
|
-
style : rendererOutput.style || {}
|
432
|
-
tabIndex : '-1'
|
444
|
+
style : rendererOutput.style || {}
|
433
445
|
};
|
434
446
|
|
435
447
|
if (column.width) {
|
@@ -449,6 +461,18 @@ class GridView extends Component {
|
|
449
461
|
return cellConfig
|
450
462
|
}
|
451
463
|
|
464
|
+
/**
|
465
|
+
* Triggered before the selectionModel config gets changed.
|
466
|
+
* @param {Neo.selection.Model} value
|
467
|
+
* @param {Neo.selection.Model} oldValue
|
468
|
+
* @protected
|
469
|
+
*/
|
470
|
+
beforeSetSelectionModel(value, oldValue) {
|
471
|
+
oldValue?.destroy();
|
472
|
+
|
473
|
+
return ClassSystemUtil.beforeSetInstance(value, RowModel)
|
474
|
+
}
|
475
|
+
|
452
476
|
/**
|
453
477
|
* @param {Object} opts
|
454
478
|
* @param {Object} opts.record
|
@@ -467,8 +491,6 @@ class GridView extends Component {
|
|
467
491
|
trCls = me.getTrClass(record, rowIndex),
|
468
492
|
config, column, endIndex, gridRow, i, startIndex;
|
469
493
|
|
470
|
-
me.recordVnodeMap[id] = rowIndex;
|
471
|
-
|
472
494
|
if (rowIndex % 2 !== 0) {
|
473
495
|
trCls.push('neo-even')
|
474
496
|
}
|
@@ -491,7 +513,6 @@ class GridView extends Component {
|
|
491
513
|
cls : trCls,
|
492
514
|
cn : [],
|
493
515
|
role : 'row',
|
494
|
-
tabIndex : '-1',
|
495
516
|
|
496
517
|
style: {
|
497
518
|
height : me.rowHeight + 'px',
|
@@ -657,27 +678,28 @@ class GridView extends Component {
|
|
657
678
|
|
658
679
|
/**
|
659
680
|
* @param {String} rowId
|
660
|
-
* @returns {
|
681
|
+
* @returns {Record}
|
661
682
|
*/
|
662
683
|
getRecordByRowId(rowId) {
|
663
|
-
|
684
|
+
let recordId = rowId.split('__')[2],
|
685
|
+
{store} = this,
|
686
|
+
{model} = store,
|
687
|
+
keyField = model?.getField(store.getKeyProperty()),
|
688
|
+
keyType = keyField?.type?.toLowerCase();
|
689
|
+
|
690
|
+
if (keyType === 'int' || keyType === 'integer') {
|
691
|
+
recordId = parseInt(recordId)
|
692
|
+
}
|
693
|
+
|
694
|
+
return store.get(recordId)
|
664
695
|
}
|
665
696
|
|
666
697
|
/**
|
667
698
|
* @param {Object} record
|
668
|
-
* @param {Number} [index]
|
669
699
|
* @returns {String}
|
670
700
|
*/
|
671
|
-
getRowId(record
|
672
|
-
|
673
|
-
{store} = me;
|
674
|
-
|
675
|
-
if (me.useRowRecordIds) {
|
676
|
-
return `${me.id}__tr__${record[store.keyProperty]}`
|
677
|
-
} else {
|
678
|
-
index = Neo.isNumber(index) ? index : store.indexOf(record);
|
679
|
-
return me.vdom.cn[index]?.id || Neo.getId('tr')
|
680
|
-
}
|
701
|
+
getRowId(record) {
|
702
|
+
return `${this.id}__tr__${record[this.store.getKeyProperty()]}`
|
681
703
|
}
|
682
704
|
|
683
705
|
/**
|
@@ -727,6 +749,14 @@ class GridView extends Component {
|
|
727
749
|
this.fireCellEvent(data, 'cellDoubleClick')
|
728
750
|
}
|
729
751
|
|
752
|
+
/**
|
753
|
+
*
|
754
|
+
*/
|
755
|
+
onConstructed() {
|
756
|
+
super.onConstructed();
|
757
|
+
this.selectionModel?.register(this)
|
758
|
+
}
|
759
|
+
|
730
760
|
/**
|
731
761
|
* @param {Object} data
|
732
762
|
*/
|
@@ -768,7 +798,7 @@ class GridView extends Component {
|
|
768
798
|
* @param {Neo.data.Model} opts.model The model instance of the changed record
|
769
799
|
* @param {Object} opts.record
|
770
800
|
*/
|
771
|
-
onStoreRecordChange({fields,
|
801
|
+
onStoreRecordChange({fields, record}) {
|
772
802
|
let me = this,
|
773
803
|
fieldNames = fields.map(field => field.name),
|
774
804
|
needsUpdate = false,
|
@@ -106,7 +106,8 @@ class Toolbar extends BaseToolbar {
|
|
106
106
|
*
|
107
107
|
*/
|
108
108
|
createItems() {
|
109
|
-
let me
|
109
|
+
let me = this,
|
110
|
+
{mounted} = me;
|
110
111
|
|
111
112
|
me.itemDefaults.showHeaderFilter = me.showHeaderFilters;
|
112
113
|
|
@@ -130,7 +131,8 @@ class Toolbar extends BaseToolbar {
|
|
130
131
|
});
|
131
132
|
|
132
133
|
me.promiseUpdate().then(() => {
|
133
|
-
|
134
|
+
// To prevent duplicate calls, we need to check the mounted state before the update call
|
135
|
+
mounted && me.passSizeToView()
|
134
136
|
})
|
135
137
|
}
|
136
138
|
|
package/src/selection/Model.mjs
CHANGED
@@ -189,11 +189,11 @@ class Model extends Base {
|
|
189
189
|
*/
|
190
190
|
register(component) {
|
191
191
|
let me = this,
|
192
|
-
cls = component.
|
192
|
+
cls = component.wrapperCls || [];
|
193
193
|
|
194
194
|
if (me.cls && !cls.includes(me.cls)) {
|
195
195
|
cls.push(me.cls);
|
196
|
-
component.
|
196
|
+
component.wrapperCls = cls
|
197
197
|
}
|
198
198
|
|
199
199
|
me.view = component;
|
@@ -30,7 +30,7 @@ class RowModel extends BaseModel {
|
|
30
30
|
addDomListener() {
|
31
31
|
let me = this;
|
32
32
|
|
33
|
-
me.view.on('rowClick', me.onRowClick, me)
|
33
|
+
me.view.gridContainer.on('rowClick', me.onRowClick, me)
|
34
34
|
}
|
35
35
|
|
36
36
|
/**
|
@@ -44,76 +44,45 @@ class RowModel extends BaseModel {
|
|
44
44
|
super.destroy(...args)
|
45
45
|
}
|
46
46
|
|
47
|
-
/**
|
48
|
-
* Finds the matching table row for a given row index
|
49
|
-
* @param {Number} index row index
|
50
|
-
* @returns {String|null} The table row node id
|
51
|
-
*/
|
52
|
-
getRowId(index) {
|
53
|
-
if (index < 0 || this.view.store.getCount() < index) {
|
54
|
-
return null
|
55
|
-
}
|
56
|
-
|
57
|
-
return this.view.vdom.cn[0].cn[1].cn[index].id
|
58
|
-
}
|
59
|
-
|
60
|
-
/**
|
61
|
-
* Finds the matching table row for a given event path
|
62
|
-
* @param {Object} path The event path
|
63
|
-
* @returns {Object|null} The node containing the table row class or null
|
64
|
-
* @protected
|
65
|
-
*/
|
66
|
-
static getRowNode(path) {
|
67
|
-
let i = 0,
|
68
|
-
len = path.length,
|
69
|
-
node = null;
|
70
|
-
|
71
|
-
for (; i < len; i++) {
|
72
|
-
if (path[i].cls.includes('neo-grid-row')) {
|
73
|
-
node = path[i]
|
74
|
-
}
|
75
|
-
}
|
76
|
-
|
77
|
-
return node
|
78
|
-
}
|
79
|
-
|
80
47
|
/**
|
81
48
|
* @param {Object} data
|
82
49
|
*/
|
83
50
|
onKeyDownDown(data) {
|
84
|
-
this.onNavKeyRow(
|
51
|
+
this.onNavKeyRow(1)
|
85
52
|
}
|
86
53
|
|
87
54
|
/**
|
88
55
|
* @param {Object} data
|
89
56
|
*/
|
90
57
|
onKeyDownUp(data) {
|
91
|
-
this.onNavKeyRow(
|
58
|
+
this.onNavKeyRow(-1)
|
92
59
|
}
|
93
60
|
|
94
61
|
/**
|
95
|
-
* @param {Object} data
|
96
62
|
* @param {Number} step
|
97
63
|
*/
|
98
|
-
onNavKeyRow(
|
64
|
+
onNavKeyRow(step) {
|
99
65
|
let me = this,
|
100
|
-
node = RowModel.getRowNode(data.path),
|
101
66
|
{view} = me,
|
102
67
|
{store} = view,
|
103
|
-
|
104
|
-
newIndex
|
105
|
-
|
106
|
-
|
68
|
+
currentIndex = 0,
|
69
|
+
newIndex, newRecord, rowId;
|
70
|
+
|
71
|
+
if (me.hasSelection()) {
|
72
|
+
currentIndex = store.indexOf(view.getRecordByRowId(me.items[0]))
|
73
|
+
}
|
74
|
+
|
75
|
+
newIndex = (currentIndex + step) % store.getCount();
|
107
76
|
|
108
77
|
while (newIndex < 0) {
|
109
78
|
newIndex += store.getCount()
|
110
79
|
}
|
111
80
|
|
112
|
-
|
81
|
+
newRecord = store.getAt(newIndex);
|
82
|
+
rowId = view.getRowId(newRecord);
|
113
83
|
|
114
|
-
if (
|
115
|
-
me.select(
|
116
|
-
view.focus(id);
|
84
|
+
if (rowId) {
|
85
|
+
me.select(rowId);
|
117
86
|
|
118
87
|
view.fire('select', {
|
119
88
|
record: store.getAt(newIndex)
|