mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Rewrote the PostHelpers and put them in a utils folder
This commit is contained in:
parent
482ac1572b
commit
45bd1299ce
@ -70,7 +70,7 @@ import HcCategory from '~/components/Category'
|
|||||||
import HcRibbon from '~/components/Ribbon'
|
import HcRibbon from '~/components/Ribbon'
|
||||||
// import { randomBytes } from 'crypto'
|
// import { randomBytes } from 'crypto'
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
import { postMenuModalsData, deletePostMutationData } from '~/components/utils/PostHelpers'
|
import { postMenuModalsData, deletePostMutation } from '~/components/utils/PostHelpers'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'HcPostCard',
|
name: 'HcPostCard',
|
||||||
@ -113,7 +113,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
async deletePostCallback() {
|
async deletePostCallback() {
|
||||||
try {
|
try {
|
||||||
await this.$apollo.mutate(deletePostMutationData(this.post.id))
|
await this.$apollo.mutate(deletePostMutation(this.post.id))
|
||||||
this.$toast.success(this.$t('delete.contribution.success'))
|
this.$toast.success(this.$t('delete.contribution.success'))
|
||||||
this.$emit('removePostFromList')
|
this.$emit('removePostFromList')
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import gql from 'graphql-tag'
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
export default {
|
export function postMenuModalsData(truncatedPostName, confirmCallback, cancelCallback = () => {}) {
|
||||||
postMenuModalsData(truncatedPostName, confirmCallback, cancelCallback = () => {}) {
|
|
||||||
return {
|
return {
|
||||||
delete: {
|
delete: {
|
||||||
titleIdent: 'delete.contribution.title',
|
titleIdent: 'delete.contribution.title',
|
||||||
@ -24,8 +23,10 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
deletePostMutationData(postId) {
|
|
||||||
|
export function deletePostMutation(postId) {
|
||||||
|
// TODO: Replace "gqlMutation" with "DeletePost" from '~/graphql/PostMutations.js', has not worked for me.
|
||||||
var gqlMutation = gql`
|
var gqlMutation = gql`
|
||||||
mutation($id: ID!) {
|
mutation($id: ID!) {
|
||||||
DeletePost(id: $id) {
|
DeletePost(id: $id) {
|
||||||
@ -39,5 +40,4 @@ export default {
|
|||||||
id: postId,
|
id: postId,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import gql from 'graphql-tag'
|
|||||||
|
|
||||||
export default app => {
|
export default app => {
|
||||||
return {
|
return {
|
||||||
CreatePost: gql(`
|
CreatePost: gql`
|
||||||
mutation($title: String!, $content: String!) {
|
mutation($title: String!, $content: String!) {
|
||||||
CreatePost(title: $title, content: $content) {
|
CreatePost(title: $title, content: $content) {
|
||||||
id
|
id
|
||||||
@ -12,8 +12,8 @@ export default app => {
|
|||||||
contentExcerpt
|
contentExcerpt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`),
|
`,
|
||||||
UpdatePost: gql(`
|
UpdatePost: gql`
|
||||||
mutation($id: ID!, $title: String!, $content: String!) {
|
mutation($id: ID!, $title: String!, $content: String!) {
|
||||||
UpdatePost(id: $id, title: $title, content: $content) {
|
UpdatePost(id: $id, title: $title, content: $content) {
|
||||||
id
|
id
|
||||||
@ -23,6 +23,13 @@ export default app => {
|
|||||||
contentExcerpt
|
contentExcerpt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`),
|
`,
|
||||||
|
DeletePost: gql`
|
||||||
|
mutation($id: ID!) {
|
||||||
|
DeletePost(id: $id) {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,7 +71,7 @@ import HcUser from '~/components/User'
|
|||||||
import HcShoutButton from '~/components/ShoutButton.vue'
|
import HcShoutButton from '~/components/ShoutButton.vue'
|
||||||
import HcCommentForm from '~/components/comments/CommentForm'
|
import HcCommentForm from '~/components/comments/CommentForm'
|
||||||
import HcCommentList from '~/components/comments/CommentList'
|
import HcCommentList from '~/components/comments/CommentList'
|
||||||
import { postMenuModalsData, deletePostMutationData } from '~/components/utils/PostHelpers'
|
import { postMenuModalsData, deletePostMutation } from '~/components/utils/PostHelpers'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'PostSlug',
|
name: 'PostSlug',
|
||||||
@ -224,7 +224,7 @@ export default {
|
|||||||
},
|
},
|
||||||
async deletePostCallback() {
|
async deletePostCallback() {
|
||||||
try {
|
try {
|
||||||
await this.$apollo.mutate(deletePostMutationData(this.post.id))
|
await this.$apollo.mutate(deletePostMutation(this.post.id))
|
||||||
this.$toast.success(this.$t('delete.contribution.success'))
|
this.$toast.success(this.$t('delete.contribution.success'))
|
||||||
this.$router.history.push('/') // Redirect to index (main) page
|
this.$router.history.push('/') // Redirect to index (main) page
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user