From 89c49b6fb46e607aee07afd5bc436e8f2f605bfe Mon Sep 17 00:00:00 2001 From: Tusooa Zhu Date: Thu, 17 Mar 2022 17:11:53 -0400 Subject: [PATCH] Allow editing announcements --- src/components/announcement/announcement.js | 31 +++++++++++- src/components/announcement/announcement.vue | 50 ++++++++++++++++++- .../announcement_editor.vue | 24 ++++++--- .../announcements_page/announcements_page.vue | 7 --- src/modules/announcements.js | 6 +++ src/services/api/api.service.js | 23 +++++++-- 6 files changed, 118 insertions(+), 23 deletions(-) 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 @@ />