Next step

This commit is contained in:
Wolfgang Huß 2019-09-30 13:34:11 +02:00
parent eb6226f42d
commit 78b43b05a4
2 changed files with 53 additions and 42 deletions

View File

@ -1,5 +1,10 @@
<template> <template>
<ds-modal :title="title" :is-open="isOpen" @cancel="cancel"> <ds-modal
:title="title"
:is-open="isOpen"
:width="{ base: '100%', sm: '200px', md: '200px', lg: '200px' }"
@cancel="cancel"
>
<transition name="ds-transition-fade"> <transition name="ds-transition-fade">
<ds-flex v-if="success" class="hc-modal-success" centered> <ds-flex v-if="success" class="hc-modal-success" centered>
<sweetalert-icon icon="success" /> <sweetalert-icon icon="success" />
@ -8,18 +13,18 @@
<!-- eslint-disable-next-line vue/no-v-html --> <!-- eslint-disable-next-line vue/no-v-html -->
<p v-html="message" /> <p v-html="message" />
<ds-select <ds-radio
model="XXX" :model="form.reasonCategory"
:label="$t('report.reason.category.label')"
:options="form.reasonCategoryOptions" :options="form.reasonCategoryOptions"
icon="comment" :placeholder="$t('report.reason.category.placeholder')"
:label="$t('report.reason.addText.label')"
:placeholder="$t('report.reason.addText.placeholder')"
/> />
<ds-input <ds-input
id="text" id="text"
:label="$t('report.reason.addText.label')" :label="$t('report.reason.addText.label')"
:placeholder="$t('report.reason.addText.placeholder')" :placeholder="$t('report.reason.addText.placeholder')"
/> />
<ds-space />
<template slot="footer"> <template slot="footer">
<ds-button class="cancel" icon="close" @click="cancel">{{ $t('report.cancel') }}</ds-button> <ds-button class="cancel" icon="close" @click="cancel">{{ $t('report.cancel') }}</ds-button>
@ -28,6 +33,7 @@
danger danger
class="confirm" class="confirm"
icon="exclamation-circle" icon="exclamation-circle"
:disabled="failsValidations"
:loading="loading" :loading="loading"
@click="confirm" @click="confirm"
> >
@ -56,13 +62,14 @@ export default {
isOpen: true, isOpen: true,
success: false, success: false,
loading: false, loading: false,
failsValidations: true,
form: { form: {
reasonCategory: null, reasonCategory: null,
reasonCategoryOptions: [ reasonCategoryOptions: [
this.$t('report.reason.category.options.discrimination-etc'), this.$t('report.reason.category.options.discrimination-etc'),
this.$t('report.reason.category.options.pornographic-content-links'), this.$t('report.reason.category.options.pornographic-content-links'),
this.$t('report.reason.category.options.glorific-trivia-of-cruel-inhuman-acts'), this.$t('report.reason.category.options.glorific-trivia-of-cruel-inhuman-acts'),
this.$t('report.reason.category.options.unauthorized-disclosure-personalinformation'), this.$t('report.reason.category.options.doxing'),
this.$t('report.reason.category.options.intentional-intimidation-stalking-persecution'), this.$t('report.reason.category.options.intentional-intimidation-stalking-persecution'),
this.$t('report.reason.category.options.advert-products-services-commercial'), this.$t('report.reason.category.options.advert-products-services-commercial'),
this.$t('report.reason.category.options.criminal-behavior-violation-german-law'), this.$t('report.reason.category.options.criminal-behavior-violation-german-law'),
@ -71,7 +78,7 @@ export default {
reasonAddText: '', reasonAddText: '',
}, },
formSchema: { formSchema: {
reasonAddText: { required: true, min: 0, max: 150 }, reasonAddText: { required: true, min: 0, max: 200 },
}, },
} }
}, },
@ -94,11 +101,13 @@ export default {
}, 1000) }, 1000)
}, },
async confirm() { async confirm() {
const { reasonCategory, reasonAddText } = this.form
this.loading = true this.loading = true
try {
// TODO: Use the "modalData" structure introduced in "ConfirmModal" and refactor this here. Be aware that all the Jest tests have to be refactored as well !!! // TODO: Use the "modalData" structure introduced in "ConfirmModal" and refactor this here. Be aware that all the Jest tests have to be refactored as well !!!
// await this.modalData.buttons.confirm.callback() // await this.modalData.buttons.confirm.callback()
await this.$apollo.mutate({ this.$apollo
.mutate({
mutation: gql` mutation: gql`
mutation($id: ID!) { mutation($id: ID!) {
report(id: $id) { report(id: $id) {
@ -108,6 +117,7 @@ export default {
`, `,
variables: { id: this.id }, variables: { id: this.id },
}) })
.then(({ _data }) => {
this.success = true this.success = true
this.$toast.success(this.$t('report.success')) this.$toast.success(this.$t('report.success'))
setTimeout(() => { setTimeout(() => {
@ -117,7 +127,9 @@ export default {
this.$emit('close') this.$emit('close')
}, 500) }, 500)
}, 1500) }, 1500)
} catch (err) { this.loading = false
})
.catch(err => {
this.$emit('close') this.$emit('close')
this.success = false this.success = false
switch (err.message) { switch (err.message) {
@ -131,9 +143,8 @@ export default {
this.$toast.error(this.$t('report.comment.error')) this.$toast.error(this.$t('report.comment.error'))
break break
} }
} finally {
this.loading = false this.loading = false
} })
}, },
}, },
} }

View File

@ -436,13 +436,13 @@
}, },
"reason": { "reason": {
"category": { "category": {
"label": "Why you like to report this?", "label": "Select a category:",
"placeholder": "Additional information …", "placeholder": "Category …",
"options": { "options": {
"discrimination-etc": "Discriminatory posts, comments, utterances or insults", "discrimination-etc": "Discriminatory posts, comments, utterances or insults",
"pornographic-content-links": "Posting or linking of clearly pornographic material", "pornographic-content-links": "Posting or linking of clearly pornographic material",
"glorific-trivia-of-cruel-inhuman-acts": "Glorification or trivialization of cruel or inhuman acts of violence", "glorific-trivia-of-cruel-inhuman-acts": "Glorification or trivialization of cruel or inhuman acts of violence",
"unauthorized-disclosure-personalinformation": "The disclosure of others' personal information without their consent or threat there of (\"doxing\")", "doxing": "The disclosure of others' personal information without their consent or threat there of (\"doxing\")",
"intentional-intimidation-stalking-persecution": "Intentional intimidation, stalking or persecution", "intentional-intimidation-stalking-persecution": "Intentional intimidation, stalking or persecution",
"advert-products-services-commercial": "Advertising products and services with commercial intent", "advert-products-services-commercial": "Advertising products and services with commercial intent",
"criminal-behavior-violation-german-law": "Criminal behavior or violation of German law", "criminal-behavior-violation-german-law": "Criminal behavior or violation of German law",
@ -450,7 +450,7 @@
} }
}, },
"addText": { "addText": {
"label": "Why you like to report this?", "label": "Please explain why you like to report this?",
"placeholder": "Additional information …" "placeholder": "Additional information …"
} }
} }