Commit 7d2cd24624a31299647d90753bd452d8fee1f0e1

Authored by Neeraj Sharma
1 parent 610e873a0e

fixed bugs

Showing 1 changed file with 26 additions and 20 deletions   Show diff stats
src/pages/Course/courseDetail.vue
... ... @@ -441,7 +441,7 @@
441 441 </td>
442 442 </tr>
443 443 </template>
444   - <template slot="expand" slot-scope="props">
  444 + <template slot="expand">
445 445 <v-data-table :items="chapters" hide-actions item-key="chapterName" style="width: auto;">
446 446 <template slot="items" slot-scope="props">
447 447 <tr class="tr" @click="props.expanded = !props.expanded">
... ... @@ -708,6 +708,7 @@ export default {
708 708 editChapter: {},
709 709 index: "",
710 710 addChapterItem: {},
  711 + addChapterItemObj: {},
711 712 addChapterDialog: false
712 713 }),
713 714 methods: {
... ... @@ -722,7 +723,7 @@ export default {
722 723 .then(response => {
723 724 this.editChapter.courseId = "";
724 725 this.courseData = response.data.data;
725   - console.log("this.courseData", this.courseData);
  726 + // console.log("this.courseData", this.courseData);
726 727 this.showLoader = false;
727 728 })
728 729 .catch(err => {
... ... @@ -740,7 +741,9 @@ export default {
740 741 })
741 742 .then(response => {
742 743 this.CourseDetailsList = response.data.data;
743   - this.chapters = response.data.data[0].chapters;
  744 + if (response.data.data[0]) {
  745 + this.chapters = response.data.data[0].chapters;
  746 + }
744 747 // console.log("response.data.data", this.CourseDetailsList);
745 748 this.showLoader = false;
746 749 })
... ... @@ -759,12 +762,10 @@ export default {
759 762 this.courseId = id;
760 763 },
761 764 addChapters(item) {
762   - this.files = [];
763 765 this.editedIndex = this.CourseDetailsList.indexOf(item);
764   - let addChapterItem = Object.assign({}, item);
765   - this.addChapterItem.courseDetailId = addChapterItem._id;
  766 + this.addChapterItemObj = Object.assign({}, item);
  767 + this.addChapterItem.courseDetailId = this.addChapterItemObj._id;
766 768 this.addChapterDialog = true;
767   - console.log("this.addChapterItem", this.addChapterItem);
768 769 },
769 770 submitChapter() {
770 771 this.addChapterItem.chapterPoints = [];
... ... @@ -781,9 +782,9 @@ export default {
781 782 this.snackbar = true;
782 783 this.text = response.data.message;
783 784 this.color = "green";
  785 + this.addChapterItem = {};
  786 + this.removeChapterPoint();
784 787 this.getCourseDetailsList();
785   - this.clear();
786   - this.findsChapterPoint = "";
787 788 })
788 789 .catch(error => {
789 790 this.snackbar = true;
... ... @@ -800,13 +801,11 @@ export default {
800 801 editItem(item) {
801 802 this.editedIndex = this.CourseDetailsList.indexOf(item);
802 803 this.editedCourse = Object.assign({}, item);
803   - console.log("this.editChapter", this.editedCourse);
804 804 this.editCourseDetailDialog = true;
805 805 },
806 806 editChapterItem(item) {
807 807 this.editedIndex = this.chapters.indexOf(item);
808 808 this.editChapter = Object.assign({}, item);
809   - // console.log("this.editChapter", this.editChapter);
810 809 this.editChapterDetailDialog = true;
811 810 },
812 811 deleteItem(item) {
... ... @@ -897,7 +896,7 @@ export default {
897 896 this.text = response.data.message;
898 897 this.color = "green";
899 898 this.clear();
900   - this.files = "";
  899 + this.removeAddFind();
901 900 })
902 901 .catch(error => {
903 902 this.snackbar = true;
... ... @@ -909,32 +908,36 @@ export default {
909 908 },
910 909 clear() {
911 910 this.$refs.form.reset();
912   - this.files = [];
913 911 },
914 912 saveChapter() {
915 913 this.editedItem.courseDetailId = this.editedItem._id;
  914 + console.log("this.updates", this.updates);
916 915 for (let i = 0; i < this.updates.length; i++) {
917   - this.editChapter.chapterPoints.push(this.updates[i].value);
  916 + if (this.updates[i].value != "") {
  917 + var chapterPoints = [];
  918 + chapterPoints.push(this.updates[i].value);
  919 + } else {
  920 + chapterPoints = this.editChapter.chapterPoints;
  921 + }
918 922 }
919 923 var updateData = {
920 924 courseDetailId: this.courseId,
921 925 chapterId: this.editChapter._id,
922 926 chapterName: this.editChapter.chapterName,
923 927 description: this.editChapter.description,
924   - chapterPoints: this.editChapter.chapterPoints
  928 + chapterPoints: chapterPoints
925 929 };
926 930 this.editLoading = true;
927 931 http()
928 932 .put("/updateChapters", updateData)
929 933 .then(response => {
930   - this.getCourseDetailsList();
931   - this.close();
  934 + this.editChapterDetailDialog = false;
932 935 this.snackbar = true;
933 936 this.text = response.data.message;
934 937 this.color = "green";
935 938 this.editLoading = false;
936   - // this.editChapterPointName = "";
937   - this.editFiles = [];
  939 + this.removeUpdatePoints();
  940 + this.getCourseDetailsList();
938 941 })
939 942 .catch(error => {
940 943 this.editLoading = false;
... ... @@ -993,11 +996,14 @@ export default {
993 996 },
994 997 addChapterPoint: function() {
995 998 this.findsChapterPoint.push({ value: "" });
  999 + console.log("this.findsChapterPoint", this.findsChapterPoint);
996 1000 },
997 1001 update: function() {
998   - console.log("click");
999 1002 this.updates.push({ value: "" });
1000 1003 },
  1004 + removeUpdatePoints: function() {
  1005 + this.updates = [{ value: "" }];
  1006 + },
1001 1007 deleteFind: function(index) {
1002 1008 this.finds.splice(index, 1);
1003 1009 if (index === 0) this.addFind();
... ...