logo

pleroma-fe

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

bookmark_folder_edit.js (2199B)


  1. import EmojiPicker from '../emoji_picker/emoji_picker.vue'
  2. import apiService from '../../services/api/api.service'
  3. const BookmarkFolderEdit = {
  4. data () {
  5. return {
  6. name: '',
  7. nameDraft: '',
  8. emoji: '',
  9. emojiUrl: null,
  10. emojiDraft: '',
  11. emojiUrlDraft: null,
  12. emojiPickerExpanded: false,
  13. reallyDelete: false
  14. }
  15. },
  16. components: {
  17. EmojiPicker
  18. },
  19. created () {
  20. if (!this.id) return
  21. const credentials = this.$store.state.users.currentUser.credentials
  22. apiService.fetchBookmarkFolders({ credentials })
  23. .then((folders) => {
  24. const folder = folders.find(folder => folder.id === this.id)
  25. if (!folder) return
  26. this.nameDraft = this.name = folder.name
  27. this.emojiDraft = this.emoji = folder.emoji
  28. this.emojiUrlDraft = this.emojiUrl = folder.emoji_url
  29. })
  30. },
  31. computed: {
  32. id () {
  33. return this.$route.params.id
  34. }
  35. },
  36. methods: {
  37. selectEmoji (event) {
  38. this.emojiDraft = event.insertion
  39. this.emojiUrlDraft = event.insertionUrl
  40. },
  41. showEmojiPicker () {
  42. if (!this.emojiPickerExpanded) {
  43. this.$refs.picker.showPicker()
  44. }
  45. },
  46. onShowPicker () {
  47. this.emojiPickerExpanded = true
  48. },
  49. onClosePicker () {
  50. this.emojiPickerExpanded = false
  51. },
  52. updateFolder () {
  53. this.$store.dispatch('setBookmarkFolder', { folderId: this.id, name: this.nameDraft, emoji: this.emojiDraft })
  54. .then(() => {
  55. this.$router.push({ name: 'bookmark-folders' })
  56. })
  57. },
  58. createFolder () {
  59. this.$store.dispatch('createBookmarkFolder', { name: this.nameDraft, emoji: this.emojiDraft })
  60. .then(() => {
  61. this.$router.push({ name: 'bookmark-folders' })
  62. })
  63. .catch((e) => {
  64. this.$store.dispatch('pushGlobalNotice', {
  65. messageKey: 'bookmark_folders.error',
  66. messageArgs: [e.message],
  67. level: 'error'
  68. })
  69. })
  70. },
  71. deleteFolder () {
  72. this.$store.dispatch('deleteBookmarkFolder', { folderId: this.id })
  73. this.$router.push({ name: 'bookmark-folders' })
  74. }
  75. }
  76. }
  77. export default BookmarkFolderEdit