mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Dispatch request for report
This commit is contained in:
parent
00e61e5978
commit
487fe2aabe
@ -53,6 +53,7 @@ export default {
|
|||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
placement: { type: String, default: 'top-end' },
|
placement: { type: String, default: 'top-end' },
|
||||||
|
itemId: { type: String, required: true },
|
||||||
name: { type: String, required: true },
|
name: { type: String, required: true },
|
||||||
context: {
|
context: {
|
||||||
type: String,
|
type: String,
|
||||||
@ -95,6 +96,7 @@ export default {
|
|||||||
name: 'report',
|
name: 'report',
|
||||||
data: {
|
data: {
|
||||||
context: this.context,
|
context: this.context,
|
||||||
|
id: this.itemId,
|
||||||
name: this.name
|
name: this.name
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -53,6 +53,7 @@
|
|||||||
<no-ssr>
|
<no-ssr>
|
||||||
<content-menu
|
<content-menu
|
||||||
context="contribution"
|
context="contribution"
|
||||||
|
:item-id="post.id"
|
||||||
:name="post.title"
|
:name="post.title"
|
||||||
/>
|
/>
|
||||||
</no-ssr>
|
</no-ssr>
|
||||||
|
|||||||
@ -4,14 +4,46 @@
|
|||||||
:is-open="isOpen"
|
:is-open="isOpen"
|
||||||
:confirm-label="$t('report.submit')"
|
:confirm-label="$t('report.submit')"
|
||||||
:cancel-label="$t('report.cancel')"
|
:cancel-label="$t('report.cancel')"
|
||||||
@close="close"
|
confrim-icon="warning"
|
||||||
|
@confirm="report"
|
||||||
|
@cancel="close"
|
||||||
>
|
>
|
||||||
<p>Are you sure that you want to report the {{ data.context }} "<b>{{ data.name | truncate(30) }}</b>"?</p>
|
<p>Are you sure that you want to report the {{ data.context }} "<b>{{ data.name | truncate(30) }}</b>"?</p>
|
||||||
|
<template
|
||||||
|
slot="footer"
|
||||||
|
slot-scope="{ cancel, confirm, cancelLabel, confirmLabel }"
|
||||||
|
>
|
||||||
|
<ds-button
|
||||||
|
ghost
|
||||||
|
icon="close"
|
||||||
|
:disabled="disabled || loading"
|
||||||
|
@click.prevent="cancel('cancel')"
|
||||||
|
>
|
||||||
|
{{ cancelLabel }}
|
||||||
|
</ds-button>
|
||||||
|
<ds-button
|
||||||
|
danger
|
||||||
|
icon="exclamation-circle"
|
||||||
|
:loading="loading"
|
||||||
|
:disabled="disabled || loading"
|
||||||
|
@click.prevent="confirm('confirm')"
|
||||||
|
>
|
||||||
|
{{ confirmLabel }}
|
||||||
|
</ds-button>
|
||||||
|
</template>
|
||||||
</ds-modal>
|
</ds-modal>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
loading: false,
|
||||||
|
disabled: false
|
||||||
|
}
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
data() {
|
data() {
|
||||||
return this.$store.getters['modal/data'] || {}
|
return this.$store.getters['modal/data'] || {}
|
||||||
@ -23,9 +55,51 @@ export default {
|
|||||||
return this.$store.getters['modal/open'] === 'report'
|
return this.$store.getters['modal/open'] === 'report'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
isOpen(open) {
|
||||||
|
if (open) {
|
||||||
|
this.disabled = false
|
||||||
|
this.loading = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
close() {
|
close() {
|
||||||
this.$store.commit('modal/SET_OPEN', {})
|
this.$store.commit('modal/SET_OPEN', {})
|
||||||
|
},
|
||||||
|
report() {
|
||||||
|
console.log('')
|
||||||
|
this.loading = true
|
||||||
|
this.$apollo
|
||||||
|
.mutate({
|
||||||
|
mutation: gql`
|
||||||
|
mutation($id: ID!, $type: _ResourceType!, $description: String) {
|
||||||
|
report(
|
||||||
|
resource: { id: $id, type: $type }
|
||||||
|
description: $description
|
||||||
|
) {
|
||||||
|
id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
variables: {
|
||||||
|
id: this.data.id,
|
||||||
|
type: this.data.context,
|
||||||
|
description: '-'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
this.isOpen = false
|
||||||
|
this.$toast.success(err.message)
|
||||||
|
this.disabled = true
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
this.$toast.error(err.message)
|
||||||
|
this.disabled = false
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
style="float: right; display: inline-block; margin-top: -5rem;"
|
style="float: right; display: inline-block; margin-top: -5rem;"
|
||||||
placement="bottom-end"
|
placement="bottom-end"
|
||||||
context="contribution"
|
context="contribution"
|
||||||
|
:item-id="post.id"
|
||||||
:name="post.title"
|
:name="post.title"
|
||||||
/>
|
/>
|
||||||
</no-ssr>
|
</no-ssr>
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
style="float: right; display: inline-block; margin-top: -3.5rem; margin-right: -0.5rem;"
|
style="float: right; display: inline-block; margin-top: -3.5rem; margin-right: -0.5rem;"
|
||||||
placement="bottom-start"
|
placement="bottom-start"
|
||||||
context="user"
|
context="user"
|
||||||
|
:item-id="user.id"
|
||||||
:name="user.name"
|
:name="user.name"
|
||||||
/>
|
/>
|
||||||
</no-ssr>
|
</no-ssr>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user