diff --git a/src/pages/Subjects/subjects.vue b/src/pages/Subjects/subjects.vue index c98f210..4708db1 100644 --- a/src/pages/Subjects/subjects.vue +++ b/src/pages/Subjects/subjects.vue @@ -39,44 +39,46 @@ - - - + + + + + + + + + + + + + + + + + + + + Cancel + + Save + - - - - - - - - - - - - - - - Cancel - - Save - - + @@ -291,11 +293,13 @@ export default { color: "", showLoader: false, loading: false, + editLoading: false, date: null, search: "", dialog: false, dialog1: false, valid: true, + validEditSubject: true, isActive: true, newActive: false, gender: ["Male", "Female"], @@ -304,6 +308,7 @@ export default { }, token: "", nameRules: [v => !!v || " Class Name is required"], + nameEditSubjectRules: [v => !!v || " Class Name is required"], subjectRules: [v => !!v || " Subject Name is required"], headers: [ { @@ -336,6 +341,7 @@ export default { }, editItem(item) { + console.log("item", item); this.editedItem = Object.assign({}, item); this.dialog = true; }, @@ -379,10 +385,6 @@ export default { }, close() { this.dialog = false; - setTimeout(() => { - this.editedItem = Object.assign({}, this.defaultItem); - this.editedIndex = -1; - }, 300); }, close1() { this.dialog1 = false; @@ -410,42 +412,45 @@ export default { this.$refs.form.reset(); }, save() { - let editSubject = { - classId: this.addSubject.selectName, - subjectId: this.editedItem._id, - subjectName: this.editedItem.subjectName - }; - http() - .put("/updateSubject", editSubject) - .then(response => { - // console.log("editEvent",editEvent); - if ((this.snackbar = true)) { + if (this.$refs.formEditSubject.validate()) { + let editSubject = { + classId: this.addSubject.selectName, + subjectId: this.editedItem._id, + subjectName: this.editedItem.subjectName + }; + this.editLoading = true; + http() + .put("/updateSubject", editSubject) + .then(response => { + this.snackbar = true; this.text = "Successfully Edit Existing Subject"; - } - // this.getClassSubject(); - http() - .get( - "/getParticularClass", - { params: { classId: this.selectClassId } }, - { - headers: { Authorization: "Bearer " + this.token } - } - ) - .then(response => { - this.subjectList = response.data.data; - this.getClassSubject(); - this.snackbar = true; - this.color = "green"; - this.text = response.data.message; - }) - .catch(err => { - console.log("err====>", err); - }); - }) - .catch(error => { - // console.log(error); - }); - this.close(); + this.editLoading = false; + http() + .get( + "/getParticularClass", + { params: { classId: this.selectClassId } }, + { + headers: { Authorization: "Bearer " + this.token } + } + ) + .then(response => { + this.subjectList = response.data.data; + this.getClassSubject(); + this.snackbar = true; + this.color = "green"; + this.text = response.data.message; + this.close(); + }) + .catch(err => { + console.log("err====>", err); + }); + }) + .catch(error => { + this.editLoading = false; + + // console.log(error); + }); + } }, getClassSubject() { this.selectClassId = this.selectClassId;