@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monoui/vuejs",
3
- "version": "1.1.16",
3
+ "version": "1.1.19",
4
4
  "description": "This project will contain MonoFor UI Framework",
5
5
  "main": "./dist/main.js",
6
6
  "repository": "git@gitlab.com:monoui/vuejs.git",
@@ -185,69 +185,73 @@
185
185
  </div>
186
186
  <slot name="pagination-seperator" />
187
187
  <slot name="pagination">
188
- <div class="d-flex justify-content-between align-items-center mt-2">
189
- <slot name="pagination-filters">
190
- <div>
191
- <div v-show="!isDataEmpty">
192
- <span>Show</span>
193
- <b-dropdown
194
- :text="itemPerPageText"
195
- class="m-md-2"
196
- size="sm"
197
- variant="light"
198
- >
199
- <template
200
- v-for="perPage in filteredPerPageValues"
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
- <b-dropdown-item
203
- :key="'per-page-' + perPage"
204
- @click="changeItemPerPage(perPage)"
202
+ <template
203
+ v-for="perPage in filteredPerPageValues"
205
204
  >
206
- {{ perPage }}
207
- </b-dropdown-item>
208
- </template>
209
- <b-dropdown-divider
210
- v-if="
211
- filteredPerPageValues &&
212
- filteredPerPageValues.length &&
213
- inLimit()
214
- "
215
- />
216
- <template>
217
- <b-dropdown-item
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
- All ({{ settings.totalItemCount }})
226
- </b-dropdown-item>
227
- </template>
228
- </b-dropdown>
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
- </div>
231
- </slot>
232
- <slot name="pagination-center" v-bind="settings">
233
- <div>
234
- <span v-show="!isDataEmpty">
235
- {{ settings.totalItemCount }} rows
236
- </span>
237
- </div>
238
- </slot>
239
- <slot name="pagination-buttons">
240
- <div>
241
- <b-pagination
242
- v-if="settings.pageCount > 1"
243
- v-model="settings.currentPage"
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.settings.currentPage = this.getHistoryParameter(
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 (filter) {
799
- filter.Value = value;
800
- } else {
801
- this.filters.push({
802
- Column: column,
803
- Value: value
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
- const value = parameters[paramName] ? true : false;
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 (sort) {
819
- sort.Value = value;
820
- } else {
821
- this.sorting.push({ Column: column, Asc: value });
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({}, "", url);
873
+ window.history.pushState(null, "", url);
834
874
  return;
835
875
  }
836
876