diff --git a/src/components/announcement/announcement.js b/src/components/announcement/announcement.js index 309eecea75..253e2bb233 100644 --- a/src/components/announcement/announcement.js +++ b/src/components/announcement/announcement.js @@ -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 } } } diff --git a/src/components/announcement/announcement.vue b/src/components/announcement/announcement.vue index 5ddeebf586..1e4edcca52 100644 --- a/src/components/announcement/announcement.vue +++ b/src/components/announcement/announcement.vue @@ -16,7 +16,10 @@ />