Skip to content

Commit 0bc04c3

Browse files
committed
grid.column.Progress #6546
1 parent f2e4975 commit 0bc04c3

11 files changed

Lines changed: 137 additions & 9 deletions

File tree

examples/grid/bigData/GridContainer.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class GridContainer extends BaseGridContainer {
4646
* @protected
4747
*/
4848
afterSetAmountColumns(value, oldValue) {
49-
let i = 6,
49+
let i = 7,
5050
columns = [
5151
{type: 'index', dataField: 'id', text: '#', width: 60},
5252
{cellAlign: 'left', dataField: 'firstname', defaultSortDirection: 'ASC', text: 'Firstname', width: 150},
@@ -57,7 +57,8 @@ class GridContainer extends BaseGridContainer {
5757
text : record.firstname + ' ++',
5858
width : 130
5959
})},
60-
{type: 'animatedChange', dataField: 'counter', text: 'Counter'}
60+
{type: 'animatedChange', dataField: 'counter', text: 'Counter'},
61+
{type: 'progress', dataField: 'progress', text: 'Progress', width: 150}
6162
];
6263

6364
for (; i <= value; i++) {

examples/grid/bigData/MainModel.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ class MainModel extends Model {
2424
* @protected
2525
*/
2626
afterSetAmountColumns(value, oldValue) {
27-
let i = 6,
27+
let i = 7,
2828
fields = [
2929
{name: 'id', type: 'Int'},
3030
{name: 'countAction'},
3131
{name: 'counter', type: 'Int'},
3232
{name: 'firstname', type: 'String'},
33-
{name: 'lastname', type: 'String'}
33+
{name: 'lastname', type: 'String'},
34+
{name: 'progress', type: 'Int'}
3435
];
3536

3637
for (; i <= value; i++) {

examples/grid/bigData/MainStore.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,13 @@ class MainStore extends Store {
113113
column, record;
114114

115115
for (; row < amountRows; row++) {
116-
column = 5;
116+
column = 7;
117117
record = {
118118
id : row + 1,
119119
counter : Math.round(Math.random() * 100),
120120
firstname: me.firstnames[Math.floor(Math.random() * amountFirstnames)],
121-
lastname : me.lastnames[ Math.floor(Math.random() * amountLastnames)]
121+
lastname : me.lastnames[ Math.floor(Math.random() * amountLastnames)],
122+
progress : Math.round(Math.random() * 100)
122123
};
123124

124125
for (; column <= amountColumns; column++) {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.neo-grid-cell {
2+
.neo-progress-wrapper {
3+
progress[value] {
4+
appearance: none;
5+
border : none;
6+
display : flex;
7+
height : var(--grid-cell-progress-height);
8+
9+
@-moz-document url-prefix() {
10+
background-color: var(--grid-cell-progress-track-color);
11+
border-radius : var(--grid-cell-progress-border-radius);
12+
box-shadow : 0 2px 5px rgba(0, 0, 0, 0.25) inset;
13+
}
14+
15+
// for webkit the progress-bar is the track
16+
&::-webkit-progress-bar {
17+
background-color: var(--grid-cell-progress-track-color);
18+
border-radius : var(--grid-cell-progress-border-radius);
19+
box-shadow : 0 2px 5px rgba(0, 0, 0, 0.25) inset;
20+
}
21+
22+
// for mozilla the progress-bar is the active range
23+
&::-moz-progress-bar {
24+
background-color: var(--grid-cell-progress-active-color);
25+
border-radius : var(--grid-cell-progress-border-radius);
26+
}
27+
28+
&::-webkit-progress-value {
29+
background-color: var(--grid-cell-progress-active-color);
30+
border-radius : var(--grid-cell-progress-border-radius);
31+
}
32+
}
33+
}
34+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
:root .neo-theme-dark { // .neo-grid-cell
2+
--grid-cell-progress-active-color : #5d83a7;
3+
--grid-cell-progress-border-radius: 2px;
4+
--grid-cell-progress-height : 10px;
5+
--grid-cell-progress-track-color : #333;
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
:root .neo-theme-light { // .neo-grid-cell
2+
--grid-cell-progress-active-color : #5d83a7;
3+
--grid-cell-progress-border-radius: 2px;
4+
--grid-cell-progress-height : 10px;
5+
--grid-cell-progress-track-color : #eee;
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
:root .neo-theme-neo-light { // .neo-grid-cell
2+
--grid-cell-progress-active-color : #5d83a7;
3+
--grid-cell-progress-border-radius: 2px;
4+
--grid-cell-progress-height : 10px;
5+
--grid-cell-progress-track-color : #eee;
6+
}

src/grid/Container.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class GridContainer extends BaseContainer {
2222
animatedChange: column.AnimatedChange,
2323
column : column.Base,
2424
component : column.Component,
25-
index : column.Index
25+
index : column.Index,
26+
progress : column.Progress
2627
}
2728
/**
2829
* @member {Object} delayable

src/grid/column/Component.mjs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ class Component extends Column {
1515
* @member {Function|Object|null} component=null
1616
*/
1717
component: null,
18+
/**
19+
* @member {Object} defaults
20+
* @protected
21+
*/
22+
defaults: null,
1823
/**
1924
* Components can delegate event listeners (or button handlers) into methods somewhere inside
2025
* the view controller or component tree hierarchy.
@@ -37,6 +42,16 @@ class Component extends Column {
3742
*/
3843
map = new Map()
3944

45+
/**
46+
* Override as needed inside class extensions
47+
* @param {Object} config
48+
* @param {Record} record
49+
* @returns {Object}
50+
*/
51+
applyRecordConfigs(config, record) {
52+
return config
53+
}
54+
4055
/**
4156
* @param {Object} data
4257
* @param {Neo.column.Base} data.column
@@ -54,14 +69,16 @@ class Component extends Column {
5469
{appName, view, windowId} = gridContainer,
5570
me = this,
5671
{recordProperty} = me,
57-
id = `${me.id}-component-${rowIndex % (view.availableRows + 2 * view.bufferRowRange)}`,
72+
id = me.getComponentId(rowIndex),
5873
component = me.map.get(id),
5974
componentConfig = me.component;
6075

6176
if (Neo.typeOf(componentConfig) === 'Function') {
6277
componentConfig = componentConfig(data)
6378
}
6479

80+
componentConfig = me.applyRecordConfigs(componentConfig, record);
81+
6582
if (component) {
6683
delete componentConfig.className;
6784
delete componentConfig.module;
@@ -73,6 +90,7 @@ class Component extends Column {
7390
component.set(componentConfig)
7491
} else {
7592
component = Neo.create({
93+
...me.defaults,
7694
...componentConfig,
7795
appName,
7896
id,
@@ -88,6 +106,17 @@ class Component extends Column {
88106

89107
return component.createVdomReference()
90108
}
109+
110+
/**
111+
* @param {Number} rowIndex
112+
* @returns {String}
113+
*/
114+
getComponentId(rowIndex) {
115+
let me = this,
116+
{view} = me.parent;
117+
118+
return `${me.id}-component-${rowIndex % (view.availableRows + 2 * view.bufferRowRange)}`
119+
}
91120
}
92121

93122
export default Neo.setupClass(Component);

src/grid/column/Progress.mjs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import ComponentColumn from './Component.mjs';
2+
import ProgressComponent from '../../component/Progress.mjs';
3+
4+
/**
5+
* @class Neo.grid.column.Progress
6+
* @extends Neo.grid.column.Component
7+
*/
8+
class Progress extends ComponentColumn {
9+
static config = {
10+
/**
11+
* @member {String} className='Neo.grid.column.Progress'
12+
* @protected
13+
*/
14+
className: 'Neo.grid.column.Progress',
15+
/**
16+
* @member {Object} defaults
17+
* @protected
18+
*/
19+
defaults: {
20+
module: ProgressComponent
21+
},
22+
/**
23+
* @member {String} type='progress'
24+
* @protected
25+
*/
26+
type: 'progress'
27+
}
28+
29+
/**
30+
* @param {Object} config
31+
* @param {Record} record
32+
* @returns {Object}
33+
*/
34+
applyRecordConfigs(config, record) {
35+
return {
36+
value: record[this.dataField],
37+
...config
38+
}
39+
}
40+
}
41+
42+
export default Neo.setupClass(Progress);

0 commit comments

Comments
 (0)