quasar-ui-danx 0.3.30 → 0.3.31
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/danx.es.js +2756 -2752
- package/dist/danx.es.js.map +1 -1
- package/dist/danx.umd.js +5 -5
- package/dist/danx.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ActionTable/listControls.ts +386 -382
@@ -3,391 +3,395 @@ import { ActionTargetItem, getItem, setItem, waitForRef } from "../../helpers";
|
|
3
3
|
import { getFilterFromUrl } from "./listHelpers";
|
4
4
|
|
5
5
|
export interface ListActionsOptions {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
6
|
+
listRoute: Function;
|
7
|
+
summaryRoute?: Function | null;
|
8
|
+
filterFieldOptionsRoute?: Function | null;
|
9
|
+
moreRoute?: Function | null;
|
10
|
+
itemDetailsRoute?: Function | null;
|
11
|
+
urlPattern?: RegExp | null;
|
12
|
+
filterDefaults?: Record<string, any>;
|
13
|
+
refreshFilters?: boolean;
|
14
14
|
}
|
15
15
|
|
16
16
|
export interface PagedItems {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
data: any[] | undefined;
|
18
|
+
meta: {
|
19
|
+
total: number;
|
20
|
+
last_page?: number;
|
21
|
+
} | undefined;
|
22
22
|
}
|
23
23
|
|
24
|
-
export function useListControls(
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
}: ListActionsOptions) {
|
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
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
24
|
+
export function useListControls({
|
25
|
+
listRoute,
|
26
|
+
summaryRoute = null,
|
27
|
+
filterFieldOptionsRoute = null,
|
28
|
+
moreRoute = null,
|
29
|
+
itemDetailsRoute = null,
|
30
|
+
refreshFilters = false,
|
31
|
+
urlPattern = null,
|
32
|
+
filterDefaults = {}
|
33
|
+
}: ListActionsOptions) {
|
34
|
+
let isInitialized = false;
|
35
|
+
let PAGE_SETTINGS_KEY: string | null = null;
|
36
|
+
const pagedItems: Ref<PagedItems | null> = shallowRef(null);
|
37
|
+
const filter: Ref<object | any> = ref({});
|
38
|
+
const globalFilter = ref({});
|
39
|
+
const showFilters = ref(false);
|
40
|
+
const selectedRows = shallowRef([]);
|
41
|
+
const isLoadingList = ref(false);
|
42
|
+
const isLoadingSummary = ref(false);
|
43
|
+
const summary = shallowRef(null);
|
44
|
+
|
45
|
+
// The active ad for viewing / editing
|
46
|
+
const activeItem: ShallowRef<ActionTargetItem | null> = shallowRef(null);
|
47
|
+
// Controls the active panel (ie: tab) if rendering a panels drawer or similar
|
48
|
+
const activePanel = shallowRef(null);
|
49
|
+
|
50
|
+
// Filter fields are the field values available for the currently applied filter on Creative Groups
|
51
|
+
// (ie: all states available under the current filter)
|
52
|
+
const filterFieldOptions = ref({});
|
53
|
+
const isLoadingFilters = ref(false);
|
54
|
+
|
55
|
+
const filterActiveCount = computed(() => Object.keys(filter.value).filter(key => filter.value[key] !== undefined).length);
|
56
|
+
|
57
|
+
const PAGING_DEFAULT = {
|
58
|
+
__sort: null,
|
59
|
+
sortBy: null,
|
60
|
+
descending: false,
|
61
|
+
page: 1,
|
62
|
+
rowsNumber: 0,
|
63
|
+
rowsPerPage: 50
|
64
|
+
};
|
65
|
+
const quasarPagination = ref(PAGING_DEFAULT);
|
66
|
+
|
67
|
+
const pager = computed(() => ({
|
68
|
+
perPage: quasarPagination.value.rowsPerPage,
|
69
|
+
page: quasarPagination.value.page,
|
70
|
+
filter: { ...filter.value, ...globalFilter.value },
|
71
|
+
sort: quasarPagination.value.__sort || undefined
|
72
|
+
}));
|
73
|
+
|
74
|
+
// When any part of the filter changes, get the new list of creatives
|
75
|
+
watch(pager, () => {
|
76
|
+
saveSettings();
|
77
|
+
loadList();
|
78
|
+
});
|
79
|
+
watch(filter, () => {
|
80
|
+
saveSettings();
|
81
|
+
loadSummary();
|
82
|
+
});
|
83
|
+
watch(selectedRows, loadSummary);
|
84
|
+
|
85
|
+
if (refreshFilters) {
|
86
|
+
watch(filter, loadFilterFieldOptions);
|
87
|
+
}
|
88
|
+
|
89
|
+
async function loadList() {
|
90
|
+
if (!isInitialized) return;
|
91
|
+
isLoadingList.value = true;
|
92
|
+
setPagedItems(await listRoute(pager.value));
|
93
|
+
isLoadingList.value = false;
|
94
|
+
}
|
95
|
+
|
96
|
+
async function loadSummary() {
|
97
|
+
if (!summaryRoute || !isInitialized) return;
|
98
|
+
|
99
|
+
isLoadingSummary.value = true;
|
100
|
+
const summaryFilter = { id: null, ...filter.value, ...globalFilter.value };
|
101
|
+
if (selectedRows.value.length) {
|
102
|
+
summaryFilter.id = selectedRows.value.map((row: { id: string }) => row.id);
|
103
|
+
}
|
104
|
+
summary.value = await summaryRoute(summaryFilter);
|
105
|
+
isLoadingSummary.value = false;
|
106
|
+
}
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Loads the filter field options for the current filter.
|
110
|
+
*
|
111
|
+
* @returns {Promise<void>}
|
112
|
+
*/
|
113
|
+
async function loadFilterFieldOptions() {
|
114
|
+
if (!filterFieldOptionsRoute || !isInitialized) return;
|
115
|
+
isLoadingFilters.value = true;
|
116
|
+
filterFieldOptions.value = await filterFieldOptionsRoute(filter.value);
|
117
|
+
isLoadingFilters.value = false;
|
118
|
+
}
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Watches for a filter URL parameter and applies the filter if it is set.
|
122
|
+
*/
|
123
|
+
function applyFilterFromUrl(url: string, filterFields = null) {
|
124
|
+
if (urlPattern && url.match(urlPattern)) {
|
125
|
+
// A flat list of valid filterable field names
|
126
|
+
const validFilterKeys = filterFields?.value?.map(group => group.fields.map(field => field.name)).flat();
|
127
|
+
|
128
|
+
const urlFilter = getFilterFromUrl(url, validFilterKeys);
|
129
|
+
|
130
|
+
if (Object.keys(urlFilter).length > 0) {
|
131
|
+
filter.value = urlFilter;
|
132
|
+
|
133
|
+
// Override whatever is in local storage with this new filter
|
134
|
+
updateSettings("filter", filter.value);
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
// Set the reactive pager to map from the Laravel pagination to Quasar pagination
|
140
|
+
// and automatically update the list of ads
|
141
|
+
function setPagedItems(items: any[] | PagedItems) {
|
142
|
+
let data, meta;
|
143
|
+
|
144
|
+
if (Array.isArray(items)) {
|
145
|
+
data = items;
|
146
|
+
meta = { total: items.length };
|
147
|
+
|
148
|
+
} else {
|
149
|
+
data = items.data;
|
150
|
+
meta = items.meta;
|
151
|
+
}
|
152
|
+
|
153
|
+
// Update the Quasar pagination rows number if it is different from the total
|
154
|
+
if (meta && meta.total !== quasarPagination.value.rowsNumber) {
|
155
|
+
quasarPagination.value.rowsNumber = meta.total;
|
156
|
+
}
|
157
|
+
|
158
|
+
// Add a reactive isSaving property to each item (for performance reasons in checking saving state)
|
159
|
+
data = data.map((item: any) => {
|
160
|
+
// We want to keep the isSaving state if it is already set, as optimizations prevent reloading the
|
161
|
+
// components, and therefore reactivity is not responding to the new isSaving state
|
162
|
+
const oldItem = pagedItems.value?.data?.find(i => i.id === item.id);
|
163
|
+
return { ...item, isSaving: oldItem?.isSaving || ref(false) };
|
164
|
+
});
|
165
|
+
|
166
|
+
pagedItems.value = { data, meta };
|
167
|
+
}
|
168
|
+
|
169
|
+
/**
|
170
|
+
* Resets the filter and pagination settings to their defaults.
|
171
|
+
*/
|
172
|
+
function resetPaging() {
|
173
|
+
quasarPagination.value = PAGING_DEFAULT;
|
174
|
+
}
|
175
|
+
|
176
|
+
/**
|
177
|
+
* Updates a row in the paged items list with the new item data. Uses the item's id to find the row.
|
178
|
+
*
|
179
|
+
* @param updatedItem
|
180
|
+
*/
|
181
|
+
function setItemInList(updatedItem: any) {
|
182
|
+
const data = pagedItems.value?.data?.map(item => (item.id === updatedItem.id && (item.updated_at === null || item.updated_at <= updatedItem.updated_at)) ? updatedItem : item);
|
183
|
+
setPagedItems({
|
184
|
+
data,
|
185
|
+
meta: { total: pagedItems.value.meta.total }
|
186
|
+
});
|
187
|
+
|
188
|
+
// Update the active item as well if it is set
|
189
|
+
if (activeItem.value?.id === updatedItem.id) {
|
190
|
+
activeItem.value = { ...activeItem.value, ...updatedItem };
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
/**
|
195
|
+
* Loads more items into the list.
|
196
|
+
*/
|
197
|
+
async function loadMore(index: number, perPage = undefined) {
|
198
|
+
if (!moreRoute) return;
|
199
|
+
|
200
|
+
const newItems = await moreRoute({
|
201
|
+
page: index + 1,
|
202
|
+
perPage,
|
203
|
+
filter: { ...filter.value, ...globalFilter.value }
|
204
|
+
});
|
205
|
+
|
206
|
+
if (newItems && newItems.length > 0) {
|
207
|
+
setPagedItems({
|
208
|
+
data: [...pagedItems.value.data, ...newItems],
|
209
|
+
meta: { total: pagedItems.value.meta.total }
|
210
|
+
});
|
211
|
+
return true;
|
212
|
+
}
|
213
|
+
|
214
|
+
return false;
|
215
|
+
}
|
216
|
+
|
217
|
+
/**
|
218
|
+
* Refreshes the list, summary, and filter field options.
|
219
|
+
*/
|
220
|
+
async function refreshAll() {
|
221
|
+
return Promise.all([loadList(), loadSummary(), loadFilterFieldOptions(), getActiveItemDetails()]);
|
222
|
+
}
|
223
|
+
|
224
|
+
/**
|
225
|
+
* Updates the settings in local storage
|
226
|
+
*/
|
227
|
+
function updateSettings(key: string, value: any) {
|
228
|
+
if (!PAGE_SETTINGS_KEY) throw new Error("updateSettings failed: PAGE_SETTINGS_KEY is not set");
|
229
|
+
|
230
|
+
const settings = getItem(PAGE_SETTINGS_KEY) || {};
|
231
|
+
settings[key] = value;
|
232
|
+
setItem(PAGE_SETTINGS_KEY, settings);
|
233
|
+
}
|
234
|
+
|
235
|
+
/**
|
236
|
+
* Loads the filter and pagination settings from local storage.
|
237
|
+
*/
|
238
|
+
function loadSettings() {
|
239
|
+
if (!PAGE_SETTINGS_KEY) throw new Error("loadSettings failed: PAGE_SETTINGS_KEY is not set");
|
240
|
+
|
241
|
+
const settings = getItem(PAGE_SETTINGS_KEY);
|
242
|
+
|
243
|
+
// Load the filter settings from local storage
|
244
|
+
if (settings) {
|
245
|
+
filter.value = { ...settings.filter, ...filter.value };
|
246
|
+
quasarPagination.value = settings.quasarPagination;
|
247
|
+
} else {
|
248
|
+
// If no local storage settings, apply the default filters
|
249
|
+
filter.value = { ...filterDefaults, ...filter.value };
|
250
|
+
}
|
251
|
+
|
252
|
+
setTimeout(() => {
|
253
|
+
if (!isLoadingList.value) {
|
254
|
+
loadList();
|
255
|
+
}
|
256
|
+
|
257
|
+
if (!isLoadingSummary.value) {
|
258
|
+
loadSummary();
|
259
|
+
}
|
260
|
+
|
261
|
+
if (!isLoadingFilters.value) {
|
262
|
+
loadFilterFieldOptions();
|
263
|
+
}
|
264
|
+
}, 1);
|
265
|
+
}
|
266
|
+
|
267
|
+
/**
|
268
|
+
* Saves the current filter and pagination settings to local storage.
|
269
|
+
*/
|
270
|
+
async function saveSettings() {
|
271
|
+
if (!PAGE_SETTINGS_KEY) throw new Error("saveSettings failed: PAGE_SETTINGS_KEY is not set");
|
272
|
+
|
273
|
+
const settings = {
|
274
|
+
filter: filter.value,
|
275
|
+
quasarPagination: { ...quasarPagination.value, page: 1 }
|
276
|
+
};
|
277
|
+
// save in local storage
|
278
|
+
setItem(PAGE_SETTINGS_KEY, settings);
|
279
|
+
}
|
280
|
+
|
281
|
+
/**
|
282
|
+
* Gets the additional details for the currently active item.
|
283
|
+
* (ie: data that is not normally loaded in the list because it is not needed for the list view)
|
284
|
+
* @returns {Promise<void>}
|
285
|
+
*/
|
286
|
+
async function getActiveItemDetails() {
|
287
|
+
if (!activeItem.value || !itemDetailsRoute) return;
|
288
|
+
|
289
|
+
const result = await itemDetailsRoute(activeItem.value);
|
290
|
+
|
291
|
+
// Only set the ad details if we are the response for the currently loaded item
|
292
|
+
// NOTE: race conditions might allow the finished loading item to be different to the currently
|
293
|
+
// requested item
|
294
|
+
if (result?.id === activeItem.value?.id) {
|
295
|
+
const loadedItem = pagedItems.value?.data.find((i: { id: string }) => i.id === result.id);
|
296
|
+
activeItem.value = { ...result, isSaving: loadedItem.isSaving || ref(false) };
|
297
|
+
}
|
298
|
+
}
|
299
|
+
|
300
|
+
// Whenever the active item changes, fill the additional item details
|
301
|
+
// (ie: tasks, verifications, creatives, etc.)
|
302
|
+
if (itemDetailsRoute) {
|
303
|
+
watch(() => activeItem.value, async (newItem, oldItem) => {
|
304
|
+
if (newItem && oldItem?.id !== newItem.id) {
|
305
|
+
await getActiveItemDetails();
|
306
|
+
}
|
307
|
+
});
|
308
|
+
}
|
309
|
+
|
310
|
+
/**
|
311
|
+
* Opens the item's form with the given item and tab
|
312
|
+
*
|
313
|
+
* @param item
|
314
|
+
* @param panel
|
315
|
+
*/
|
316
|
+
function activatePanel(item, panel) {
|
317
|
+
activeItem.value = item;
|
318
|
+
activePanel.value = panel;
|
319
|
+
}
|
320
|
+
|
321
|
+
/**
|
322
|
+
* Gets the next item in the list at the given offset (ie: 1 or -1) from the current position in the list of the
|
323
|
+
* selected item. If the next item is on a previous or next page, it will load the page first then select the item
|
324
|
+
*/
|
325
|
+
async function getNextItem(offset: number) {
|
326
|
+
if (!pagedItems.value) return;
|
327
|
+
|
328
|
+
const index = pagedItems.value.data.findIndex((i: { id: string }) => i.id === activeItem.value?.id);
|
329
|
+
if (index === undefined || index === null) return;
|
330
|
+
|
331
|
+
let nextIndex = index + offset;
|
332
|
+
|
333
|
+
// Load the previous page if the offset is before index 0
|
334
|
+
if (nextIndex < 0) {
|
335
|
+
if (quasarPagination.value.page > 1) {
|
336
|
+
quasarPagination.value = { ...quasarPagination.value, page: quasarPagination.value.page - 1 };
|
337
|
+
await waitForRef(isLoadingList, false);
|
338
|
+
nextIndex = pagedItems.value.data.length - 1;
|
339
|
+
} else {
|
340
|
+
// There are no more previous pages
|
341
|
+
return;
|
342
|
+
}
|
343
|
+
}
|
344
|
+
|
345
|
+
// Load the next page if the offset is past the last index
|
346
|
+
if (nextIndex >= pagedItems.value.data.length) {
|
347
|
+
if (quasarPagination.value.page < pagedItems.value.meta.last_page) {
|
348
|
+
quasarPagination.value = { ...quasarPagination.value, page: quasarPagination.value.page + 1 };
|
349
|
+
await waitForRef(isLoadingList, false);
|
350
|
+
nextIndex = 0;
|
351
|
+
} else {
|
352
|
+
// There are no more next pages
|
353
|
+
return;
|
354
|
+
}
|
355
|
+
}
|
356
|
+
|
357
|
+
activeItem.value = pagedItems.value?.data[nextIndex];
|
358
|
+
}
|
359
|
+
|
360
|
+
// Initialize the list actions and load settings, lists, summaries, filter fields, etc.
|
361
|
+
function initialize(name: string) {
|
362
|
+
PAGE_SETTINGS_KEY = `${name}-pagination-settings`;
|
363
|
+
isInitialized = true;
|
364
|
+
loadSettings();
|
365
|
+
}
|
366
|
+
|
367
|
+
return {
|
368
|
+
// State
|
369
|
+
pagedItems,
|
370
|
+
filter,
|
371
|
+
globalFilter,
|
372
|
+
filterActiveCount,
|
373
|
+
showFilters,
|
374
|
+
summary,
|
375
|
+
filterFieldOptions,
|
376
|
+
selectedRows,
|
377
|
+
isLoadingList,
|
378
|
+
isLoadingFilters,
|
379
|
+
isLoadingSummary,
|
380
|
+
pager,
|
381
|
+
quasarPagination,
|
382
|
+
activeItem,
|
383
|
+
activePanel,
|
384
|
+
|
385
|
+
// Actions
|
386
|
+
initialize,
|
387
|
+
loadSummary,
|
388
|
+
resetPaging,
|
389
|
+
loadList,
|
390
|
+
loadMore,
|
391
|
+
refreshAll,
|
392
|
+
getNextItem,
|
393
|
+
activatePanel,
|
394
|
+
applyFilterFromUrl,
|
395
|
+
setItemInList
|
396
|
+
};
|
393
397
|
}
|