not-bulma 2.0.14 → 2.0.16
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/package.json +1 -1
- package/src/elements/button/ui.button.switch.svelte +19 -24
- package/src/elements/button/ui.buttons.row.svelte +5 -4
- package/src/elements/button/ui.buttons.svelte +4 -0
- package/src/elements/button/ui.buttons.switchers.svelte +23 -23
- package/src/frame/components/table/notTable.svelte +39 -2
- package/src/frame/components/table/notTable.svelte.js +3 -0
- package/src/frame/components/table/notTable.js +0 -850
package/package.json
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { run } from
|
|
2
|
+
import { run } from "svelte/legacy";
|
|
3
3
|
|
|
4
4
|
import UIButton from "./ui.button.svelte";
|
|
5
|
-
import { createEventDispatcher } from "svelte";
|
|
6
|
-
|
|
7
|
-
const dispatch = createEventDispatcher();
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
5
|
|
|
13
6
|
/**
|
|
14
7
|
* @typedef {Object} Props
|
|
@@ -44,7 +37,7 @@
|
|
|
44
37
|
inverted = false,
|
|
45
38
|
rounded = false,
|
|
46
39
|
disabled = false,
|
|
47
|
-
state = "",
|
|
40
|
+
state: notState = "",
|
|
48
41
|
type = "",
|
|
49
42
|
color = "",
|
|
50
43
|
size = "",
|
|
@@ -52,30 +45,32 @@
|
|
|
52
45
|
icon = false,
|
|
53
46
|
iconSide = "right",
|
|
54
47
|
uiOff = () => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
return {
|
|
49
|
+
color: "",
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
onchange = () => {},
|
|
53
|
+
onclick = () => {},
|
|
59
54
|
uiOn = () => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
return {
|
|
56
|
+
color: "success",
|
|
57
|
+
};
|
|
58
|
+
},
|
|
64
59
|
action = () => {
|
|
65
|
-
|
|
66
|
-
|
|
60
|
+
return !selected;
|
|
61
|
+
},
|
|
67
62
|
value,
|
|
68
|
-
selected = $bindable(false)
|
|
63
|
+
selected = $bindable(false),
|
|
69
64
|
} = $props();
|
|
70
65
|
|
|
71
66
|
function onClick(event) {
|
|
72
67
|
selected = action(event, value, selected);
|
|
73
|
-
|
|
68
|
+
onclick({ value, selected });
|
|
74
69
|
onChange();
|
|
75
70
|
}
|
|
76
71
|
|
|
77
72
|
function onChange() {
|
|
78
|
-
|
|
73
|
+
onchange({
|
|
79
74
|
value,
|
|
80
75
|
selected,
|
|
81
76
|
});
|
|
@@ -100,7 +95,7 @@
|
|
|
100
95
|
{inverted}
|
|
101
96
|
{rounded}
|
|
102
97
|
{disabled}
|
|
103
|
-
{
|
|
98
|
+
state={notState}
|
|
104
99
|
{type}
|
|
105
100
|
{color}
|
|
106
101
|
{size}
|
|
@@ -108,5 +103,5 @@
|
|
|
108
103
|
{icon}
|
|
109
104
|
{iconSide}
|
|
110
105
|
{value}
|
|
111
|
-
|
|
106
|
+
onclick={onClick}
|
|
112
107
|
></UIButton>
|
|
@@ -14,18 +14,19 @@
|
|
|
14
14
|
classes = "",
|
|
15
15
|
left = [],
|
|
16
16
|
center = [],
|
|
17
|
-
right = []
|
|
17
|
+
right = [],
|
|
18
|
+
disabled = false,
|
|
18
19
|
} = $props();
|
|
19
20
|
</script>
|
|
20
21
|
|
|
21
22
|
<div class="columns {classes}">
|
|
22
23
|
<div class="column">
|
|
23
|
-
<UIButtons values={left}></UIButtons>
|
|
24
|
+
<UIButtons values={left} {disabled}></UIButtons>
|
|
24
25
|
</div>
|
|
25
26
|
<div class="column">
|
|
26
|
-
<UIButtons values={center} centered={true}></UIButtons>
|
|
27
|
+
<UIButtons values={center} centered={true} {disabled}></UIButtons>
|
|
27
28
|
</div>
|
|
28
29
|
<div class="column">
|
|
29
|
-
<UIButtons values={right} right={true}></UIButtons>
|
|
30
|
+
<UIButtons values={right} right={true} {disabled}></UIButtons>
|
|
30
31
|
</div>
|
|
31
32
|
</div>
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
let {
|
|
18
18
|
values = [],
|
|
19
19
|
centered = false,
|
|
20
|
+
disabled = false,
|
|
20
21
|
right = false,
|
|
21
22
|
classes = "",
|
|
22
23
|
buttonComponent = UIButton,
|
|
@@ -41,6 +42,9 @@
|
|
|
41
42
|
{@const SvelteComponent = buttonComponent}
|
|
42
43
|
<SvelteComponent
|
|
43
44
|
{...item}
|
|
45
|
+
disabled={Object.hasOwn(item, "disabled")
|
|
46
|
+
? item.disabled
|
|
47
|
+
: disabled}
|
|
44
48
|
bind:value={item.value}
|
|
45
49
|
action={item.action ? item.action : action}
|
|
46
50
|
{onclick}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
const dispatch = createEventDispatcher();
|
|
4
4
|
import UIButtonSwitch from "./ui.button.switch.svelte";
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
const selectHistory = [];
|
|
8
7
|
|
|
9
8
|
export function selectAll() {
|
|
@@ -84,7 +83,6 @@
|
|
|
84
83
|
}
|
|
85
84
|
}
|
|
86
85
|
|
|
87
|
-
|
|
88
86
|
/**
|
|
89
87
|
* @typedef {Object} Props
|
|
90
88
|
* @property {any} [values]
|
|
@@ -105,29 +103,31 @@
|
|
|
105
103
|
classes = "",
|
|
106
104
|
buttonComponent = UIButtonSwitch,
|
|
107
105
|
action = (ev, value, selected) => {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
let newSelected = !selected;
|
|
107
|
+
const indexOfCurrent = values.indexOf((itm) => itm.value === value);
|
|
108
|
+
const cnt = countSelected() + (newSelected ? 1 : -1);
|
|
111
109
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
110
|
+
if (min) {
|
|
111
|
+
if (cnt < min) {
|
|
112
|
+
selectUpToMin(cnt, indexOfCurrent);
|
|
113
|
+
values = values;
|
|
114
|
+
}
|
|
116
115
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
if (max) {
|
|
117
|
+
if (max < cnt) {
|
|
118
|
+
deselectDownToMin(cnt, indexOfCurrent);
|
|
119
|
+
values = values;
|
|
120
|
+
}
|
|
122
121
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
},
|
|
122
|
+
if (newSelected) {
|
|
123
|
+
addToHistory(indexOfCurrent);
|
|
124
|
+
}
|
|
125
|
+
return newSelected;
|
|
126
|
+
},
|
|
129
127
|
min = 0,
|
|
130
|
-
max = 100
|
|
128
|
+
max = 100,
|
|
129
|
+
onclick = () => {},
|
|
130
|
+
onchange = () => {},
|
|
131
131
|
} = $props();
|
|
132
132
|
</script>
|
|
133
133
|
|
|
@@ -143,8 +143,8 @@
|
|
|
143
143
|
bind:value={item.value}
|
|
144
144
|
bind:selected={item.selected}
|
|
145
145
|
action={item.action ? item.action : action}
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
{onclick}
|
|
147
|
+
{onchange}
|
|
148
148
|
/>
|
|
149
149
|
{/each}
|
|
150
150
|
</div>
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
showSearch = true,
|
|
50
50
|
showSelect = true,
|
|
51
51
|
selectAll = false,
|
|
52
|
+
showTotals = false,
|
|
52
53
|
getItemId = (item) => item._id,
|
|
53
54
|
//event handlers
|
|
54
55
|
onRowSelectChange = () => {},
|
|
@@ -61,6 +62,8 @@
|
|
|
61
62
|
onGoToPage = () => {},
|
|
62
63
|
onGoToPrevPage = () => {},
|
|
63
64
|
onGoToNextPage = () => {},
|
|
65
|
+
onGoToFirstPage = () => {},
|
|
66
|
+
onGoToLastPage = () => {},
|
|
64
67
|
} = $props();
|
|
65
68
|
|
|
66
69
|
function _onSearchInput(ev) {
|
|
@@ -129,6 +132,19 @@
|
|
|
129
132
|
return call(e);
|
|
130
133
|
};
|
|
131
134
|
}
|
|
135
|
+
|
|
136
|
+
let enableButtonFirst = $derived(state?.pagination?.pages?.current > 0);
|
|
137
|
+
|
|
138
|
+
let enableButtonPrev = $derived(state?.pagination?.pages?.current > 0);
|
|
139
|
+
|
|
140
|
+
let enableButtonNext = $derived(
|
|
141
|
+
state?.pagination?.pages?.current < state?.pagination?.pages.to
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
let enableButtonLast = $derived(
|
|
145
|
+
state?.pagination?.pages?.current < state?.pagination?.pages.to &&
|
|
146
|
+
state?.pagination?.pages.count > 1
|
|
147
|
+
);
|
|
132
148
|
</script>
|
|
133
149
|
|
|
134
150
|
{#if links.length}
|
|
@@ -166,6 +182,12 @@
|
|
|
166
182
|
{#if state.updating}
|
|
167
183
|
<UILoader loading={true} title="Загрузка..." size="container"></UILoader>
|
|
168
184
|
{:else}
|
|
185
|
+
{#if showTotals}
|
|
186
|
+
<ul class="pagination-list">
|
|
187
|
+
<li>Страниц: {state?.pagination?.pages?.count ?? 0}</li>
|
|
188
|
+
<li>Записей: {state?.count ?? 0}</li>
|
|
189
|
+
</ul>
|
|
190
|
+
{/if}
|
|
169
191
|
<table class="table">
|
|
170
192
|
<thead>
|
|
171
193
|
{#if showSelect}
|
|
@@ -219,20 +241,35 @@
|
|
|
219
241
|
</table>
|
|
220
242
|
{#if state?.pagination?.pages?.list.length >= 1}
|
|
221
243
|
<nav class="pagination is-centered" aria-label="pagination">
|
|
222
|
-
{#if
|
|
244
|
+
{#if enableButtonFirst}
|
|
245
|
+
<a
|
|
246
|
+
href
|
|
247
|
+
class="pagination-first"
|
|
248
|
+
onclick={preventDefault(onGoToFirstPage)}>Первая</a
|
|
249
|
+
>
|
|
250
|
+
{/if}
|
|
251
|
+
{#if enableButtonPrev}
|
|
223
252
|
<a
|
|
224
253
|
href
|
|
225
254
|
class="pagination-previous"
|
|
226
255
|
onclick={preventDefault(onGoToPrevPage)}>Назад</a
|
|
227
256
|
>
|
|
228
257
|
{/if}
|
|
229
|
-
{#if
|
|
258
|
+
{#if enableButtonNext}
|
|
230
259
|
<a
|
|
231
260
|
href
|
|
232
261
|
class="pagination-next"
|
|
233
262
|
onclick={preventDefault(onGoToNextPage)}>Вперед</a
|
|
234
263
|
>
|
|
235
264
|
{/if}
|
|
265
|
+
{#if enableButtonLast}
|
|
266
|
+
<a
|
|
267
|
+
href
|
|
268
|
+
class="pagination-last"
|
|
269
|
+
onclick={preventDefault(onGoToLastPage)}
|
|
270
|
+
>Последняя {state?.pagination.pages.count + 1}</a
|
|
271
|
+
>
|
|
272
|
+
{/if}
|
|
236
273
|
<ul class="pagination-list">
|
|
237
274
|
{#if state && state?.pagination && state?.pagination.pages && state?.pagination.pages.list}
|
|
238
275
|
{#each state?.pagination.pages.list as page (page.index)}
|
|
@@ -257,6 +257,7 @@ class notTable extends EventEmitter {
|
|
|
257
257
|
showSelect: this.getOptions("showSelect"),
|
|
258
258
|
showSearch: this.getOptions("showSearch"),
|
|
259
259
|
showSort: this.getOptions("showSort"),
|
|
260
|
+
showTotals: this.getOptions("showTotals"),
|
|
260
261
|
idField: this.getOptions("idField"),
|
|
261
262
|
getItemId: this.getOptions("getItemId"),
|
|
262
263
|
filter: this.getFilter(),
|
|
@@ -275,6 +276,8 @@ class notTable extends EventEmitter {
|
|
|
275
276
|
this.#ui.table.$on("onGoToPage", (e) => this.goToPage(e));
|
|
276
277
|
this.#ui.table.$on("onGoToNextPage", () => this.goToNext());
|
|
277
278
|
this.#ui.table.$on("onGoToPrevPage", () => this.goToPrev());
|
|
279
|
+
this.#ui.table.$on("onGoToFirstPage", () => this.goToFirst());
|
|
280
|
+
this.#ui.table.$on("onGoToLastPage", () => this.goToLast());
|
|
278
281
|
}
|
|
279
282
|
|
|
280
283
|
getActions() {
|
|
@@ -1,850 +0,0 @@
|
|
|
1
|
-
import EventEmitter from "wolfy87-eventemitter";
|
|
2
|
-
import notPath from "not-path";
|
|
3
|
-
import notCommon from "../../common.js";
|
|
4
|
-
|
|
5
|
-
import * as Stores from "./stores.js";
|
|
6
|
-
import UITable from "./notTable.svelte";
|
|
7
|
-
import UIAdapterSvelte from "../../ui.adapter.svelte.js";
|
|
8
|
-
|
|
9
|
-
const CONST_ID_DUBLICATE_POSTFIX = "__dublicate__";
|
|
10
|
-
|
|
11
|
-
const OPT_DEFAULT_PAGE_SIZE = 20,
|
|
12
|
-
OPT_DEFAULT_PAGE_NUMBER = 0,
|
|
13
|
-
OPT_DEFAULT_PAGE_RANGE = 6,
|
|
14
|
-
OPT_DEFAULT_SORT_DIRECTION = 1,
|
|
15
|
-
OPT_DEFAULT_SEARCH = "",
|
|
16
|
-
OPT_DEFAULT_RETURN = {},
|
|
17
|
-
OPT_DEFAULT_COMBINED = false,
|
|
18
|
-
OPT_DEFAULT_COMBINED_ACTION = "listAndCount",
|
|
19
|
-
OPT_DEFAULT_COUNT_ACTION = "count",
|
|
20
|
-
OPT_DEFAULT_LIST_ACTION = "list",
|
|
21
|
-
OPT_DEFAULT_SORT_FIELD = "_id",
|
|
22
|
-
OPT_FIELD_NAME_PRE_PROC = "preprocessor";
|
|
23
|
-
|
|
24
|
-
const DEFAULT_OPTIONS = {
|
|
25
|
-
ui: UITable,
|
|
26
|
-
links: [],
|
|
27
|
-
actions: [],
|
|
28
|
-
endless: false,
|
|
29
|
-
idField: "_id",
|
|
30
|
-
getItemId: (item) => {
|
|
31
|
-
return item._id;
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
class notTable extends EventEmitter {
|
|
36
|
-
constructor(input = {}) {
|
|
37
|
-
super();
|
|
38
|
-
this.id = "table-" + Math.random();
|
|
39
|
-
this.options = {
|
|
40
|
-
...DEFAULT_OPTIONS,
|
|
41
|
-
...(input.options ? input.options : {}),
|
|
42
|
-
};
|
|
43
|
-
this.ui = {};
|
|
44
|
-
this.data = {
|
|
45
|
-
raw: [],
|
|
46
|
-
filtered: [],
|
|
47
|
-
refined: [],
|
|
48
|
-
selected: {},
|
|
49
|
-
};
|
|
50
|
-
this.state = {
|
|
51
|
-
pagination: {
|
|
52
|
-
items: {
|
|
53
|
-
count: 0,
|
|
54
|
-
from: 0,
|
|
55
|
-
to: 0,
|
|
56
|
-
},
|
|
57
|
-
pages: {
|
|
58
|
-
count: 0,
|
|
59
|
-
from: 0,
|
|
60
|
-
to: 0,
|
|
61
|
-
current: 0,
|
|
62
|
-
list: [],
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
this.working = {};
|
|
67
|
-
|
|
68
|
-
this.stores = Stores.create(this.id, {
|
|
69
|
-
raw: [],
|
|
70
|
-
filtered: [],
|
|
71
|
-
refined: [],
|
|
72
|
-
selected: {},
|
|
73
|
-
state: this.state,
|
|
74
|
-
working: this.working,
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
this.stores.working.subscribe(this.onWorkingUpdate.bind(this));
|
|
78
|
-
//полученные из сети
|
|
79
|
-
this.stores.raw.subscribe(this.onRawUpdate.bind(this));
|
|
80
|
-
//применены фильтры, сортировки и т.д.
|
|
81
|
-
this.stores.filtered.subscribe(this.onFilteredUpdate.bind(this));
|
|
82
|
-
//урезаны до минимального набора, точно соотвествующего табличному формату
|
|
83
|
-
this.stores.refined.subscribe(this.onRefinedUpdate.bind(this));
|
|
84
|
-
//словарь с идентификаторами выбранных строк
|
|
85
|
-
this.stores.selected.subscribe(this.onSelectedUpdate.bind(this));
|
|
86
|
-
//pagination, items information
|
|
87
|
-
this.stores.state.subscribe(this.onStateUpdate.bind(this));
|
|
88
|
-
|
|
89
|
-
if (notCommon.objHas(input, "data") && Array.isArray(input.data)) {
|
|
90
|
-
this.stores.raw.update((val) => {
|
|
91
|
-
val = input.data;
|
|
92
|
-
return val;
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
this.setCombinedActionName(
|
|
97
|
-
this.getOptions(
|
|
98
|
-
"interface.combinedAction",
|
|
99
|
-
OPT_DEFAULT_COMBINED_ACTION
|
|
100
|
-
)
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
if (notCommon.objHas(this.options, "filter")) {
|
|
104
|
-
this.setFilter(this.options.filter, true);
|
|
105
|
-
} else {
|
|
106
|
-
this.resetFilter();
|
|
107
|
-
}
|
|
108
|
-
if (notCommon.objHas(this.options, "pager")) {
|
|
109
|
-
this.setPager(this.options.pager, true);
|
|
110
|
-
} else {
|
|
111
|
-
this.resetPager();
|
|
112
|
-
}
|
|
113
|
-
if (notCommon.objHas(this.options, "sorter")) {
|
|
114
|
-
this.setSorter(this.options.sorter, true);
|
|
115
|
-
} else {
|
|
116
|
-
this.resetSorter(true);
|
|
117
|
-
}
|
|
118
|
-
if (notCommon.objHas(this.options, "return")) {
|
|
119
|
-
this.setReturn(this.options.return);
|
|
120
|
-
} else {
|
|
121
|
-
this.setReturn();
|
|
122
|
-
}
|
|
123
|
-
if (notCommon.objHas(this.options, "search")) {
|
|
124
|
-
this.setSearch(this.options.search, true);
|
|
125
|
-
} else {
|
|
126
|
-
this.setSearch();
|
|
127
|
-
}
|
|
128
|
-
this.render();
|
|
129
|
-
this.updateData();
|
|
130
|
-
return this;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
onWorkingUpdate(val) {
|
|
134
|
-
this.working = val;
|
|
135
|
-
return val;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
onRawUpdate(val) {
|
|
139
|
-
this.data.raw = val;
|
|
140
|
-
return val;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
onFilteredUpdate(val) {
|
|
144
|
-
this.data.filtered = val;
|
|
145
|
-
this.refineFiltered();
|
|
146
|
-
return val;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
onRefinedUpdate(val) {
|
|
150
|
-
this.data.refined = val;
|
|
151
|
-
this.clearSelected();
|
|
152
|
-
return val;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
onStateUpdate(val) {
|
|
156
|
-
this.state = val;
|
|
157
|
-
return val;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
onSearchChange(line) {
|
|
161
|
-
if (line.length > 3) {
|
|
162
|
-
this.setSearch(line);
|
|
163
|
-
} else {
|
|
164
|
-
this.setSearch();
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
onSorterChange(sorter) {
|
|
169
|
-
if (sorter) {
|
|
170
|
-
this.setSorter(sorter);
|
|
171
|
-
} else {
|
|
172
|
-
this.resetSorter();
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
onFilterChange({ filter, actionName }) {
|
|
177
|
-
if (actionName.indexOf(OPT_DEFAULT_COMBINED_ACTION) === 0) {
|
|
178
|
-
this.setCombinedActionName(actionName);
|
|
179
|
-
}
|
|
180
|
-
if (filter) {
|
|
181
|
-
this.setFilter(filter);
|
|
182
|
-
} else {
|
|
183
|
-
this.resetFilter();
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
onSelectedUpdate(val) {
|
|
188
|
-
this.data.selected = val;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
clearSelected() {
|
|
192
|
-
this.data.selected = {};
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
getSelected(object = false, store = "refined") {
|
|
196
|
-
let res = [];
|
|
197
|
-
for (let id in this.data.selected) {
|
|
198
|
-
if (this.data.selected[id]) {
|
|
199
|
-
if (object) {
|
|
200
|
-
let indx = this.data[store].findIndex(
|
|
201
|
-
(item) => item._id === id
|
|
202
|
-
);
|
|
203
|
-
if (indx > -1) {
|
|
204
|
-
res.push(this.data[store][indx]);
|
|
205
|
-
}
|
|
206
|
-
} else {
|
|
207
|
-
res.push(id);
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return res;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
getItemId(item) {
|
|
215
|
-
return this.getOptions("getItemId", DEFAULT_OPTIONS.getItemId)(item);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
selectAll() {
|
|
219
|
-
this.stores.selected.update(() => {
|
|
220
|
-
let value = {};
|
|
221
|
-
this.data.filtered.forEach((item) => {
|
|
222
|
-
value[this.getItemId(item)] = true;
|
|
223
|
-
});
|
|
224
|
-
return value;
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
selectNone() {
|
|
229
|
-
this.stores.selected.update(() => {
|
|
230
|
-
let value = {};
|
|
231
|
-
this.data.filtered.forEach((item) => {
|
|
232
|
-
value[this.getItemId(item)] = false;
|
|
233
|
-
});
|
|
234
|
-
return value;
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
render() {
|
|
239
|
-
if (!this.ui.table) {
|
|
240
|
-
this.ui.table = new UIAdapterSvelte(
|
|
241
|
-
this.options.ui,
|
|
242
|
-
this.options.targetEl,
|
|
243
|
-
{
|
|
244
|
-
filterUI: this.getOptions("filterUI", undefined),
|
|
245
|
-
id: this.id,
|
|
246
|
-
helpers: Object.assign({}, this.getHelpers()),
|
|
247
|
-
fields: this.getOptions("fields"),
|
|
248
|
-
actions: this.getActions(),
|
|
249
|
-
links: this.getLinks(),
|
|
250
|
-
search: "",
|
|
251
|
-
showSelect: this.getOptions("showSelect"),
|
|
252
|
-
showSearch: this.getOptions("showSearch"),
|
|
253
|
-
showSort: this.getOptions("showSort"),
|
|
254
|
-
idField: this.getOptions("idField"),
|
|
255
|
-
getItemId: this.getOptions("getItemId"),
|
|
256
|
-
filter: this.getFilter(),
|
|
257
|
-
}
|
|
258
|
-
);
|
|
259
|
-
}
|
|
260
|
-
this.ui.table.$on("onSearchChange", (e) => this.onSearchChange(e));
|
|
261
|
-
this.ui.table.$on("onSorterChange", (e) => this.onSorterChange(e));
|
|
262
|
-
this.ui.table.$on("onFilterChange", (e) => this.onFilterChange(e));
|
|
263
|
-
this.ui.table.$on("onGoToPage", (e) => this.goToPage(e));
|
|
264
|
-
this.ui.table.$on("onGoToNextPage", () => this.goToNext());
|
|
265
|
-
this.ui.table.$on("onGoToPrevPage", () => this.goToPrev());
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
getActions() {
|
|
269
|
-
return this.getOptions("actions", []);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
getLinks() {
|
|
273
|
-
return this.getOptions("links", []);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
getHelpers() {
|
|
277
|
-
return this.options.helpers || {};
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
setWorking(key, value) {
|
|
281
|
-
this.stores.working.update((val) => {
|
|
282
|
-
notPath.set(key, val, this.getHelpers(), value);
|
|
283
|
-
return val;
|
|
284
|
-
});
|
|
285
|
-
return this;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
getWorking(key, def) {
|
|
289
|
-
let res = notPath.get(key, this.working, this.getHelpers());
|
|
290
|
-
if (res === undefined) {
|
|
291
|
-
return def;
|
|
292
|
-
} else {
|
|
293
|
-
return res;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
setState(key, value) {
|
|
298
|
-
this.stores.state.update((val) => {
|
|
299
|
-
notPath.set(key, val, this.getHelpers(), value);
|
|
300
|
-
return val;
|
|
301
|
-
});
|
|
302
|
-
return this;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
getState(key, def) {
|
|
306
|
-
let res = notPath.get(key, this.state, this.getHelpers());
|
|
307
|
-
if (res === undefined) {
|
|
308
|
-
return def;
|
|
309
|
-
} else {
|
|
310
|
-
return res;
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
setOptions(key, value) {
|
|
315
|
-
notPath.set(key, this.options, this.getHelpers(), value);
|
|
316
|
-
return this;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
getOptions(key, def) {
|
|
320
|
-
let res = notPath.get(key, this.options, this.getHelpers());
|
|
321
|
-
if (res === undefined) {
|
|
322
|
-
return def;
|
|
323
|
-
} else {
|
|
324
|
-
return res;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
setFilter(hash, withoutInvalidation = false) {
|
|
329
|
-
this.setState("filter", hash);
|
|
330
|
-
if (withoutInvalidation) {
|
|
331
|
-
return this;
|
|
332
|
-
}
|
|
333
|
-
this.invalidateData();
|
|
334
|
-
this.updateData();
|
|
335
|
-
return this;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
resetFilter() {
|
|
339
|
-
this.setState("filter", {});
|
|
340
|
-
return this;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
getFilter() {
|
|
344
|
-
return this.getState("filter");
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
setPager(hash, withoutInvalidation = false) {
|
|
348
|
-
this.setState("pager", hash);
|
|
349
|
-
if (withoutInvalidation) {
|
|
350
|
-
return this;
|
|
351
|
-
}
|
|
352
|
-
this.updateData();
|
|
353
|
-
return this;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
getDefaultPageNumber() {
|
|
357
|
-
return isNaN(this.getOptions("pager.page"))
|
|
358
|
-
? OPT_DEFAULT_PAGE_NUMBER
|
|
359
|
-
: this.getOptions("pager.page");
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
getDefaultPageSize() {
|
|
363
|
-
return isNaN(this.getOptions("pager.size"))
|
|
364
|
-
? OPT_DEFAULT_PAGE_SIZE
|
|
365
|
-
: this.getOptions("pager.size");
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
resetPager() {
|
|
369
|
-
this.setState("pager", {
|
|
370
|
-
size: this.getDefaultPageSize(),
|
|
371
|
-
page: this.getDefaultPageNumber(),
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
getPager() {
|
|
376
|
-
return this.getState("pager");
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
setSorter(hash, withoutInvalidation = false) {
|
|
380
|
-
this.setWorking("sorter", hash);
|
|
381
|
-
if (withoutInvalidation) {
|
|
382
|
-
return this;
|
|
383
|
-
}
|
|
384
|
-
this.invalidateData();
|
|
385
|
-
this.updateData();
|
|
386
|
-
return this;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
resetSorter(withoutInvalidation = false) {
|
|
390
|
-
let t = {};
|
|
391
|
-
t[OPT_DEFAULT_SORT_FIELD] = OPT_DEFAULT_SORT_DIRECTION;
|
|
392
|
-
return this.setSorter(t, withoutInvalidation);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
getSorter() {
|
|
396
|
-
return this.getWorking("sorter");
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
getSorterDirection() {
|
|
400
|
-
try {
|
|
401
|
-
let names = Object.keys(this.getSorter());
|
|
402
|
-
return this.getSorter()[names[0]];
|
|
403
|
-
} catch (e) {
|
|
404
|
-
return OPT_DEFAULT_SORT_DIRECTION;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
getSearch() {
|
|
409
|
-
let search =
|
|
410
|
-
typeof this.getWorking("search") !== "undefined" &&
|
|
411
|
-
this.getWorking("search") !== null;
|
|
412
|
-
return search ? this.getWorking("search") : "";
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
setSearch(line = OPT_DEFAULT_SEARCH, withoutInvalidation = false) {
|
|
416
|
-
this.setWorking("search", line);
|
|
417
|
-
if (withoutInvalidation) {
|
|
418
|
-
return this;
|
|
419
|
-
}
|
|
420
|
-
this.invalidateData();
|
|
421
|
-
this.updateData();
|
|
422
|
-
return this;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
getReturn() {
|
|
426
|
-
return this.getWorking("return");
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
setReturn(ret = OPT_DEFAULT_RETURN) {
|
|
430
|
-
this.setWorking("return", ret);
|
|
431
|
-
return this;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
clearFilteredData() {
|
|
435
|
-
this.stores.filtered.update((val) => {
|
|
436
|
-
val.splice(0, val.length);
|
|
437
|
-
return val;
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
clearRawData() {
|
|
442
|
-
this.stores.raw.update((val) => {
|
|
443
|
-
val.splice(0, val.length);
|
|
444
|
-
return val;
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
clearRefinedData() {
|
|
449
|
-
this.stores.refined.update((val) => {
|
|
450
|
-
val.splice(0, val.length);
|
|
451
|
-
return val;
|
|
452
|
-
});
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
invalidateData() {
|
|
456
|
-
//clearing filtered and sorted
|
|
457
|
-
this.clearFilteredData();
|
|
458
|
-
//in case live loading from server
|
|
459
|
-
if (this.isLive()) {
|
|
460
|
-
//clearing loaded data
|
|
461
|
-
this.clearRawData();
|
|
462
|
-
}
|
|
463
|
-
//resset pager anyway
|
|
464
|
-
this.resetPager();
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
isLive() {
|
|
468
|
-
return (
|
|
469
|
-
this.getOptions("interface") && this.getOptions("interface.factory")
|
|
470
|
-
);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
setUpdating() {
|
|
474
|
-
this.setState("updating", true);
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
setUpdated() {
|
|
478
|
-
this.setState("updating", false);
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
ifUpdating() {
|
|
482
|
-
return this.getState("updating");
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
getDataInterface() {
|
|
486
|
-
let factory = this.getOptions("interface.factory");
|
|
487
|
-
if (typeof factory === "function") {
|
|
488
|
-
return factory({});
|
|
489
|
-
} else {
|
|
490
|
-
return factory;
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
getLoadDataActionName() {
|
|
495
|
-
return this.getOptions("interface.listAction")
|
|
496
|
-
? this.getOptions("interface.listAction")
|
|
497
|
-
: OPT_DEFAULT_LIST_ACTION;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
setCombinedActionName(actionName = OPT_DEFAULT_COUNT_ACTION) {
|
|
501
|
-
this.setWorking("interface.combinedAction", actionName);
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
getCombinedActionName() {
|
|
505
|
-
return this.getWorking("interface.combinedAction")
|
|
506
|
-
? this.getWorking("interface.combinedAction")
|
|
507
|
-
: OPT_DEFAULT_COMBINED_ACTION;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
getCountActionName() {
|
|
511
|
-
return this.getOptions("interface.countAction")
|
|
512
|
-
? this.getOptions("interface.countAction")
|
|
513
|
-
: OPT_DEFAULT_COUNT_ACTION;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
loadData() {
|
|
517
|
-
//load from server
|
|
518
|
-
let query = this.getDataInterface()
|
|
519
|
-
.setFilter(this.getFilter())
|
|
520
|
-
.setSorter(this.getSorter())
|
|
521
|
-
.setReturn(this.getReturn())
|
|
522
|
-
.setSearch(this.getSearch())
|
|
523
|
-
.setPager(this.getPager()),
|
|
524
|
-
actionName;
|
|
525
|
-
if (this.getOptions("interface.combined", OPT_DEFAULT_COMBINED)) {
|
|
526
|
-
actionName = this.getCombinedActionName();
|
|
527
|
-
} else {
|
|
528
|
-
actionName = this.getLoadDataActionName();
|
|
529
|
-
}
|
|
530
|
-
return query["$" + actionName]();
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
goToNext() {
|
|
534
|
-
let next = isNaN(this.getState("pager.page"))
|
|
535
|
-
? this.getDefaultPageNumber()
|
|
536
|
-
: this.getState("pager.page") + 1;
|
|
537
|
-
this.setState(
|
|
538
|
-
"pager.page",
|
|
539
|
-
Math.min(next, this.getState("pagination.pages.to"))
|
|
540
|
-
);
|
|
541
|
-
this.updateData();
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
goToPrev() {
|
|
545
|
-
let prev = isNaN(this.getState("pager.page"))
|
|
546
|
-
? this.getDefaultPageNumber()
|
|
547
|
-
: this.getState("pager.page") - 1;
|
|
548
|
-
this.setState(
|
|
549
|
-
"pager.page",
|
|
550
|
-
Math.max(prev, this.getState("pagination.pages.from"))
|
|
551
|
-
);
|
|
552
|
-
this.updateData();
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
goToFirst() {
|
|
556
|
-
this.setState("pager.page", this.getState("pagination.pages.from"));
|
|
557
|
-
this.updateData();
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
goToLast() {
|
|
561
|
-
this.setState("pager.page", this.getState("pagination.pages.to"));
|
|
562
|
-
this.updateData();
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
goToPage(pageNumber) {
|
|
566
|
-
this.setState("pager.page", pageNumber);
|
|
567
|
-
this.updateData();
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
testDataItem(item) {
|
|
571
|
-
let strValue = this.getSearch().toLowerCase();
|
|
572
|
-
for (let k in item) {
|
|
573
|
-
let toComp = item[k].toString().toLowerCase();
|
|
574
|
-
if (toComp.indexOf(strValue) > -1) {
|
|
575
|
-
return true;
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
return false;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
getRowsCount() {
|
|
582
|
-
let query = this.getDataInterface().setFilter(this.getFilter());
|
|
583
|
-
return query["$" + this.getCountActionName()]()
|
|
584
|
-
.then((data) => {
|
|
585
|
-
this.updatePagination(data.count);
|
|
586
|
-
})
|
|
587
|
-
.catch((e) => {
|
|
588
|
-
this.error(e);
|
|
589
|
-
});
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
updatePagination(itemsCount) {
|
|
593
|
-
this.log("update pagination", itemsCount);
|
|
594
|
-
this.state.pagination.pages.list.splice(
|
|
595
|
-
0,
|
|
596
|
-
this.state.pagination.pages.list.length
|
|
597
|
-
);
|
|
598
|
-
let itemsFrom =
|
|
599
|
-
(this.getPager().page - OPT_DEFAULT_PAGE_NUMBER) *
|
|
600
|
-
this.getPager().size +
|
|
601
|
-
1,
|
|
602
|
-
pagesCount =
|
|
603
|
-
itemsCount % this.getPager().size
|
|
604
|
-
? Math.floor(itemsCount / this.getPager().size) + 1
|
|
605
|
-
: Math.round(itemsCount / this.getPager().size),
|
|
606
|
-
pagesFrom = Math.max(
|
|
607
|
-
OPT_DEFAULT_PAGE_NUMBER,
|
|
608
|
-
this.getPager().page - OPT_DEFAULT_PAGE_RANGE
|
|
609
|
-
),
|
|
610
|
-
pagesTo = Math.min(
|
|
611
|
-
pagesCount - (1 - OPT_DEFAULT_PAGE_NUMBER),
|
|
612
|
-
this.getPager().page + OPT_DEFAULT_PAGE_RANGE
|
|
613
|
-
),
|
|
614
|
-
list = [],
|
|
615
|
-
itemsTo = Math.min(
|
|
616
|
-
itemsFrom + this.getPager().size - 1,
|
|
617
|
-
itemsCount
|
|
618
|
-
);
|
|
619
|
-
for (let t = pagesFrom; t <= pagesTo; t++) {
|
|
620
|
-
list.push({
|
|
621
|
-
index: t,
|
|
622
|
-
active: t === this.getPager().page,
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
this.stores.state.update((val) => {
|
|
627
|
-
this.log("update pagination", val);
|
|
628
|
-
val.pagination.items.count = itemsCount;
|
|
629
|
-
val.pagination.items.from = itemsFrom;
|
|
630
|
-
val.pagination.items.to = itemsTo;
|
|
631
|
-
val.pagination.pages.count = pagesCount;
|
|
632
|
-
val.pagination.pages.from = pagesFrom;
|
|
633
|
-
val.pagination.pages.to = pagesTo;
|
|
634
|
-
val.pagination.pages.current = this.getPager().page;
|
|
635
|
-
val.pagination.pages.list.splice(
|
|
636
|
-
0,
|
|
637
|
-
val.pagination.pages.list.length,
|
|
638
|
-
...list
|
|
639
|
-
);
|
|
640
|
-
return val;
|
|
641
|
-
});
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
updateData() {
|
|
645
|
-
if (this.isLive()) {
|
|
646
|
-
if (this.ifUpdating()) {
|
|
647
|
-
return;
|
|
648
|
-
}
|
|
649
|
-
if (!this.getOptions("endless", false)) {
|
|
650
|
-
this.clearRawData();
|
|
651
|
-
}
|
|
652
|
-
this.setUpdating();
|
|
653
|
-
if (this.getOptions("interface.combined", OPT_DEFAULT_COMBINED)) {
|
|
654
|
-
this.loadData()
|
|
655
|
-
.then((data) => {
|
|
656
|
-
let full =
|
|
657
|
-
notCommon.objHas(data, "status") &&
|
|
658
|
-
notCommon.objHas(data, "result");
|
|
659
|
-
this.stores.filtered.update((val) => {
|
|
660
|
-
if (!this.getOptions("endless", false)) {
|
|
661
|
-
this.clearFilteredData();
|
|
662
|
-
}
|
|
663
|
-
if (full && data?.result.list) {
|
|
664
|
-
val.push(...(data.result.list || []));
|
|
665
|
-
} else {
|
|
666
|
-
if (
|
|
667
|
-
notCommon.objHas(data, "list") &&
|
|
668
|
-
Array.isArray(data.list)
|
|
669
|
-
) {
|
|
670
|
-
val.push(...data.list);
|
|
671
|
-
} else if (Array.isArray(data)) {
|
|
672
|
-
val.push(...data);
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
return val;
|
|
676
|
-
});
|
|
677
|
-
this.setWorking(
|
|
678
|
-
"lastCount",
|
|
679
|
-
full ? data.result.count : data.count
|
|
680
|
-
);
|
|
681
|
-
})
|
|
682
|
-
.then(() => {
|
|
683
|
-
this.updatePagination(this.getWorking("lastCount"));
|
|
684
|
-
})
|
|
685
|
-
.catch(this.error.bind(this))
|
|
686
|
-
.then(this.setUpdated.bind(this));
|
|
687
|
-
} else {
|
|
688
|
-
this.loadData()
|
|
689
|
-
.then((data) => {
|
|
690
|
-
this.stores.filtered.update((val) => {
|
|
691
|
-
val.push(...data);
|
|
692
|
-
return val;
|
|
693
|
-
});
|
|
694
|
-
})
|
|
695
|
-
.then(this.getRowsCount.bind(this))
|
|
696
|
-
.catch(this.error.bind(this))
|
|
697
|
-
.then(this.setUpdated.bind(this));
|
|
698
|
-
}
|
|
699
|
-
} else {
|
|
700
|
-
//local magic
|
|
701
|
-
this.setUpdating();
|
|
702
|
-
this.processData();
|
|
703
|
-
this.setUpdated();
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
getData() {
|
|
708
|
-
return this.data;
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
processData() {
|
|
712
|
-
let thatFilter = this.getFilter();
|
|
713
|
-
//this.getData('rows').__setPassive;
|
|
714
|
-
this.log(this.getData());
|
|
715
|
-
if (
|
|
716
|
-
typeof thatFilter !== "undefined" &&
|
|
717
|
-
thatFilter !== null &&
|
|
718
|
-
typeof thatFilter.filterSearch !== "undefined" &&
|
|
719
|
-
thatFilter.filterSearch !== null &&
|
|
720
|
-
thatFilter.filterSearch.length > 0
|
|
721
|
-
) {
|
|
722
|
-
this.stores.filtered.update((val) => {
|
|
723
|
-
val.splice(
|
|
724
|
-
0,
|
|
725
|
-
val.length,
|
|
726
|
-
...this.data.raw.filter(this.testDataItem.bind(this))
|
|
727
|
-
);
|
|
728
|
-
return val;
|
|
729
|
-
});
|
|
730
|
-
} else {
|
|
731
|
-
this.stores.filtered.update((val) => {
|
|
732
|
-
val.splice(0, val.length, ...this.data.raw);
|
|
733
|
-
return val;
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
////sorter
|
|
737
|
-
let thatSorter = this.getSorter();
|
|
738
|
-
if (typeof thatSorter !== "undefined" && thatSorter !== null) {
|
|
739
|
-
this.stores.filtered.update((val) => {
|
|
740
|
-
val.sort((item1, item2) => {
|
|
741
|
-
let t1 = notPath.get(thatSorter.sortByField, item1, {}),
|
|
742
|
-
t2 = notPath.get(thatSorter.sortByField, item2, {});
|
|
743
|
-
if (isNaN(t1)) {
|
|
744
|
-
if (
|
|
745
|
-
typeof t1 !== "undefined" &&
|
|
746
|
-
typeof t2 !== "undefined" &&
|
|
747
|
-
t1.localeCompare
|
|
748
|
-
) {
|
|
749
|
-
return (
|
|
750
|
-
t1.localeCompare() * -thatSorter.sortDirection
|
|
751
|
-
);
|
|
752
|
-
} else {
|
|
753
|
-
return 0;
|
|
754
|
-
}
|
|
755
|
-
} else {
|
|
756
|
-
return (t1 < t2 ? 1 : -1) * thatSorter.sortDirection;
|
|
757
|
-
}
|
|
758
|
-
});
|
|
759
|
-
return val;
|
|
760
|
-
});
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
error() {
|
|
765
|
-
if (this.options.logger) {
|
|
766
|
-
this.options.logger.error(...arguments);
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
log() {
|
|
771
|
-
if (this.options.logger) {
|
|
772
|
-
this.options.logger.log(...arguments);
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
checkFieldsNames() {
|
|
777
|
-
const fieldId = this.getOptions("idField");
|
|
778
|
-
const pathId = ":" + fieldId;
|
|
779
|
-
let fields = this.getOptions("fields", []);
|
|
780
|
-
fields.forEach((field) => {
|
|
781
|
-
if (pathId === field.path) {
|
|
782
|
-
field.path = field.path + CONST_ID_DUBLICATE_POSTFIX;
|
|
783
|
-
}
|
|
784
|
-
});
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
readFieldValue(path, item, helpers) {
|
|
788
|
-
if (path.indexOf(CONST_ID_DUBLICATE_POSTFIX) > -1) {
|
|
789
|
-
const fieldId = this.getOptions("idField");
|
|
790
|
-
const pathId = ":" + fieldId;
|
|
791
|
-
return notPath.get(pathId, item, helpers);
|
|
792
|
-
} else {
|
|
793
|
-
return notPath.get(path, item, helpers);
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
|
|
797
|
-
refineFiltered() {
|
|
798
|
-
let result = [];
|
|
799
|
-
this.checkFieldsNames();
|
|
800
|
-
this.data.filtered.forEach((item, index) => {
|
|
801
|
-
let refined = {};
|
|
802
|
-
if (this.getOptions("idField")) {
|
|
803
|
-
refined[this.getOptions("idField")] =
|
|
804
|
-
item[this.getOptions("idField")];
|
|
805
|
-
}
|
|
806
|
-
this.getOptions("fields", []).forEach((field) => {
|
|
807
|
-
let preprocessed = null,
|
|
808
|
-
val = this.readFieldValue(
|
|
809
|
-
field.path,
|
|
810
|
-
item,
|
|
811
|
-
this.getOptions("helpers")
|
|
812
|
-
);
|
|
813
|
-
if (notCommon.objHas(field, OPT_FIELD_NAME_PRE_PROC)) {
|
|
814
|
-
try {
|
|
815
|
-
preprocessed = field[OPT_FIELD_NAME_PRE_PROC](
|
|
816
|
-
val,
|
|
817
|
-
item,
|
|
818
|
-
index
|
|
819
|
-
);
|
|
820
|
-
} catch (e) {
|
|
821
|
-
this.error(
|
|
822
|
-
"Error while preprocessing cell value",
|
|
823
|
-
val,
|
|
824
|
-
item,
|
|
825
|
-
index
|
|
826
|
-
);
|
|
827
|
-
this.error(e);
|
|
828
|
-
}
|
|
829
|
-
notPath.set(field.path, refined, preprocessed);
|
|
830
|
-
} else {
|
|
831
|
-
notPath.set(field.path, refined, val);
|
|
832
|
-
}
|
|
833
|
-
});
|
|
834
|
-
result.push(refined);
|
|
835
|
-
});
|
|
836
|
-
this.stores.refined.update((val) => {
|
|
837
|
-
val.splice(0, val.length, ...result);
|
|
838
|
-
return val;
|
|
839
|
-
});
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
$destroy() {
|
|
843
|
-
for (let name in this.ui) {
|
|
844
|
-
this.ui[name].$destroy && this.ui[name].$destroy();
|
|
845
|
-
delete this.ui[name];
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
export default notTable;
|