vue-laravel-crud 1.7.3 → 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.
@@ -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-51199a53]:last-child,\ntr td[data-v-51199a53]:first-child {\n width: 1%;\n white-space: nowrap; }\n\n.crud-pagination[data-v-51199a53] {\n display: flex;\n align-items: center;\n width: 100%;\n justify-content: center;\n margin-top: 1rem; }\n\n.crud-header[data-v-51199a53] {\n display: flex;\n justify-content: space-between;\n max-height: 3rem; }\n .crud-header[data-v-51199a53] .crud-title[data-v-51199a53] {\n margin: 0; }\n .crud-header[data-v-51199a53] .crud-search[data-v-51199a53] {\n max-width: 15rem; }\n .crud-header[data-v-51199a53] .crud-search[data-v-51199a53] .btn[data-v-51199a53] {\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-51199a53] .crud-search[data-v-51199a53] .btn[data-v-51199a53].open[data-v-51199a53] {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0; }\n .crud-header[data-v-51199a53] .table-options[data-v-51199a53] {\n margin-bottom: 1rem;\n display: flex;\n align-items: center;\n justify-content: flex-end; }\n\n.custom-control[data-v-51199a53] {\n position: relative; }\n\n@media (min-width: 992px) {\n .table[data-v-51199a53] {\n table-layout: auto; }\n .table[data-v-51199a53] tbody[data-v-51199a53] td[data-v-51199a53] {\n overflow: scroll;\n -ms-overflow-style: none;\n /* IE and Edge */\n scrollbar-width: none;\n /* Firefox */ }\n .table[data-v-51199a53] tbody[data-v-51199a53] td[data-v-51199a53]::-webkit-scrollbar {\n display: none; } }\n";
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 (
@@ -12867,6 +12867,25 @@ const _sfc_main = {
12867
12867
  this.$emit("select", this.item);
12868
12868
  this.$emit("selectItems", this.selectedItems);
12869
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
+ },
12870
12889
  showItem(id, itemIndex = null) {
12871
12890
  if (itemIndex == null) {
12872
12891
  let item = this.items.find(it => it.id == id);
@@ -13097,21 +13116,25 @@ const _sfc_main = {
13097
13116
  this.loading = false;
13098
13117
  },
13099
13118
  async deleteItemBulkVuex() {
13100
- /*
13101
- let result = await this.model.api().delete('/' + id, {
13102
- delete: 1
13103
- });
13104
-
13105
- console.debug("delete item vuex", result);
13106
- let responseStatus = result.response.status;
13107
-
13108
- if (result.response.data.error) {
13109
- this.toastError(result.response.data.error);
13110
- this.loading = false;
13111
- return;
13112
- }
13113
-
13114
- this.toastSuccess("Elemento eliminado.");*/
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.");
13115
13138
  },
13116
13139
  deleteItem(id, index) {
13117
13140
  if (this.useVuexORM) {
@@ -13287,19 +13310,19 @@ const _sfc_main = {
13287
13310
  },
13288
13311
  async saveItemVuex(event = null) {
13289
13312
  console.debug("save item 1", this.item);
13290
- let jsondata = this.item.$toJson();
13291
- console.debug("save item 2", this.item, jsondata);
13292
13313
  let result;
13293
13314
  let create = false;
13294
13315
  if (this.vuexLocalforage) {
13295
13316
  if (this.item.id) {
13296
- result = await this.model.$update(this.item.id, jsondata);
13317
+ result = await this.model.$update(this.item.id, this.item);
13297
13318
  create = false;
13298
13319
  } else {
13299
- result = await this.model.$create(jsondata);
13320
+ result = await this.model.$create(this.item);
13300
13321
  create = true;
13301
13322
  }
13302
13323
  } else {
13324
+ let jsondata = this.item.$toJson();
13325
+ console.debug("save item 2", this.item, jsondata);
13303
13326
  if (this.item.id) {
13304
13327
  result = await this.model.api().put('/' + this.item.id, jsondata);
13305
13328
  create = false;
@@ -14604,7 +14627,7 @@ var _sfc_render = function render() {
14604
14627
  }) : _vm._e()], 2) : _vm._e()], 1);
14605
14628
  };
14606
14629
  var _sfc_staticRenderFns = [];
14607
- var __component__ = /*#__PURE__*/normalizeComponent(_sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, "51199a53", null, null);
14630
+ var __component__ = /*#__PURE__*/normalizeComponent(_sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, "4e32274c", null, null);
14608
14631
  var component = __component__.exports;
14609
14632
 
14610
14633
  // Import vue component