quasar-factory-lib 0.0.48 → 0.0.49
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/dist/components/Table/Table.vue.d.ts +4 -9
- package/dist/components/Table/utils/filterMethod.d.ts +1 -1
- package/dist/layouts/PdaLayout.vue.d.ts +5 -9
- package/dist/pages/TablePage.vue.d.ts +5 -9
- package/dist/quasar-factory-lib.js +678 -665
- package/dist/quasar-factory-lib.umd.cjs +9 -9
- package/dist/store/table.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/Table/Table.vue +39 -9
- package/src/components/Table/utils/filterMethod.ts +3 -1
- package/src/pages/TablePage.vue +2 -2
- package/src/store/table.js +2 -1
package/dist/store/table.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export const tableStore: import("pinia").StoreDefinition<"tableStore", {
|
|
|
3
3
|
filterValue: import("@vueuse/shared").RemovableRef<string>;
|
|
4
4
|
lastFilterValue: import("@vueuse/shared").RemovableRef<string>;
|
|
5
5
|
visiblecolumns: import("@vueuse/shared").RemovableRef<never[]>;
|
|
6
|
+
prepared: import("@vueuse/shared").RemovableRef<boolean>;
|
|
6
7
|
}, {}, {
|
|
7
8
|
setFilterValue(val: any): void;
|
|
8
9
|
cleanTableFilter(): void;
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
<!-- eslint-disable vue/no-v-model-argument -->
|
|
4
4
|
<!-- eslint-disable vue/no-use-v-if-with-v-for -->
|
|
5
5
|
<div>
|
|
6
|
+
{{filteredRows.length}}
|
|
6
7
|
<q-table
|
|
7
8
|
v-if="!showSkeleton"
|
|
8
9
|
ref="myTable"
|
|
@@ -11,6 +12,7 @@
|
|
|
11
12
|
:grid="smallDevice"
|
|
12
13
|
:style="tableStyle"
|
|
13
14
|
flat
|
|
15
|
+
:filter-method="customFilter"
|
|
14
16
|
bordered
|
|
15
17
|
:rows="rowsData"
|
|
16
18
|
:columns="columns"
|
|
@@ -21,7 +23,6 @@
|
|
|
21
23
|
table-class="text-grey-9"
|
|
22
24
|
table-header-class="main-color"
|
|
23
25
|
:filter="filterComputed"
|
|
24
|
-
:filter-method="filterMethod"
|
|
25
26
|
:sort-method="customSortMethod"
|
|
26
27
|
separator="horizontal"
|
|
27
28
|
binary-state-sort
|
|
@@ -127,10 +128,10 @@ export default defineComponent({
|
|
|
127
128
|
type: Array as () => string[],
|
|
128
129
|
required: true
|
|
129
130
|
},
|
|
130
|
-
filterMethod: {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
},
|
|
131
|
+
// filterMethod: {
|
|
132
|
+
// type: Function,
|
|
133
|
+
// default: function () {}
|
|
134
|
+
// },
|
|
134
135
|
// sortMethod: {
|
|
135
136
|
// type: Function,
|
|
136
137
|
// default: function () {}
|
|
@@ -182,6 +183,10 @@ export default defineComponent({
|
|
|
182
183
|
type: Function,
|
|
183
184
|
default: function () {}
|
|
184
185
|
}
|
|
186
|
+
// filteredRows: {
|
|
187
|
+
// type: Array,
|
|
188
|
+
// required: true
|
|
189
|
+
// }
|
|
185
190
|
},
|
|
186
191
|
emits: [
|
|
187
192
|
'onSelectVisibleColumns',
|
|
@@ -207,7 +212,8 @@ export default defineComponent({
|
|
|
207
212
|
loading: false,
|
|
208
213
|
forceRender: false,
|
|
209
214
|
totalPage: 0,
|
|
210
|
-
pageSize:
|
|
215
|
+
pageSize: 5,
|
|
216
|
+
filteredRows: [] as object | []
|
|
211
217
|
}
|
|
212
218
|
},
|
|
213
219
|
computed: {
|
|
@@ -236,6 +242,7 @@ export default defineComponent({
|
|
|
236
242
|
pageLength (): number {
|
|
237
243
|
return (this.totalPage + 1) * this.pageSize
|
|
238
244
|
}
|
|
245
|
+
|
|
239
246
|
},
|
|
240
247
|
watch: {
|
|
241
248
|
rows (val) {
|
|
@@ -244,6 +251,7 @@ export default defineComponent({
|
|
|
244
251
|
visibleColumns (val: string [] | []) {
|
|
245
252
|
this.visibleColumnsData = val
|
|
246
253
|
}
|
|
254
|
+
|
|
247
255
|
},
|
|
248
256
|
mounted () {
|
|
249
257
|
},
|
|
@@ -304,7 +312,12 @@ export default defineComponent({
|
|
|
304
312
|
sortBy: string,
|
|
305
313
|
descending: boolean
|
|
306
314
|
) {
|
|
307
|
-
|
|
315
|
+
let data = []
|
|
316
|
+
if (this.store.filterValue === '') {
|
|
317
|
+
data = [...this.rows];
|
|
318
|
+
} else {
|
|
319
|
+
data = [...this.filteredRows];
|
|
320
|
+
}
|
|
308
321
|
|
|
309
322
|
if (sortBy) {
|
|
310
323
|
data.sort((a, b) => {
|
|
@@ -352,9 +365,26 @@ export default defineComponent({
|
|
|
352
365
|
}
|
|
353
366
|
});
|
|
354
367
|
}
|
|
355
|
-
return data;
|
|
356
|
-
}
|
|
368
|
+
return data.slice(0, this.pageLength);
|
|
369
|
+
},
|
|
370
|
+
customFilter(rows: string | [], terms: { search: string }) {
|
|
371
|
+
console.log('terms', terms)
|
|
372
|
+
if (this.store.filterValue === '') return this.rows.slice(0, this.pageLength);
|
|
357
373
|
|
|
374
|
+
const filteredRows = this.rows.filter((row) => {
|
|
375
|
+
const rowValues = Object.values(row).join(" ").toLowerCase();
|
|
376
|
+
|
|
377
|
+
if (terms.search && terms.search.trim() !== '') {
|
|
378
|
+
if (rowValues.includes(terms.search.toLowerCase())) {
|
|
379
|
+
return true;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return false
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
this.filteredRows = filteredRows
|
|
386
|
+
return filteredRows.slice(0, this.pageLength);
|
|
387
|
+
}
|
|
358
388
|
}
|
|
359
389
|
})
|
|
360
390
|
</script>
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import infiniteScroll from './infiniteScroll'
|
|
4
4
|
const filterMethod = {
|
|
5
|
-
filter (self: { filteredRows: object [] | [] }, rows: string | [], terms: { search: string })
|
|
5
|
+
filter (self: { filteredRows: object [] | [] }, rows: string | [], terms: { search: string }) {
|
|
6
|
+
console.log(rows)
|
|
6
7
|
if (terms.search !== '') {
|
|
7
8
|
const filteredRows = []
|
|
8
9
|
const lowerSearch = terms.search ? terms.search.toLowerCase() : ''
|
|
@@ -14,6 +15,7 @@ const filterMethod = {
|
|
|
14
15
|
self.filteredRows = filteredRows
|
|
15
16
|
return infiniteScroll.paginationNewTable(self, filteredRows)
|
|
16
17
|
} else {
|
|
18
|
+
self.filteredRows = rows
|
|
17
19
|
return infiniteScroll.paginationNewTable(self, rows)
|
|
18
20
|
}
|
|
19
21
|
},
|
package/src/pages/TablePage.vue
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<q-page-container class=" full-width column justify-center">
|
|
3
3
|
<q-page
|
|
4
4
|
class="full-width column justify-center align-center items-center"
|
|
5
|
-
style="
|
|
5
|
+
style=""
|
|
6
6
|
>
|
|
7
7
|
<div
|
|
8
8
|
class="full-width"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
:show-skeleton="false"
|
|
19
19
|
:selection-type="'multiple'"
|
|
20
20
|
:getCellClass="getCellClass"
|
|
21
|
-
:
|
|
21
|
+
:filtered-rows="filteredRows"
|
|
22
22
|
@on-select-visible-columns="saveSelectedColumns"
|
|
23
23
|
@on-update-basic-checkbox-value="onUpdateBasicCheckboxValue"
|
|
24
24
|
@on-update-customized-checkbox-value="onUpdateCustomizedCheckboxValue"
|
package/src/store/table.js
CHANGED
|
@@ -5,7 +5,8 @@ export const tableStore = defineStore('tableStore', {
|
|
|
5
5
|
disableScannerButtons: useStorage('disableScannerButtons', false),
|
|
6
6
|
filterValue: useStorage('filterValue', ''),
|
|
7
7
|
lastFilterValue: useStorage('lastFilterValue', ''),
|
|
8
|
-
visiblecolumns: useStorage('visiblecolumns', [])
|
|
8
|
+
visiblecolumns: useStorage('visiblecolumns', []),
|
|
9
|
+
prepared: useStorage('prepared', false),
|
|
9
10
|
}),
|
|
10
11
|
getters: {
|
|
11
12
|
},
|