vue-laravel-crud 1.6.6 → 1.6.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-laravel-crud",
3
- "version": "1.6.6",
3
+ "version": "1.6.8",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/clonixdev/vue-laravel-crud",
6
6
  "main": "dist/vue-laravel-crud.ssr.js",
@@ -343,6 +343,12 @@ export default /*#__PURE__*/ {
343
343
  type: String,
344
344
  default: "id",
345
345
  },
346
+
347
+ bulkDelete: {
348
+ type: Boolean,
349
+ default: false,
350
+ },
351
+
346
352
  },
347
353
 
348
354
  mounted() {
@@ -852,6 +858,78 @@ export default /*#__PURE__*/ {
852
858
  this.loading = false;
853
859
  });
854
860
  },
861
+
862
+ confirmBulkDelete(){
863
+ this.$bvModal
864
+ .msgBoxConfirm(this.messageRemoveConfirm, {
865
+ size: "sm",
866
+ buttonSize: "sm",
867
+ okVariant: "danger",
868
+ okTitle: this.messageRemove,
869
+ cancelTitle: "NO",
870
+ centered: true,
871
+ })
872
+ .then((value) => {
873
+ if (value) {
874
+ this.deleteItemBulk();
875
+ }
876
+ })
877
+ .catch((error) => {
878
+ this.toastError(error);
879
+ this.loading = false;
880
+ });
881
+ },
882
+ deleteItemBulk(){
883
+ if (this.useVuexORM) {
884
+ return this.deleteItemBulkVuex();
885
+ }
886
+
887
+ if (!this.ajax) {
888
+ return this.deleteItemBulkLocal();
889
+ }
890
+
891
+
892
+ let ids = this.selectedItems.map(it => it.id);
893
+
894
+ this.loading = true;
895
+ axios
896
+ .delete(this.apiUrl + "/" + this.modelName + "/bulk-destroy", {ids: ids} )
897
+ .then((response) => {
898
+ this.items = this.items.filter(it => ids.includes(it.id));
899
+ this.toastSuccess("Elemento/s eliminado.");
900
+ this.$emit("itemDeleted", {});
901
+ this.loading = false;
902
+ })
903
+ .catch((error) => {
904
+ this.toastError(error);
905
+ this.loading = false;
906
+ });
907
+ },
908
+ async deleteItemBulkLocal() {
909
+ let ids = this.selectedItems.map(it => it.id);
910
+ this.items = this.items.filter(it => ids.includes(it.id));
911
+ this.item = null;
912
+ this.toastSuccess("Elemento Eliminado");
913
+ this.$emit("itemDeleted", {});
914
+ this.loading = false;
915
+ },
916
+ async deleteItemBulkVuex() {
917
+ /*
918
+ let result = await this.model.api().delete('/' + id, {
919
+ delete: 1
920
+ });
921
+
922
+ console.debug("delete item vuex", result);
923
+ let responseStatus = result.response.status;
924
+
925
+ if (result.response.data.error) {
926
+ this.toastError(result.response.data.error);
927
+ this.loading = false;
928
+ return;
929
+ }
930
+
931
+ this.toastSuccess("Elemento eliminado.");*/
932
+ },
855
933
  deleteItem(id, index) {
856
934
 
857
935
  if (this.useVuexORM) {
@@ -1385,11 +1463,12 @@ export default /*#__PURE__*/ {
1385
1463
  <slot name="tableActions" v-bind:createItem="createItem" v-bind:toggleDisplayMode="toggleDisplayMode"
1386
1464
  v-bind:loading="loading">
1387
1465
  <slot name="tableActionsPrepend" v-bind:loading="loading"> </slot>
1466
+
1388
1467
  <b-button variant="info" v-if="showPrincipalSortBtn" @click="togglePrincipalSort()" :disabled="loading">
1389
1468
  <b-icon-sort-numeric-down v-if="principalSort"></b-icon-sort-numeric-down>
1390
1469
  <b-icon-sort-numeric-up v-else></b-icon-sort-numeric-up>
1391
1470
  </b-button>
1392
-
1471
+ <b-button variant="danger" @click="confirmBulkDelete()" v-if="bulkDelete"><b-icon-trash></b-icon-trash></b-button>
1393
1472
  <b-button variant="success" v-if="showCreateBtn" @click="createItem()" :disabled="loading">
1394
1473
  <b-icon-plus></b-icon-plus>{{ messageNew }}
1395
1474
  </b-button>