Skip to content

Commit

Permalink
feat: Add announcement start and end dates
Browse files Browse the repository at this point in the history
  • Loading branch information
w940853815 committed Sep 6, 2024
1 parent 40bb841 commit 896b056
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions src/components/Widgets/Announcement/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,29 @@ export default {
]),
announcement() {
const ann = this.publicSettings.ANNOUNCEMENT
return { id: ann['ID'], subject: ann['SUBJECT'], content: ann['CONTENT'], link: ann['LINK'] }
return {
id: ann['ID'],
subject: ann['SUBJECT'],
content: ann['CONTENT'],
link: ann['LINK'],
date_start: ann['DATE_START'],
date_end: ann['DATE_END']
}
},
enabled() {
return this.publicSettings.ANNOUNCEMENT_ENABLED && (this.announcement.content || this.announcement.subject)
return this.publicSettings.ANNOUNCEMENT_ENABLED && (this.announcement.content || this.announcement.subject) && this.isDateValid
},
title() {
return this.$t('Announcement') + ': ' + this.announcement.subject
},
isDateValid() {
if (this.announcement.date_start === undefined || this.announcement.date_end === undefined) {
return true
}
const now = new Date()
const start = new Date(this.announcement.date_start)
const end = new Date(this.announcement.date_end)
return now >= start && now <= end
}
},
methods: {
Expand Down
2 changes: 1 addition & 1 deletion src/views/settings/Feature/Announcement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default {
fieldsMeta: {
ANNOUNCEMENT: {
fields: [
'SUBJECT', 'CONTENT', 'LINK'
'SUBJECT', 'CONTENT', 'DATE_START', 'DATE_END', 'LINK'
],
fieldsMeta: {
CONTENT: {
Expand Down

0 comments on commit 896b056

Please sign in to comment.