Commit a43d2364 authored by TTS Kieu Tuan Anh's avatar TTS Kieu Tuan Anh

posts

parent 038b61a2
...@@ -301,12 +301,11 @@ export default { ...@@ -301,12 +301,11 @@ export default {
message: [], message: [],
editedIndex: -1, editedIndex: -1,
editedItem: { editedItem: {
name: "", title: "",
id: "", category_id: "",
ordering: "", content: "",
user_id: "",
status: "", status: "",
created_at: "",
updated_at: "",
}, },
defaultItem: { defaultItem: {
name: "", name: "",
...@@ -425,7 +424,10 @@ export default { ...@@ -425,7 +424,10 @@ export default {
this.$bvModal.hide("modal-create"); this.$bvModal.hide("modal-create");
self.$toast.success("Post created successfully!", { self.$toast.success("Post created successfully!", {
duration: 3000, duration: 3000,
}); })
this.editedItem = response.data.data
console.log(this.editedItem)
this.posts.push(this.editedItem)
}) })
.catch((errors) => { .catch((errors) => {
this.$bvModal.hide("modal-create"); this.$bvModal.hide("modal-create");
...@@ -487,7 +489,7 @@ export default { ...@@ -487,7 +489,7 @@ export default {
this.eContent = item.content; this.eContent = item.content;
this.eStatus = item.status; this.eStatus = item.status;
this.eUserId = item.user_id; this.eUserId = item.user_id;
// this.eImages = item.images this.editedIndex = this.posts.indexOf(item)
}, },
updatePost() { updatePost() {
const self = this; const self = this;
...@@ -514,7 +516,10 @@ export default { ...@@ -514,7 +516,10 @@ export default {
self.$toast.success("Post updated successfully!", { self.$toast.success("Post updated successfully!", {
duration: 3000, duration: 3000,
}); });
console.log(response); console.log(response)
this.editedItem = response.data.data
this.$bvModal.hide('modal-edit')
Object.assign(this.posts[this.editedIndex], this.editedItem)
}) })
.catch((error) => { .catch((error) => {
console.log(error); console.log(error);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment