@monoui/vuejs 1.1.16 → 1.1.19
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/main.js +4 -4
- package/package.json +1 -1
- package/src/components/Table/Table.vue +137 -97
package/package.json
CHANGED
|
@@ -185,69 +185,73 @@
|
|
|
185
185
|
</div>
|
|
186
186
|
<slot name="pagination-seperator" />
|
|
187
187
|
<slot name="pagination">
|
|
188
|
-
<div class="
|
|
189
|
-
<
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
188
|
+
<div :class="paginationClass">
|
|
189
|
+
<div
|
|
190
|
+
class="d-flex justify-content-between align-items-center mt-2"
|
|
191
|
+
>
|
|
192
|
+
<slot name="pagination-filters">
|
|
193
|
+
<div>
|
|
194
|
+
<div v-show="!isDataEmpty">
|
|
195
|
+
<span>Show</span>
|
|
196
|
+
<b-dropdown
|
|
197
|
+
:text="itemPerPageText"
|
|
198
|
+
class="m-md-2"
|
|
199
|
+
size="sm"
|
|
200
|
+
variant="light"
|
|
201
201
|
>
|
|
202
|
-
<
|
|
203
|
-
|
|
204
|
-
@click="changeItemPerPage(perPage)"
|
|
202
|
+
<template
|
|
203
|
+
v-for="perPage in filteredPerPageValues"
|
|
205
204
|
>
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
v-if="inLimit()"
|
|
219
|
-
@click="
|
|
220
|
-
changeItemPerPage(
|
|
221
|
-
settings.totalItemCount
|
|
222
|
-
)
|
|
205
|
+
<b-dropdown-item
|
|
206
|
+
:key="'per-page-' + perPage"
|
|
207
|
+
@click="changeItemPerPage(perPage)"
|
|
208
|
+
>
|
|
209
|
+
{{ perPage }}
|
|
210
|
+
</b-dropdown-item>
|
|
211
|
+
</template>
|
|
212
|
+
<b-dropdown-divider
|
|
213
|
+
v-if="
|
|
214
|
+
filteredPerPageValues &&
|
|
215
|
+
filteredPerPageValues.length &&
|
|
216
|
+
inLimit()
|
|
223
217
|
"
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
218
|
+
/>
|
|
219
|
+
<template>
|
|
220
|
+
<b-dropdown-item
|
|
221
|
+
v-if="inLimit()"
|
|
222
|
+
@click="
|
|
223
|
+
changeItemPerPage(
|
|
224
|
+
settings.totalItemCount
|
|
225
|
+
)
|
|
226
|
+
"
|
|
227
|
+
>
|
|
228
|
+
All ({{ settings.totalItemCount }})
|
|
229
|
+
</b-dropdown-item>
|
|
230
|
+
</template>
|
|
231
|
+
</b-dropdown>
|
|
232
|
+
</div>
|
|
233
|
+
</div>
|
|
234
|
+
</slot>
|
|
235
|
+
<slot name="pagination-center" v-bind="settings">
|
|
236
|
+
<div>
|
|
237
|
+
<span v-show="!isDataEmpty">
|
|
238
|
+
{{ settings.totalItemCount }} rows
|
|
239
|
+
</span>
|
|
229
240
|
</div>
|
|
230
|
-
</
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
:total-rows="settings.totalItemCount"
|
|
245
|
-
:per-page="settings.itemPerPage"
|
|
246
|
-
@change="changePage"
|
|
247
|
-
v-bind="pagination"
|
|
248
|
-
/>
|
|
249
|
-
</div>
|
|
250
|
-
</slot>
|
|
241
|
+
</slot>
|
|
242
|
+
<slot name="pagination-buttons">
|
|
243
|
+
<div>
|
|
244
|
+
<b-pagination
|
|
245
|
+
v-if="settings.pageCount > 1"
|
|
246
|
+
v-model="settings.currentPage"
|
|
247
|
+
:total-rows="settings.totalItemCount"
|
|
248
|
+
:per-page="settings.itemPerPage"
|
|
249
|
+
@change="changePage"
|
|
250
|
+
v-bind="pagination"
|
|
251
|
+
/>
|
|
252
|
+
</div>
|
|
253
|
+
</slot>
|
|
254
|
+
</div>
|
|
251
255
|
</div>
|
|
252
256
|
</slot>
|
|
253
257
|
<slot name="footer" />
|
|
@@ -408,6 +412,11 @@ export default {
|
|
|
408
412
|
type: Number,
|
|
409
413
|
required: false,
|
|
410
414
|
default: 300
|
|
415
|
+
},
|
|
416
|
+
paginationClass: {
|
|
417
|
+
type: String,
|
|
418
|
+
required: false,
|
|
419
|
+
default: ""
|
|
411
420
|
}
|
|
412
421
|
},
|
|
413
422
|
watch: {
|
|
@@ -417,6 +426,12 @@ export default {
|
|
|
417
426
|
},
|
|
418
427
|
data() {
|
|
419
428
|
return {
|
|
429
|
+
defaultSettings: {
|
|
430
|
+
currentPage: 1,
|
|
431
|
+
pageCount: 0,
|
|
432
|
+
itemPerPage: 10,
|
|
433
|
+
totalItemCount: 0
|
|
434
|
+
},
|
|
420
435
|
settings: {
|
|
421
436
|
currentPage: 1,
|
|
422
437
|
pageCount: 0,
|
|
@@ -451,27 +466,45 @@ export default {
|
|
|
451
466
|
return this.settings.totalItemCount <= 0;
|
|
452
467
|
}
|
|
453
468
|
},
|
|
469
|
+
created() {
|
|
470
|
+
this.addPopStateListener();
|
|
471
|
+
},
|
|
454
472
|
async mounted() {
|
|
455
|
-
this.
|
|
456
|
-
"page",
|
|
457
|
-
this.settings.currentPage
|
|
458
|
-
);
|
|
459
|
-
this.settings.itemPerPage = this.getHistoryParameter(
|
|
460
|
-
"limit",
|
|
461
|
-
this.settings.itemPerPage
|
|
462
|
-
);
|
|
463
|
-
if (this.searchColumn) {
|
|
464
|
-
this.searchWord = this.getHistoryParameter(
|
|
465
|
-
`f-${this.searchColumn}`,
|
|
466
|
-
this.searchWord
|
|
467
|
-
);
|
|
468
|
-
}
|
|
469
|
-
this.loadHistoryFilters();
|
|
470
|
-
this.loadHistorySorting();
|
|
473
|
+
this.loadHistory();
|
|
471
474
|
if (this.autoLoad) await this.getValues();
|
|
472
475
|
},
|
|
473
|
-
created() {},
|
|
474
476
|
methods: {
|
|
477
|
+
addPopStateListener() {
|
|
478
|
+
window.addEventListener("popstate", this.popStateEvent);
|
|
479
|
+
},
|
|
480
|
+
removePopStateListener() {
|
|
481
|
+
window.removeEventListener("popstate", this.popStateEvent);
|
|
482
|
+
},
|
|
483
|
+
async popStateEvent() {
|
|
484
|
+
this.loadHistory();
|
|
485
|
+
await this.getValues(false);
|
|
486
|
+
},
|
|
487
|
+
loadHistory() {
|
|
488
|
+
this.settings.currentPage = this.getHistoryParameter(
|
|
489
|
+
"page",
|
|
490
|
+
this.defaultSettings.currentPage
|
|
491
|
+
);
|
|
492
|
+
this.settings.itemPerPage = this.getHistoryParameter(
|
|
493
|
+
"limit",
|
|
494
|
+
this.defaultSettings.itemPerPage
|
|
495
|
+
);
|
|
496
|
+
if (this.searchColumn) {
|
|
497
|
+
this.searchWord = this.getHistoryParameter(
|
|
498
|
+
`f-${this.searchColumn}`,
|
|
499
|
+
this.searchWord
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
this.loadHistoryFilters();
|
|
503
|
+
this.loadHistorySorting();
|
|
504
|
+
// console.log("loadHistory:settings", this.settings);
|
|
505
|
+
// console.log("loadHistory:filters", this.filters);
|
|
506
|
+
// console.log("loadHistory:sorting", this.sorting);
|
|
507
|
+
},
|
|
475
508
|
sortableIcon(column) {
|
|
476
509
|
const currentSort = this.sorting.find(x => x.Column === column);
|
|
477
510
|
if (!currentSort) {
|
|
@@ -527,6 +560,13 @@ export default {
|
|
|
527
560
|
this.$emit("loading", this.isLoading);
|
|
528
561
|
const { currentPage, itemPerPage } = this.settings;
|
|
529
562
|
|
|
563
|
+
let result = await this.requestFunction(
|
|
564
|
+
this.filters,
|
|
565
|
+
this.sorting,
|
|
566
|
+
currentPage,
|
|
567
|
+
itemPerPage
|
|
568
|
+
);
|
|
569
|
+
|
|
530
570
|
this.clearHistoryParameters("f-");
|
|
531
571
|
for (const filter of this.filters) {
|
|
532
572
|
this.addHistoryParameter(`f-${filter.Column}`, filter.Value);
|
|
@@ -537,13 +577,6 @@ export default {
|
|
|
537
577
|
this.addHistoryParameter(`s-${sort.Column}`, sort.Asc ? 1 : 0);
|
|
538
578
|
}
|
|
539
579
|
|
|
540
|
-
let result = await this.requestFunction(
|
|
541
|
-
this.filters,
|
|
542
|
-
this.sorting,
|
|
543
|
-
currentPage,
|
|
544
|
-
itemPerPage
|
|
545
|
-
);
|
|
546
|
-
|
|
547
580
|
if (!result || result.status !== 200) {
|
|
548
581
|
this.isLoading = false;
|
|
549
582
|
this.isDataEmpty = true;
|
|
@@ -795,13 +828,15 @@ export default {
|
|
|
795
828
|
|
|
796
829
|
if (filter && !value) {
|
|
797
830
|
this.filters.splice(this.filters.indexOf(filter), 1);
|
|
798
|
-
} else if (
|
|
799
|
-
filter
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
831
|
+
} else if (value) {
|
|
832
|
+
if (filter) {
|
|
833
|
+
filter.Value = value;
|
|
834
|
+
} else {
|
|
835
|
+
this.filters.push({
|
|
836
|
+
Column: column,
|
|
837
|
+
Value: value
|
|
838
|
+
});
|
|
839
|
+
}
|
|
805
840
|
}
|
|
806
841
|
}
|
|
807
842
|
},
|
|
@@ -810,27 +845,32 @@ export default {
|
|
|
810
845
|
const trimName = this.getHistoryName("s-");
|
|
811
846
|
const names = Object.keys(parameters);
|
|
812
847
|
for (const paramName of names) {
|
|
813
|
-
|
|
848
|
+
var paramValue = parameters[paramName];
|
|
849
|
+
let value = undefined;
|
|
850
|
+
if (paramValue && paramValue === "1") value = true;
|
|
851
|
+
else if (paramValue && paramValue === "0") value = false;
|
|
814
852
|
const column = paramName.replace(trimName, "");
|
|
815
853
|
|
|
816
854
|
let sort = this.sorting.find(x => x.Column === column);
|
|
817
855
|
|
|
818
|
-
if (
|
|
819
|
-
sort
|
|
820
|
-
|
|
821
|
-
|
|
856
|
+
if (value !== undefined) {
|
|
857
|
+
if (sort) {
|
|
858
|
+
sort.Value = value;
|
|
859
|
+
} else {
|
|
860
|
+
this.sorting.push({ Column: column, Asc: value });
|
|
861
|
+
}
|
|
822
862
|
}
|
|
823
863
|
}
|
|
824
864
|
},
|
|
825
865
|
addHistoryParameter(name, value, storage = this.historyStorage) {
|
|
826
866
|
if (!this.history || !name || !storage) return;
|
|
827
|
-
|
|
867
|
+
// console.log("addHistoryParameter", name, value, storage);
|
|
828
868
|
try {
|
|
829
869
|
if (storage === "query") {
|
|
830
870
|
const url = new URL(window.location);
|
|
831
871
|
const historyName = this.getHistoryName(name);
|
|
832
872
|
url.searchParams.set(historyName, value);
|
|
833
|
-
window.history.pushState(
|
|
873
|
+
window.history.pushState(null, "", url);
|
|
834
874
|
return;
|
|
835
875
|
}
|
|
836
876
|
|