@neovici/cosmoz-omnitable 8.0.0-beta.4 → 8.0.0-beta.5
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/cosmoz-omnitable-column-amount.js +4 -4
- package/cosmoz-omnitable-column-autocomplete.js +3 -3
- package/cosmoz-omnitable-column-date.js +4 -4
- package/cosmoz-omnitable-column-datetime.js +4 -4
- package/cosmoz-omnitable-column-list-mixin.js +1 -1
- package/cosmoz-omnitable-column-mixin.js +5 -4
- package/cosmoz-omnitable-column-number.js +4 -4
- package/cosmoz-omnitable-column-time.js +4 -4
- package/lib/use-processed-items.js +5 -4
- package/lib/utils-amount.js +4 -4
- package/lib/utils-date.js +7 -7
- package/lib/utils-number.js +4 -4
- package/lib/utils-time.js +4 -4
- package/package.json +1 -1
|
@@ -35,8 +35,8 @@ class OmnitableColumnAmount extends columnMixin(PolymerElement) {
|
|
|
35
35
|
|
|
36
36
|
getFilterFn(column, filter) {
|
|
37
37
|
const
|
|
38
|
-
min = getComparableValue(
|
|
39
|
-
max = getComparableValue(
|
|
38
|
+
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
39
|
+
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
40
40
|
|
|
41
41
|
if (min == null && max == null) {
|
|
42
42
|
return;
|
|
@@ -56,8 +56,8 @@ class OmnitableColumnAmount extends columnMixin(PolymerElement) {
|
|
|
56
56
|
return getString(column, item);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
getComparableValue(
|
|
60
|
-
return getComparableValue(
|
|
59
|
+
getComparableValue(column, item) {
|
|
60
|
+
return getComparableValue(column, item);
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
serializeFilter({ rates }, filter) {
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
import { get } from '@polymer/polymer/lib/utils/path';
|
|
15
15
|
|
|
16
16
|
export const
|
|
17
|
-
getComparableValue = (
|
|
17
|
+
getComparableValue = ({ valuePath, textProperty, valueProperty }, item) => {
|
|
18
18
|
const property = textProperty ? strProp(textProperty) : prop(valueProperty),
|
|
19
19
|
values = array(valuePath && get(item, valuePath)).map(property);
|
|
20
20
|
return values.length > 1 ? values.filter(Boolean).join(',') : values[0];
|
|
@@ -63,8 +63,8 @@ class OmnitableColumnAutocomplete extends listColumnMixin(columnMixin(PolymerEle
|
|
|
63
63
|
>${ spinner }</cosmoz-autocomplete-ui>`;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
getComparableValue(
|
|
67
|
-
return getComparableValue(
|
|
66
|
+
getComparableValue(column, item) {
|
|
67
|
+
return getComparableValue(column, item);
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
computeSource(column, data) {
|
|
@@ -27,8 +27,8 @@ class OmnitableColumnDate extends columnMixin(PolymerElement) {
|
|
|
27
27
|
|
|
28
28
|
getFilterFn(column, filter) {
|
|
29
29
|
const
|
|
30
|
-
min = getComparableValue(
|
|
31
|
-
max = getComparableValue(
|
|
30
|
+
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
31
|
+
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
32
32
|
|
|
33
33
|
if (min == null && max == null) {
|
|
34
34
|
return;
|
|
@@ -48,8 +48,8 @@ class OmnitableColumnDate extends columnMixin(PolymerElement) {
|
|
|
48
48
|
return getString(column, item);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
getComparableValue(
|
|
52
|
-
return getComparableValue(
|
|
51
|
+
getComparableValue(column, item) {
|
|
52
|
+
return getComparableValue(column, item);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
serializeFilter(column, filter) {
|
|
@@ -36,8 +36,8 @@ class OmnitableColumnDatetime extends columnMixin(PolymerElement) {
|
|
|
36
36
|
|
|
37
37
|
getFilterFn(column, filter) {
|
|
38
38
|
const
|
|
39
|
-
min = getComparableValue(
|
|
40
|
-
max = getComparableValue(
|
|
39
|
+
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
40
|
+
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
41
41
|
|
|
42
42
|
if (min == null && max == null) {
|
|
43
43
|
return;
|
|
@@ -57,8 +57,8 @@ class OmnitableColumnDatetime extends columnMixin(PolymerElement) {
|
|
|
57
57
|
return getString(column, item);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
getComparableValue(
|
|
61
|
-
return getComparableValue(
|
|
60
|
+
getComparableValue(column, item) {
|
|
61
|
+
return getComparableValue(column, item);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
serializeFilter(column, filter) {
|
|
@@ -130,7 +130,7 @@ const
|
|
|
130
130
|
return getString(column, item);
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
getComparableValue(
|
|
133
|
+
getComparableValue({ valuePath, valueProperty }, item) {
|
|
134
134
|
const value = get(item, valuePath);
|
|
135
135
|
if (valueProperty == null) {
|
|
136
136
|
return value;
|
|
@@ -3,6 +3,7 @@ import { get } from '@polymer/polymer/lib/utils/path';
|
|
|
3
3
|
export const
|
|
4
4
|
getString = ({ valuePath }, item) => get(item, valuePath),
|
|
5
5
|
toXlsxValue = getString,
|
|
6
|
+
getComparableValue = getString,
|
|
6
7
|
|
|
7
8
|
applySingleFilter = ({ valuePath }, filter) => item => {
|
|
8
9
|
const value = get(item, valuePath);
|
|
@@ -87,12 +88,12 @@ export const
|
|
|
87
88
|
return filter;
|
|
88
89
|
}
|
|
89
90
|
|
|
90
|
-
getComparableValue(
|
|
91
|
-
return
|
|
91
|
+
getComparableValue(column, item) {
|
|
92
|
+
return getComparableValue(column, item);
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
computeSource() {
|
|
95
|
-
return
|
|
95
|
+
computeSource(column, data) {
|
|
96
|
+
return data;
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
_propertiesChanged(currentProps, changedProps, oldProps) {
|
|
@@ -36,8 +36,8 @@ class OmnitableColumnNumber extends columnMixin(PolymerElement) {
|
|
|
36
36
|
|
|
37
37
|
getFilterFn(column, filter) {
|
|
38
38
|
const
|
|
39
|
-
min = getComparableValue(
|
|
40
|
-
max = getComparableValue(
|
|
39
|
+
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
40
|
+
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
41
41
|
|
|
42
42
|
if (min == null && max == null) {
|
|
43
43
|
return;
|
|
@@ -57,8 +57,8 @@ class OmnitableColumnNumber extends columnMixin(PolymerElement) {
|
|
|
57
57
|
return getString(column, item);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
getComparableValue(
|
|
61
|
-
return getComparableValue(
|
|
60
|
+
getComparableValue(column, item) {
|
|
61
|
+
return getComparableValue(column, item);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
serializeFilter(column, filter) {
|
|
@@ -38,8 +38,8 @@ class OmnitableColumnTime extends columnMixin(PolymerElement) {
|
|
|
38
38
|
|
|
39
39
|
getFilterFn(column, filter) {
|
|
40
40
|
const
|
|
41
|
-
min = getComparableValue(
|
|
42
|
-
max = getComparableValue(
|
|
41
|
+
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
42
|
+
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
43
43
|
|
|
44
44
|
if (min == null && max == null) {
|
|
45
45
|
return;
|
|
@@ -59,8 +59,8 @@ class OmnitableColumnTime extends columnMixin(PolymerElement) {
|
|
|
59
59
|
return getString(column, item);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
getComparableValue(
|
|
63
|
-
return getComparableValue(
|
|
62
|
+
getComparableValue(column, item) {
|
|
63
|
+
return getComparableValue(column, item);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
serializeFilter(column, filter) {
|
|
@@ -78,12 +78,12 @@ export const useProcessedItems = ({ data, columns, groupOnColumn, groupOnDescend
|
|
|
78
78
|
// todo: extract function
|
|
79
79
|
processedItems = useMemo(() => {
|
|
80
80
|
if (!groupOnColumn && sortOnColumn != null && sortOnColumn.sortOn != null) {
|
|
81
|
-
return filteredItems.slice().sort(sortBy(a => sortOnColumn.getComparableValue(
|
|
81
|
+
return filteredItems.slice().sort(sortBy(a => sortOnColumn.getComparableValue({ ...sortOnColumn, valuePath: sortOnColumn.sortOn }, a), descending));
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
if (groupOnColumn != null && groupOnColumn.groupOn != null) {
|
|
85
85
|
const groupedResults = filteredItems.reduce((acc, item) => {
|
|
86
|
-
const gval = groupOnColumn.getComparableValue(
|
|
86
|
+
const gval = groupOnColumn.getComparableValue({ ...groupOnColumn, valuePath: groupOnColumn.groupOn }, item);
|
|
87
87
|
|
|
88
88
|
if (gval === undefined) {
|
|
89
89
|
return acc;
|
|
@@ -104,7 +104,8 @@ export const useProcessedItems = ({ data, columns, groupOnColumn, groupOnDescend
|
|
|
104
104
|
return acc;
|
|
105
105
|
}, []);
|
|
106
106
|
|
|
107
|
-
groupedResults.sort(sortBy(
|
|
107
|
+
groupedResults.sort(sortBy(
|
|
108
|
+
a => groupOnColumn.getComparableValue({ ...groupOnColumn, valuePath: groupOnColumn.groupOn }, a.items[0]), groupOnDescending));
|
|
108
109
|
|
|
109
110
|
if (!sortOnColumn) {
|
|
110
111
|
return groupedResults;
|
|
@@ -113,7 +114,7 @@ export const useProcessedItems = ({ data, columns, groupOnColumn, groupOnDescend
|
|
|
113
114
|
return groupedResults
|
|
114
115
|
.filter(group => Array.isArray(group.items))
|
|
115
116
|
.map(group => {
|
|
116
|
-
group.items.sort(sortBy(a => sortOnColumn.getComparableValue(
|
|
117
|
+
group.items.sort(sortBy(a => sortOnColumn.getComparableValue({ ...sortOnColumn, valuePath: sortOnColumn.sortOn }, a), descending));
|
|
117
118
|
return group;
|
|
118
119
|
});
|
|
119
120
|
}
|
package/lib/utils-amount.js
CHANGED
|
@@ -45,7 +45,7 @@ export const
|
|
|
45
45
|
return lNumber === valAmount ? amount : lAmount;
|
|
46
46
|
},
|
|
47
47
|
|
|
48
|
-
getComparableValue = (
|
|
48
|
+
getComparableValue = ({ valuePath, rates }, item) => {
|
|
49
49
|
if (item == null) {
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
@@ -70,15 +70,15 @@ export const
|
|
|
70
70
|
},
|
|
71
71
|
|
|
72
72
|
applySingleFilter = (column, filter) => item => {
|
|
73
|
-
const value = getComparableValue(
|
|
73
|
+
const value = getComparableValue(column, item);
|
|
74
74
|
|
|
75
75
|
if (value == null) {
|
|
76
76
|
return false;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
const
|
|
80
|
-
min = getComparableValue(
|
|
81
|
-
max = getComparableValue(
|
|
80
|
+
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
81
|
+
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
82
82
|
|
|
83
83
|
return !(value < min || value > max);
|
|
84
84
|
},
|
package/lib/utils-date.js
CHANGED
|
@@ -56,11 +56,11 @@ export const
|
|
|
56
56
|
/**
|
|
57
57
|
* Get comparable number from date
|
|
58
58
|
*
|
|
59
|
-
* @param {Object} item Item to be processed
|
|
60
59
|
* @param {String} valuePath Property path
|
|
60
|
+
* @param {Object} item Item to be processed
|
|
61
61
|
* @returns {Number|void} Valid value or void
|
|
62
62
|
*/
|
|
63
|
-
getComparableValue = (
|
|
63
|
+
getComparableValue = ({ valuePath }, item) => {
|
|
64
64
|
if (item == null) {
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
@@ -100,8 +100,8 @@ export const
|
|
|
100
100
|
return date;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
const comparableDate = getComparableValue(date),
|
|
104
|
-
comparableLDate = getComparableValue(lDate),
|
|
103
|
+
const comparableDate = getComparableValue({}, date),
|
|
104
|
+
comparableLDate = getComparableValue({}, lDate),
|
|
105
105
|
limitedValue = limitFunc(comparableDate, comparableLDate);
|
|
106
106
|
return limitedValue === comparableDate ? date : lDate;
|
|
107
107
|
},
|
|
@@ -188,15 +188,15 @@ export const
|
|
|
188
188
|
},
|
|
189
189
|
|
|
190
190
|
applySingleFilter = (column, filter) => item => {
|
|
191
|
-
const value = getComparableValue(
|
|
191
|
+
const value = getComparableValue(column, item);
|
|
192
192
|
|
|
193
193
|
if (value == null) {
|
|
194
194
|
return false;
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
const
|
|
198
|
-
min = getComparableValue(
|
|
199
|
-
max = getComparableValue(
|
|
198
|
+
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
199
|
+
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
200
200
|
|
|
201
201
|
return !(value < min || value > max);
|
|
202
202
|
};
|
package/lib/utils-number.js
CHANGED
|
@@ -50,7 +50,7 @@ export const
|
|
|
50
50
|
return string;
|
|
51
51
|
},
|
|
52
52
|
|
|
53
|
-
getComparableValue = (
|
|
53
|
+
getComparableValue = ({ valuePath, maximumFractionDigits }, item) => {
|
|
54
54
|
if (item == null) {
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
@@ -98,15 +98,15 @@ export const
|
|
|
98
98
|
},
|
|
99
99
|
|
|
100
100
|
applySingleFilter = (column, filter) => item => {
|
|
101
|
-
const value = getComparableValue(
|
|
101
|
+
const value = getComparableValue(column, item);
|
|
102
102
|
|
|
103
103
|
if (value == null) {
|
|
104
104
|
return false;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
const
|
|
108
|
-
min = getComparableValue(
|
|
109
|
-
max = getComparableValue(
|
|
108
|
+
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
109
|
+
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
110
110
|
|
|
111
111
|
return !(value < min || value > max);
|
|
112
112
|
};
|
package/lib/utils-time.js
CHANGED
|
@@ -67,7 +67,7 @@ export const
|
|
|
67
67
|
return toLocalISOString(date).slice(11, 19);
|
|
68
68
|
},
|
|
69
69
|
|
|
70
|
-
getComparableValue = (
|
|
70
|
+
getComparableValue = ({ valuePath }, item) => {
|
|
71
71
|
if (item == null) {
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
@@ -83,15 +83,15 @@ export const
|
|
|
83
83
|
},
|
|
84
84
|
|
|
85
85
|
applySingleFilter = (column, filter) => item => {
|
|
86
|
-
const value = getComparableValue(
|
|
86
|
+
const value = getComparableValue(column, item);
|
|
87
87
|
|
|
88
88
|
if (value == null) {
|
|
89
89
|
return false;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
const
|
|
93
|
-
min = getComparableValue(
|
|
94
|
-
max = getComparableValue(
|
|
93
|
+
min = getComparableValue({ ...column, valuePath: 'min' }, filter),
|
|
94
|
+
max = getComparableValue({ ...column, valuePath: 'max' }, filter);
|
|
95
95
|
|
|
96
96
|
return !(value < min || value > max);
|
|
97
97
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neovici/cosmoz-omnitable",
|
|
3
|
-
"version": "8.0.0-beta.
|
|
3
|
+
"version": "8.0.0-beta.5",
|
|
4
4
|
"description": "[](https://travis-ci.org/Neovici/cosmoz-omnitable)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"web-components"
|