vue-laravel-crud 1.5.4 → 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.
@@ -11878,7 +11878,7 @@ var InfiniteLoading = /*@__PURE__*/getDefaultExportFromCjs(vueInfiniteLoadingExp
11878
11878
 
11879
11879
  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}}
11880
11880
 
11881
- var css = "tr td[data-v-1c8b3f68]:last-child,\ntr td[data-v-1c8b3f68]:first-child {\n width: 1%;\n white-space: nowrap; }\n\n.crud-pagination[data-v-1c8b3f68] {\n display: flex;\n justify-content: center; }\n\n.crud-header[data-v-1c8b3f68] {\n display: flex;\n justify-content: space-between;\n max-height: 3rem; }\n .crud-header[data-v-1c8b3f68] .crud-title[data-v-1c8b3f68] {\n margin: 0; }\n .crud-header[data-v-1c8b3f68] .crud-search[data-v-1c8b3f68] {\n max-width: 15rem; }\n .crud-header[data-v-1c8b3f68] .crud-search[data-v-1c8b3f68] .btn[data-v-1c8b3f68] {\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-1c8b3f68] .crud-search[data-v-1c8b3f68] .btn[data-v-1c8b3f68].open[data-v-1c8b3f68] {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0; }\n .crud-header[data-v-1c8b3f68] .table-options[data-v-1c8b3f68] {\n margin-bottom: 1rem;\n display: flex;\n align-items: center;\n justify-content: flex-end; }\n\n.custom-control[data-v-1c8b3f68] {\n position: relative;\n top: -15px; }\n\n@media (min-width: 992px) {\n .table[data-v-1c8b3f68] {\n table-layout: auto; }\n .table[data-v-1c8b3f68] tbody[data-v-1c8b3f68] td[data-v-1c8b3f68] {\n overflow: scroll;\n -ms-overflow-style: none;\n /* IE and Edge */\n scrollbar-width: none;\n /* Firefox */ }\n .table[data-v-1c8b3f68] tbody[data-v-1c8b3f68] td[data-v-1c8b3f68]::-webkit-scrollbar {\n display: none; } }\n";
11881
+ var css = "tr td[data-v-44f025cd]:last-child,\ntr td[data-v-44f025cd]:first-child {\n width: 1%;\n white-space: nowrap; }\n\n.crud-pagination[data-v-44f025cd] {\n display: flex;\n justify-content: center; }\n\n.crud-header[data-v-44f025cd] {\n display: flex;\n justify-content: space-between;\n max-height: 3rem; }\n .crud-header[data-v-44f025cd] .crud-title[data-v-44f025cd] {\n margin: 0; }\n .crud-header[data-v-44f025cd] .crud-search[data-v-44f025cd] {\n max-width: 15rem; }\n .crud-header[data-v-44f025cd] .crud-search[data-v-44f025cd] .btn[data-v-44f025cd] {\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-44f025cd] .crud-search[data-v-44f025cd] .btn[data-v-44f025cd].open[data-v-44f025cd] {\n border-top-right-radius: 0;\n border-bottom-right-radius: 0; }\n .crud-header[data-v-44f025cd] .table-options[data-v-44f025cd] {\n margin-bottom: 1rem;\n display: flex;\n align-items: center;\n justify-content: flex-end; }\n\n.custom-control[data-v-44f025cd] {\n position: relative;\n top: -15px; }\n\n@media (min-width: 992px) {\n .table[data-v-44f025cd] {\n table-layout: auto; }\n .table[data-v-44f025cd] tbody[data-v-44f025cd] td[data-v-44f025cd] {\n overflow: scroll;\n -ms-overflow-style: none;\n /* IE and Edge */\n scrollbar-width: none;\n /* Firefox */ }\n .table[data-v-44f025cd] tbody[data-v-44f025cd] td[data-v-44f025cd]::-webkit-scrollbar {\n display: none; } }\n";
11882
11882
  n(css, {});
11883
11883
 
11884
11884
  function normalizeComponent (
@@ -12010,7 +12010,8 @@ const _sfc_main = {
12010
12010
  MODE_CARDS: 2,
12011
12011
  MODE_CUSTOM: 3
12012
12012
  },
12013
- infiniteScrollKey: 1
12013
+ infiniteScrollKey: 1,
12014
+ optionsLoaded: false
12014
12015
  };
12015
12016
  },
12016
12017
  watch: {
@@ -12322,6 +12323,7 @@ const _sfc_main = {
12322
12323
  this.items = this.models;
12323
12324
  this.pagination.total = this.items.length;
12324
12325
  }
12326
+ this.loadOptions();
12325
12327
  },
12326
12328
  computed: {
12327
12329
  itemValue() {
@@ -12357,6 +12359,9 @@ const _sfc_main = {
12357
12359
  return prop => {
12358
12360
  return this.internalFilters.find(inf => inf.column == prop);
12359
12361
  };
12362
+ },
12363
+ columnOptions() {
12364
+ return column => {};
12360
12365
  }
12361
12366
  },
12362
12367
  methods: {
@@ -12739,6 +12744,9 @@ const _sfc_main = {
12739
12744
  order: v[this.orderProp]
12740
12745
  });
12741
12746
  });
12747
+ if (!this.ajax) {
12748
+ return;
12749
+ }
12742
12750
  axios.post(this.apiUrl + "/" + this.modelName + "/sort", {
12743
12751
  order: order
12744
12752
  }).then(response => {
@@ -12754,16 +12762,23 @@ const _sfc_main = {
12754
12762
  }
12755
12763
  },
12756
12764
  getArrayValue(value, displayProp) {
12765
+ let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
12757
12766
  if (!Array.isArray(value)) return "N/A";
12767
+ let values = [];
12768
+ let valuesFinal = [];
12758
12769
  if (value.length > 0) {
12759
12770
  if (typeof value[0] === "object" && displayProp) {
12760
- return value.map(vv => vv[displayProp]).join(",");
12771
+ values = value.map(vv => vv[displayProp]);
12761
12772
  } else {
12762
- return value.join(",");
12773
+ values = value.join(",");
12763
12774
  }
12764
12775
  } else {
12765
12776
  return "";
12766
12777
  }
12778
+ values.forEach(val => {
12779
+ valuesFinal.push(this.getStateValue(val, options));
12780
+ });
12781
+ return values.join(",");
12767
12782
  },
12768
12783
  getStateValue(value, options) {
12769
12784
  if (!options) {
@@ -12834,6 +12849,20 @@ const _sfc_main = {
12834
12849
  this.toastSuccess("Elemento Modificado");
12835
12850
  this.loading = false;
12836
12851
  },
12852
+ async loadOptions() {
12853
+ for (let i = 0; i < this.columns.length; i++) {
12854
+ const column = this.columns[i];
12855
+ if (typeof column.options === 'function') {
12856
+ // Si las opciones son una función (promesa), esperar y actualizar
12857
+ const options = await column.options();
12858
+ this.$set(this.columns, i, {
12859
+ ...column,
12860
+ options
12861
+ });
12862
+ }
12863
+ }
12864
+ this.optionsLoaded = true;
12865
+ },
12837
12866
  async saveItem() {
12838
12867
  let event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
12839
12868
  this.loading = true;
@@ -13118,9 +13147,7 @@ var _sfc_render = function render() {
13118
13147
  }
13119
13148
  })], 1)])]) : column.type == 'state' ? _c('div', {
13120
13149
  staticClass: "form-group"
13121
- }, [_c('label', [_vm._v(_vm._s(column.label))]), _c('div', {
13122
- staticClass: "d-none"
13123
- }, [_vm._v(_vm._s(column.options))]), _c('select', {
13150
+ }, [_c('label', [_vm._v(_vm._s(column.label))]), _vm.optionsLoaded ? _c('select', {
13124
13151
  directives: [{
13125
13152
  name: "model",
13126
13153
  rawName: "v-model",
@@ -13152,11 +13179,9 @@ var _sfc_render = function render() {
13152
13179
  "value": option.id ? option.id : option.value
13153
13180
  }
13154
13181
  }, [_vm._v(" " + _vm._s(option.text ? option.text : option.label ? option.label : "") + " ")]);
13155
- })], 2)]) : column.type == 'array' ? _c('div', {
13182
+ })], 2) : _vm._e()]) : column.type == 'array' ? _c('div', {
13156
13183
  staticClass: "form-group"
13157
- }, [_c('label', [_vm._v(_vm._s(column.label))]), _c('div', {
13158
- staticClass: "d-none"
13159
- }, [_vm._v(_vm._s(column.options))]), _c('select', {
13184
+ }, [_c('label', [_vm._v(_vm._s(column.label))]), _vm.optionsLoaded ? _c('select', {
13160
13185
  directives: [{
13161
13186
  name: "model",
13162
13187
  rawName: "v-model",
@@ -13188,7 +13213,7 @@ var _sfc_render = function render() {
13188
13213
  "value": option.id ? option.id : option.value
13189
13214
  }
13190
13215
  }, [_vm._v(" " + _vm._s(option.text ? option.text : option.label ? option.label : "") + " ")]);
13191
- }) : _vm._e()], 2)]) : _c('div', {
13216
+ }) : _vm._e()], 2) : _vm._e()]) : _c('div', {
13192
13217
  staticClass: "form-group"
13193
13218
  }, [_c('label', [_vm._v(_vm._s(column.label))]), _c('input', {
13194
13219
  directives: [{
@@ -13384,7 +13409,7 @@ var _sfc_render = function render() {
13384
13409
  callback: function ($$v) {
13385
13410
  _vm.$set(_vm.internalFilterByProp(column.prop + '_from'), "value", $$v);
13386
13411
  },
13387
- expression: "internalFilterByProp(column.prop + '_from').value\n "
13412
+ expression: "internalFilterByProp(column.prop + '_from').value\n "
13388
13413
  }
13389
13414
  })], 1), _c('div', {
13390
13415
  staticClass: "col-6"
@@ -13401,9 +13426,9 @@ var _sfc_render = function render() {
13401
13426
  callback: function ($$v) {
13402
13427
  _vm.$set(_vm.internalFilterByProp(column.prop + '_to'), "value", $$v);
13403
13428
  },
13404
- expression: "internalFilterByProp(column.prop + '_to').value\n "
13429
+ expression: "internalFilterByProp(column.prop + '_to').value\n "
13405
13430
  }
13406
- })], 1)]) : column.type == 'state' ? _c('select', {
13431
+ })], 1)]) : column.type == 'state' && _vm.optionsLoaded ? _c('select', {
13407
13432
  directives: [{
13408
13433
  name: "model",
13409
13434
  rawName: "v-model",
@@ -13438,7 +13463,7 @@ var _sfc_render = function render() {
13438
13463
  "value": option.id
13439
13464
  }
13440
13465
  }, [_vm._v(" " + _vm._s(option.text ? option.text : option.label ? option.label : "") + " ")]);
13441
- })], 2) : column.type == 'array' ? _c('select', {
13466
+ })], 2) : column.type == 'array' && _vm.optionsLoaded ? _c('select', {
13442
13467
  directives: [{
13443
13468
  name: "model",
13444
13469
  rawName: "v-model",
@@ -13595,7 +13620,7 @@ var _sfc_render = function render() {
13595
13620
  },
13596
13621
  expression: "item.selected"
13597
13622
  }
13598
- })], 1) : column.type == 'state' ? _c('span', [_vm._v(" " + _vm._s(_vm.getStateValue(_vm.itemValue(column, item), column.options)) + " ")]) : column.type == 'array' ? _c('span', [_vm._v(" " + _vm._s(_vm.getArrayValue(_vm.itemValue(column, item), column.displayProp)) + " ")]) : _c('span', [_vm._v(" " + _vm._s(_vm.itemValue(column, item)) + " ")])];
13623
+ })], 1) : column.type == 'state' && _vm.optionsLoaded ? _c('span', [_vm._v(" " + _vm._s(_vm.getStateValue(_vm.itemValue(column, item), column.options)) + " ")]) : column.type == 'array' && _vm.optionsLoaded ? _c('span', [_vm._v(" " + _vm._s(_vm.getArrayValue(_vm.itemValue(column, item), column.displayProp, column.options)) + " ")]) : _c('span', [_vm._v(" " + _vm._s(_vm.itemValue(column, item)) + " ")])];
13599
13624
  }, {
13600
13625
  "item": item,
13601
13626
  "index": index,
@@ -13748,7 +13773,7 @@ var _sfc_render = function render() {
13748
13773
  attrs: {
13749
13774
  "variant": "danger"
13750
13775
  }
13751
- }, [_c('b-icon-x-circle')], 1) : _vm._e()], 1) : column.type == 'date' ? _c('span', [_vm._v(" " + _vm._s(_vm.itemValue(column, item)) + " ")]) : column.type == 'state' ? _c('span', [_vm._v(" " + _vm._s(_vm.getStateValue(_vm.itemValue(column, item), column.options)) + " ")]) : column.type == 'array' ? _c('span', [_vm._v(" " + _vm._s(_vm.getArrayValue(_vm.itemValue(column, item), column.displayProp)) + " ")]) : _c('span', [_vm._v(" " + _vm._s(_vm.itemValue(column, item)) + " ")])];
13776
+ }, [_c('b-icon-x-circle')], 1) : _vm._e()], 1) : column.type == 'date' ? _c('span', [_vm._v(" " + _vm._s(_vm.itemValue(column, item)) + " ")]) : column.type == 'state' ? _c('span', [_vm._v(" " + _vm._s(_vm.getStateValue(_vm.itemValue(column, item), column.options)) + " ")]) : column.type == 'array' ? _c('span', [_vm._v(" " + _vm._s(_vm.getArrayValue(_vm.itemValue(column, item), column.displayProp, column.options)) + " ")]) : _c('span', [_vm._v(" " + _vm._s(_vm.itemValue(column, item)) + " ")])];
13752
13777
  }, {
13753
13778
  "item": item,
13754
13779
  "index": index,
@@ -13943,7 +13968,7 @@ var _sfc_render = function render() {
13943
13968
  }) : _vm._e()], 2)], 1);
13944
13969
  };
13945
13970
  var _sfc_staticRenderFns = [];
13946
- var __component__ = /*#__PURE__*/normalizeComponent(_sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, "1c8b3f68", null, null);
13971
+ var __component__ = /*#__PURE__*/normalizeComponent(_sfc_main, _sfc_render, _sfc_staticRenderFns, false, null, "44f025cd", null, null);
13947
13972
  var component = __component__.exports;
13948
13973
 
13949
13974
  // Import vue component