yandere_fe/src/components/user_note/user_note.js

45 lines
803 B
JavaScript
Raw Normal View History

2022-08-20 13:02:27 -04:00
const UserNote = {
props: {
user: Object,
relationship: Object
},
data () {
return {
localNote: '',
2022-08-20 13:18:57 -04:00
editing: false,
frozen: false
2022-08-20 13:02:27 -04:00
}
},
computed: {
shouldShow () {
return this.relationship.note || this.editing
}
},
methods: {
startEditing () {
this.localNote = this.relationship.note
this.editing = true
},
cancelEditing () {
this.editing = false
},
finalizeEditing () {
2022-08-20 13:18:57 -04:00
this.frozen = true
this.$store.dispatch('editUserNote', {
id: this.user.id,
comment: this.localNote
})
.then(() => {
this.frozen = false
this.editing = false
})
.catch(() => {
this.frozen = false
})
2022-08-20 13:02:27 -04:00
}
}
}
export default UserNote