fix reporting modal
This commit is contained in:
parent
05f25c21e0
commit
a077938f73
7 changed files with 30 additions and 42 deletions
|
|
@ -20,6 +20,10 @@ const List = {
|
||||||
type: Function,
|
type: Function,
|
||||||
default: () => '',
|
default: () => '',
|
||||||
},
|
},
|
||||||
|
preSelect: {
|
||||||
|
type: Array,
|
||||||
|
default: [],
|
||||||
|
},
|
||||||
nonInteractive: {
|
nonInteractive: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
|
|
@ -44,7 +48,7 @@ const List = {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
items: [],
|
items: [],
|
||||||
selected: new Set([]),
|
selected: new Set(this.preSelect),
|
||||||
loading: false,
|
loading: false,
|
||||||
bottomedOut: true,
|
bottomedOut: true,
|
||||||
error: null,
|
error: null,
|
||||||
|
|
|
||||||
|
|
@ -108,12 +108,11 @@ const UsersTab = {
|
||||||
...this.fetchOptions,
|
...this.fetchOptions,
|
||||||
page,
|
page,
|
||||||
})
|
})
|
||||||
.then(({ count, users }) => ({ count, items: users }))
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
fetchOptions() {
|
fetchOptions() {
|
||||||
this.$refs.usersList.reset()
|
this.$refs.usersList?.reset()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -299,10 +299,12 @@ export const BUTTONS = [
|
||||||
label: 'user_card.report',
|
label: 'user_card.report',
|
||||||
if: ({ loggedIn }) => loggedIn,
|
if: ({ loggedIn }) => loggedIn,
|
||||||
action({ status }) {
|
action({ status }) {
|
||||||
return useReportsStore().openUserReportingModal({
|
useReportsStore().openUserReportingModal({
|
||||||
userId: status.user.id,
|
userId: status.user.id,
|
||||||
statusIds: [status.id],
|
statusIds: [status.id],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return Promise.resolve()
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
].map((button) => {
|
].map((button) => {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { mapState } from 'pinia'
|
||||||
|
|
||||||
import Checkbox from 'src/components/checkbox/checkbox.vue'
|
import Checkbox from 'src/components/checkbox/checkbox.vue'
|
||||||
import List from 'src/components/list/list.vue'
|
import List from 'src/components/list/list.vue'
|
||||||
import Modal from 'src/components/modal/modal.vue'
|
import Modal from 'src/components/modal/modal.vue'
|
||||||
|
|
@ -16,19 +18,17 @@ const UserReportingModal = {
|
||||||
return {
|
return {
|
||||||
comment: '',
|
comment: '',
|
||||||
forward: false,
|
forward: false,
|
||||||
statusIdsToReport: [],
|
statusIdsToReport: new Set(),
|
||||||
processing: false,
|
processing: false,
|
||||||
error: false,
|
error: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
reportModal() {
|
|
||||||
return useReportsStore().reportModal
|
|
||||||
},
|
|
||||||
isLoggedIn() {
|
isLoggedIn() {
|
||||||
return !!this.$store.state.users.currentUser
|
return !!this.$store.state.users.currentUser
|
||||||
},
|
},
|
||||||
isOpen() {
|
isOpen() {
|
||||||
|
console.log(this.reportModal)
|
||||||
return this.isLoggedIn && this.reportModal.activated
|
return this.isLoggedIn && this.reportModal.activated
|
||||||
},
|
},
|
||||||
userId() {
|
userId() {
|
||||||
|
|
@ -43,31 +43,26 @@ const UserReportingModal = {
|
||||||
this.user.screen_name.substr(this.user.screen_name.indexOf('@') + 1)
|
this.user.screen_name.substr(this.user.screen_name.indexOf('@') + 1)
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
statuses() {
|
...mapState(useReportsStore, ['reportModal']),
|
||||||
return this.reportModal.statuses
|
|
||||||
},
|
|
||||||
preTickedIds() {
|
|
||||||
return this.reportModal.preTickedIds
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
userId: 'resetState',
|
userId: 'resetState',
|
||||||
preTickedIds(newValue) {
|
|
||||||
this.statusIdsToReport = newValue
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
resetState() {
|
resetState() {
|
||||||
// Reset state
|
// Reset state
|
||||||
this.comment = ''
|
this.comment = ''
|
||||||
this.forward = false
|
this.forward = false
|
||||||
this.statusIdsToReport = this.preTickedIds
|
this.statusIdsToReport = new Set(this.reportModal.preTickedIds)
|
||||||
this.processing = false
|
this.processing = false
|
||||||
this.error = false
|
this.error = false
|
||||||
},
|
},
|
||||||
closeModal() {
|
closeModal() {
|
||||||
useReportsStore().closeUserReportingModal()
|
useReportsStore().closeUserReportingModal()
|
||||||
},
|
},
|
||||||
|
onListSelect(selected) {
|
||||||
|
this.statusIdsToReport = selected
|
||||||
|
},
|
||||||
reportUser() {
|
reportUser() {
|
||||||
this.processing = true
|
this.processing = true
|
||||||
this.error = false
|
this.error = false
|
||||||
|
|
@ -75,7 +70,7 @@ const UserReportingModal = {
|
||||||
userId: this.userId,
|
userId: this.userId,
|
||||||
comment: this.comment,
|
comment: this.comment,
|
||||||
forward: this.forward,
|
forward: this.forward,
|
||||||
statusIds: this.statusIdsToReport,
|
statusIds: [...this.statusIdsToReport],
|
||||||
}
|
}
|
||||||
this.$store.state.api.backendInteractor
|
this.$store.state.api.backendInteractor
|
||||||
.reportUser({ ...params })
|
.reportUser({ ...params })
|
||||||
|
|
@ -92,23 +87,6 @@ const UserReportingModal = {
|
||||||
clearError() {
|
clearError() {
|
||||||
this.error = false
|
this.error = false
|
||||||
},
|
},
|
||||||
isChecked(statusId) {
|
|
||||||
return this.statusIdsToReport.indexOf(statusId) !== -1
|
|
||||||
},
|
|
||||||
toggleStatus(checked, statusId) {
|
|
||||||
if (checked === this.isChecked(statusId)) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (checked) {
|
|
||||||
this.statusIdsToReport.push(statusId)
|
|
||||||
} else {
|
|
||||||
this.statusIdsToReport.splice(
|
|
||||||
this.statusIdsToReport.indexOf(statusId),
|
|
||||||
1,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
resize(e) {
|
resize(e) {
|
||||||
const target = e.target || e
|
const target = e.target || e
|
||||||
if (!(target instanceof window.Element)) {
|
if (!(target instanceof window.Element)) {
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="user-reporting-panel-right">
|
<div class="user-reporting-panel-right">
|
||||||
<List
|
<List
|
||||||
:external-items="statuses"
|
:external-items="reportModal.statuses"
|
||||||
|
:pre-select="reportModal.preTickedIds"
|
||||||
selectable
|
selectable
|
||||||
|
@select="onListSelect"
|
||||||
>
|
>
|
||||||
<template #item="{item}">
|
<template #item="{item}">
|
||||||
<Status
|
<Status
|
||||||
|
|
|
||||||
|
|
@ -307,8 +307,12 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
opts,
|
opts,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const statuses = activities.map(parseStatus)
|
||||||
|
|
||||||
|
await window.vuex.dispatch('addNewStatuses', { statuses })
|
||||||
|
|
||||||
return {
|
return {
|
||||||
items: activities.map(parseStatus),
|
items: statuses,
|
||||||
count: total,
|
count: total,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -318,10 +322,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
||||||
})
|
})
|
||||||
const status = parseStatus(raw)
|
const status = parseStatus(raw)
|
||||||
|
|
||||||
await window.vuex.dispatch('addNewStatuses', {
|
await window.vuex.dispatch('addNewStatuses', { statuses: [status] })
|
||||||
statuses: [status],
|
|
||||||
userId: false,
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Users stuff
|
// Users stuff
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,12 @@ export const useReportsStore = defineStore('reports', {
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
openUserReportingModal({ userId, statusIds = [] }) {
|
openUserReportingModal({ userId, statusIds = [] }) {
|
||||||
|
console.log('ASS')
|
||||||
const preTickedStatuses = statusIds.map(
|
const preTickedStatuses = statusIds.map(
|
||||||
(id) => window.vuex.state.statuses.allStatusesObject[id],
|
(id) => window.vuex.state.statuses.allStatusesObject[id],
|
||||||
)
|
)
|
||||||
const preTickedIds = statusIds
|
const preTickedIds = statusIds
|
||||||
|
console.log(preTickedStatuses)
|
||||||
const statuses = preTickedStatuses.concat(
|
const statuses = preTickedStatuses.concat(
|
||||||
filter(
|
filter(
|
||||||
window.vuex.state.statuses.allStatuses,
|
window.vuex.state.statuses.allStatuses,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue