vue-laravel-crud 1.3.15 → 1.3.17
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 +75 -90
- package/dist/vue-laravel-crud.min.js +2 -2
- package/dist/vue-laravel-crud.ssr.js +113 -106
- package/package.json +1 -1
- package/src/vue-laravel-crud.vue +81 -76
package/src/vue-laravel-crud.vue
CHANGED
|
@@ -100,6 +100,10 @@ export default /*#__PURE__*/ {
|
|
|
100
100
|
type: String,
|
|
101
101
|
default: "",
|
|
102
102
|
},
|
|
103
|
+
hideModalAfterSave: {
|
|
104
|
+
type: Boolean,
|
|
105
|
+
default: true,
|
|
106
|
+
},
|
|
103
107
|
refreshAfterSave: {
|
|
104
108
|
type: Boolean,
|
|
105
109
|
default: true,
|
|
@@ -448,6 +452,7 @@ export default /*#__PURE__*/ {
|
|
|
448
452
|
},
|
|
449
453
|
|
|
450
454
|
refresh() {
|
|
455
|
+
this.$emit("refresh", {});
|
|
451
456
|
this.fetchItems();
|
|
452
457
|
},
|
|
453
458
|
isColumnHasFilter(column) {
|
|
@@ -462,7 +467,7 @@ export default /*#__PURE__*/ {
|
|
|
462
467
|
}, 1);
|
|
463
468
|
},
|
|
464
469
|
fetchItems(page = 1) {
|
|
465
|
-
|
|
470
|
+
|
|
466
471
|
this.loading = true;
|
|
467
472
|
axios
|
|
468
473
|
.get(this.apiUrl + "/" + this.modelName, {
|
|
@@ -508,6 +513,7 @@ export default /*#__PURE__*/ {
|
|
|
508
513
|
}
|
|
509
514
|
|
|
510
515
|
this.loading = false;
|
|
516
|
+
this.$emit("afterFetch", {});
|
|
511
517
|
})
|
|
512
518
|
.catch((error) => {
|
|
513
519
|
//console.debug(error);
|
|
@@ -517,64 +523,59 @@ export default /*#__PURE__*/ {
|
|
|
517
523
|
},
|
|
518
524
|
|
|
519
525
|
removeItem: function (id, index) {
|
|
520
|
-
let _this = this;
|
|
521
|
-
|
|
522
526
|
this.$bvModal
|
|
523
|
-
.msgBoxConfirm(
|
|
527
|
+
.msgBoxConfirm(this.messageRemoveConfirm, {
|
|
524
528
|
size: "sm",
|
|
525
529
|
buttonSize: "sm",
|
|
526
530
|
okVariant: "danger",
|
|
527
|
-
okTitle:
|
|
531
|
+
okTitle: this.messageRemove,
|
|
528
532
|
cancelTitle: "NO",
|
|
529
533
|
centered: true,
|
|
530
534
|
})
|
|
531
535
|
.then((value) => {
|
|
532
536
|
if (value) {
|
|
533
|
-
|
|
537
|
+
this.loading = true;
|
|
534
538
|
axios
|
|
535
|
-
.delete(
|
|
536
|
-
.then(
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
539
|
+
.delete(this.apiUrl + "/" + this.modelName + "/" + id)
|
|
540
|
+
.then( (response) => {
|
|
541
|
+
this.items.splice(index, 1);
|
|
542
|
+
this.toastSuccess("Elemento eliminado.");
|
|
543
|
+
this.loading = false;
|
|
540
544
|
})
|
|
541
|
-
.catch(
|
|
542
|
-
|
|
543
|
-
|
|
545
|
+
.catch( (error) => {
|
|
546
|
+
this.toastError(error);
|
|
547
|
+
this.loading = false;
|
|
544
548
|
});
|
|
545
549
|
}
|
|
546
550
|
})
|
|
547
551
|
.catch((error) => {
|
|
548
|
-
|
|
549
|
-
|
|
552
|
+
this.toastError(error);
|
|
553
|
+
this.loading = false;
|
|
550
554
|
});
|
|
551
555
|
},
|
|
552
556
|
|
|
553
557
|
saveSort() {
|
|
554
558
|
if (this.orderable) {
|
|
555
|
-
|
|
556
|
-
_this.loading = true;
|
|
557
|
-
|
|
559
|
+
this.loading = true;
|
|
558
560
|
let order = [];
|
|
559
|
-
|
|
560
561
|
this.items.forEach((v, k) => {
|
|
561
562
|
order.push({ id: v.id, order: v[this.orderProp] });
|
|
562
563
|
});
|
|
563
564
|
|
|
564
565
|
axios
|
|
565
|
-
.post(this.apiUrl + "/" +
|
|
566
|
+
.post(this.apiUrl + "/" + this.modelName + "/sort", {
|
|
566
567
|
order: order,
|
|
567
568
|
})
|
|
568
|
-
.then(
|
|
569
|
+
.then( (response) => {
|
|
569
570
|
let data = response.data;
|
|
570
|
-
|
|
571
|
-
if (
|
|
572
|
-
|
|
571
|
+
this.toastSuccess("Orden Actualizado");
|
|
572
|
+
if (this.refreshAfterSave) this.refresh();
|
|
573
|
+
this.loading = false;
|
|
573
574
|
})
|
|
574
|
-
.catch(
|
|
575
|
+
.catch( (error) => {
|
|
575
576
|
//console.debug(error);
|
|
576
|
-
|
|
577
|
-
|
|
577
|
+
this.toastError(error);
|
|
578
|
+
this.loading = false;
|
|
578
579
|
});
|
|
579
580
|
}
|
|
580
581
|
},
|
|
@@ -616,8 +617,7 @@ export default /*#__PURE__*/ {
|
|
|
616
617
|
return ops.join(", ");
|
|
617
618
|
},
|
|
618
619
|
async saveItem(event = null) {
|
|
619
|
-
|
|
620
|
-
_this.loading = true;
|
|
620
|
+
this.loading = true;
|
|
621
621
|
|
|
622
622
|
if (this.validate) {
|
|
623
623
|
let validation_result = true;
|
|
@@ -634,90 +634,95 @@ export default /*#__PURE__*/ {
|
|
|
634
634
|
if (this.item.id) {
|
|
635
635
|
axios
|
|
636
636
|
.put(
|
|
637
|
-
this.apiUrl + "/" +
|
|
638
|
-
|
|
637
|
+
this.apiUrl + "/" + this.modelName + "/" + this.item.id,
|
|
638
|
+
this.item
|
|
639
639
|
)
|
|
640
|
-
.then(
|
|
641
|
-
|
|
640
|
+
.then((response) => {
|
|
641
|
+
if(this.hideModalAfterSave){
|
|
642
|
+
this.$bvModal.hide("modal-form-item-" + this.modelName);
|
|
643
|
+
}
|
|
644
|
+
|
|
642
645
|
let itemSv = response.data;
|
|
643
|
-
let itemIndex =
|
|
644
|
-
(item) => item.id ==
|
|
646
|
+
let itemIndex = this.items.findIndex(
|
|
647
|
+
(item) => item.id == this.item.id
|
|
645
648
|
);
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
if (
|
|
650
|
-
|
|
649
|
+
this.items[itemIndex] = itemSv;
|
|
650
|
+
this.item = itemSv;
|
|
651
|
+
this.loading = false;
|
|
652
|
+
if (this.refreshAfterSave) this.refresh();
|
|
653
|
+
this.toastSuccess("Elemento Modificado");
|
|
651
654
|
})
|
|
652
|
-
.catch(
|
|
653
|
-
|
|
654
|
-
|
|
655
|
+
.catch((error) => {
|
|
656
|
+
this.toastError(error);
|
|
657
|
+
this.loading = false;
|
|
655
658
|
});
|
|
656
659
|
} else {
|
|
657
660
|
if (this.createMultipart) {
|
|
658
661
|
const formData = new FormData();
|
|
659
662
|
|
|
660
|
-
Object.keys(
|
|
661
|
-
if (
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
let files = _this.item[key];
|
|
663
|
+
Object.keys(this.item).forEach((key) => {
|
|
664
|
+
if (this.item[key][0] && this.item[key][0].name) {
|
|
665
|
+
let files = this.item[key];
|
|
665
666
|
for (var x = 0; x < files.length; x++) {
|
|
666
667
|
formData.append(
|
|
667
668
|
key + "[]",
|
|
668
|
-
|
|
669
|
-
|
|
669
|
+
this.item[key][x],
|
|
670
|
+
this.item[key][x].name
|
|
670
671
|
);
|
|
671
672
|
}
|
|
672
|
-
} else formData.append(key,
|
|
673
|
+
} else formData.append(key, this.item[key]);
|
|
673
674
|
});
|
|
674
675
|
|
|
675
676
|
axios
|
|
676
|
-
.post(this.apiUrl + "/" +
|
|
677
|
-
.then(
|
|
678
|
-
|
|
679
|
-
|
|
677
|
+
.post(this.apiUrl + "/" + this.modelName, formData)
|
|
678
|
+
.then( (response) => {
|
|
679
|
+
this.loading = false;
|
|
680
|
+
if(this.hideModalAfterSave){
|
|
681
|
+
this.$bvModal.hide("modal-form-item-" + this.modelName);
|
|
682
|
+
}
|
|
680
683
|
if (response.data.success) {
|
|
681
684
|
if (response.data.message) {
|
|
682
|
-
|
|
685
|
+
this.toastSuccess(response.data.message);
|
|
683
686
|
}
|
|
684
687
|
return;
|
|
685
688
|
}
|
|
686
689
|
|
|
687
690
|
let itemSv = response.data;
|
|
688
691
|
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
if (
|
|
692
|
-
|
|
692
|
+
this.items.push(itemSv);
|
|
693
|
+
this.item = itemSv;
|
|
694
|
+
if (this.refreshAfterSave) this.refresh();
|
|
695
|
+
this.toastSuccess("Elemento Creado");
|
|
693
696
|
})
|
|
694
|
-
.catch(
|
|
695
|
-
|
|
696
|
-
|
|
697
|
+
.catch( (error) => {
|
|
698
|
+
this.toastError(error);
|
|
699
|
+
this.loading = false;
|
|
697
700
|
});
|
|
698
701
|
} else {
|
|
699
702
|
axios
|
|
700
|
-
.post(this.apiUrl + "/" +
|
|
701
|
-
.then(
|
|
702
|
-
|
|
703
|
-
|
|
703
|
+
.post(this.apiUrl + "/" + this.modelName, this.item)
|
|
704
|
+
.then( (response) => {
|
|
705
|
+
this.loading = false;
|
|
706
|
+
if(this.hideModalAfterSave){
|
|
707
|
+
this.$bvModal.hide("modal-form-item-" + this.modelName);
|
|
708
|
+
}
|
|
704
709
|
if (response.data.success) {
|
|
705
710
|
if (response.data.message) {
|
|
706
|
-
|
|
711
|
+
this.toastSuccess(response.data.message);
|
|
707
712
|
}
|
|
708
713
|
return;
|
|
709
714
|
}
|
|
710
715
|
|
|
711
716
|
let itemSv = response.data;
|
|
712
717
|
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
if (
|
|
716
|
-
|
|
718
|
+
this.items.push(itemSv);
|
|
719
|
+
this.item = itemSv;
|
|
720
|
+
if (this.refreshAfterSave) this.refresh();
|
|
721
|
+
this.toastSuccess("Elemento Creado");
|
|
717
722
|
})
|
|
718
|
-
.catch(
|
|
719
|
-
|
|
720
|
-
|
|
723
|
+
.catch( (error) => {
|
|
724
|
+
this.toastError(error);
|
|
725
|
+
this.loading = false;
|
|
721
726
|
});
|
|
722
727
|
}
|
|
723
728
|
}
|