not-bulma 1.0.91 → 1.0.93
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/form/ui.named.numbers.list.svelte +1 -0
- package/src/elements/form/ui.select.svelte +8 -3
- package/src/frame/components/table/notTable.js +11 -0
- package/src/frame/components/table/notTable.svelte +186 -128
- package/src/frame/components/table/notTableFilter.svelte +4 -0
- package/src/frame/crud/actions/list.js +1 -0
package/package.json
CHANGED
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
export let formErrors = false;
|
|
25
25
|
export let formLevelError = false;
|
|
26
26
|
|
|
27
|
+
let selectedVariants = [];
|
|
28
|
+
|
|
27
29
|
$: iconClasses = (icon ? " has-icons-left " : "") + " has-icons-right ";
|
|
28
30
|
$: allErrors = [].concat(
|
|
29
31
|
errors ? errors : [],
|
|
@@ -36,9 +38,12 @@
|
|
|
36
38
|
? UICommon.CLASS_OK
|
|
37
39
|
: UICommon.CLASS_ERR;
|
|
38
40
|
$: multipleClass = multiple ? " is-multiple " : "";
|
|
39
|
-
$:
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
$: {
|
|
42
|
+
value;
|
|
43
|
+
selectedVariants = Array.isArray(variants)
|
|
44
|
+
? variants.filter(filterSelectedVariants)
|
|
45
|
+
: [];
|
|
46
|
+
}
|
|
42
47
|
|
|
43
48
|
function filterSelectedVariants(variant) {
|
|
44
49
|
if (Array.isArray(value) && multiple) {
|
|
@@ -155,6 +155,14 @@ class notTable extends EventEmitter {
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
+
onFilterChange(filter) {
|
|
159
|
+
if (filter) {
|
|
160
|
+
this.setFilter(filter);
|
|
161
|
+
} else {
|
|
162
|
+
this.resetFilter();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
158
166
|
onSelectedUpdate(val) {
|
|
159
167
|
this.data.selected = val;
|
|
160
168
|
}
|
|
@@ -211,6 +219,7 @@ class notTable extends EventEmitter {
|
|
|
211
219
|
this.ui.table = new this.options.ui({
|
|
212
220
|
target: this.options.targetEl,
|
|
213
221
|
props: {
|
|
222
|
+
filterUI: this.getOptions("filterUI", undefined),
|
|
214
223
|
id: this.id,
|
|
215
224
|
helpers: Object.assign({}, this.getHelpers()),
|
|
216
225
|
fields: this.getOptions("fields"),
|
|
@@ -221,10 +230,12 @@ class notTable extends EventEmitter {
|
|
|
221
230
|
showSearch: this.getOptions("showSearch"),
|
|
222
231
|
idField: this.getOptions("idField"),
|
|
223
232
|
getItemId: this.getOptions("getItemId"),
|
|
233
|
+
filter: this.getFilter(),
|
|
224
234
|
},
|
|
225
235
|
});
|
|
226
236
|
}
|
|
227
237
|
this.ui.table.$on("searchChange", (e) => this.onSearchChange(e.detail));
|
|
238
|
+
this.ui.table.$on("filterChange", (e) => this.onFilterChange(e.detail));
|
|
228
239
|
this.ui.table.$on("goToPage", (e) => this.goToPage(e.detail));
|
|
229
240
|
this.ui.table.$on("goToNextPage", () => this.goToNext());
|
|
230
241
|
this.ui.table.$on("goToPrevPage", () => this.goToPrev());
|
|
@@ -1,140 +1,198 @@
|
|
|
1
1
|
<script>
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
2
|
+
import { LOCALE } from "../../../locale";
|
|
3
|
+
|
|
4
|
+
import * as Stores from "./stores.js";
|
|
5
|
+
|
|
6
|
+
import UITableRow from "./notTableRow.svelte";
|
|
7
|
+
|
|
8
|
+
import { UILinks } from "../../../elements/link";
|
|
9
|
+
import { UIButtons } from "../../../elements/button";
|
|
10
|
+
|
|
11
|
+
import { onMount, createEventDispatcher } from "svelte";
|
|
12
|
+
let dispatch = createEventDispatcher();
|
|
13
|
+
|
|
14
|
+
export let id;
|
|
15
|
+
|
|
16
|
+
export let filterUI;
|
|
17
|
+
|
|
18
|
+
export let helpers = {};
|
|
19
|
+
export let state = {};
|
|
20
|
+
export let filter = {};
|
|
21
|
+
export let fields = [];
|
|
22
|
+
export let selected = {};
|
|
23
|
+
export let items = [];
|
|
24
|
+
export let actions = [];
|
|
25
|
+
export let links = [];
|
|
26
|
+
export let search = "";
|
|
27
|
+
export let showSearch = true;
|
|
28
|
+
export let showSelect = true;
|
|
29
|
+
export let selectAll = false;
|
|
30
|
+
|
|
31
|
+
export let getItemId = (item) => item._id;
|
|
32
|
+
|
|
33
|
+
onMount(() => {
|
|
34
|
+
if (showSelect) {
|
|
35
|
+
Stores.get(id).selected.subscribe((value) => {
|
|
36
|
+
selected = value;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
Stores.get(id).refined.subscribe((value) => {
|
|
40
|
+
items = value;
|
|
41
|
+
if (showSelect) {
|
|
42
|
+
for (let itemId in selected) {
|
|
43
|
+
if (!items.some((item) => getItemId(item) === itemId)) {
|
|
44
|
+
delete selected[itemId];
|
|
45
|
+
} else {
|
|
46
|
+
if (
|
|
47
|
+
!Object.prototype.hasOwnProperty.call(
|
|
48
|
+
selected,
|
|
49
|
+
itemId
|
|
50
|
+
)
|
|
51
|
+
) {
|
|
52
|
+
selected[itemId] = false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
selected = selected;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
Stores.get(id).state.subscribe((value) => {
|
|
60
|
+
state = value;
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
function onSearchInput(ev) {
|
|
65
|
+
try {
|
|
66
|
+
let data = ev.currentTarget.value.trim();
|
|
67
|
+
dispatch("searchChange", data);
|
|
68
|
+
} catch (e) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function onFilterChange({ detail }) {
|
|
74
|
+
try {
|
|
75
|
+
dispatch("filterChange", detail);
|
|
76
|
+
} catch (e) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function goPrev() {
|
|
82
|
+
dispatch("goToPrevPage");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function goNext() {
|
|
86
|
+
dispatch("goToNextPage");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function goTo(e) {
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
let el = e.target;
|
|
92
|
+
dispatch("goToPage", parseInt(el.dataset.page));
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function onSelectAll() {
|
|
97
|
+
Stores.get(id).selected.update((value) => {
|
|
98
|
+
items.forEach((item) => {
|
|
99
|
+
value[getItemId(item)] = selectAll;
|
|
100
|
+
});
|
|
101
|
+
return value;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
90
104
|
</script>
|
|
91
105
|
|
|
92
106
|
{#if links.length}
|
|
93
|
-
<div class="field is-grouped">
|
|
94
|
-
|
|
95
|
-
</div>
|
|
107
|
+
<div class="field is-grouped">
|
|
108
|
+
<UILinks values={links} />
|
|
109
|
+
</div>
|
|
96
110
|
{/if}
|
|
97
111
|
{#if actions.length}
|
|
98
|
-
<div class="field is-grouped">
|
|
99
|
-
|
|
100
|
-
</div>
|
|
112
|
+
<div class="field is-grouped">
|
|
113
|
+
<UIButtons values={actions} />
|
|
114
|
+
</div>
|
|
101
115
|
{/if}
|
|
102
|
-
{#if showSearch
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
116
|
+
{#if showSearch}
|
|
117
|
+
{#if filterUI}
|
|
118
|
+
<svelte:component
|
|
119
|
+
this={filterUI}
|
|
120
|
+
bind:filter
|
|
121
|
+
on:change={onFilterChange}
|
|
122
|
+
/>
|
|
123
|
+
{:else}
|
|
124
|
+
<div class="field">
|
|
125
|
+
<div class="control">
|
|
126
|
+
<input
|
|
127
|
+
class="input"
|
|
128
|
+
type="text"
|
|
129
|
+
placeholder="Поиск"
|
|
130
|
+
bind:value={search}
|
|
131
|
+
on:input={onSearchInput}
|
|
132
|
+
/>
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
{/if}
|
|
108
136
|
{/if}
|
|
109
137
|
<table class="table">
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
138
|
+
<thead>
|
|
139
|
+
{#if showSelect}
|
|
140
|
+
<th
|
|
141
|
+
><input
|
|
142
|
+
type="checkbox"
|
|
143
|
+
id="table-row-select-page"
|
|
144
|
+
bind:checked={selectAll}
|
|
145
|
+
placeholder=""
|
|
146
|
+
name="row_selected_all"
|
|
147
|
+
on:change={onSelectAll}
|
|
148
|
+
/></th
|
|
149
|
+
>
|
|
150
|
+
{/if}
|
|
151
|
+
{#each fields as field}
|
|
152
|
+
<th class={field.hideOnMobile ? "is-hidden-touch" : ""}
|
|
153
|
+
>{$LOCALE[field.title]}</th
|
|
154
|
+
>
|
|
155
|
+
{/each}
|
|
156
|
+
</thead>
|
|
157
|
+
<tbody>
|
|
158
|
+
{#each items as item (item._id)}
|
|
159
|
+
<UITableRow
|
|
160
|
+
{id}
|
|
161
|
+
{item}
|
|
162
|
+
{fields}
|
|
163
|
+
{helpers}
|
|
164
|
+
{showSelect}
|
|
165
|
+
{getItemId}
|
|
166
|
+
on:rowSelectChange
|
|
167
|
+
/>
|
|
168
|
+
{/each}
|
|
169
|
+
</tbody>
|
|
123
170
|
</table>
|
|
124
171
|
<nav class="pagination is-centered" aria-label="pagination">
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
172
|
+
<a href class="pagination-previous" on:click={goPrev}>Назад</a>
|
|
173
|
+
<a href class="pagination-next" on:click={goNext}>Вперед</a>
|
|
174
|
+
<ul class="pagination-list">
|
|
175
|
+
{#if state.pagination && state.pagination.pages && state.pagination.pages.list}
|
|
176
|
+
{#each state.pagination.pages.list as page}
|
|
177
|
+
<li>
|
|
178
|
+
{#if page.active}
|
|
179
|
+
<a
|
|
180
|
+
href
|
|
181
|
+
class="pagination-link is-current"
|
|
182
|
+
aria-label="Страница {page.index}"
|
|
183
|
+
aria-current="page">{page.index + 1}</a
|
|
184
|
+
>
|
|
185
|
+
{:else}
|
|
186
|
+
<a
|
|
187
|
+
href
|
|
188
|
+
class="pagination-link"
|
|
189
|
+
aria-label="Страница {page.index}"
|
|
190
|
+
data-page={page.index}
|
|
191
|
+
on:click={goTo}>{page.index + 1}</a
|
|
192
|
+
>
|
|
193
|
+
{/if}
|
|
194
|
+
</li>
|
|
195
|
+
{/each}
|
|
196
|
+
{/if}
|
|
197
|
+
</ul>
|
|
140
198
|
</nav>
|