Allow posting announcements with other metadata
This commit is contained in:
parent
db5c0c3502
commit
56e6d86f88
|
@ -1,14 +1,19 @@
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import Announcement from '../announcement/announcement.vue'
|
import Announcement from '../announcement/announcement.vue'
|
||||||
|
import Checkbox from '../checkbox/checkbox.vue'
|
||||||
|
|
||||||
const AnnouncementsPage = {
|
const AnnouncementsPage = {
|
||||||
components: {
|
components: {
|
||||||
Announcement
|
Announcement,
|
||||||
|
Checkbox
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
newAnnouncement: {
|
newAnnouncement: {
|
||||||
content: ''
|
content: '',
|
||||||
|
startsAt: undefined,
|
||||||
|
endsAt: undefined,
|
||||||
|
allDay: false
|
||||||
},
|
},
|
||||||
posting: false,
|
posting: false,
|
||||||
error: undefined
|
error: undefined
|
||||||
|
@ -29,6 +34,11 @@ const AnnouncementsPage = {
|
||||||
postAnnouncement () {
|
postAnnouncement () {
|
||||||
this.posting = true
|
this.posting = true
|
||||||
this.$store.dispatch('postAnnouncement', this.newAnnouncement)
|
this.$store.dispatch('postAnnouncement', this.newAnnouncement)
|
||||||
|
.then(() => {
|
||||||
|
this.newAnnouncement.content = ''
|
||||||
|
this.startsAt = undefined
|
||||||
|
this.endsAt = undefined
|
||||||
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
this.error = error.error
|
this.error = error.error
|
||||||
})
|
})
|
||||||
|
|
|
@ -23,6 +23,29 @@
|
||||||
:placeholder="$t('announcements.post_placeholder')"
|
:placeholder="$t('announcements.post_placeholder')"
|
||||||
:disabled="posting"
|
:disabled="posting"
|
||||||
/>
|
/>
|
||||||
|
<span class="announcement-metadata">
|
||||||
|
<label for="announcement-start-time">{{ $t('announcements.start_time_prompt') }}</label>
|
||||||
|
<input
|
||||||
|
id="announcement-start-time"
|
||||||
|
v-model="newAnnouncement.startsAt"
|
||||||
|
:type="newAnnouncement.allDay ? 'date' : 'datetime-local'"
|
||||||
|
>
|
||||||
|
</span>
|
||||||
|
<span class="announcement-metadata">
|
||||||
|
<label for="announcement-end-time">{{ $t('announcements.end_time_prompt') }}</label>
|
||||||
|
<input
|
||||||
|
id="announcement-end-time"
|
||||||
|
v-model="newAnnouncement.endsAt"
|
||||||
|
:type="newAnnouncement.allDay ? 'date' : 'datetime-local'"
|
||||||
|
>
|
||||||
|
</span>
|
||||||
|
<span class="announcement-metadata">
|
||||||
|
<Checkbox
|
||||||
|
id="announcement-all-day"
|
||||||
|
v-model="newAnnouncement.allDay"
|
||||||
|
/>
|
||||||
|
<label for="announcement-all-day">{{ $t('announcements.all_day_prompt') }}</label>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<button
|
<button
|
||||||
|
@ -80,6 +103,9 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
.announcement-metadata {
|
||||||
|
margin-top: 0.5em;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.post-textarea {
|
.post-textarea {
|
||||||
|
|
|
@ -1381,11 +1381,11 @@ const postAnnouncement = ({ credentials, content, startsAt, endsAt, allDay }) =>
|
||||||
const payload = { content }
|
const payload = { content }
|
||||||
|
|
||||||
if (typeof startsAt !== 'undefined') {
|
if (typeof startsAt !== 'undefined') {
|
||||||
payload['starts_at'] = startsAt
|
payload['starts_at'] = new Date(startsAt).toISOString()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof endsAt !== 'undefined') {
|
if (typeof endsAt !== 'undefined') {
|
||||||
payload['ends_at'] = endsAt
|
payload['ends_at'] = new Date(endsAt).toISOString()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof allDay !== 'undefined') {
|
if (typeof allDay !== 'undefined') {
|
||||||
|
|
Loading…
Reference in a new issue