logo

pleroma-fe

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

announcements_page.js (1454B)


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