logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

announcements_page.js (1395B)


  1. import { mapState } from 'vuex'
  2. import Announcement from '../announcement/announcement.vue'
  3. import AnnouncementEditor from '../announcement_editor/announcement_editor.vue'
  4. const AnnouncementsPage = {
  5. components: {
  6. Announcement,
  7. AnnouncementEditor
  8. },
  9. data () {
  10. return {
  11. newAnnouncement: {
  12. content: '',
  13. startsAt: undefined,
  14. endsAt: undefined,
  15. allDay: false
  16. },
  17. posting: false,
  18. error: undefined
  19. }
  20. },
  21. mounted () {
  22. this.$store.dispatch('fetchAnnouncements')
  23. },
  24. computed: {
  25. ...mapState({
  26. currentUser: state => state.users.currentUser
  27. }),
  28. announcements () {
  29. return this.$store.state.announcements.announcements
  30. },
  31. canPostAnnouncement () {
  32. return this.currentUser && this.currentUser.privileges.includes('announcements_manage_announcements')
  33. }
  34. },
  35. methods: {
  36. postAnnouncement () {
  37. this.posting = true
  38. this.$store.dispatch('postAnnouncement', this.newAnnouncement)
  39. .then(() => {
  40. this.newAnnouncement.content = ''
  41. this.startsAt = undefined
  42. this.endsAt = undefined
  43. })
  44. .catch(error => {
  45. this.error = error.error
  46. })
  47. .finally(() => {
  48. this.posting = false
  49. })
  50. },
  51. clearError () {
  52. this.error = undefined
  53. }
  54. }
  55. }
  56. export default AnnouncementsPage