vue-laravel-crud 1.5.3 → 1.5.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/dist/vue-laravel-crud.esm.js +47 -22
- package/dist/vue-laravel-crud.min.js +4 -4
- package/dist/vue-laravel-crud.ssr.js +228 -129
- package/package.json +1 -1
- package/src/vue-laravel-crud.vue +314 -275
package/src/vue-laravel-crud.vue
CHANGED
|
@@ -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
|
-
|
|
439
|
+
this.fetchItems(page, true).then(() => {
|
|
434
440
|
$state.loaded();
|
|
435
|
-
|
|
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(
|
|
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
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
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,22 +791,22 @@ export default /*#__PURE__*/ {
|
|
|
785
791
|
});
|
|
786
792
|
},
|
|
787
793
|
|
|
788
|
-
async deleteItemLocal(id,index) {
|
|
789
|
-
if (
|
|
794
|
+
async deleteItemLocal(id, index) {
|
|
795
|
+
if (id || index) {
|
|
790
796
|
let itemIndex;
|
|
791
797
|
|
|
792
|
-
if (
|
|
798
|
+
if (id) {
|
|
793
799
|
itemIndex = this.items.findIndex((item) => item.id == this.item.id);
|
|
794
800
|
} else {
|
|
795
|
-
itemIndex =
|
|
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
|
-
|
|
870
|
+
values = value.map((vv) => vv[displayProp]);
|
|
859
871
|
} else {
|
|
860
|
-
|
|
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,64 @@ export default /*#__PURE__*/ {
|
|
|
908
926
|
//throw new Error('Something is wrong.')
|
|
909
927
|
}
|
|
910
928
|
result.save();
|
|
911
|
-
if (this.refreshAfterSave
|
|
929
|
+
if (this.refreshAfterSave) this.refresh();
|
|
912
930
|
this.loading = false;
|
|
913
931
|
this.toastSuccess("Elemento Modificado");
|
|
914
932
|
|
|
915
|
-
|
|
916
|
-
|
|
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
|
-
|
|
945
|
+
let itemIndex;
|
|
928
946
|
|
|
929
|
-
if(this.item.id){
|
|
947
|
+
if (this.item.id) {
|
|
930
948
|
itemIndex = this.items.findIndex(
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
}else{
|
|
949
|
+
(item) => item.id == this.item.id
|
|
950
|
+
);
|
|
951
|
+
} else {
|
|
934
952
|
|
|
935
953
|
itemIndex = this.items.findIndex(
|
|
936
|
-
|
|
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
960
|
this.$bvModal.hide("modal-form-item-" + this.modelName);
|
|
943
|
-
|
|
944
|
-
}else{
|
|
961
|
+
}
|
|
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
|
-
|
|
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 (typeof column.options === 'function') {
|
|
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
|
+
}
|
|
984
|
+
|
|
985
|
+
this.optionsLoaded = true;
|
|
986
|
+
},
|
|
956
987
|
async saveItem(event = null) {
|
|
957
988
|
this.loading = true;
|
|
958
989
|
if (this.validate) {
|
|
@@ -990,7 +1021,7 @@ export default /*#__PURE__*/ {
|
|
|
990
1021
|
this.items[itemIndex] = itemSv;
|
|
991
1022
|
this.item = itemSv;
|
|
992
1023
|
this.loading = false;
|
|
993
|
-
if (this.refreshAfterSave
|
|
1024
|
+
if (this.refreshAfterSave) this.refresh();
|
|
994
1025
|
this.toastSuccess("Elemento Modificado");
|
|
995
1026
|
this.$emit("itemSaved", { item: this.item });
|
|
996
1027
|
this.$emit("itemUpdated", { item: this.item });
|
|
@@ -1071,7 +1102,7 @@ export default /*#__PURE__*/ {
|
|
|
1071
1102
|
}
|
|
1072
1103
|
if (event) event.preventDefault();
|
|
1073
1104
|
},
|
|
1074
|
-
clearItems(){
|
|
1105
|
+
clearItems() {
|
|
1075
1106
|
this.items = [];
|
|
1076
1107
|
},
|
|
1077
1108
|
|
|
@@ -1196,10 +1227,9 @@ export default /*#__PURE__*/ {
|
|
|
1196
1227
|
|
|
1197
1228
|
<div class="form-group" v-else-if="column.type == 'state'">
|
|
1198
1229
|
<label>{{ column.label }}</label>
|
|
1199
|
-
|
|
1200
|
-
|
|
1230
|
+
|
|
1201
1231
|
<select class="form-control" v-model="internalFilterByProp(column.prop).value"
|
|
1202
|
-
@change="onChangeFilter($event)">
|
|
1232
|
+
@change="onChangeFilter($event)" v-if="optionsLoaded">
|
|
1203
1233
|
<option value=""></option>
|
|
1204
1234
|
<option :value="option.id ? option.id : option.value" v-for="option in column.options"
|
|
1205
1235
|
:key="option.id ? option.id : option.value">
|
|
@@ -1216,10 +1246,9 @@ export default /*#__PURE__*/ {
|
|
|
1216
1246
|
|
|
1217
1247
|
<div class="form-group" v-else-if="column.type == 'array'">
|
|
1218
1248
|
<label>{{ column.label }}</label>
|
|
1219
|
-
|
|
1220
|
-
|
|
1249
|
+
|
|
1221
1250
|
<select class="form-control" v-model="internalFilterByProp(column.prop).value"
|
|
1222
|
-
@change="onChangeFilter($event)">
|
|
1251
|
+
@change="onChangeFilter($event)" v-if="optionsLoaded">
|
|
1223
1252
|
<option value=""></option>
|
|
1224
1253
|
<template v-if="column.options">
|
|
1225
1254
|
<option :value="option.id ? option.id : option.value" v-for="option in column.options"
|
|
@@ -1236,6 +1265,7 @@ export default /*#__PURE__*/ {
|
|
|
1236
1265
|
</select>
|
|
1237
1266
|
</div>
|
|
1238
1267
|
|
|
1268
|
+
|
|
1239
1269
|
<div class="form-group" v-else>
|
|
1240
1270
|
<label>{{ column.label }}</label>
|
|
1241
1271
|
|
|
@@ -1292,106 +1322,189 @@ export default /*#__PURE__*/ {
|
|
|
1292
1322
|
</b-button-group>
|
|
1293
1323
|
</div>
|
|
1294
1324
|
</div>
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
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>
|
|
1325
|
+
|
|
1326
|
+
<div :class="['table-responsive', tableContainerClass]" v-if="displayMode == displayModes.MODE_TABLE">
|
|
1327
|
+
<table :class="['table table-hover table-striped w-100', tableClass]">
|
|
1328
|
+
<thead class="thead-light">
|
|
1329
|
+
<tr>
|
|
1330
|
+
<slot name="rowHead">
|
|
1331
|
+
<th v-for="(column, indexc) in columns" :key="indexc"
|
|
1332
|
+
:style="{ width: column.width ? column.width : 'inherit' }" scope="col">
|
|
1333
|
+
<slot :name="'filter-' + column.prop" v-bind:column="column" v-bind:filter="filter"
|
|
1334
|
+
v-bind:internalFilterByProp="internalFilterByProp" v-if="enableFilters &&
|
|
1335
|
+
filtersVisible &&
|
|
1336
|
+
isColumnHasFilter(column) &&
|
|
1337
|
+
internalFilterByProp(column.prop)
|
|
1338
|
+
">
|
|
1339
|
+
|
|
1340
|
+
<div class="form-group">
|
|
1341
|
+
<select v-if="column.type == 'boolean'" class="form-control form-control-md p-2"
|
|
1342
|
+
v-model="internalFilterByProp(column.prop).value" @change="onChangeFilter($event)">
|
|
1343
|
+
<option value="">{{ column.label }}</option>
|
|
1344
|
+
<option value="1">Sí</option>
|
|
1345
|
+
<option value="0">No</option>
|
|
1346
|
+
</select>
|
|
1347
|
+
|
|
1348
|
+
<div class="row" v-else-if="column.type == 'date'">
|
|
1349
|
+
<div class="col-6">
|
|
1350
|
+
<b-form-datepicker v-model="internalFilterByProp(column.prop + '_from').value
|
|
1351
|
+
" today-button reset-button close-button locale="es"
|
|
1352
|
+
class="form-control-md p-2"></b-form-datepicker>
|
|
1329
1353
|
</div>
|
|
1354
|
+
<div class="col-6">
|
|
1355
|
+
<b-form-datepicker v-model="internalFilterByProp(column.prop + '_to').value
|
|
1356
|
+
" today-button reset-button close-button locale="es"
|
|
1357
|
+
class="form-control-md p-2"></b-form-datepicker>
|
|
1358
|
+
</div>
|
|
1359
|
+
</div>
|
|
1330
1360
|
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
</
|
|
1361
|
+
<select v-else-if="column.type == 'state' && optionsLoaded" class="form-control form-control-md p-2"
|
|
1362
|
+
v-model="internalFilterByProp(column.prop).value" @change="onChangeFilter($event)"
|
|
1363
|
+
:placeholder="column.label">
|
|
1364
|
+
<option value="">{{ column.label }}</option>
|
|
1365
|
+
<option :value="option.id" v-for="(option, indexo) in column.options" :key="indexo">
|
|
1366
|
+
{{
|
|
1367
|
+
option.text
|
|
1368
|
+
? option.text
|
|
1369
|
+
: option.label
|
|
1370
|
+
? option.label
|
|
1371
|
+
: ""
|
|
1372
|
+
}}
|
|
1373
|
+
</option>
|
|
1374
|
+
</select>
|
|
1375
|
+
|
|
1376
|
+
<select v-else-if="column.type == 'array' && optionsLoaded" class="form-control form-control-md p-2"
|
|
1377
|
+
v-model="internalFilterByProp(column.prop).value" @change="onChangeFilter($event)"
|
|
1378
|
+
:placeholder="column.label">
|
|
1379
|
+
<option value="">{{ column.label }}</option>
|
|
1380
|
+
<option :value="option.id" v-for="(option, indexo) in column.options" :key="indexo">
|
|
1381
|
+
{{
|
|
1382
|
+
option.text
|
|
1383
|
+
? option.text
|
|
1384
|
+
: option.label
|
|
1385
|
+
? option.label
|
|
1386
|
+
: ""
|
|
1387
|
+
}}
|
|
1388
|
+
</option>
|
|
1389
|
+
</select>
|
|
1344
1390
|
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
option.text
|
|
1351
|
-
? option.text
|
|
1352
|
-
: option.label
|
|
1353
|
-
? option.label
|
|
1354
|
-
: ""
|
|
1355
|
-
}}
|
|
1356
|
-
</option>
|
|
1357
|
-
</select>
|
|
1391
|
+
<b-form-checkbox v-else-if="column.type == 'checkbox'" name="select-all" @change="toggleAll()">
|
|
1392
|
+
</b-form-checkbox>
|
|
1393
|
+
<input v-else class="form-control form-control-md p-2"
|
|
1394
|
+
v-model="internalFilterByProp(column.prop).value" :placeholder="column.label"
|
|
1395
|
+
@change="onChangeFilter($event)" />
|
|
1358
1396
|
|
|
1359
|
-
|
|
1360
|
-
|
|
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)" />
|
|
1397
|
+
</div>
|
|
1398
|
+
</slot>
|
|
1364
1399
|
|
|
1365
|
-
|
|
1366
|
-
</slot>
|
|
1400
|
+
<span v-else>{{ column.label }}</span>
|
|
1367
1401
|
|
|
1368
|
-
|
|
1402
|
+
<span v-if="sortable && internalFilterByProp(column.prop + '_sort')" class="sort-filter"
|
|
1403
|
+
@click="toggleSortFilter(column)"><b-icon-sort-down
|
|
1404
|
+
v-if="!internalFilterByProp(column.prop + '_sort').value"></b-icon-sort-down><b-icon-sort-up
|
|
1405
|
+
v-if="internalFilterByProp(column.prop + '_sort').value == 'ASC'"></b-icon-sort-up>
|
|
1406
|
+
<b-icon-sort-down v-if="internalFilterByProp(column.prop + '_sort').value == 'DESC'"></b-icon-sort-down>
|
|
1407
|
+
</span>
|
|
1408
|
+
</th>
|
|
1409
|
+
</slot>
|
|
1410
|
+
</tr>
|
|
1411
|
+
</thead>
|
|
1369
1412
|
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1413
|
+
<draggable v-model="items" :group="draggableGroup" tag="tbody" :draggable="orderable ? '.item' : '.none'"
|
|
1414
|
+
@start="drag = true" @end="drag = false" @sort="onSort()" @add="onDraggableAdded($event)"
|
|
1415
|
+
@change="onDraggableChange($event)" :options="draggableOptions">
|
|
1416
|
+
<tr v-for="(item, index) in itemsList" v-bind:key="index" @mouseover="onRowHover(item, index)"
|
|
1417
|
+
@click="onRowClick(item, index)" class="item">
|
|
1418
|
+
|
|
1419
|
+
<th :colspan="columns.length" v-if="grouped && item.crudgroup">
|
|
1420
|
+
<span>{{ item.crudgrouplabel }}</span>
|
|
1421
|
+
</th>
|
|
1422
|
+
|
|
1423
|
+
|
|
1424
|
+
<slot name="row" v-bind:item="item" v-else>
|
|
1425
|
+
<td v-for="(column, indexc) in columns" :key="indexc" :scope="column.prop == 'id' ? 'row' : ''">
|
|
1426
|
+
<slot :name="'cell-' + column.prop" v-bind:item="item" v-bind:index="index" v-bind:itemindex="index"
|
|
1427
|
+
v-bind:columnindex="indexc">
|
|
1428
|
+
<span v-if="column.type == 'boolean'">
|
|
1429
|
+
<b-badge variant="success" v-if="itemValue(column, item) == 'true' ||
|
|
1430
|
+
itemValue(column, item) == 1 ||
|
|
1431
|
+
itemValue(column, item) == '1'
|
|
1432
|
+
"><b-icon-check-circle></b-icon-check-circle></b-badge>
|
|
1433
|
+
<b-badge variant="danger" v-if="!itemValue(column, item) ||
|
|
1434
|
+
itemValue(column, item) == '0' ||
|
|
1435
|
+
itemValue(column, item) == 'false'
|
|
1436
|
+
"><b-icon-x-circle></b-icon-x-circle></b-badge>
|
|
1376
1437
|
</span>
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1438
|
+
<span v-else-if="column.type == 'date'">
|
|
1439
|
+
{{
|
|
1440
|
+
itemValue(column, item)
|
|
1441
|
+
? moment(itemValue(column, item)).format(
|
|
1442
|
+
column.format ? column.format : 'L LT'
|
|
1443
|
+
)
|
|
1444
|
+
: itemValue(column, item)
|
|
1445
|
+
}}
|
|
1446
|
+
</span>
|
|
1447
|
+
<span v-else-if="column.type == 'select'">
|
|
1448
|
+
<b-form-checkbox v-model="item.selected" @change="onCheckSelect($event, item)">
|
|
1449
|
+
</b-form-checkbox>
|
|
1450
|
+
</span>
|
|
1451
|
+
<span v-else-if="column.type == 'state' && optionsLoaded">
|
|
1452
|
+
{{
|
|
1453
|
+
getStateValue(itemValue(column, item), column.options)
|
|
1454
|
+
}}
|
|
1455
|
+
</span>
|
|
1456
|
+
<span v-else-if="column.type == 'array' && optionsLoaded">
|
|
1457
|
+
{{
|
|
1458
|
+
getArrayValue(
|
|
1459
|
+
itemValue(column, item),
|
|
1460
|
+
column.displayProp,
|
|
1461
|
+
column.options
|
|
1462
|
+
)
|
|
1463
|
+
}}
|
|
1464
|
+
</span>
|
|
1465
|
+
<span v-else>
|
|
1466
|
+
{{ itemValue(column, item) }}
|
|
1467
|
+
</span>
|
|
1468
|
+
</slot>
|
|
1469
|
+
|
|
1470
|
+
<b-button-group v-if="column.type == 'actions'">
|
|
1471
|
+
<slot name="rowAction" v-bind:item="item" v-bind:index="index" v-bind:showItem="showItem"
|
|
1472
|
+
v-bind:updateItem="updateItem" v-bind:removeItem="removeItem">
|
|
1473
|
+
<b-button variant="primary" @click="showItem(item.id, index)">
|
|
1474
|
+
<b-icon-eye></b-icon-eye>
|
|
1475
|
+
</b-button>
|
|
1476
|
+
<b-button variant="secondary" @click="updateItem(item.id, index)">
|
|
1477
|
+
<b-icon-pencil></b-icon-pencil>
|
|
1478
|
+
</b-button>
|
|
1479
|
+
<b-button variant="danger" @click="removeItem(item.id, index)">
|
|
1480
|
+
<b-icon-trash></b-icon-trash>
|
|
1481
|
+
</b-button>
|
|
1482
|
+
</slot>
|
|
1483
|
+
</b-button-group>
|
|
1484
|
+
</td>
|
|
1485
|
+
</slot>
|
|
1486
|
+
|
|
1487
|
+
</tr>
|
|
1391
1488
|
|
|
1489
|
+
</draggable>
|
|
1490
|
+
|
|
1491
|
+
</table>
|
|
1492
|
+
<p v-if="!loading && items && items.length == 0 && !infiniteScroll" class="p-3">
|
|
1493
|
+
{{ messageEmptyResults }}
|
|
1494
|
+
</p>
|
|
1495
|
+
</div>
|
|
1392
1496
|
|
|
1393
|
-
|
|
1394
|
-
|
|
1497
|
+
<div v-if="displayMode == displayModes.MODE_CARDS">
|
|
1498
|
+
<draggable v-model="items" :group="draggableGroup" class="row" :draggable="orderable ? '.item' : '.none'"
|
|
1499
|
+
@start="drag = true" @end="drag = false" @sort="onSort()" @add="onDraggableAdded($event)"
|
|
1500
|
+
@change="onDraggableChange($event)" :options="draggableOptions">
|
|
1501
|
+
<b-col v-for="(item, index) in itemsList" v-bind:key="index" :cols="colXs" :sm="colSm" :md="colMd" :lg="colLg"
|
|
1502
|
+
:xl="colXl" class="item">
|
|
1503
|
+
<b-card :title="item.title" tag="article" class="mb-2 card-crud" :class="cardClass"
|
|
1504
|
+
:hideFooter="cardHideFooter">
|
|
1505
|
+
<slot name="card" v-bind:item="item">
|
|
1506
|
+
<div v-for="(column, indexc) in columns" :key="indexc">
|
|
1507
|
+
<b-card-text v-if="column.type != 'actions'">{{ column.label }}:
|
|
1395
1508
|
<slot :name="'cell-' + column.prop" v-bind:item="item" v-bind:index="index" v-bind:itemindex="index"
|
|
1396
1509
|
v-bind:columnindex="indexc">
|
|
1397
1510
|
<span v-if="column.type == 'boolean'">
|
|
@@ -1405,17 +1518,7 @@ export default /*#__PURE__*/ {
|
|
|
1405
1518
|
"><b-icon-x-circle></b-icon-x-circle></b-badge>
|
|
1406
1519
|
</span>
|
|
1407
1520
|
<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>
|
|
1521
|
+
{{ itemValue(column, item) }}
|
|
1419
1522
|
</span>
|
|
1420
1523
|
<span v-else-if="column.type == 'state'">
|
|
1421
1524
|
{{
|
|
@@ -1426,7 +1529,8 @@ export default /*#__PURE__*/ {
|
|
|
1426
1529
|
{{
|
|
1427
1530
|
getArrayValue(
|
|
1428
1531
|
itemValue(column, item),
|
|
1429
|
-
column.displayProp
|
|
1532
|
+
column.displayProp,
|
|
1533
|
+
column.options
|
|
1430
1534
|
)
|
|
1431
1535
|
}}
|
|
1432
1536
|
</span>
|
|
@@ -1434,125 +1538,61 @@ export default /*#__PURE__*/ {
|
|
|
1434
1538
|
{{ itemValue(column, item) }}
|
|
1435
1539
|
</span>
|
|
1436
1540
|
</slot>
|
|
1541
|
+
</b-card-text>
|
|
1542
|
+
</div>
|
|
1543
|
+
</slot>
|
|
1437
1544
|
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
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>
|
|
1545
|
+
<template v-slot:footer>
|
|
1546
|
+
<b-button-group>
|
|
1547
|
+
<slot name="rowAction" v-bind:item="item" v-bind:index="index" v-bind:showItem="showItem"
|
|
1548
|
+
v-bind:updateItem="updateItem" v-bind:removeItem="removeItem">
|
|
1549
|
+
<b-button variant="primary" @click="showItem(item.id, index)">
|
|
1550
|
+
<b-icon-eye></b-icon-eye>
|
|
1551
|
+
</b-button>
|
|
1552
|
+
<b-button variant="secondary" @click="updateItem(item.id, index)">
|
|
1553
|
+
<b-icon-pencil></b-icon-pencil>
|
|
1554
|
+
</b-button>
|
|
1555
|
+
<b-button variant="danger" @click="removeItem(item.id, index)">
|
|
1556
|
+
<b-icon-trash></b-icon-trash>
|
|
1557
|
+
</b-button>
|
|
1558
|
+
</slot>
|
|
1559
|
+
</b-button-group>
|
|
1560
|
+
</template>
|
|
1561
|
+
</b-card>
|
|
1562
|
+
</b-col>
|
|
1464
1563
|
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
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>
|
|
1564
|
+
</draggable>
|
|
1565
|
+
|
|
1566
|
+
<p v-if="!loading && items && items.length == 0 && !infiniteScroll" class="p-3">
|
|
1567
|
+
{{ messageEmptyResults }}
|
|
1568
|
+
</p>
|
|
1532
1569
|
|
|
1570
|
+
</div>
|
|
1571
|
+
|
|
1572
|
+
<div v-if="displayMode == displayModes.MODE_CUSTOM">
|
|
1573
|
+
<div :class="listContainerClass">
|
|
1533
1574
|
<p v-if="!loading && items && items.length == 0 && !infiniteScroll" class="p-3">
|
|
1534
1575
|
{{ messageEmptyResults }}
|
|
1535
1576
|
</p>
|
|
1536
|
-
|
|
1537
|
-
|
|
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>
|
|
1577
|
+
<div :class="listItemClass" v-for="(item, index) in itemsList" v-bind:key="index">
|
|
1578
|
+
<slot name="card" v-bind:item="item"> </slot>
|
|
1547
1579
|
</div>
|
|
1548
1580
|
</div>
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1581
|
+
</div>
|
|
1582
|
+
<b-overlay :show="loading" rounded="sm"></b-overlay>
|
|
1583
|
+
<infinite-loading ref="infiniteLoading" @infinite="infiniteHandler" v-if="infiniteScroll"
|
|
1584
|
+
:forceUseInfiniteWrapper="true" :key="infiniteScrollKey">
|
|
1585
|
+
<div slot="spinner">
|
|
1586
|
+
<div class="text-center">{{ messageLoading }}</div>
|
|
1587
|
+
</div>
|
|
1588
|
+
<div slot="no-more">
|
|
1589
|
+
<div class="text-center" v-if="!loading">{{ messageNoMore }}</div>
|
|
1590
|
+
</div>
|
|
1591
|
+
<div slot="no-results">
|
|
1592
|
+
<div class="text-center" v-if="!loading">{{ items.length == 0 ? messageEmptyResults : messageNoMore }}</div>
|
|
1593
|
+
</div>
|
|
1594
|
+
</infinite-loading>
|
|
1595
|
+
|
|
1556
1596
|
<div class="crud-paginator" v-if="!infiniteScroll">
|
|
1557
1597
|
<b-pagination v-if="showPaginator" v-model="pagination.current_page" :total-rows="pagination.total"
|
|
1558
1598
|
:per-page="pagination.per_page" @change="onPaginationChange($event)"></b-pagination>
|
|
@@ -1666,5 +1706,4 @@ tr td:first-child {
|
|
|
1666
1706
|
}
|
|
1667
1707
|
}
|
|
1668
1708
|
}
|
|
1669
|
-
}
|
|
1670
|
-
</style>
|
|
1709
|
+
}</style>
|