vue-laravel-crud 1.5.4 → 1.5.6

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.
@@ -41,6 +41,7 @@ export default /*#__PURE__*/ {
41
41
  MODE_CUSTOM: 3,
42
42
  },
43
43
  infiniteScrollKey: 1,
44
+ optionsLoaded: false,
44
45
 
45
46
  };
46
47
  },
@@ -56,8 +57,8 @@ export default /*#__PURE__*/ {
56
57
  }
57
58
  },
58
59
 
59
- models(val){
60
- if(!this.ajax){
60
+ models(val) {
61
+ if (!this.ajax) {
61
62
  this.items = val;
62
63
  }
63
64
  },
@@ -330,10 +331,10 @@ export default /*#__PURE__*/ {
330
331
  if (field.type === 'relation') {
331
332
  // Si es una relación, inicializa como un objeto vacío.
332
333
 
333
- if(this.vuexInitRelations == true || (Array.isArray(this.vuexInitRelations) && this.vuexInitRelations.includes(fieldName))){
334
+ if (this.vuexInitRelations == true || (Array.isArray(this.vuexInitRelations) && this.vuexInitRelations.includes(fieldName))) {
334
335
  itemDefault[fieldName] = {};
335
336
  }
336
-
337
+
337
338
  } else {
338
339
  // Si es un campo, verifica si tiene un valor por defecto definido
339
340
  if (field.default !== undefined) {
@@ -357,8 +358,8 @@ export default /*#__PURE__*/ {
357
358
  }
358
359
 
359
360
  this.itemDefault = JSON.parse(JSON.stringify(itemDefault));
360
-
361
-
361
+
362
+
362
363
  } else {
363
364
  this.item = this.model;
364
365
  this.itemDefault = JSON.parse(JSON.stringify(this.item));
@@ -375,7 +376,7 @@ export default /*#__PURE__*/ {
375
376
  this.pagination.total = this.items.length;
376
377
  }
377
378
 
378
-
379
+ this.loadOptions();
379
380
  },
380
381
  computed: {
381
382
  itemValue() {
@@ -423,20 +424,25 @@ export default /*#__PURE__*/ {
423
424
  return this.internalFilters.find((inf) => inf.column == prop);
424
425
  };
425
426
  },
427
+ columnOptions() {
428
+ return (column) => {
429
+
430
+ }
431
+ }
426
432
  },
427
433
  methods: {
428
434
  infiniteHandler($state) {
429
435
  const hasNextPage = this.pagination.total > 0 && (!this.firstLoad || (this.pagination.current_page * this.pagination.per_page) <= this.pagination.total);
430
- console.debug("Has next page",hasNextPage,this.pagination);
436
+ console.debug("Has next page", hasNextPage, this.pagination);
431
437
  if (hasNextPage) {
432
438
  const page = this.pagination.current_page + 1;
433
- this.fetchItems(page,true).then(() => {
439
+ this.fetchItems(page, true).then(() => {
434
440
  $state.loaded();
435
- }).catch(error =>{
436
- console.debug("infinite handler error",error);
441
+ }).catch(error => {
442
+ console.debug("infinite handler error", error);
437
443
  $state.error();
438
- });
439
- }else{
444
+ });
445
+ } else {
440
446
  $state.complete();
441
447
  }
442
448
  },
@@ -592,7 +598,7 @@ export default /*#__PURE__*/ {
592
598
  },
593
599
  createItem() {
594
600
  if (this.useVuexORM) {
595
- this.item = new this.model( JSON.parse(JSON.stringify(this.itemDefault)));
601
+ this.item = new this.model(JSON.parse(JSON.stringify(this.itemDefault)));
596
602
  } else {
597
603
  this.item = JSON.parse(JSON.stringify(this.itemDefault));
598
604
  }
@@ -616,21 +622,21 @@ export default /*#__PURE__*/ {
616
622
  if (!this.ajax) {
617
623
  return;
618
624
  }
619
- if(this.infiniteScroll){
625
+ if (this.infiniteScroll) {
620
626
  this.pagination.current_page = 1;
621
627
  this.infiniteScrollKey++;
622
- }
623
-
628
+ }
629
+
624
630
  const fetchPromise = this.fetchItems(this.pagination.current_page);
625
631
 
626
- if(this.infiniteScroll && fetchPromise){
632
+ if (this.infiniteScroll && fetchPromise) {
627
633
  fetchPromise.then(() => {
628
634
  const infiniteLoadingRef = this.$refs.infiniteLoading;
629
- if(infiniteLoadingRef){
630
- infiniteLoadingRef.stateChanger.reset();
631
- }else{
632
- console.debug("infiniteLoadingRef not set");
633
- }
635
+ if (infiniteLoadingRef) {
636
+ infiniteLoadingRef.stateChanger.reset();
637
+ } else {
638
+ console.debug("infiniteLoadingRef not set");
639
+ }
634
640
  });
635
641
  }
636
642
  },
@@ -659,14 +665,14 @@ export default /*#__PURE__*/ {
659
665
  }
660
666
  });
661
667
 
662
-
668
+
663
669
  let itemsResult = this.model.query().withAll().get();
664
670
  //let itemsResult = result.entities[this.model.entity];
665
671
 
666
- if(itemsResult){
672
+ if (itemsResult) {
667
673
  this.items = itemsResult;
668
674
  }
669
- console.debug("fetch page vuex ",itemsResult, page, this.items,result);
675
+ console.debug("fetch page vuex ", itemsResult, page, this.items, result);
670
676
  this.loading = false;
671
677
  this.firstLoad = true;
672
678
  },
@@ -767,7 +773,7 @@ export default /*#__PURE__*/ {
767
773
  }
768
774
 
769
775
  if (!this.ajax) {
770
- return this.deleteItemLocal(id,index);
776
+ return this.deleteItemLocal(id, index);
771
777
  }
772
778
 
773
779
  this.loading = true;
@@ -785,7 +791,7 @@ export default /*#__PURE__*/ {
785
791
  });
786
792
  },
787
793
 
788
- async deleteItemLocal(id,index) {
794
+ async deleteItemLocal(id, index) {
789
795
  if (id || index) {
790
796
  let itemIndex;
791
797
 
@@ -794,13 +800,13 @@ export default /*#__PURE__*/ {
794
800
  } else {
795
801
  itemIndex = index;
796
802
  }
797
-
803
+
798
804
  // Assuming this.items is an array
799
805
  this.items.splice(itemIndex, 1);
800
806
  this.item = null;
801
807
  this.toastSuccess("Elemento Eliminado");
802
808
  this.$emit("itemDeleted", {});
803
-
809
+
804
810
  } else {
805
811
  // Handle the case where there's no item.id or item.index
806
812
  console.error("Cannot delete item without ID or index");
@@ -833,6 +839,10 @@ export default /*#__PURE__*/ {
833
839
  this.items.forEach((v, k) => {
834
840
  order.push({ id: v.id, order: v[this.orderProp] });
835
841
  });
842
+
843
+ if (!this.ajax) {
844
+ return;
845
+ }
836
846
  axios
837
847
  .post(this.apiUrl + "/" + this.modelName + "/sort", {
838
848
  order: order,
@@ -850,18 +860,26 @@ export default /*#__PURE__*/ {
850
860
  });
851
861
  }
852
862
  },
853
- getArrayValue(value, displayProp) {
863
+ getArrayValue(value, displayProp,options = []) {
854
864
  if (!Array.isArray(value)) return "N/A";
855
-
865
+ let values = [];
866
+ let valuesFinal = [];
867
+
856
868
  if (value.length > 0) {
857
869
  if (typeof value[0] === "object" && displayProp) {
858
- return value.map((vv) => vv[displayProp]).join(",");
870
+ values = value.map((vv) => vv[displayProp]);
859
871
  } else {
860
- return value.join(",");
872
+ values = value.join(",");
861
873
  }
862
874
  } else {
863
875
  return "";
864
876
  }
877
+
878
+ values.forEach(val =>{
879
+ valuesFinal.push(this.getStateValue(val,options));
880
+ })
881
+
882
+ return values.join(",");
865
883
  },
866
884
  getStateValue(value, options) {
867
885
  if (!options) {
@@ -908,51 +926,66 @@ export default /*#__PURE__*/ {
908
926
  //throw new Error('Something is wrong.')
909
927
  }
910
928
  result.save();
911
- if (this.refreshAfterSave ) this.refresh();
929
+ if (this.refreshAfterSave) this.refresh();
912
930
  this.loading = false;
913
931
  this.toastSuccess("Elemento Modificado");
914
932
 
915
- if (this.hideModalAfterSave || ((create && this.hideModalAfterCreate) || (!create && this.hideModalAfterUpdate) )) {
916
- this.$bvModal.hide("modal-form-item-" + this.modelName);
933
+ if (this.hideModalAfterSave || ((create && this.hideModalAfterCreate) || (!create && this.hideModalAfterUpdate))) {
934
+ this.$bvModal.hide("modal-form-item-" + this.modelName);
917
935
  }
918
936
 
919
937
 
920
938
  },
921
939
 
922
- async saveItemLocal(event = null){
940
+ async saveItemLocal(event = null) {
923
941
 
924
942
  const itemSave = JSON.parse(JSON.stringify(this.item));
925
943
  if (this.item.id || this.item.index) {
926
944
 
927
- let itemIndex ;
945
+ let itemIndex;
928
946
 
929
- if(this.item.id){
947
+ if (this.item.id) {
930
948
  itemIndex = this.items.findIndex(
931
- (item) => item.id == this.item.id
932
- );
933
- }else{
949
+ (item) => item.id == this.item.id
950
+ );
951
+ } else {
934
952
 
935
953
  itemIndex = this.items.findIndex(
936
- (item) => item.index == this.item.index
937
- );
954
+ (item) => item.index == this.item.index
955
+ );
938
956
  }
939
-
957
+
940
958
  this.items[itemIndex] = itemSave;
941
959
  if (this.hideModalAfterSave || this.hideModalAfterUpdate) {
942
- this.$bvModal.hide("modal-form-item-" + this.modelName);
960
+ this.$bvModal.hide("modal-form-item-" + this.modelName);
943
961
  }
944
- }else{
962
+ } else {
945
963
 
946
964
  itemSave.index = this.items.length + 1;
947
965
  this.items.push(itemSave);
948
966
  if (this.hideModalAfterSave || this.hideModalAfterCreate) {
949
- this.$bvModal.hide("modal-form-item-" + this.modelName);
967
+ this.$bvModal.hide("modal-form-item-" + this.modelName);
950
968
  }
951
969
  }
952
970
  this.toastSuccess("Elemento Modificado");
953
971
  this.loading = false;
954
972
 
955
973
  },
974
+ async loadOptions() {
975
+ for (let i = 0; i < this.columns.length; i++) {
976
+ const column = this.columns[i];
977
+
978
+ if (column.options instanceof Promise) {
979
+ // Si las opciones son una función (promesa), esperar y actualizar
980
+ const options = await column.options;
981
+ this.$set(this.columns, i, { ...column, options });
982
+
983
+ console.debug("Options promise",this.columns);
984
+ }
985
+ }
986
+
987
+ this.optionsLoaded = true;
988
+ },
956
989
  async saveItem(event = null) {
957
990
  this.loading = true;
958
991
  if (this.validate) {
@@ -990,7 +1023,7 @@ export default /*#__PURE__*/ {
990
1023
  this.items[itemIndex] = itemSv;
991
1024
  this.item = itemSv;
992
1025
  this.loading = false;
993
- if (this.refreshAfterSave ) this.refresh();
1026
+ if (this.refreshAfterSave) this.refresh();
994
1027
  this.toastSuccess("Elemento Modificado");
995
1028
  this.$emit("itemSaved", { item: this.item });
996
1029
  this.$emit("itemUpdated", { item: this.item });
@@ -1071,7 +1104,7 @@ export default /*#__PURE__*/ {
1071
1104
  }
1072
1105
  if (event) event.preventDefault();
1073
1106
  },
1074
- clearItems(){
1107
+ clearItems() {
1075
1108
  this.items = [];
1076
1109
  },
1077
1110
 
@@ -1196,10 +1229,9 @@ export default /*#__PURE__*/ {
1196
1229
 
1197
1230
  <div class="form-group" v-else-if="column.type == 'state'">
1198
1231
  <label>{{ column.label }}</label>
1199
- <div class="d-none">{{ column.options }}</div>
1200
-
1232
+
1201
1233
  <select class="form-control" v-model="internalFilterByProp(column.prop).value"
1202
- @change="onChangeFilter($event)">
1234
+ @change="onChangeFilter($event)" v-if="optionsLoaded">
1203
1235
  <option value=""></option>
1204
1236
  <option :value="option.id ? option.id : option.value" v-for="option in column.options"
1205
1237
  :key="option.id ? option.id : option.value">
@@ -1216,10 +1248,9 @@ export default /*#__PURE__*/ {
1216
1248
 
1217
1249
  <div class="form-group" v-else-if="column.type == 'array'">
1218
1250
  <label>{{ column.label }}</label>
1219
- <div class="d-none">{{ column.options }}</div>
1220
-
1251
+
1221
1252
  <select class="form-control" v-model="internalFilterByProp(column.prop).value"
1222
- @change="onChangeFilter($event)">
1253
+ @change="onChangeFilter($event)" v-if="optionsLoaded">
1223
1254
  <option value=""></option>
1224
1255
  <template v-if="column.options">
1225
1256
  <option :value="option.id ? option.id : option.value" v-for="option in column.options"
@@ -1236,6 +1267,7 @@ export default /*#__PURE__*/ {
1236
1267
  </select>
1237
1268
  </div>
1238
1269
 
1270
+
1239
1271
  <div class="form-group" v-else>
1240
1272
  <label>{{ column.label }}</label>
1241
1273
 
@@ -1292,106 +1324,189 @@ export default /*#__PURE__*/ {
1292
1324
  </b-button-group>
1293
1325
  </div>
1294
1326
  </div>
1295
-
1296
- <div :class="['table-responsive', tableContainerClass]" v-if="displayMode == displayModes.MODE_TABLE">
1297
- <table :class="['table table-hover table-striped w-100', tableClass]">
1298
- <thead class="thead-light">
1299
- <tr>
1300
- <slot name="rowHead">
1301
- <th v-for="(column, indexc) in columns" :key="indexc"
1302
- :style="{ width: column.width ? column.width : 'inherit' }" scope="col">
1303
- <slot :name="'filter-' + column.prop" v-bind:column="column" v-bind:filter="filter"
1304
- v-bind:internalFilterByProp="internalFilterByProp" v-if="enableFilters &&
1305
- filtersVisible &&
1306
- isColumnHasFilter(column) &&
1307
- internalFilterByProp(column.prop)
1308
- ">
1309
-
1310
- <div class="form-group">
1311
- <select v-if="column.type == 'boolean'" class="form-control form-control-md p-2"
1312
- v-model="internalFilterByProp(column.prop).value" @change="onChangeFilter($event)">
1313
- <option value="">{{ column.label }}</option>
1314
- <option value="1">Sí</option>
1315
- <option value="0">No</option>
1316
- </select>
1317
-
1318
- <div class="row" v-else-if="column.type == 'date'">
1319
- <div class="col-6">
1320
- <b-form-datepicker v-model="internalFilterByProp(column.prop + '_from').value
1321
- " today-button reset-button close-button locale="es"
1322
- class="form-control-md p-2"></b-form-datepicker>
1323
- </div>
1324
- <div class="col-6">
1325
- <b-form-datepicker v-model="internalFilterByProp(column.prop + '_to').value
1326
- " today-button reset-button close-button locale="es"
1327
- class="form-control-md p-2"></b-form-datepicker>
1328
- </div>
1327
+
1328
+ <div :class="['table-responsive', tableContainerClass]" v-if="displayMode == displayModes.MODE_TABLE">
1329
+ <table :class="['table table-hover table-striped w-100', tableClass]">
1330
+ <thead class="thead-light">
1331
+ <tr>
1332
+ <slot name="rowHead">
1333
+ <th v-for="(column, indexc) in columns" :key="indexc"
1334
+ :style="{ width: column.width ? column.width : 'inherit' }" scope="col">
1335
+ <slot :name="'filter-' + column.prop" v-bind:column="column" v-bind:filter="filter"
1336
+ v-bind:internalFilterByProp="internalFilterByProp" v-if="enableFilters &&
1337
+ filtersVisible &&
1338
+ isColumnHasFilter(column) &&
1339
+ internalFilterByProp(column.prop)
1340
+ ">
1341
+
1342
+ <div class="form-group">
1343
+ <select v-if="column.type == 'boolean'" class="form-control form-control-md p-2"
1344
+ v-model="internalFilterByProp(column.prop).value" @change="onChangeFilter($event)">
1345
+ <option value="">{{ column.label }}</option>
1346
+ <option value="1">Sí</option>
1347
+ <option value="0">No</option>
1348
+ </select>
1349
+
1350
+ <div class="row" v-else-if="column.type == 'date'">
1351
+ <div class="col-6">
1352
+ <b-form-datepicker v-model="internalFilterByProp(column.prop + '_from').value
1353
+ " today-button reset-button close-button locale="es"
1354
+ class="form-control-md p-2"></b-form-datepicker>
1355
+ </div>
1356
+ <div class="col-6">
1357
+ <b-form-datepicker v-model="internalFilterByProp(column.prop + '_to').value
1358
+ " today-button reset-button close-button locale="es"
1359
+ class="form-control-md p-2"></b-form-datepicker>
1329
1360
  </div>
1361
+ </div>
1330
1362
 
1331
- <select v-else-if="column.type == 'state'" class="form-control form-control-md p-2"
1332
- v-model="internalFilterByProp(column.prop).value" @change="onChangeFilter($event)" :placeholder="column.label">
1333
- <option value="">{{ column.label }}</option>
1334
- <option :value="option.id" v-for="(option, indexo) in column.options" :key="indexo">
1335
- {{
1336
- option.text
1337
- ? option.text
1338
- : option.label
1339
- ? option.label
1340
- : ""
1341
- }}
1342
- </option>
1343
- </select>
1363
+ <select v-else-if="column.type == 'state' && optionsLoaded" class="form-control form-control-md p-2"
1364
+ v-model="internalFilterByProp(column.prop).value" @change="onChangeFilter($event)"
1365
+ :placeholder="column.label">
1366
+ <option value="">{{ column.label }}</option>
1367
+ <option :value="option.id" v-for="(option, indexo) in column.options" :key="indexo">
1368
+ {{
1369
+ option.text
1370
+ ? option.text
1371
+ : option.label
1372
+ ? option.label
1373
+ : ""
1374
+ }}
1375
+ </option>
1376
+ </select>
1377
+
1378
+ <select v-else-if="column.type == 'array' && optionsLoaded" class="form-control form-control-md p-2"
1379
+ v-model="internalFilterByProp(column.prop).value" @change="onChangeFilter($event)"
1380
+ :placeholder="column.label">
1381
+ <option value="">{{ column.label }}</option>
1382
+ <option :value="option.id" v-for="(option, indexo) in column.options" :key="indexo">
1383
+ {{
1384
+ option.text
1385
+ ? option.text
1386
+ : option.label
1387
+ ? option.label
1388
+ : ""
1389
+ }}
1390
+ </option>
1391
+ </select>
1344
1392
 
1345
- <select v-else-if="column.type == 'array'" class="form-control form-control-md p-2"
1346
- v-model="internalFilterByProp(column.prop).value" @change="onChangeFilter($event)" :placeholder="column.label">
1347
- <option value="">{{ column.label }}</option>
1348
- <option :value="option.id" v-for="(option, indexo) in column.options" :key="indexo">
1349
- {{
1350
- option.text
1351
- ? option.text
1352
- : option.label
1353
- ? option.label
1354
- : ""
1355
- }}
1356
- </option>
1357
- </select>
1393
+ <b-form-checkbox v-else-if="column.type == 'checkbox'" name="select-all" @change="toggleAll()">
1394
+ </b-form-checkbox>
1395
+ <input v-else class="form-control form-control-md p-2"
1396
+ v-model="internalFilterByProp(column.prop).value" :placeholder="column.label"
1397
+ @change="onChangeFilter($event)" />
1358
1398
 
1359
- <b-form-checkbox v-else-if="column.type == 'checkbox'" name="select-all" @change="toggleAll()">
1360
- </b-form-checkbox>
1361
- <input v-else class="form-control form-control-md p-2"
1362
- v-model="internalFilterByProp(column.prop).value" :placeholder="column.label"
1363
- @change="onChangeFilter($event)" />
1399
+ </div>
1400
+ </slot>
1364
1401
 
1365
- </div>
1366
- </slot>
1402
+ <span v-else>{{ column.label }}</span>
1367
1403
 
1368
- <span v-else>{{ column.label }}</span>
1404
+ <span v-if="sortable && internalFilterByProp(column.prop + '_sort')" class="sort-filter"
1405
+ @click="toggleSortFilter(column)"><b-icon-sort-down
1406
+ v-if="!internalFilterByProp(column.prop + '_sort').value"></b-icon-sort-down><b-icon-sort-up
1407
+ v-if="internalFilterByProp(column.prop + '_sort').value == 'ASC'"></b-icon-sort-up>
1408
+ <b-icon-sort-down v-if="internalFilterByProp(column.prop + '_sort').value == 'DESC'"></b-icon-sort-down>
1409
+ </span>
1410
+ </th>
1411
+ </slot>
1412
+ </tr>
1413
+ </thead>
1369
1414
 
1370
- <span v-if="sortable && internalFilterByProp(column.prop + '_sort')" class="sort-filter"
1371
- @click="toggleSortFilter(column)"><b-icon-sort-down
1372
- v-if="!internalFilterByProp(column.prop + '_sort').value"></b-icon-sort-down><b-icon-sort-up
1373
- v-if="internalFilterByProp(column.prop + '_sort').value == 'ASC'"></b-icon-sort-up>
1374
- <b-icon-sort-down
1375
- v-if="internalFilterByProp(column.prop + '_sort').value == 'DESC'"></b-icon-sort-down>
1415
+ <draggable v-model="items" :group="draggableGroup" tag="tbody" :draggable="orderable ? '.item' : '.none'"
1416
+ @start="drag = true" @end="drag = false" @sort="onSort()" @add="onDraggableAdded($event)"
1417
+ @change="onDraggableChange($event)" :options="draggableOptions">
1418
+ <tr v-for="(item, index) in itemsList" v-bind:key="index" @mouseover="onRowHover(item, index)"
1419
+ @click="onRowClick(item, index)" class="item">
1420
+
1421
+ <th :colspan="columns.length" v-if="grouped && item.crudgroup">
1422
+ <span>{{ item.crudgrouplabel }}</span>
1423
+ </th>
1424
+
1425
+
1426
+ <slot name="row" v-bind:item="item" v-else>
1427
+ <td v-for="(column, indexc) in columns" :key="indexc" :scope="column.prop == 'id' ? 'row' : ''">
1428
+ <slot :name="'cell-' + column.prop" v-bind:item="item" v-bind:index="index" v-bind:itemindex="index"
1429
+ v-bind:columnindex="indexc">
1430
+ <span v-if="column.type == 'boolean'">
1431
+ <b-badge variant="success" v-if="itemValue(column, item) == 'true' ||
1432
+ itemValue(column, item) == 1 ||
1433
+ itemValue(column, item) == '1'
1434
+ "><b-icon-check-circle></b-icon-check-circle></b-badge>
1435
+ <b-badge variant="danger" v-if="!itemValue(column, item) ||
1436
+ itemValue(column, item) == '0' ||
1437
+ itemValue(column, item) == 'false'
1438
+ "><b-icon-x-circle></b-icon-x-circle></b-badge>
1376
1439
  </span>
1377
- </th>
1378
- </slot>
1379
- </tr>
1380
- </thead>
1381
-
1382
- <draggable v-model="items" :group="draggableGroup" tag="tbody" :draggable="orderable ? '.item' : '.none'"
1383
- @start="drag = true" @end="drag = false" @sort="onSort()" @add="onDraggableAdded($event)"
1384
- @change="onDraggableChange($event)" :options="draggableOptions">
1385
- <tr v-for="(item, index) in itemsList" v-bind:key="index" @mouseover="onRowHover(item, index)"
1386
- @click="onRowClick(item, index)" class="item">
1387
-
1388
- <th :colspan="columns.length" v-if="grouped && item.crudgroup">
1389
- <span>{{ item.crudgrouplabel }}</span>
1390
- </th>
1440
+ <span v-else-if="column.type == 'date'">
1441
+ {{
1442
+ itemValue(column, item)
1443
+ ? moment(itemValue(column, item)).format(
1444
+ column.format ? column.format : 'L LT'
1445
+ )
1446
+ : itemValue(column, item)
1447
+ }}
1448
+ </span>
1449
+ <span v-else-if="column.type == 'select'">
1450
+ <b-form-checkbox v-model="item.selected" @change="onCheckSelect($event, item)">
1451
+ </b-form-checkbox>
1452
+ </span>
1453
+ <span v-else-if="column.type == 'state' && optionsLoaded">
1454
+ {{
1455
+ getStateValue(itemValue(column, item), column.options)
1456
+ }}
1457
+ </span>
1458
+ <span v-else-if="column.type == 'array' && optionsLoaded">
1459
+ {{
1460
+ getArrayValue(
1461
+ itemValue(column, item),
1462
+ column.displayProp,
1463
+ column.options
1464
+ )
1465
+ }}
1466
+ </span>
1467
+ <span v-else>
1468
+ {{ itemValue(column, item) }}
1469
+ </span>
1470
+ </slot>
1471
+
1472
+ <b-button-group v-if="column.type == 'actions'">
1473
+ <slot name="rowAction" v-bind:item="item" v-bind:index="index" v-bind:showItem="showItem"
1474
+ v-bind:updateItem="updateItem" v-bind:removeItem="removeItem">
1475
+ <b-button variant="primary" @click="showItem(item.id, index)">
1476
+ <b-icon-eye></b-icon-eye>
1477
+ </b-button>
1478
+ <b-button variant="secondary" @click="updateItem(item.id, index)">
1479
+ <b-icon-pencil></b-icon-pencil>
1480
+ </b-button>
1481
+ <b-button variant="danger" @click="removeItem(item.id, index)">
1482
+ <b-icon-trash></b-icon-trash>
1483
+ </b-button>
1484
+ </slot>
1485
+ </b-button-group>
1486
+ </td>
1487
+ </slot>
1391
1488
 
1489
+ </tr>
1392
1490
 
1393
- <slot name="row" v-bind:item="item" v-else>
1394
- <td v-for="(column, indexc) in columns" :key="indexc" :scope="column.prop == 'id' ? 'row' : ''">
1491
+ </draggable>
1492
+
1493
+ </table>
1494
+ <p v-if="!loading && items && items.length == 0 && !infiniteScroll" class="p-3">
1495
+ {{ messageEmptyResults }}
1496
+ </p>
1497
+ </div>
1498
+
1499
+ <div v-if="displayMode == displayModes.MODE_CARDS">
1500
+ <draggable v-model="items" :group="draggableGroup" class="row" :draggable="orderable ? '.item' : '.none'"
1501
+ @start="drag = true" @end="drag = false" @sort="onSort()" @add="onDraggableAdded($event)"
1502
+ @change="onDraggableChange($event)" :options="draggableOptions">
1503
+ <b-col v-for="(item, index) in itemsList" v-bind:key="index" :cols="colXs" :sm="colSm" :md="colMd" :lg="colLg"
1504
+ :xl="colXl" class="item">
1505
+ <b-card :title="item.title" tag="article" class="mb-2 card-crud" :class="cardClass"
1506
+ :hideFooter="cardHideFooter">
1507
+ <slot name="card" v-bind:item="item">
1508
+ <div v-for="(column, indexc) in columns" :key="indexc">
1509
+ <b-card-text v-if="column.type != 'actions'">{{ column.label }}:
1395
1510
  <slot :name="'cell-' + column.prop" v-bind:item="item" v-bind:index="index" v-bind:itemindex="index"
1396
1511
  v-bind:columnindex="indexc">
1397
1512
  <span v-if="column.type == 'boolean'">
@@ -1405,17 +1520,7 @@ export default /*#__PURE__*/ {
1405
1520
  "><b-icon-x-circle></b-icon-x-circle></b-badge>
1406
1521
  </span>
1407
1522
  <span v-else-if="column.type == 'date'">
1408
- {{
1409
- itemValue(column, item)
1410
- ? moment(itemValue(column, item)).format(
1411
- column.format ? column.format : 'L LT'
1412
- )
1413
- : itemValue(column, item)
1414
- }}
1415
- </span>
1416
- <span v-else-if="column.type == 'select'">
1417
- <b-form-checkbox v-model="item.selected" @change="onCheckSelect($event, item)">
1418
- </b-form-checkbox>
1523
+ {{ itemValue(column, item) }}
1419
1524
  </span>
1420
1525
  <span v-else-if="column.type == 'state'">
1421
1526
  {{
@@ -1426,7 +1531,8 @@ export default /*#__PURE__*/ {
1426
1531
  {{
1427
1532
  getArrayValue(
1428
1533
  itemValue(column, item),
1429
- column.displayProp
1534
+ column.displayProp,
1535
+ column.options
1430
1536
  )
1431
1537
  }}
1432
1538
  </span>
@@ -1434,125 +1540,61 @@ export default /*#__PURE__*/ {
1434
1540
  {{ itemValue(column, item) }}
1435
1541
  </span>
1436
1542
  </slot>
1543
+ </b-card-text>
1544
+ </div>
1545
+ </slot>
1437
1546
 
1438
- <b-button-group v-if="column.type == 'actions'">
1439
- <slot name="rowAction" v-bind:item="item" v-bind:index="index" v-bind:showItem="showItem"
1440
- v-bind:updateItem="updateItem" v-bind:removeItem="removeItem">
1441
- <b-button variant="primary" @click="showItem(item.id, index)">
1442
- <b-icon-eye></b-icon-eye>
1443
- </b-button>
1444
- <b-button variant="secondary" @click="updateItem(item.id, index)">
1445
- <b-icon-pencil></b-icon-pencil>
1446
- </b-button>
1447
- <b-button variant="danger" @click="removeItem(item.id, index)">
1448
- <b-icon-trash></b-icon-trash>
1449
- </b-button>
1450
- </slot>
1451
- </b-button-group>
1452
- </td>
1453
- </slot>
1454
-
1455
- </tr>
1456
-
1457
- </draggable>
1458
-
1459
- </table>
1460
- <p v-if="!loading && items && items.length == 0 && !infiniteScroll" class="p-3">
1461
- {{ messageEmptyResults }}
1462
- </p>
1463
- </div>
1547
+ <template v-slot:footer>
1548
+ <b-button-group>
1549
+ <slot name="rowAction" v-bind:item="item" v-bind:index="index" v-bind:showItem="showItem"
1550
+ v-bind:updateItem="updateItem" v-bind:removeItem="removeItem">
1551
+ <b-button variant="primary" @click="showItem(item.id, index)">
1552
+ <b-icon-eye></b-icon-eye>
1553
+ </b-button>
1554
+ <b-button variant="secondary" @click="updateItem(item.id, index)">
1555
+ <b-icon-pencil></b-icon-pencil>
1556
+ </b-button>
1557
+ <b-button variant="danger" @click="removeItem(item.id, index)">
1558
+ <b-icon-trash></b-icon-trash>
1559
+ </b-button>
1560
+ </slot>
1561
+ </b-button-group>
1562
+ </template>
1563
+ </b-card>
1564
+ </b-col>
1464
1565
 
1465
- <div v-if="displayMode == displayModes.MODE_CARDS">
1466
- <draggable v-model="items" :group="draggableGroup" class="row" :draggable="orderable ? '.item' : '.none'"
1467
- @start="drag = true" @end="drag = false" @sort="onSort()" @add="onDraggableAdded($event)"
1468
- @change="onDraggableChange($event)" :options="draggableOptions">
1469
- <b-col v-for="(item, index) in itemsList" v-bind:key="index" :cols="colXs" :sm="colSm" :md="colMd" :lg="colLg"
1470
- :xl="colXl" class="item">
1471
- <b-card :title="item.title" tag="article" class="mb-2 card-crud" :class="cardClass"
1472
- :hideFooter="cardHideFooter">
1473
- <slot name="card" v-bind:item="item">
1474
- <div v-for="(column, indexc) in columns" :key="indexc">
1475
- <b-card-text v-if="column.type != 'actions'">{{ column.label }}:
1476
- <slot :name="'cell-' + column.prop" v-bind:item="item" v-bind:index="index" v-bind:itemindex="index"
1477
- v-bind:columnindex="indexc">
1478
- <span v-if="column.type == 'boolean'">
1479
- <b-badge variant="success" v-if="itemValue(column, item) == 'true' ||
1480
- itemValue(column, item) == 1 ||
1481
- itemValue(column, item) == '1'
1482
- "><b-icon-check-circle></b-icon-check-circle></b-badge>
1483
- <b-badge variant="danger" v-if="!itemValue(column, item) ||
1484
- itemValue(column, item) == '0' ||
1485
- itemValue(column, item) == 'false'
1486
- "><b-icon-x-circle></b-icon-x-circle></b-badge>
1487
- </span>
1488
- <span v-else-if="column.type == 'date'">
1489
- {{ itemValue(column, item) }}
1490
- </span>
1491
- <span v-else-if="column.type == 'state'">
1492
- {{
1493
- getStateValue(itemValue(column, item), column.options)
1494
- }}
1495
- </span>
1496
- <span v-else-if="column.type == 'array'">
1497
- {{
1498
- getArrayValue(
1499
- itemValue(column, item),
1500
- column.displayProp
1501
- )
1502
- }}
1503
- </span>
1504
- <span v-else>
1505
- {{ itemValue(column, item) }}
1506
- </span>
1507
- </slot>
1508
- </b-card-text>
1509
- </div>
1510
- </slot>
1511
-
1512
- <template v-slot:footer>
1513
- <b-button-group>
1514
- <slot name="rowAction" v-bind:item="item" v-bind:index="index" v-bind:showItem="showItem"
1515
- v-bind:updateItem="updateItem" v-bind:removeItem="removeItem">
1516
- <b-button variant="primary" @click="showItem(item.id, index)">
1517
- <b-icon-eye></b-icon-eye>
1518
- </b-button>
1519
- <b-button variant="secondary" @click="updateItem(item.id, index)">
1520
- <b-icon-pencil></b-icon-pencil>
1521
- </b-button>
1522
- <b-button variant="danger" @click="removeItem(item.id, index)">
1523
- <b-icon-trash></b-icon-trash>
1524
- </b-button>
1525
- </slot>
1526
- </b-button-group>
1527
- </template>
1528
- </b-card>
1529
- </b-col>
1530
-
1531
- </draggable>
1566
+ </draggable>
1532
1567
 
1568
+ <p v-if="!loading && items && items.length == 0 && !infiniteScroll" class="p-3">
1569
+ {{ messageEmptyResults }}
1570
+ </p>
1571
+
1572
+ </div>
1573
+
1574
+ <div v-if="displayMode == displayModes.MODE_CUSTOM">
1575
+ <div :class="listContainerClass">
1533
1576
  <p v-if="!loading && items && items.length == 0 && !infiniteScroll" class="p-3">
1534
1577
  {{ messageEmptyResults }}
1535
1578
  </p>
1536
-
1537
- </div>
1538
-
1539
- <div v-if="displayMode == displayModes.MODE_CUSTOM">
1540
- <div :class="listContainerClass">
1541
- <p v-if="!loading && items && items.length == 0 && !infiniteScroll" class="p-3">
1542
- {{ messageEmptyResults }}
1543
- </p>
1544
- <div :class="listItemClass" v-for="(item, index) in itemsList" v-bind:key="index">
1545
- <slot name="card" v-bind:item="item"> </slot>
1546
- </div>
1579
+ <div :class="listItemClass" v-for="(item, index) in itemsList" v-bind:key="index">
1580
+ <slot name="card" v-bind:item="item"> </slot>
1547
1581
  </div>
1548
1582
  </div>
1549
- <b-overlay :show="loading" rounded="sm"></b-overlay>
1550
- <infinite-loading ref="infiniteLoading" @infinite="infiniteHandler" v-if="infiniteScroll" :forceUseInfiniteWrapper="true" :key="infiniteScrollKey">
1551
- <div slot="spinner"><div class="text-center">{{ messageLoading }}</div></div>
1552
- <div slot="no-more"><div class="text-center" v-if="!loading">{{ messageNoMore }}</div></div>
1553
- <div slot="no-results"><div class="text-center" v-if="!loading">{{ items.length == 0 ? messageEmptyResults : messageNoMore }}</div></div>
1554
- </infinite-loading>
1555
-
1583
+ </div>
1584
+ <b-overlay :show="loading" rounded="sm"></b-overlay>
1585
+ <infinite-loading ref="infiniteLoading" @infinite="infiniteHandler" v-if="infiniteScroll"
1586
+ :forceUseInfiniteWrapper="true" :key="infiniteScrollKey">
1587
+ <div slot="spinner">
1588
+ <div class="text-center">{{ messageLoading }}</div>
1589
+ </div>
1590
+ <div slot="no-more">
1591
+ <div class="text-center" v-if="!loading">{{ messageNoMore }}</div>
1592
+ </div>
1593
+ <div slot="no-results">
1594
+ <div class="text-center" v-if="!loading">{{ items.length == 0 ? messageEmptyResults : messageNoMore }}</div>
1595
+ </div>
1596
+ </infinite-loading>
1597
+
1556
1598
  <div class="crud-paginator" v-if="!infiniteScroll">
1557
1599
  <b-pagination v-if="showPaginator" v-model="pagination.current_page" :total-rows="pagination.total"
1558
1600
  :per-page="pagination.per_page" @change="onPaginationChange($event)"></b-pagination>
@@ -1666,5 +1708,4 @@ tr td:first-child {
1666
1708
  }
1667
1709
  }
1668
1710
  }
1669
- }
1670
- </style>
1711
+ }</style>