Make API requests to edit note

This commit is contained in:
Tusooa Zhu 2022-08-20 13:18:57 -04:00 committed by tusooa
commit 9f51517ecd
No known key found for this signature in database
GPG key ID: 7B467EDE43A08224
4 changed files with 39 additions and 4 deletions

View file

@ -6,7 +6,8 @@ const UserNote = {
data () {
return {
localNote: '',
editing: false
editing: false,
frozen: false
}
},
computed: {
@ -23,7 +24,19 @@ const UserNote = {
this.editing = false
},
finalizeEditing () {
this.editing = false
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
})
}
}
}

View file

@ -15,6 +15,7 @@
<button
v-show="editing"
class="button-default btn"
:disabled="frozen"
@click="finalizeEditing"
>
{{ $t('user_card.edit_note_apply') }}
@ -22,6 +23,7 @@
<button
v-show="editing"
class="button-default btn"
:disabled="frozen"
@click="cancelEditing"
>
{{ $t('user_card.edit_note_cancel') }}
@ -30,9 +32,8 @@
</div>
<input
v-show="editing"
v-model="localNote"
class="note-text"
type="string"
:model="localNote"
>
<span
v-show="!editing"