mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2026-01-16 09:54:41 +00:00
prototype frontend
This commit is contained in:
parent
ed206f1bec
commit
de1d9a4544
@ -471,6 +471,9 @@ export default {
|
||||
})
|
||||
).records.map((r) => r.get('inviteCodes'))
|
||||
},
|
||||
currentlyPinnedPostsCount: async (parent, _args, context: Context, _resolveInfo) => {
|
||||
return 0
|
||||
},
|
||||
...Resolver('Group', {
|
||||
undefinedToNull: ['deleted', 'disabled', 'locationName', 'about'],
|
||||
hasMany: {
|
||||
|
||||
@ -48,6 +48,8 @@ type Group {
|
||||
|
||||
"inviteCodes to this group the current user has generated"
|
||||
inviteCodes: [InviteCode]! @neo4j_ignore
|
||||
|
||||
currentlyPinnedPostsCount: Int! @neo4j_ignore
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -434,7 +434,7 @@ export default shield(
|
||||
Room: isAuthenticated,
|
||||
Message: isAuthenticated,
|
||||
UnreadRooms: isAuthenticated,
|
||||
PostsPinnedCounts: isAdmin,
|
||||
PostsPinnedCounts: isAuthenticated,
|
||||
|
||||
// Invite Code
|
||||
validateInviteCode: allow,
|
||||
|
||||
@ -244,6 +244,27 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
console.log(this.resourceType, this.resource)
|
||||
if (
|
||||
this.resourceType === 'contribution' &&
|
||||
this.resource.group &&
|
||||
this.resource.group.myRole === 'owner' &&
|
||||
(this.canBeGroupPinned || this.resource.groupPinnedBy)
|
||||
) {
|
||||
routes.push({
|
||||
label: this.resource.groupPinnedBy
|
||||
? this.$t(`post.menu.groupUnpin`)
|
||||
: this.$t(`post.menu.groupPin`),
|
||||
callback: () => {
|
||||
this.$emit(
|
||||
this.resource.groupPinnedBy ? 'unpinGroupPost' : 'pinGroupPost',
|
||||
this.resource,
|
||||
)
|
||||
},
|
||||
icon: this.resource.groupPinnedBy ? 'unlink' : 'link',
|
||||
})
|
||||
}
|
||||
|
||||
return routes
|
||||
},
|
||||
isModerator() {
|
||||
@ -258,6 +279,14 @@ export default {
|
||||
(this.maxPinnedPosts > 1 && this.currentlyPinnedPosts < this.maxPinnedPosts)
|
||||
)
|
||||
},
|
||||
canBeGroupPinned() {
|
||||
return (
|
||||
this.maxPinnedPosts === 1 ||
|
||||
(this.maxPinnedPosts > 1 &&
|
||||
this.resource.group &&
|
||||
this.resource.group.currentlyPinnedPostsCount < this.maxPinnedPosts)
|
||||
)
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
openItem(route, toggleMenu) {
|
||||
|
||||
@ -112,6 +112,8 @@
|
||||
:is-owner="isAuthor"
|
||||
@pinPost="pinPost"
|
||||
@unpinPost="unpinPost"
|
||||
@pinGroupPost="pinGroupPost"
|
||||
@unpinGroupPost="unpinGroupPost"
|
||||
@pushPost="pushPost"
|
||||
@unpushPost="unpushPost"
|
||||
@toggleObservePost="toggleObservePost"
|
||||
@ -229,6 +231,12 @@ export default {
|
||||
unpinPost(post) {
|
||||
this.$emit('unpinPost', post)
|
||||
},
|
||||
pinGroupPost(post) {
|
||||
this.$emit('pinGroupPost', post)
|
||||
},
|
||||
unpinGroupPost(post) {
|
||||
this.$emit('unpinPost', post)
|
||||
},
|
||||
pushPost(post) {
|
||||
this.$emit('pushPost', post)
|
||||
},
|
||||
|
||||
@ -48,6 +48,8 @@
|
||||
@removePostFromList="posts = removePostFromList(post, posts)"
|
||||
@pinPost="pinPost(post, refetchPostList)"
|
||||
@unpinPost="unpinPost(post, refetchPostList)"
|
||||
@pinGroupPost="pinGroupPost(post, refetchPostList)"
|
||||
@unpinGroupPost="unpinGroupPost(post, refetchPostList)"
|
||||
@pushPost="pushPost(post, refetchPostList)"
|
||||
@unpushPost="unpushPost(post, refetchPostList)"
|
||||
@toggleObservePost="
|
||||
|
||||
@ -173,6 +173,40 @@ export default () => {
|
||||
}
|
||||
}
|
||||
`,
|
||||
pinGroupPost: gql`
|
||||
mutation ($id: ID!) {
|
||||
pinGroupPost(id: $id) {
|
||||
id
|
||||
title
|
||||
slug
|
||||
content
|
||||
contentExcerpt
|
||||
language
|
||||
pinnedBy {
|
||||
id
|
||||
name
|
||||
role
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
unpinGroupPost: gql`
|
||||
mutation ($id: ID!) {
|
||||
unpinGroupPost(id: $id) {
|
||||
id
|
||||
title
|
||||
slug
|
||||
content
|
||||
contentExcerpt
|
||||
language
|
||||
pinnedBy {
|
||||
id
|
||||
name
|
||||
role
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
pushPost: gql`
|
||||
mutation ($id: ID!) {
|
||||
pushPost(id: $id) {
|
||||
|
||||
@ -52,6 +52,8 @@ export default (i18n) => {
|
||||
name
|
||||
slug
|
||||
groupType
|
||||
myRole
|
||||
currentlyPinnedPostsCount
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -95,6 +97,8 @@ export const filterPosts = (i18n) => {
|
||||
name
|
||||
slug
|
||||
groupType
|
||||
myRole
|
||||
currentlyPinnedPostsCount
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -137,6 +141,8 @@ export const profilePagePosts = (i18n) => {
|
||||
name
|
||||
slug
|
||||
groupType
|
||||
myRole
|
||||
currentlyPinnedPostsCount
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,6 +14,6 @@ export default {
|
||||
}),
|
||||
},
|
||||
async created() {
|
||||
if (this.isAdmin && this.maxPinnedPosts === 0) await this.fetchPinnedPostsCount()
|
||||
/* if (this.isAdmin && this.maxPinnedPosts === 0) */ await this.fetchPinnedPostsCount()
|
||||
},
|
||||
}
|
||||
|
||||
@ -38,6 +38,36 @@ export default {
|
||||
})
|
||||
.catch((error) => this.$toast.error(error.message))
|
||||
},
|
||||
pinGroupPost(post, refetchPostList = () => {}) {
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: PostMutations().pinGroupPost,
|
||||
variables: {
|
||||
id: post.id,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
this.$toast.success(this.$t('post.menu.groupPinnedSuccessfully'))
|
||||
// this.storePinGroupPost()
|
||||
refetchPostList()
|
||||
})
|
||||
.catch((error) => this.$toast.error(error.message))
|
||||
},
|
||||
unpinGroupPost(post, refetchPostList = () => {}) {
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: PostMutations().unpinGroupPost,
|
||||
variables: {
|
||||
id: post.id,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
this.$toast.success(this.$t('post.menu.groupUnpinnedSuccessfully'))
|
||||
// this.storeUnpinGroupPost()
|
||||
refetchPostList()
|
||||
})
|
||||
.catch((error) => this.$toast.error(error.message))
|
||||
},
|
||||
pushPost(post, refetchPostList = () => {}) {
|
||||
this.$apollo
|
||||
.mutate({
|
||||
|
||||
@ -246,6 +246,8 @@
|
||||
@removePostFromList="posts = removePostFromList(post, posts)"
|
||||
@pinPost="pinPost(post, refetchPostList)"
|
||||
@unpinPost="unpinPost(post, refetchPostList)"
|
||||
@pinGroupPost="pinGroupPost(post, refetchPostList)"
|
||||
@unpinGroupPost="unpinGroupPost(post, refetchPostList)"
|
||||
@pushPost="pushPost(post, refetchPostList)"
|
||||
@unpushPost="unpushPost(post, refetchPostList)"
|
||||
@toggleObservePost="
|
||||
|
||||
@ -116,6 +116,8 @@
|
||||
@removePostFromList="posts = removePostFromList(post, posts)"
|
||||
@pinPost="pinPost(post, refetchPostList)"
|
||||
@unpinPost="unpinPost(post, refetchPostList)"
|
||||
@pinGroupPost="pinGroupPost(post, refetchPostList)"
|
||||
@unpinGroupPost="unpinGroupPost(post, refetchPostList)"
|
||||
@pushPost="pushPost(post, refetchPostList)"
|
||||
@unpushPost="unpushPost(post, refetchPostList)"
|
||||
@toggleObservePost="
|
||||
|
||||
@ -58,6 +58,8 @@
|
||||
:is-owner="isAuthor"
|
||||
@pinPost="pinPost"
|
||||
@unpinPost="unpinPost"
|
||||
@pinGroupPost="pinGroupPost"
|
||||
@unpinGroupPost="unpinGroupPost"
|
||||
@pushPost="pushPost"
|
||||
@unpushPost="unpushPost"
|
||||
@toggleObservePost="toggleObservePost"
|
||||
|
||||
@ -160,6 +160,8 @@
|
||||
@removePostFromList="posts = removePostFromList(post, posts)"
|
||||
@pinPost="pinPost(post, refetchPostList)"
|
||||
@unpinPost="unpinPost(post, refetchPostList)"
|
||||
@pinGroupPost="pinGroupPost(post, refetchPostList)"
|
||||
@unpinGroupPost="unpinGroupPost(post, refetchPostList)"
|
||||
@pushPost="pushPost(post, refetchPostList)"
|
||||
@unpushPost="unpushPost(post, refetchPostList)"
|
||||
@toggleObservePost="
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user