vue-laravel-crud 1.6.4 → 1.6.5

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": "vue-laravel-crud",
3
- "version": "1.6.4",
3
+ "version": "1.6.5",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/clonixdev/vue-laravel-crud",
6
6
  "main": "dist/vue-laravel-crud.ssr.js",
@@ -174,6 +174,11 @@ export default /*#__PURE__*/ {
174
174
  type: Boolean,
175
175
  default: true,
176
176
  },
177
+ showPrincipalSortBtn: {
178
+ type: Boolean,
179
+ default: false,
180
+ },
181
+
177
182
  showHeader: {
178
183
  type: Boolean,
179
184
  default: true,
@@ -212,7 +217,7 @@ export default /*#__PURE__*/ {
212
217
  type: Number,
213
218
  },
214
219
  colXl: {
215
- default: 3,
220
+ default: 4,
216
221
  type: Number,
217
222
  },
218
223
 
@@ -333,6 +338,10 @@ export default /*#__PURE__*/ {
333
338
  default: 3,
334
339
  },
335
340
 
341
+ principalSortColumn: {
342
+ type: String,
343
+ default: "id",
344
+ },
336
345
  },
337
346
 
338
347
  mounted() {
@@ -440,9 +449,22 @@ export default /*#__PURE__*/ {
440
449
  return [
441
450
  ...this.filters,
442
451
  ...this.filter,
443
- ...this.internalFilter
452
+ ...this.internalFilter,
453
+ ...this.sortFilter
444
454
  ];
445
455
  },
456
+ sortFilter(){
457
+ if(this.showPrincipalSortBtn){
458
+ if(this.principalSort){
459
+ return [[this.principalSortColumn,'SORTASC','']];
460
+ }else{
461
+ return [[this.principalSortColumn,'SORTDESC','']];
462
+ }
463
+ }else{
464
+ return [];
465
+ }
466
+
467
+ },
446
468
  internalFilter() {
447
469
  let filter = [];
448
470
  this.forceRecomputeCounter;
@@ -467,6 +489,13 @@ export default /*#__PURE__*/ {
467
489
  // Actualizar isMobile cuando cambia el tamaño de la pantalla
468
490
  this.isMobile = window.matchMedia("(max-width: 1024px)").matches;
469
491
  },
492
+
493
+ togglePrincipalSort(){
494
+ this.principalSort = !this.principalSort;
495
+ setTimeout(() => {
496
+ this.refresh();
497
+ }, 1);
498
+ },
470
499
  infiniteHandler($state) {
471
500
 
472
501
 
@@ -1355,6 +1384,10 @@ export default /*#__PURE__*/ {
1355
1384
  <slot name="tableActions" v-bind:createItem="createItem" v-bind:toggleDisplayMode="toggleDisplayMode"
1356
1385
  v-bind:loading="loading">
1357
1386
  <slot name="tableActionsPrepend" v-bind:loading="loading"> </slot>
1387
+ <b-button variant="success" v-if="showPrincipalSortBtn" @click="togglePrincipalSort()" :disabled="loading">
1388
+ <b-icon-sort-numeric-down v-if="principalSort"></b-icon-sort-numeric-down>
1389
+ <b-icon-sort-numeric-up v-else></b-icon-sort-numeric-up>
1390
+ </b-button>
1358
1391
  <b-button variant="success" v-if="showCreateBtn" @click="createItem()" :disabled="loading">
1359
1392
  <b-icon-plus></b-icon-plus>{{ messageNew }}
1360
1393
  </b-button>