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
|
@@ -12115,7 +12115,7 @@ if (typeof window !== 'undefined' && window.Vue) {
|
|
|
12115
12115
|
|
|
12116
12116
|
var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
|
|
12117
12117
|
|
|
12118
|
-
var css = "tr td[data-v-
|
|
12118
|
+
var css = "tr td[data-v-4e32274c]:last-child,\ntr td[data-v-4e32274c]:first-child {\n width: 1%;\n white-space: nowrap; }\n\n.crud-pagination[data-v-4e32274c] {\n display: flex;\n align-items: center;\n width: 100%;\n justify-content: center;\n margin-top: 1rem; }\n\n.crud-header[data-v-4e32274c] {\n display: flex;\n justify-content: space-between;\n max-height: 3rem; }\n .crud-header[data-v-4e32274c] .crud-title[data-v-4e32274c] {\n margin: 0; }\n .crud-header[data-v-4e32274c] .crud-search[data-v-4e32274c] {\n max-width: 15rem; }\n .crud-header[data-v-4e32274c] .crud-search[data-v-4e32274c] .btn[data-v-4e32274c] {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n border-top-right-radius: 0.375rem;\n border-bottom-right-radius: 0.375rem; }\n .crud-header[data-v-4e32274c] .crud-search[data-v-4e32274c] .btn[data-v-4e32274c].open[data-v-4e32274c] {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0; }\n .crud-header[data-v-4e32274c] .table-options[data-v-4e32274c] {\n margin-bottom: 1rem;\n display: flex;\n align-items: center;\n justify-content: flex-end; }\n\n.custom-control[data-v-4e32274c] {\n position: relative; }\n\n@media (min-width: 992px) {\n .table[data-v-4e32274c] {\n table-layout: auto; }\n .table[data-v-4e32274c] tbody[data-v-4e32274c] td[data-v-4e32274c] {\n overflow: scroll;\n -ms-overflow-style: none;\n /* IE and Edge */\n scrollbar-width: none;\n /* Firefox */ }\n .table[data-v-4e32274c] tbody[data-v-4e32274c] td[data-v-4e32274c]::-webkit-scrollbar {\n display: none; } }\n";
|
|
12119
12119
|
n(css, {});
|
|
12120
12120
|
|
|
12121
12121
|
function normalizeComponent (
|
|
@@ -12569,9 +12569,12 @@ const _sfc_main = {
|
|
|
12569
12569
|
// Agregar un oyente de eventos para actualizar isMobile cuando cambia el tamaño de la pantalla
|
|
12570
12570
|
window.addEventListener("resize", this.handleResize);
|
|
12571
12571
|
if (this.useVuexORM) {
|
|
12572
|
-
|
|
12572
|
+
if (this.vuexLocalforage) {
|
|
12573
|
+
this.item = {};
|
|
12574
|
+
} else {
|
|
12575
|
+
this.item = new this.model();
|
|
12576
|
+
}
|
|
12573
12577
|
const fields = this.model.fields();
|
|
12574
|
-
|
|
12575
12578
|
// Inicializa el objeto "itemDefault" con los valores por defecto
|
|
12576
12579
|
const itemDefault = {};
|
|
12577
12580
|
for (const fieldName of Object.keys(fields)) {
|
|
@@ -12864,6 +12867,25 @@ const _sfc_main = {
|
|
|
12864
12867
|
this.$emit("select", this.item);
|
|
12865
12868
|
this.$emit("selectItems", this.selectedItems);
|
|
12866
12869
|
},
|
|
12870
|
+
updateData(data, allowCreate = true) {
|
|
12871
|
+
// Convertir this.items a un mapa para acceso rápido por id
|
|
12872
|
+
const itemsMap = new Map(this.items.map(item => [item.id, item]));
|
|
12873
|
+
|
|
12874
|
+
// Recorrer cada elemento de data
|
|
12875
|
+
data.forEach(newItem => {
|
|
12876
|
+
if (itemsMap.has(newItem.id)) {
|
|
12877
|
+
// Actualizar el item existente
|
|
12878
|
+
const existingItem = itemsMap.get(newItem.id);
|
|
12879
|
+
Object.assign(existingItem, newItem);
|
|
12880
|
+
} else if (allowCreate) {
|
|
12881
|
+
// Agregar el nuevo item si allowCreate es true
|
|
12882
|
+
this.items.push(newItem);
|
|
12883
|
+
}
|
|
12884
|
+
});
|
|
12885
|
+
|
|
12886
|
+
// Convertir el mapa de vuelta a un array, si es necesario
|
|
12887
|
+
this.items = Array.from(itemsMap.values());
|
|
12888
|
+
},
|
|
12867
12889
|
showItem(id, itemIndex = null) {
|
|
12868
12890
|
if (itemIndex == null) {
|
|
12869
12891
|
let item = this.items.find(it => it.id == id);
|
|
@@ -12876,7 +12898,11 @@ const _sfc_main = {
|
|
|
12876
12898
|
},
|
|
12877
12899
|
createItem() {
|
|
12878
12900
|
if (this.useVuexORM) {
|
|
12879
|
-
|
|
12901
|
+
if (this.vuexLocalforage) {
|
|
12902
|
+
this.item = JSON.parse(JSON.stringify(this.itemDefault));
|
|
12903
|
+
} else {
|
|
12904
|
+
this.item = new this.model(JSON.parse(JSON.stringify(this.itemDefault)));
|
|
12905
|
+
}
|
|
12880
12906
|
} else {
|
|
12881
12907
|
this.item = JSON.parse(JSON.stringify(this.itemDefault));
|
|
12882
12908
|
}
|
|
@@ -13090,21 +13116,25 @@ const _sfc_main = {
|
|
|
13090
13116
|
this.loading = false;
|
|
13091
13117
|
},
|
|
13092
13118
|
async deleteItemBulkVuex() {
|
|
13093
|
-
|
|
13094
|
-
|
|
13095
|
-
|
|
13096
|
-
|
|
13097
|
-
|
|
13098
|
-
|
|
13099
|
-
|
|
13100
|
-
|
|
13101
|
-
|
|
13102
|
-
|
|
13103
|
-
|
|
13104
|
-
|
|
13105
|
-
|
|
13106
|
-
|
|
13107
|
-
|
|
13119
|
+
let ids = this.selectedItems.map(it => it.id);
|
|
13120
|
+
if (this.vuexLocalforage) {
|
|
13121
|
+
await this.model.$delete(ids);
|
|
13122
|
+
} else {
|
|
13123
|
+
let result = await this.model.api().delete('/bulk-destroy', {
|
|
13124
|
+
params: {
|
|
13125
|
+
ids: ids
|
|
13126
|
+
},
|
|
13127
|
+
delete: ids
|
|
13128
|
+
});
|
|
13129
|
+
console.debug("delete item vuex", result);
|
|
13130
|
+
result.response.status;
|
|
13131
|
+
if (result.response.data.error) {
|
|
13132
|
+
this.toastError(result.response.data.error);
|
|
13133
|
+
this.loading = false;
|
|
13134
|
+
return;
|
|
13135
|
+
}
|
|
13136
|
+
}
|
|
13137
|
+
this.toastSuccess("Elemento eliminados.");
|
|
13108
13138
|
},
|
|
13109
13139
|
deleteItem(id, index) {
|
|
13110
13140
|
if (this.useVuexORM) {
|
|
@@ -13280,19 +13310,19 @@ const _sfc_main = {
|
|
|
13280
13310
|
},
|
|
13281
13311
|
async saveItemVuex(event = null) {
|
|
13282
13312
|
console.debug("save item 1", this.item);
|
|
13283
|
-
let jsondata = this.item.$toJson();
|
|
13284
|
-
console.debug("save item 2", this.item, jsondata);
|
|
13285
13313
|
let result;
|
|
13286
13314
|
let create = false;
|
|
13287
13315
|
if (this.vuexLocalforage) {
|
|
13288
13316
|
if (this.item.id) {
|
|
13289
|
-
result = await this.model.$update(this.item.id,
|
|
13317
|
+
result = await this.model.$update(this.item.id, this.item);
|
|
13290
13318
|
create = false;
|
|
13291
13319
|
} else {
|
|
13292
|
-
result = await this.model.$create(
|
|
13320
|
+
result = await this.model.$create(this.item);
|
|
13293
13321
|
create = true;
|
|
13294
13322
|
}
|
|
13295
13323
|
} else {
|
|
13324
|
+
let jsondata = this.item.$toJson();
|
|
13325
|
+
console.debug("save item 2", this.item, jsondata);
|
|
13296
13326
|
if (this.item.id) {
|
|
13297
13327
|
result = await this.model.api().put('/' + this.item.id, jsondata);
|
|
13298
13328
|
create = false;
|
|
@@ -14597,7 +14627,7 @@ var _sfc_render = function render() {
|
|
|
14597
14627
|
}) : _vm._e()], 2) : _vm._e()], 1);
|
|
14598
14628
|
};
|
|
14599
14629
|
var _sfc_staticRenderFns = [];
|
|
14600
|
-
var __component__ = /*#__PURE__*/normalizeComponent(_sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, "
|
|
14630
|
+
var __component__ = /*#__PURE__*/normalizeComponent(_sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, "4e32274c", null, null);
|
|
14601
14631
|
var component = __component__.exports;
|
|
14602
14632
|
|
|
14603
14633
|
// Import vue component
|