aboutsummaryrefslogtreecommitdiff
path: root/src/components/announcement/announcement.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/announcement/announcement.js')
-rw-r--r--src/components/announcement/announcement.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/components/announcement/announcement.js b/src/components/announcement/announcement.js
index b1f5ee77..309eecea 100644
--- a/src/components/announcement/announcement.js
+++ b/src/components/announcement/announcement.js
@@ -1,6 +1,21 @@
import { mapState } from 'vuex'
+import AnnouncementEditor from '../announcement_editor/announcement_editor.vue'
+import localeService from '../../services/locale/locale.service.js'
const Announcement = {
+ components: {
+ AnnouncementEditor
+ },
+ data () {
+ return {
+ editing: false,
+ newAnnouncement: {
+ content: '',
+ startsAt: undefined,
+ endsAt: undefined
+ }
+ }
+ },
props: {
announcement: Object
},
@@ -13,6 +28,22 @@ const Announcement = {
},
isRead () {
return this.announcement.read
+ },
+ startsAt () {
+ const time = this.announcement['starts_at']
+ if (!time) {
+ return
+ }
+
+ return this.formatTimeOrDate(time, localeService.internalToBrowserLocale(this.$i18n.locale))
+ },
+ endsAt () {
+ const time = this.announcement['ends_at']
+ if (!time) {
+ return
+ }
+
+ return this.formatTimeOrDate(time, localeService.internalToBrowserLocale(this.$i18n.locale))
}
},
methods: {
@@ -23,6 +54,10 @@ const Announcement = {
},
deleteAnnouncement () {
return this.$store.dispatch('deleteAnnouncement', this.announcement.id)
+ },
+ formatTimeOrDate (time, locale) {
+ const d = new Date(time)
+ return this.announcement['all_day'] ? d.toLocaleDateString(locale) : d.toLocaleString(locale)
}
}
}