diff --git a/backend/src/models/Post.js b/backend/src/models/Post.js index 5ac8378c2..2d2a164db 100644 --- a/backend/src/models/Post.js +++ b/backend/src/models/Post.js @@ -45,4 +45,5 @@ module.exports = { default: () => new Date().toISOString(), }, language: { type: 'string', allow: [null] }, + checkedBlur: { type: 'boolean', default: false }, } diff --git a/backend/src/schema/resolvers/posts.js b/backend/src/schema/resolvers/posts.js index ee6a82d42..44558be4d 100644 --- a/backend/src/schema/resolvers/posts.js +++ b/backend/src/schema/resolvers/posts.js @@ -297,7 +297,15 @@ export default { }, Post: { ...Resolver('Post', { - undefinedToNull: ['activityId', 'objectId', 'image', 'language', 'pinnedAt', 'pinned'], + undefinedToNull: [ + 'activityId', + 'objectId', + 'image', + 'language', + 'pinnedAt', + 'pinned', + 'checkedBlur', + ], hasMany: { tags: '-[:TAGGED]->(related:Tag)', categories: '-[:CATEGORIZED]->(related:Category)', diff --git a/backend/src/schema/types/type/Post.gql b/backend/src/schema/types/type/Post.gql index b29ac5386..f24018567 100644 --- a/backend/src/schema/types/type/Post.gql +++ b/backend/src/schema/types/type/Post.gql @@ -82,6 +82,7 @@ input _PostFilter { emotions_none: _PostEMOTEDFilter emotions_single: _PostEMOTEDFilter emotions_every: _PostEMOTEDFilter + checkedBlur: Boolean } enum _PostOrdering { @@ -127,6 +128,7 @@ type Post { createdAt: String updatedAt: String language: String + checkedBlur: Boolean pinnedAt: String @cypher( statement: "MATCH (this)<-[pinned:PINNED]-(:User) WHERE NOT this.deleted = true AND NOT this.disabled = true RETURN pinned.createdAt" ) @@ -140,7 +142,6 @@ type Post { LIMIT 10 """ ) - tags: [Tag]! @relation(name: "TAGGED", direction: "OUT") categories: [Category]! @relation(name: "CATEGORIZED", direction: "OUT") @@ -183,6 +184,7 @@ type Mutation { language: String categoryIds: [ID] contentExcerpt: String + checkedBlur: Boolean ): Post UpdatePost( id: ID! @@ -195,6 +197,7 @@ type Mutation { visibility: Visibility language: String categoryIds: [ID] + checkedBlur: Boolean ): Post DeletePost(id: ID!): Post AddPostEmotions(to: _PostInput!, data: _EMOTEDInput!): EMOTED @@ -215,6 +218,7 @@ type Query { createdAt: String updatedAt: String language: String + checkedBlur: Boolean first: Int offset: Int orderBy: [_PostOrdering] diff --git a/backend/src/seed/seed-db.js b/backend/src/seed/seed-db.js index 692d95542..1fd819a87 100644 --- a/backend/src/seed/seed-db.js +++ b/backend/src/seed/seed-db.js @@ -352,6 +352,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] language: sample(languages), image: faker.image.unsplash.food(), categoryIds: ['cat16'], + checkedBlur: true, }), factory.create('Post', { author: bobDerBaumeister, @@ -359,24 +360,28 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] language: sample(languages), image: faker.image.unsplash.technology(), categoryIds: ['cat1'], + checkedBlur: false, }), factory.create('Post', { author: huey, id: 'p3', language: sample(languages), categoryIds: ['cat3'], + checkedBlur: false, }), factory.create('Post', { author: dewey, id: 'p4', language: sample(languages), categoryIds: ['cat4'], + checkedBlur: false, }), factory.create('Post', { author: louie, id: 'p5', language: sample(languages), categoryIds: ['cat5'], + checkedBlur: false, }), factory.create('Post', { authorId: 'u1', @@ -384,17 +389,20 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] language: sample(languages), image: faker.image.unsplash.buildings(), categoryIds: ['cat6'], + checkedBlur: false, }), factory.create('Post', { author: huey, id: 'p9', language: sample(languages), categoryIds: ['cat9'], + checkedBlur: false, }), factory.create('Post', { author: dewey, id: 'p10', categoryIds: ['cat10'], + checkedBlur: true, }), factory.create('Post', { author: louie, @@ -402,12 +410,14 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] language: sample(languages), image: faker.image.unsplash.people(), categoryIds: ['cat11'], + checkedBlur: false, }), factory.create('Post', { author: bobDerBaumeister, id: 'p13', language: sample(languages), categoryIds: ['cat13'], + checkedBlur: false, }), factory.create('Post', { author: jennyRostock, @@ -415,12 +425,14 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] language: sample(languages), image: faker.image.unsplash.objects(), categoryIds: ['cat14'], + checkedBlur: false, }), factory.create('Post', { author: huey, id: 'p15', language: sample(languages), categoryIds: ['cat15'], + checkedBlur: false, }), ]) @@ -434,8 +446,20 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] const hashtagAndMention1 = 'The new physics of #QuantenFlussTheorie can explain #QuantumGravity! @peter-lustig got that already. ;-)' const createPostMutation = gql` - mutation($id: ID, $title: String!, $content: String!, $categoryIds: [ID]) { - CreatePost(id: $id, title: $title, content: $content, categoryIds: $categoryIds) { + mutation( + $id: ID + $title: String! + $content: String! + $categoryIds: [ID] + $checkedBlur: Boolean + ) { + CreatePost( + id: $id + title: $title + content: $content + categoryIds: $categoryIds + checkedBlur: $checkedBlur + ) { id } } @@ -449,6 +473,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] title: `Nature Philosophy Yoga`, content: hashtag1, categoryIds: ['cat2'], + checkedBlur: false, }, }), mutate({ @@ -458,6 +483,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] title: 'This is post #7', content: `${mention1} ${faker.lorem.paragraph()}`, categoryIds: ['cat7'], + checkedBlur: false, }, }), mutate({ @@ -468,6 +494,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] title: `Quantum Flow Theory explains Quantum Gravity`, content: hashtagAndMention1, categoryIds: ['cat8'], + checkedBlur: false, }, }), mutate({ @@ -477,6 +504,7 @@ const languages = ['de', 'en', 'es', 'fr', 'it', 'pt', 'pl'] title: 'This is post #12', content: `${mention2} ${faker.lorem.paragraph()}`, categoryIds: ['cat12'], + checkedBlur: false, }, }), ]) diff --git a/webapp/components/ContributionForm/ContributionForm.spec.js b/webapp/components/ContributionForm/ContributionForm.spec.js index 185e9ad56..603724eca 100644 --- a/webapp/components/ContributionForm/ContributionForm.spec.js +++ b/webapp/components/ContributionForm/ContributionForm.spec.js @@ -245,10 +245,9 @@ describe('ContributionForm.vue', () => { expect(mocks.$apollo.mutate).toHaveBeenCalledTimes(1) }) - describe('questionable images should be blurred', () => { - + describe('questionable images should be blurred', () => { it('questionable images unset be blurred', async () => { - await wrapper.find('input[type="checkbox"]').trigger('click') + await wrapper.find('input[type="checkbox"]').trigger('click') expect(wrapper.find('input[type="checkbox"]').exists()).toBe(true) }) }) diff --git a/webapp/components/ContributionForm/ContributionForm.vue b/webapp/components/ContributionForm/ContributionForm.vue index aa74b498c..98e515766 100644 --- a/webapp/components/ContributionForm/ContributionForm.vue +++ b/webapp/components/ContributionForm/ContributionForm.vue @@ -15,6 +15,27 @@ /> + + + + + + +
+ + + {{ $t('contribution.shockingPicture-text') }} + + + +
+
@@ -78,28 +99,7 @@ - - - - - - - +
this.contribution.language === o.value) : null form.categoryIds = this.categoryIds(this.contribution.categories) + form.checkedBlur = this.contribution.checkedBlur + + // console.log(this.contribution.checkedBlur) + // console.log(this.contribution) } + return { form, formSchema: { @@ -186,6 +193,7 @@ export default { }, }, language: { required: true }, + checkedBlur: { required: false }, }, languageOptions, id, @@ -194,9 +202,13 @@ export default { users: [], contentMin: 3, hashtags: [], - checkedBlur: false, elem: null, - elem1: null, + checkedBlur: false, + } + }, + created() { + if (this.contribution && this.contribution.checkedBlur) { + this.checkedChange() } }, computed: { @@ -209,21 +221,29 @@ export default { }, methods: { checkedChange() { - this.elem = this.$el.querySelector('img') - this.elem1 = this.$el.querySelector('img.thumbnail-preview') + // console.log( 'checkedChange') + // console.log( 'this.checkedBlur old', this.checkedBlur) + // console.log( 'THIS', this.$el) + // console.log( 'THIS.form', this.form) + + if (this.$el) { + this.elem = this.$el.querySelector('img') + } else { + } if (this.checkedBlur) { this.elem.classList.remove('img-blur-in') this.checkedBlur = false + this.form.checkedBlur = false + this.form.checkbox = false } else { if (this.elem != null) { - this.elem.classList.add('img-blur-in') + this.elem.classList.add('img-blur-in') } - if (this.elem1 != null) { - this.elem1.classList.add('img-blur-in') - } - this.checkedBlur = true + this.form.checkedBlur = true + this.form.checkbox = true } + // console.log( 'this.checkedBlur new', this.checkedBlur) }, submit() { const { @@ -246,6 +266,7 @@ export default { language, image, imageUpload: teaserImage, + checkedBlur: this.form.checkbox, }, }) .then(({ data }) => { @@ -307,6 +328,21 @@ export default { } + + diff --git a/webapp/components/PostCard/PostCard.vue b/webapp/components/PostCard/PostCard.vue index e65e17102..78f9f9e95 100644 --- a/webapp/components/PostCard/PostCard.vue +++ b/webapp/components/PostCard/PostCard.vue @@ -2,8 +2,17 @@ + + + + + +