Allow editing announcements
This commit is contained in:
parent
0e51e824a2
commit
89c49b6fb4
6 changed files with 118 additions and 23 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue