vue-laravel-crud 1.7.2 → 1.7.4
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 +54 -24
- package/dist/vue-laravel-crud.min.js +1 -1
- package/dist/vue-laravel-crud.ssr.js +283 -231
- package/package.json +1 -1
- package/src/vue-laravel-crud.vue +86 -49
package/package.json
CHANGED
package/src/vue-laravel-crud.vue
CHANGED
|
@@ -386,12 +386,13 @@ export default /*#__PURE__*/ {
|
|
|
386
386
|
|
|
387
387
|
if (this.useVuexORM) {
|
|
388
388
|
|
|
389
|
-
|
|
390
|
-
|
|
389
|
+
if (this.vuexLocalforage) {
|
|
390
|
+
this.item = {};
|
|
391
|
+
} else {
|
|
392
|
+
this.item = new this.model();
|
|
393
|
+
}
|
|
391
394
|
let itemVuexOrmDefault = {};
|
|
392
|
-
|
|
393
395
|
const fields = this.model.fields();
|
|
394
|
-
|
|
395
396
|
// Inicializa el objeto "itemDefault" con los valores por defecto
|
|
396
397
|
const itemDefault = {};
|
|
397
398
|
for (const fieldName of Object.keys(fields)) {
|
|
@@ -747,6 +748,26 @@ export default /*#__PURE__*/ {
|
|
|
747
748
|
this.$emit("select", this.item);
|
|
748
749
|
this.$emit("selectItems", this.selectedItems);
|
|
749
750
|
},
|
|
751
|
+
|
|
752
|
+
updateData(data, allowCreate = true) {
|
|
753
|
+
// Convertir this.items a un mapa para acceso rápido por id
|
|
754
|
+
const itemsMap = new Map(this.items.map(item => [item.id, item]));
|
|
755
|
+
|
|
756
|
+
// Recorrer cada elemento de data
|
|
757
|
+
data.forEach(newItem => {
|
|
758
|
+
if (itemsMap.has(newItem.id)) {
|
|
759
|
+
// Actualizar el item existente
|
|
760
|
+
const existingItem = itemsMap.get(newItem.id);
|
|
761
|
+
Object.assign(existingItem, newItem);
|
|
762
|
+
} else if (allowCreate) {
|
|
763
|
+
// Agregar el nuevo item si allowCreate es true
|
|
764
|
+
this.items.push(newItem);
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
|
|
768
|
+
// Convertir el mapa de vuelta a un array, si es necesario
|
|
769
|
+
this.items = Array.from(itemsMap.values());
|
|
770
|
+
},
|
|
750
771
|
showItem(id, itemIndex = null) {
|
|
751
772
|
if (itemIndex == null) {
|
|
752
773
|
let item = this.items.find((it) => it.id == id);
|
|
@@ -759,7 +780,13 @@ export default /*#__PURE__*/ {
|
|
|
759
780
|
},
|
|
760
781
|
createItem() {
|
|
761
782
|
if (this.useVuexORM) {
|
|
762
|
-
|
|
783
|
+
|
|
784
|
+
if (this.vuexLocalforage) {
|
|
785
|
+
this.item = JSON.parse(JSON.stringify(this.itemDefault));
|
|
786
|
+
} else {
|
|
787
|
+
this.item = new this.model(JSON.parse(JSON.stringify(this.itemDefault)));
|
|
788
|
+
}
|
|
789
|
+
|
|
763
790
|
} else {
|
|
764
791
|
this.item = JSON.parse(JSON.stringify(this.itemDefault));
|
|
765
792
|
}
|
|
@@ -820,10 +847,10 @@ export default /*#__PURE__*/ {
|
|
|
820
847
|
|
|
821
848
|
let result;
|
|
822
849
|
|
|
823
|
-
if(this.vuexLocalforage){
|
|
850
|
+
if (this.vuexLocalforage) {
|
|
824
851
|
await this.model.$fetch();
|
|
825
852
|
|
|
826
|
-
}else{
|
|
853
|
+
} else {
|
|
827
854
|
this.model.deleteAll();
|
|
828
855
|
|
|
829
856
|
result = await this.model.api().get('', {
|
|
@@ -836,7 +863,7 @@ export default /*#__PURE__*/ {
|
|
|
836
863
|
|
|
837
864
|
|
|
838
865
|
}
|
|
839
|
-
|
|
866
|
+
|
|
840
867
|
|
|
841
868
|
let itemsResult = this.model.query().withAll().get();
|
|
842
869
|
//let itemsResult = result.entities[this.model.entity];
|
|
@@ -1000,21 +1027,30 @@ export default /*#__PURE__*/ {
|
|
|
1000
1027
|
this.loading = false;
|
|
1001
1028
|
},
|
|
1002
1029
|
async deleteItemBulkVuex() {
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1030
|
+
|
|
1031
|
+
let ids = this.selectedItems.map(it => it.id);
|
|
1032
|
+
|
|
1033
|
+
|
|
1034
|
+
if (this.vuexLocalforage) {
|
|
1035
|
+
await this.model.$delete(ids);
|
|
1036
|
+
|
|
1037
|
+
} else {
|
|
1038
|
+
let result = await this.model.api().delete('/bulk-destroy' , {
|
|
1039
|
+
params: { ids: ids},
|
|
1040
|
+
delete: ids
|
|
1041
|
+
});
|
|
1042
|
+
|
|
1043
|
+
console.debug("delete item vuex", result);
|
|
1044
|
+
let responseStatus = result.response.status;
|
|
1045
|
+
|
|
1046
|
+
if (result.response.data.error) {
|
|
1047
|
+
this.toastError(result.response.data.error);
|
|
1048
|
+
this.loading = false;
|
|
1049
|
+
return;
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1016
1052
|
|
|
1017
|
-
|
|
1053
|
+
this.toastSuccess("Elemento eliminados.");
|
|
1018
1054
|
},
|
|
1019
1055
|
deleteItem(id, index) {
|
|
1020
1056
|
|
|
@@ -1069,13 +1105,13 @@ export default /*#__PURE__*/ {
|
|
|
1069
1105
|
async deleteItemVuex(id, index) {
|
|
1070
1106
|
|
|
1071
1107
|
|
|
1072
|
-
if(this.vuexLocalforage){
|
|
1108
|
+
if (this.vuexLocalforage) {
|
|
1073
1109
|
await this.model.$delete(id);
|
|
1074
1110
|
|
|
1075
|
-
}else{
|
|
1111
|
+
} else {
|
|
1076
1112
|
let result = await this.model.api().delete('/' + id, {
|
|
1077
|
-
|
|
1078
|
-
|
|
1113
|
+
delete: 1
|
|
1114
|
+
});
|
|
1079
1115
|
|
|
1080
1116
|
console.debug("delete item vuex", result);
|
|
1081
1117
|
let responseStatus = result.response.status;
|
|
@@ -1087,7 +1123,7 @@ export default /*#__PURE__*/ {
|
|
|
1087
1123
|
}
|
|
1088
1124
|
}
|
|
1089
1125
|
|
|
1090
|
-
|
|
1126
|
+
|
|
1091
1127
|
|
|
1092
1128
|
this.toastSuccess("Elemento eliminado.");
|
|
1093
1129
|
},
|
|
@@ -1140,7 +1176,7 @@ export default /*#__PURE__*/ {
|
|
|
1140
1176
|
}
|
|
1141
1177
|
|
|
1142
1178
|
params.format = 'JSON';
|
|
1143
|
-
|
|
1179
|
+
|
|
1144
1180
|
this.loading = true;
|
|
1145
1181
|
axios
|
|
1146
1182
|
.get(this.apiUrl + "/" + this.modelName + "/export", { params: params, responseType: "blob", })
|
|
@@ -1224,24 +1260,24 @@ export default /*#__PURE__*/ {
|
|
|
1224
1260
|
},
|
|
1225
1261
|
async saveItemVuex(event = null) {
|
|
1226
1262
|
console.debug("save item 1", this.item);
|
|
1227
|
-
let jsondata = this.item.$toJson();
|
|
1228
|
-
console.debug("save item 2", this.item, jsondata);
|
|
1229
1263
|
let result;
|
|
1230
|
-
|
|
1231
1264
|
let create = false;
|
|
1232
1265
|
|
|
1233
1266
|
|
|
1234
|
-
if(this.vuexLocalforage){
|
|
1267
|
+
if (this.vuexLocalforage) {
|
|
1235
1268
|
|
|
1236
1269
|
if (this.item.id) {
|
|
1237
|
-
result = await this.model.$update(this.item.id,
|
|
1270
|
+
result = await this.model.$update(this.item.id, this.item);
|
|
1238
1271
|
create = false;
|
|
1239
1272
|
} else {
|
|
1240
|
-
result = await this.model.$create(
|
|
1273
|
+
result = await this.model.$create(this.item);
|
|
1241
1274
|
create = true;
|
|
1242
1275
|
}
|
|
1243
|
-
|
|
1244
|
-
}else{
|
|
1276
|
+
|
|
1277
|
+
} else {
|
|
1278
|
+
|
|
1279
|
+
let jsondata = this.item.$toJson();
|
|
1280
|
+
console.debug("save item 2", this.item, jsondata);
|
|
1245
1281
|
if (this.item.id) {
|
|
1246
1282
|
result = await this.model.api().put('/' + this.item.id, jsondata);
|
|
1247
1283
|
create = false;
|
|
@@ -1250,7 +1286,7 @@ export default /*#__PURE__*/ {
|
|
|
1250
1286
|
create = true;
|
|
1251
1287
|
}
|
|
1252
1288
|
|
|
1253
|
-
|
|
1289
|
+
|
|
1254
1290
|
let responseStatus = result.response.status;
|
|
1255
1291
|
if (result.response.data.error) {
|
|
1256
1292
|
this.toastError(result.response.data.error);
|
|
@@ -1258,11 +1294,11 @@ export default /*#__PURE__*/ {
|
|
|
1258
1294
|
return;
|
|
1259
1295
|
//throw new Error('Something is wrong.')
|
|
1260
1296
|
}
|
|
1261
|
-
|
|
1297
|
+
|
|
1262
1298
|
result.save();
|
|
1263
1299
|
}
|
|
1264
1300
|
|
|
1265
|
-
|
|
1301
|
+
|
|
1266
1302
|
if (this.refreshAfterSave) this.refresh();
|
|
1267
1303
|
this.loading = false;
|
|
1268
1304
|
this.toastSuccess("Elemento Modificado");
|
|
@@ -1501,7 +1537,7 @@ export default /*#__PURE__*/ {
|
|
|
1501
1537
|
appendToast: true,
|
|
1502
1538
|
});
|
|
1503
1539
|
},
|
|
1504
|
-
downloadBlobResponse(response,extension = null) {
|
|
1540
|
+
downloadBlobResponse(response, extension = null) {
|
|
1505
1541
|
const url = window.URL.createObjectURL(new Blob([response.data]));
|
|
1506
1542
|
const link = document.createElement("a");
|
|
1507
1543
|
link.href = url;
|
|
@@ -1511,20 +1547,20 @@ export default /*#__PURE__*/ {
|
|
|
1511
1547
|
|
|
1512
1548
|
|
|
1513
1549
|
if (contentdisposition) {
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1550
|
+
filename = contentdisposition.split('filename=')[1].split('.')[0];
|
|
1551
|
+
filename = filename.replace('_', '');
|
|
1552
|
+
filename = filename.replace('"', '');
|
|
1553
|
+
extension = contentdisposition.split('.')[1].split(';')[0];
|
|
1554
|
+
extension = extension.replace('_', '');
|
|
1555
|
+
extension = extension.replace('"', '');
|
|
1520
1556
|
}
|
|
1521
1557
|
|
|
1522
1558
|
|
|
1523
|
-
console.debug("DOWNLOAD ",filename,extension);
|
|
1559
|
+
console.debug("DOWNLOAD ", filename, extension);
|
|
1524
1560
|
link.setAttribute("download", filename + '.' + extension);
|
|
1525
1561
|
document.body.appendChild(link);
|
|
1526
1562
|
link.click();
|
|
1527
|
-
|
|
1563
|
+
},
|
|
1528
1564
|
onChangeFilter(event) {
|
|
1529
1565
|
this.forceRecomputeCounter++;
|
|
1530
1566
|
console.debug("Filters debug ", this.finalFilters, this.internalFilter, this.internalFilters, this.filter, this.filters);
|
|
@@ -1981,7 +2017,8 @@ export default /*#__PURE__*/ {
|
|
|
1981
2017
|
</div>
|
|
1982
2018
|
</infinite-loading>
|
|
1983
2019
|
<div class="paginator-data" v-if="!infiniteScroll">
|
|
1984
|
-
Filas: {{ pagination.total }} | xPág: {{ pagination.per_page }} | Pág: {{ pagination.current_page }} |
|
|
2020
|
+
Filas: {{ pagination.total }} | xPág: {{ pagination.per_page }} | Pág: {{ pagination.current_page }} |
|
|
2021
|
+
Seleccionados:
|
|
1985
2022
|
{{
|
|
1986
2023
|
selectedItems.length }}
|
|
1987
2024
|
</div>
|