Skip to content

Commit b0cc2f4

Browse files
committed
Small fix in computeLength
1 parent 8707cd9 commit b0cc2f4

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

exmg-data-helper.html

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@
9292
}
9393

9494
_computeLength(rawItems) {
95-
return this.rawItems.length;
95+
const rawItems = this.rawItems || [];
96+
return rawItems.length;
9697
}
9798

9899
_ramItemsChanged() {
@@ -105,30 +106,27 @@
105106
}
106107

107108
_updatePage() {
108-
109-
console.log('pageIndex, pageSize',this.pageIndex, this.pageSize);
110-
111109
if(this.rawItems === undefined) {
112110
return;
113111
}
114112
/* Make sure to always start with same array to ensure consistency in sorting results */
115-
var workArray = this.rawItems.slice();
116-
var start = (this.pageIndex * this.pageSize);
113+
const workArray = this.rawItems.slice();
114+
const start = (this.pageIndex * this.pageSize);
117115

118116
console.log('start, this._doSort', start, this._doSort);
119117

120118
if(this._doSort && this.sorted) {
121-
var lookupItemByPath = (item, path) => {
122-
var parts = path.split(".");
119+
const lookupItemByPath = (item, path) => {
120+
const parts = path.split(".");
123121
if (parts.length === 1){
124122
return item[parts[0]];
125123
}
126124
return lookupItemByPath(item[parts[0]], parts.slice(1).join("."));
127125
};
128126

129127
workArray.sort((a, b) => {
130-
var fieldA = lookupItemByPath(a, this.sorted);
131-
var fieldB = lookupItemByPath(b, this.sorted);
128+
const fieldA = lookupItemByPath(a, this.sorted);
129+
const fieldB = lookupItemByPath(b, this.sorted);
132130
if(typeof fieldA === 'number' || typeof fieldA === 'boolean') {
133131
return this.sortDirection === 'ASC' ? fieldA - fieldB : fieldB - fieldA;
134132
} else {
@@ -148,14 +146,7 @@
148146
}
149147

150148
this.set('items', []);
151-
152-
console.log('start, this._doSort', workArray, workArray.slice(start, start + this.pageSize));
153149
this.set('items', workArray.slice(start, start + this.pageSize));
154-
// for(var i = start; i < start + this.pageSize; i++) {
155-
// if(workArray[i] !== undefined) {
156-
// this.push('items', workArray[i]);
157-
// }
158-
// }
159150
}
160151

161152
}

0 commit comments

Comments
 (0)