Allow editing announcements

This commit is contained in:
Tusooa Zhu 2022-03-17 17:11:53 -04:00 committed by tusooa
commit 89c49b6fb4
No known key found for this signature in database
GPG key ID: 7B467EDE43A08224
6 changed files with 118 additions and 23 deletions

View file

@ -12,8 +12,10 @@ const Announcement = {
newAnnouncement: {
content: '',
startsAt: undefined,
endsAt: undefined
}
endsAt: undefined,
allDay: undefined
},
editError: ''
}
},
props: {
@ -58,6 +60,31 @@ const Announcement = {
formatTimeOrDate (time, locale) {
const d = new Date(time)
return this.announcement['all_day'] ? d.toLocaleDateString(locale) : d.toLocaleString(locale)
},
enterEditMode () {
this.newAnnouncement.content = this.announcement.pleroma['raw_content']
this.newAnnouncement.startsAt = this.announcement['starts_at']
this.newAnnouncement.endsAt = this.announcement['ends_at']
this.newAnnouncement.allDay = this.announcement['all_day']
this.editing = true
},
submitEdit () {
this.$store.dispatch('editAnnouncement', {
id: this.announcement.id,
...this.newAnnouncement
})
.then(() => {
this.editing = false
})
.catch(error => {
this.editError = error.error
})
},
cancelEdit () {
this.editing = false
},
clearError () {
this.editError = undefined
}
}
}