vue-laravel-crud 1.7.3 → 1.7.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 +57 -38
- package/dist/vue-laravel-crud.min.js +1 -1
- package/dist/vue-laravel-crud.ssr.js +286 -245
- package/package.json +1 -1
- package/src/vue-laravel-crud.vue +69 -40
|
@@ -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-e8340149]:last-child,\ntr td[data-v-e8340149]:first-child {\n width: 1%;\n white-space: nowrap; }\n\n.crud-pagination[data-v-e8340149] {\n display: flex;\n align-items: center;\n width: 100%;\n justify-content: center;\n margin-top: 1rem; }\n\n.crud-header[data-v-e8340149] {\n display: flex;\n justify-content: space-between;\n max-height: 3rem; }\n .crud-header[data-v-e8340149] .crud-title[data-v-e8340149] {\n margin: 0; }\n .crud-header[data-v-e8340149] .crud-search[data-v-e8340149] {\n max-width: 15rem; }\n .crud-header[data-v-e8340149] .crud-search[data-v-e8340149] .btn[data-v-e8340149] {\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-e8340149] .crud-search[data-v-e8340149] .btn[data-v-e8340149].open[data-v-e8340149] {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0; }\n .crud-header[data-v-e8340149] .table-options[data-v-e8340149] {\n margin-bottom: 1rem;\n display: flex;\n align-items: center;\n justify-content: flex-end; }\n\n.custom-control[data-v-e8340149] {\n position: relative; }\n\n@media (min-width: 992px) {\n .table[data-v-e8340149] {\n table-layout: auto; }\n .table[data-v-e8340149] tbody[data-v-e8340149] td[data-v-e8340149] {\n overflow: scroll;\n -ms-overflow-style: none;\n /* IE and Edge */\n scrollbar-width: none;\n /* Firefox */ }\n .table[data-v-e8340149] tbody[data-v-e8340149] td[data-v-e8340149]::-webkit-scrollbar {\n display: none; } }\n";
|
|
12119
12119
|
n(css, {});
|
|
12120
12120
|
|
|
12121
12121
|
function normalizeComponent (
|
|
@@ -12614,17 +12614,7 @@ const _sfc_main = {
|
|
|
12614
12614
|
console.debug("crud mounted columns", this.columns);
|
|
12615
12615
|
this.internalFilters = [];
|
|
12616
12616
|
this.setupFilters();
|
|
12617
|
-
|
|
12618
|
-
this.fetchItems();
|
|
12619
|
-
} else {
|
|
12620
|
-
if (this.grouped) {
|
|
12621
|
-
this.groupItems(this.models);
|
|
12622
|
-
} else {
|
|
12623
|
-
this.items = this.models;
|
|
12624
|
-
}
|
|
12625
|
-
this.pagination.total = this.items.length;
|
|
12626
|
-
this.firstLoad = true;
|
|
12627
|
-
}
|
|
12617
|
+
this.fetchItems();
|
|
12628
12618
|
this.loadOptions();
|
|
12629
12619
|
},
|
|
12630
12620
|
computed: {
|
|
@@ -12867,6 +12857,25 @@ const _sfc_main = {
|
|
|
12867
12857
|
this.$emit("select", this.item);
|
|
12868
12858
|
this.$emit("selectItems", this.selectedItems);
|
|
12869
12859
|
},
|
|
12860
|
+
updateData(data, allowCreate = true) {
|
|
12861
|
+
// Convertir this.items a un mapa para acceso rápido por id
|
|
12862
|
+
const itemsMap = new Map(this.items.map(item => [item.id, item]));
|
|
12863
|
+
|
|
12864
|
+
// Recorrer cada elemento de data
|
|
12865
|
+
data.forEach(newItem => {
|
|
12866
|
+
if (itemsMap.has(newItem.id)) {
|
|
12867
|
+
// Actualizar el item existente
|
|
12868
|
+
const existingItem = itemsMap.get(newItem.id);
|
|
12869
|
+
Object.assign(existingItem, newItem);
|
|
12870
|
+
} else if (allowCreate) {
|
|
12871
|
+
// Agregar el nuevo item si allowCreate es true
|
|
12872
|
+
this.items.push(newItem);
|
|
12873
|
+
}
|
|
12874
|
+
});
|
|
12875
|
+
|
|
12876
|
+
// Convertir el mapa de vuelta a un array, si es necesario
|
|
12877
|
+
this.items = Array.from(itemsMap.values());
|
|
12878
|
+
},
|
|
12870
12879
|
showItem(id, itemIndex = null) {
|
|
12871
12880
|
if (itemIndex == null) {
|
|
12872
12881
|
let item = this.items.find(it => it.id == id);
|
|
@@ -12903,9 +12912,6 @@ const _sfc_main = {
|
|
|
12903
12912
|
},
|
|
12904
12913
|
refresh() {
|
|
12905
12914
|
this.$emit("refresh", {});
|
|
12906
|
-
if (!this.ajax) {
|
|
12907
|
-
return;
|
|
12908
|
-
}
|
|
12909
12915
|
if (this.infiniteScroll) {
|
|
12910
12916
|
this.pagination.current_page = 1;
|
|
12911
12917
|
this.infiniteScrollKey++;
|
|
@@ -12961,14 +12967,23 @@ const _sfc_main = {
|
|
|
12961
12967
|
this.loading = false;
|
|
12962
12968
|
this.firstLoad = true;
|
|
12963
12969
|
},
|
|
12964
|
-
|
|
12965
|
-
if (
|
|
12966
|
-
|
|
12970
|
+
fetchItemsLocal() {
|
|
12971
|
+
if (this.grouped) {
|
|
12972
|
+
this.groupItems(this.models);
|
|
12973
|
+
} else {
|
|
12974
|
+
this.items = this.models;
|
|
12967
12975
|
}
|
|
12976
|
+
this.pagination.total = this.items.length;
|
|
12977
|
+
this.firstLoad = true;
|
|
12978
|
+
},
|
|
12979
|
+
fetchItems(page = 1, concat = false) {
|
|
12968
12980
|
this.$emit("beforeFetch", {});
|
|
12969
12981
|
if (this.useVuexORM) {
|
|
12970
12982
|
return this.fetchItemsVuex(page, concat);
|
|
12971
12983
|
}
|
|
12984
|
+
if (!this.ajax) {
|
|
12985
|
+
return this.fetchItemsLocal(page, concat);
|
|
12986
|
+
}
|
|
12972
12987
|
this.loading = true;
|
|
12973
12988
|
return axios.get(this.apiUrl + "/" + this.modelName, {
|
|
12974
12989
|
params: {
|
|
@@ -13097,21 +13112,25 @@ const _sfc_main = {
|
|
|
13097
13112
|
this.loading = false;
|
|
13098
13113
|
},
|
|
13099
13114
|
async deleteItemBulkVuex() {
|
|
13100
|
-
|
|
13101
|
-
|
|
13102
|
-
|
|
13103
|
-
|
|
13104
|
-
|
|
13105
|
-
|
|
13106
|
-
|
|
13107
|
-
|
|
13108
|
-
|
|
13109
|
-
|
|
13110
|
-
|
|
13111
|
-
|
|
13112
|
-
|
|
13113
|
-
|
|
13114
|
-
|
|
13115
|
+
let ids = this.selectedItems.map(it => it.id);
|
|
13116
|
+
if (this.vuexLocalforage) {
|
|
13117
|
+
await this.model.$delete(ids);
|
|
13118
|
+
} else {
|
|
13119
|
+
let result = await this.model.api().delete('/bulk-destroy', {
|
|
13120
|
+
params: {
|
|
13121
|
+
ids: ids
|
|
13122
|
+
},
|
|
13123
|
+
delete: ids
|
|
13124
|
+
});
|
|
13125
|
+
console.debug("delete item vuex", result);
|
|
13126
|
+
result.response.status;
|
|
13127
|
+
if (result.response.data.error) {
|
|
13128
|
+
this.toastError(result.response.data.error);
|
|
13129
|
+
this.loading = false;
|
|
13130
|
+
return;
|
|
13131
|
+
}
|
|
13132
|
+
}
|
|
13133
|
+
this.toastSuccess("Elemento eliminados.");
|
|
13115
13134
|
},
|
|
13116
13135
|
deleteItem(id, index) {
|
|
13117
13136
|
if (this.useVuexORM) {
|
|
@@ -13287,19 +13306,19 @@ const _sfc_main = {
|
|
|
13287
13306
|
},
|
|
13288
13307
|
async saveItemVuex(event = null) {
|
|
13289
13308
|
console.debug("save item 1", this.item);
|
|
13290
|
-
let jsondata = this.item.$toJson();
|
|
13291
|
-
console.debug("save item 2", this.item, jsondata);
|
|
13292
13309
|
let result;
|
|
13293
13310
|
let create = false;
|
|
13294
13311
|
if (this.vuexLocalforage) {
|
|
13295
13312
|
if (this.item.id) {
|
|
13296
|
-
result = await this.model.$update(this.item.id,
|
|
13313
|
+
result = await this.model.$update(this.item.id, this.item);
|
|
13297
13314
|
create = false;
|
|
13298
13315
|
} else {
|
|
13299
|
-
result = await this.model.$create(
|
|
13316
|
+
result = await this.model.$create(this.item);
|
|
13300
13317
|
create = true;
|
|
13301
13318
|
}
|
|
13302
13319
|
} else {
|
|
13320
|
+
let jsondata = this.item.$toJson();
|
|
13321
|
+
console.debug("save item 2", this.item, jsondata);
|
|
13303
13322
|
if (this.item.id) {
|
|
13304
13323
|
result = await this.model.api().put('/' + this.item.id, jsondata);
|
|
13305
13324
|
create = false;
|
|
@@ -14604,7 +14623,7 @@ var _sfc_render = function render() {
|
|
|
14604
14623
|
}) : _vm._e()], 2) : _vm._e()], 1);
|
|
14605
14624
|
};
|
|
14606
14625
|
var _sfc_staticRenderFns = [];
|
|
14607
|
-
var __component__ = /*#__PURE__*/normalizeComponent(_sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, "
|
|
14626
|
+
var __component__ = /*#__PURE__*/normalizeComponent(_sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, "e8340149", null, null);
|
|
14608
14627
|
var component = __component__.exports;
|
|
14609
14628
|
|
|
14610
14629
|
// Import vue component
|