mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
removed categories from posts
This commit is contained in:
parent
44f43663b0
commit
f73c40c252
@ -138,8 +138,6 @@ export default {
|
|||||||
Mutation: {
|
Mutation: {
|
||||||
CreateComment: validateCreateComment,
|
CreateComment: validateCreateComment,
|
||||||
UpdateComment: validateUpdateComment,
|
UpdateComment: validateUpdateComment,
|
||||||
CreatePost: validatePost,
|
|
||||||
UpdatePost: validateUpdatePost,
|
|
||||||
UpdateUser: validateUpdateUser,
|
UpdateUser: validateUpdateUser,
|
||||||
fileReport: validateReport,
|
fileReport: validateReport,
|
||||||
review: validateReview,
|
review: validateReview,
|
||||||
|
|||||||
@ -240,7 +240,7 @@ describe('validateCreateComment', () => {
|
|||||||
|
|
||||||
describe('categories', () => {
|
describe('categories', () => {
|
||||||
describe('null', () => {
|
describe('null', () => {
|
||||||
it('throws UserInputError', async () => {
|
it.skip('throws UserInputError', async () => {
|
||||||
createPostVariables = { ...createPostVariables, categoryIds: null }
|
createPostVariables = { ...createPostVariables, categoryIds: null }
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: createPostMutation, variables: createPostVariables }),
|
mutate({ mutation: createPostMutation, variables: createPostVariables }),
|
||||||
@ -256,7 +256,7 @@ describe('validateCreateComment', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('empty', () => {
|
describe('empty', () => {
|
||||||
it('throws UserInputError', async () => {
|
it.skip('throws UserInputError', async () => {
|
||||||
createPostVariables = { ...createPostVariables, categoryIds: [] }
|
createPostVariables = { ...createPostVariables, categoryIds: [] }
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: createPostMutation, variables: createPostVariables }),
|
mutate({ mutation: createPostMutation, variables: createPostVariables }),
|
||||||
@ -272,7 +272,7 @@ describe('validateCreateComment', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('more than 3 categoryIds', () => {
|
describe('more than 3 categoryIds', () => {
|
||||||
it('throws UserInputError', async () => {
|
it.skip('throws UserInputError', async () => {
|
||||||
createPostVariables = {
|
createPostVariables = {
|
||||||
...createPostVariables,
|
...createPostVariables,
|
||||||
categoryIds: ['cat9', 'cat27', 'cat15', 'cat4'],
|
categoryIds: ['cat9', 'cat27', 'cat15', 'cat4'],
|
||||||
@ -313,7 +313,7 @@ describe('validateCreateComment', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('requires at least one category for successful update', async () => {
|
it.skip('requires at least one category for successful update', async () => {
|
||||||
await expect(
|
await expect(
|
||||||
mutate({ mutation: updatePostMutation, variables: updatePostVariables }),
|
mutate({ mutation: updatePostMutation, variables: updatePostVariables }),
|
||||||
).resolves.toMatchObject({
|
).resolves.toMatchObject({
|
||||||
|
|||||||
@ -76,7 +76,6 @@ export default {
|
|||||||
},
|
},
|
||||||
Mutation: {
|
Mutation: {
|
||||||
CreatePost: async (_parent, params, context, _resolveInfo) => {
|
CreatePost: async (_parent, params, context, _resolveInfo) => {
|
||||||
const { categoryIds } = params
|
|
||||||
const { image: imageInput } = params
|
const { image: imageInput } = params
|
||||||
delete params.categoryIds
|
delete params.categoryIds
|
||||||
delete params.image
|
delete params.image
|
||||||
@ -92,13 +91,9 @@ export default {
|
|||||||
WITH post
|
WITH post
|
||||||
MATCH (author:User {id: $userId})
|
MATCH (author:User {id: $userId})
|
||||||
MERGE (post)<-[:WROTE]-(author)
|
MERGE (post)<-[:WROTE]-(author)
|
||||||
WITH post
|
|
||||||
UNWIND $categoryIds AS categoryId
|
|
||||||
MATCH (category:Category {id: categoryId})
|
|
||||||
MERGE (post)-[:CATEGORIZED]->(category)
|
|
||||||
RETURN post {.*}
|
RETURN post {.*}
|
||||||
`,
|
`,
|
||||||
{ userId: context.user.id, categoryIds, params },
|
{ userId: context.user.id, params },
|
||||||
)
|
)
|
||||||
const [post] = createPostTransactionResponse.records.map((record) => record.get('post'))
|
const [post] = createPostTransactionResponse.records.map((record) => record.get('post'))
|
||||||
if (imageInput) {
|
if (imageInput) {
|
||||||
|
|||||||
@ -136,7 +136,7 @@ type Post {
|
|||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
tags: [Tag]! @relation(name: "TAGGED", direction: "OUT")
|
tags: [Tag]! @relation(name: "TAGGED", direction: "OUT")
|
||||||
categories: [Category]! @relation(name: "CATEGORIZED", direction: "OUT")
|
categories: [Category] @relation(name: "CATEGORIZED", direction: "OUT")
|
||||||
|
|
||||||
comments: [Comment]! @relation(name: "COMMENTS", direction: "IN")
|
comments: [Comment]! @relation(name: "COMMENTS", direction: "IN")
|
||||||
commentsCount: Int!
|
commentsCount: Int!
|
||||||
|
|||||||
@ -104,7 +104,7 @@ type User {
|
|||||||
shouted: [Post]! @relation(name: "SHOUTED", direction: "OUT")
|
shouted: [Post]! @relation(name: "SHOUTED", direction: "OUT")
|
||||||
shoutedCount: Int! @cypher(statement: "MATCH (this)-[:SHOUTED]->(r:Post) WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(DISTINCT r)")
|
shoutedCount: Int! @cypher(statement: "MATCH (this)-[:SHOUTED]->(r:Post) WHERE NOT r.deleted = true AND NOT r.disabled = true RETURN COUNT(DISTINCT r)")
|
||||||
|
|
||||||
categories: [Category]! @relation(name: "CATEGORIZED", direction: "OUT")
|
categories: [Category] @relation(name: "CATEGORIZED", direction: "OUT")
|
||||||
|
|
||||||
badges: [Badge]! @relation(name: "REWARDED", direction: "IN")
|
badges: [Badge]! @relation(name: "REWARDED", direction: "IN")
|
||||||
badgesCount: Int! @cypher(statement: "MATCH (this)<-[:REWARDED]-(r:Badge) RETURN COUNT(r)")
|
badgesCount: Int! @cypher(statement: "MATCH (this)<-[:REWARDED]-(r:Badge) RETURN COUNT(r)")
|
||||||
|
|||||||
@ -17,6 +17,7 @@ config.stubs['client-only'] = '<span><slot /></span>'
|
|||||||
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||||
config.stubs['v-popover'] = '<span><slot /></span>'
|
config.stubs['v-popover'] = '<span><slot /></span>'
|
||||||
|
|
||||||
|
/*
|
||||||
const categories = [
|
const categories = [
|
||||||
{
|
{
|
||||||
id: 'cat3',
|
id: 'cat3',
|
||||||
@ -44,6 +45,7 @@ const categories = [
|
|||||||
icon: 'tree',
|
icon: 'tree',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
*/
|
||||||
|
|
||||||
describe('ContributionForm.vue', () => {
|
describe('ContributionForm.vue', () => {
|
||||||
let wrapper,
|
let wrapper,
|
||||||
@ -136,7 +138,7 @@ describe('ContributionForm.vue', () => {
|
|||||||
describe('CreatePost', () => {
|
describe('CreatePost', () => {
|
||||||
describe('invalid form submission', () => {
|
describe('invalid form submission', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
wrapper.find(CategoriesSelect).setData({ categories })
|
// wrapper.find(CategoriesSelect).setData({ categories })
|
||||||
postTitleInput = wrapper.find('.ds-input')
|
postTitleInput = wrapper.find('.ds-input')
|
||||||
postTitleInput.setValue(postTitle)
|
postTitleInput.setValue(postTitle)
|
||||||
await wrapper.vm.updateEditorContent(postContent)
|
await wrapper.vm.updateEditorContent(postContent)
|
||||||
@ -144,10 +146,10 @@ describe('ContributionForm.vue', () => {
|
|||||||
.findAll('li')
|
.findAll('li')
|
||||||
.filter((language) => language.text() === 'English')
|
.filter((language) => language.text() === 'English')
|
||||||
englishLanguage.trigger('click')
|
englishLanguage.trigger('click')
|
||||||
dataPrivacyButton = await wrapper
|
/* dataPrivacyButton = await wrapper
|
||||||
.find(CategoriesSelect)
|
.find(CategoriesSelect)
|
||||||
.find('[data-test="category-buttons-cat12"]')
|
.find('[data-test="category-buttons-cat12"]')
|
||||||
dataPrivacyButton.trigger('click')
|
dataPrivacyButton.trigger('click') */
|
||||||
})
|
})
|
||||||
|
|
||||||
it('title cannot be empty', async () => {
|
it('title cannot be empty', async () => {
|
||||||
@ -174,7 +176,7 @@ describe('ContributionForm.vue', () => {
|
|||||||
expect(mocks.$apollo.mutate).not.toHaveBeenCalled()
|
expect(mocks.$apollo.mutate).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has at least one category', async () => {
|
it.skip('has at least one category', async () => {
|
||||||
dataPrivacyButton = await wrapper
|
dataPrivacyButton = await wrapper
|
||||||
.find(CategoriesSelect)
|
.find(CategoriesSelect)
|
||||||
.find('[data-test="category-buttons-cat12"]')
|
.find('[data-test="category-buttons-cat12"]')
|
||||||
@ -183,7 +185,7 @@ describe('ContributionForm.vue', () => {
|
|||||||
expect(mocks.$apollo.mutate).not.toHaveBeenCalled()
|
expect(mocks.$apollo.mutate).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('has no more than three categories', async () => {
|
it.skip('has no more than three categories', async () => {
|
||||||
wrapper.vm.formData.categoryIds = ['cat4', 'cat9', 'cat15', 'cat27']
|
wrapper.vm.formData.categoryIds = ['cat4', 'cat9', 'cat15', 'cat27']
|
||||||
await Vue.nextTick()
|
await Vue.nextTick()
|
||||||
wrapper.find('form').trigger('submit')
|
wrapper.find('form').trigger('submit')
|
||||||
@ -200,23 +202,23 @@ describe('ContributionForm.vue', () => {
|
|||||||
content: postContent,
|
content: postContent,
|
||||||
language: 'en',
|
language: 'en',
|
||||||
id: null,
|
id: null,
|
||||||
categoryIds: ['cat12'],
|
// categoryIds: ['cat12'],
|
||||||
image: null,
|
image: null,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
postTitleInput = wrapper.find('.ds-input')
|
postTitleInput = wrapper.find('.ds-input')
|
||||||
postTitleInput.setValue(postTitle)
|
postTitleInput.setValue(postTitle)
|
||||||
await wrapper.vm.updateEditorContent(postContent)
|
await wrapper.vm.updateEditorContent(postContent)
|
||||||
wrapper.find(CategoriesSelect).setData({ categories })
|
// wrapper.find(CategoriesSelect).setData({ categories })
|
||||||
englishLanguage = wrapper
|
englishLanguage = wrapper
|
||||||
.findAll('li')
|
.findAll('li')
|
||||||
.filter((language) => language.text() === 'English')
|
.filter((language) => language.text() === 'English')
|
||||||
englishLanguage.trigger('click')
|
englishLanguage.trigger('click')
|
||||||
await Vue.nextTick()
|
await Vue.nextTick()
|
||||||
dataPrivacyButton = await wrapper
|
/* dataPrivacyButton = await wrapper
|
||||||
.find(CategoriesSelect)
|
.find(CategoriesSelect)
|
||||||
.find('[data-test="category-buttons-cat12"]')
|
.find('[data-test="category-buttons-cat12"]')
|
||||||
dataPrivacyButton.trigger('click')
|
dataPrivacyButton.trigger('click') */
|
||||||
await Vue.nextTick()
|
await Vue.nextTick()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -293,16 +295,16 @@ describe('ContributionForm.vue', () => {
|
|||||||
postTitleInput.setValue(postTitle)
|
postTitleInput.setValue(postTitle)
|
||||||
await wrapper.vm.updateEditorContent(postContent)
|
await wrapper.vm.updateEditorContent(postContent)
|
||||||
categoryIds = ['cat12']
|
categoryIds = ['cat12']
|
||||||
wrapper.find(CategoriesSelect).setData({ categories })
|
// wrapper.find(CategoriesSelect).setData({ categories })
|
||||||
englishLanguage = wrapper
|
englishLanguage = wrapper
|
||||||
.findAll('li')
|
.findAll('li')
|
||||||
.filter((language) => language.text() === 'English')
|
.filter((language) => language.text() === 'English')
|
||||||
englishLanguage.trigger('click')
|
englishLanguage.trigger('click')
|
||||||
await Vue.nextTick()
|
await Vue.nextTick()
|
||||||
dataPrivacyButton = await wrapper
|
/* dataPrivacyButton = await wrapper
|
||||||
.find(CategoriesSelect)
|
.find(CategoriesSelect)
|
||||||
.find('[data-test="category-buttons-cat12"]')
|
.find('[data-test="category-buttons-cat12"]')
|
||||||
dataPrivacyButton.trigger('click')
|
dataPrivacyButton.trigger('click') */
|
||||||
await Vue.nextTick()
|
await Vue.nextTick()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -365,7 +367,7 @@ describe('ContributionForm.vue', () => {
|
|||||||
content: propsData.contribution.content,
|
content: propsData.contribution.content,
|
||||||
language: propsData.contribution.language,
|
language: propsData.contribution.language,
|
||||||
id: propsData.contribution.id,
|
id: propsData.contribution.id,
|
||||||
categoryIds: ['cat12'],
|
// categoryIds: ['cat12'],
|
||||||
image: {
|
image: {
|
||||||
sensitive: false,
|
sensitive: false,
|
||||||
},
|
},
|
||||||
@ -380,9 +382,9 @@ describe('ContributionForm.vue', () => {
|
|||||||
expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expect.objectContaining(expectedParams))
|
expect(mocks.$apollo.mutate).toHaveBeenCalledWith(expect.objectContaining(expectedParams))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('supports updating categories', async () => {
|
it.skip('supports updating categories', async () => {
|
||||||
expectedParams.variables.categoryIds.push('cat3')
|
expectedParams.variables.categoryIds.push('cat3')
|
||||||
wrapper.find(CategoriesSelect).setData({ categories })
|
// wrapper.find(CategoriesSelect).setData({ categories })
|
||||||
await Vue.nextTick()
|
await Vue.nextTick()
|
||||||
const healthWellbeingButton = await wrapper
|
const healthWellbeingButton = await wrapper
|
||||||
.find(CategoriesSelect)
|
.find(CategoriesSelect)
|
||||||
|
|||||||
@ -50,11 +50,6 @@
|
|||||||
{{ contentLength }}
|
{{ contentLength }}
|
||||||
<base-icon v-if="errors && errors.content" name="warning" />
|
<base-icon v-if="errors && errors.content" name="warning" />
|
||||||
</ds-chip>
|
</ds-chip>
|
||||||
<categories-select model="categoryIds" :existingCategoryIds="formData.categoryIds" />
|
|
||||||
<ds-chip size="base" :color="errors && errors.categoryIds && 'danger'">
|
|
||||||
{{ formData.categoryIds.length }} / 3
|
|
||||||
<base-icon v-if="errors && errors.categoryIds" name="warning" />
|
|
||||||
</ds-chip>
|
|
||||||
<ds-select
|
<ds-select
|
||||||
model="language"
|
model="language"
|
||||||
icon="globe"
|
icon="globe"
|
||||||
@ -86,14 +81,12 @@ import { mapGetters } from 'vuex'
|
|||||||
import HcEditor from '~/components/Editor/Editor'
|
import HcEditor from '~/components/Editor/Editor'
|
||||||
import locales from '~/locales'
|
import locales from '~/locales'
|
||||||
import PostMutations from '~/graphql/PostMutations.js'
|
import PostMutations from '~/graphql/PostMutations.js'
|
||||||
import CategoriesSelect from '~/components/CategoriesSelect/CategoriesSelect'
|
|
||||||
import ImageUploader from '~/components/ImageUploader/ImageUploader'
|
import ImageUploader from '~/components/ImageUploader/ImageUploader'
|
||||||
import links from '~/constants/links.js'
|
import links from '~/constants/links.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
HcEditor,
|
HcEditor,
|
||||||
CategoriesSelect,
|
|
||||||
ImageUploader,
|
ImageUploader,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
@ -103,7 +96,7 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
const { title, content, image, language, categories } = this.contribution
|
const { title, content, image, language } = this.contribution
|
||||||
|
|
||||||
const languageOptions = orderBy(locales, 'name').map((locale) => {
|
const languageOptions = orderBy(locales, 'name').map((locale) => {
|
||||||
return { label: locale.name, value: locale.code }
|
return { label: locale.name, value: locale.code }
|
||||||
@ -119,21 +112,10 @@ export default {
|
|||||||
imageAspectRatio,
|
imageAspectRatio,
|
||||||
imageBlurred,
|
imageBlurred,
|
||||||
language: languageOptions.find((option) => option.value === language) || null,
|
language: languageOptions.find((option) => option.value === language) || null,
|
||||||
categoryIds: categories ? categories.map((category) => category.id) : [],
|
|
||||||
},
|
},
|
||||||
formSchema: {
|
formSchema: {
|
||||||
title: { required: true, min: 3, max: 100 },
|
title: { required: true, min: 3, max: 100 },
|
||||||
content: { required: true },
|
content: { required: true },
|
||||||
categoryIds: {
|
|
||||||
type: 'array',
|
|
||||||
required: true,
|
|
||||||
validator: (_, value = []) => {
|
|
||||||
if (value.length === 0 || value.length > 3) {
|
|
||||||
return [new Error(this.$t('common.validations.categories'))]
|
|
||||||
}
|
|
||||||
return []
|
|
||||||
},
|
|
||||||
},
|
|
||||||
language: { required: true },
|
language: { required: true },
|
||||||
imageBlurred: { required: false },
|
imageBlurred: { required: false },
|
||||||
},
|
},
|
||||||
@ -155,7 +137,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
submit() {
|
submit() {
|
||||||
let image = null
|
let image = null
|
||||||
const { title, content, categoryIds } = this.formData
|
const { title, content } = this.formData
|
||||||
if (this.formData.image) {
|
if (this.formData.image) {
|
||||||
image = {
|
image = {
|
||||||
sensitive: this.formData.imageBlurred,
|
sensitive: this.formData.imageBlurred,
|
||||||
@ -172,7 +154,6 @@ export default {
|
|||||||
variables: {
|
variables: {
|
||||||
title,
|
title,
|
||||||
content,
|
content,
|
||||||
categoryIds,
|
|
||||||
id: this.contribution.id || null,
|
id: this.contribution.id || null,
|
||||||
language: this.formData.language.value,
|
language: this.formData.language.value,
|
||||||
image,
|
image,
|
||||||
|
|||||||
@ -46,21 +46,6 @@
|
|||||||
<content-viewer class="content hyphenate-text" :content="post.content" />
|
<content-viewer class="content hyphenate-text" :content="post.content" />
|
||||||
<!-- eslint-enable vue/no-v-html -->
|
<!-- eslint-enable vue/no-v-html -->
|
||||||
<ds-space margin="xx-large" />
|
<ds-space margin="xx-large" />
|
||||||
<!-- Categories -->
|
|
||||||
<div class="categories">
|
|
||||||
<ds-space margin="xx-small" />
|
|
||||||
<hc-category
|
|
||||||
v-for="category in post.categories"
|
|
||||||
:key="category.id"
|
|
||||||
:icon="category.icon"
|
|
||||||
:name="$t(`contribution.category.name.${category.slug}`)"
|
|
||||||
/>
|
|
||||||
<!-- Post language -->
|
|
||||||
<ds-tag v-if="post.language" class="category-tag language">
|
|
||||||
<base-icon name="globe" />
|
|
||||||
{{ post.language.toUpperCase() }}
|
|
||||||
</ds-tag>
|
|
||||||
</div>
|
|
||||||
<ds-space margin-bottom="small" />
|
<ds-space margin-bottom="small" />
|
||||||
<!-- Tags -->
|
<!-- Tags -->
|
||||||
<div v-if="post.tags && post.tags.length" class="tags">
|
<div v-if="post.tags && post.tags.length" class="tags">
|
||||||
@ -110,7 +95,6 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ContentViewer from '~/components/Editor/ContentViewer'
|
import ContentViewer from '~/components/Editor/ContentViewer'
|
||||||
import HcCategory from '~/components/Category'
|
|
||||||
import HcHashtag from '~/components/Hashtag/Hashtag'
|
import HcHashtag from '~/components/Hashtag/Hashtag'
|
||||||
import ContentMenu from '~/components/ContentMenu/ContentMenu'
|
import ContentMenu from '~/components/ContentMenu/ContentMenu'
|
||||||
import UserTeaser from '~/components/UserTeaser/UserTeaser'
|
import UserTeaser from '~/components/UserTeaser/UserTeaser'
|
||||||
@ -134,7 +118,6 @@ export default {
|
|||||||
mode: 'out-in',
|
mode: 'out-in',
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
HcCategory,
|
|
||||||
HcHashtag,
|
HcHashtag,
|
||||||
UserTeaser,
|
UserTeaser,
|
||||||
HcShoutButton,
|
HcShoutButton,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user