-
Notifications
You must be signed in to change notification settings - Fork 1
/
strolch-wc-inspector-paging-behavior.html
71 lines (65 loc) · 1.99 KB
/
strolch-wc-inspector-paging-behavior.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<script>
StrolchInspectorPagingBehavior = {
properties: {
dataObj: {
type: Object,
value: {
data: null,
offset: 0,
limit: 20,
dataSetSize: 0,
descending: true,
sortBy: 'id',
size: 0,
nextOffset: 0,
previousOffset: 0,
lastOffset: 0
}
}
},
_getDefaultObj: function () {
return {
data: null,
offset: 0,
limit: 20,
dataSetSize: 0,
descending: true,
sortBy: 'id',
size: 0,
nextOffset: 0,
previousOffset: 0,
lastOffset: 0
}
},
_hasNext: function (dataObj) {
return dataObj != null && dataObj.nextOffset > dataObj.offset;
},
_hasPrevious: function (dataObj) {
return dataObj != null && dataObj.previousOffset < dataObj.offset;
},
_getEnd: function (dataObj) {
if (this._hasNext(dataObj)) return dataObj.nextOffset;
return dataObj == null ? 0 : dataObj.size;
},
_setLimit: function (e) {
this.dataObj.limit = parseInt(e.target.textContent.trim());
this.queryPage();
},
_toFirstPage: function () {
this.dataObj.offset = 0;
this.queryPage();
},
_toPreviousPage: function () {
this.dataObj.offset = this.dataObj.previousOffset;
this.queryPage();
},
_toNextPage: function () {
this.dataObj.offset = this.dataObj.nextOffset;
this.queryPage();
},
_toLastPage: function () {
this.dataObj.offset = this.dataObj.lastOffset;
this.queryPage();
}
};
</script>