mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 09:56:05 +00:00
update admin interface
This commit is contained in:
parent
450b3d2639
commit
5c5cd286f6
@ -2,12 +2,24 @@
|
||||
<div class="contribution-messages-formular">
|
||||
<div class="mt-5">
|
||||
<b-form @reset.prevent="onReset" @submit="onSubmit(messageType.DIALOG)">
|
||||
<b-form-textarea
|
||||
id="textarea"
|
||||
v-model="form.text"
|
||||
:placeholder="$t('contributionLink.memo')"
|
||||
rows="3"
|
||||
></b-form-textarea>
|
||||
<b-tabs content-class="mt-3" v-model="chatOrMemo">
|
||||
<b-tab :title="$t('moderator.chat')" active>
|
||||
<b-form-textarea
|
||||
id="textarea"
|
||||
v-model="form.text"
|
||||
:placeholder="$t('contributionLink.memo')"
|
||||
rows="3"
|
||||
></b-form-textarea>
|
||||
</b-tab>
|
||||
<b-tab :title="$t('moderator.memo')">
|
||||
<b-form-textarea
|
||||
id="textarea"
|
||||
v-model="form.memo"
|
||||
:placeholder="$t('contributionLink.memo')"
|
||||
rows="3"
|
||||
></b-form-textarea>
|
||||
</b-tab>
|
||||
</b-tabs>
|
||||
<b-row class="mt-4 mb-6">
|
||||
<b-col>
|
||||
<b-button type="reset" variant="danger">{{ $t('form.cancel') }}</b-button>
|
||||
@ -17,7 +29,16 @@
|
||||
type="button"
|
||||
variant="warning"
|
||||
class="text-black"
|
||||
:disabled="disabled"
|
||||
@click.prevent="enableMemo()"
|
||||
data-test="submit-memo"
|
||||
>
|
||||
{{ $t('moderator.memo-modify') }}
|
||||
</b-button>
|
||||
<b-button
|
||||
type="button"
|
||||
variant="warning"
|
||||
class="text-black"
|
||||
:disabled="moderatorDisabled"
|
||||
@click.prevent="onSubmit(messageType.MODERATOR)"
|
||||
data-test="submit-moderator"
|
||||
>
|
||||
@ -43,6 +64,15 @@
|
||||
</template>
|
||||
<script>
|
||||
import { adminCreateContributionMessage } from '@/graphql/adminCreateContributionMessage'
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const adminUpdateContribution = gql`
|
||||
mutation ($id: Int!, $memo: String!) {
|
||||
adminUpdateContribution(id: $id, memo: $memo) {
|
||||
memo
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export default {
|
||||
name: 'ContributionMessagesFormular',
|
||||
@ -51,13 +81,19 @@ export default {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
contributionMemo: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
text: '',
|
||||
memo: this.contributionMemo,
|
||||
},
|
||||
loading: false,
|
||||
chatOrMemo: 0, // 0 = Chat, 1 = Memo
|
||||
messageType: {
|
||||
DIALOG: 'DIALOG',
|
||||
MODERATOR: 'MODERATOR',
|
||||
@ -67,34 +103,65 @@ export default {
|
||||
methods: {
|
||||
onSubmit(mType) {
|
||||
this.loading = true
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: adminCreateContributionMessage,
|
||||
variables: {
|
||||
contributionId: this.contributionId,
|
||||
message: this.form.text,
|
||||
messageType: mType,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
this.$emit('get-list-contribution-messages', this.contributionId)
|
||||
this.$emit('update-status', this.contributionId)
|
||||
this.form.text = ''
|
||||
this.toastSuccess(this.$t('message.request'))
|
||||
this.loading = false
|
||||
})
|
||||
.catch((error) => {
|
||||
this.toastError(error.message)
|
||||
this.loading = false
|
||||
})
|
||||
if (this.chatOrMemo === 0) {
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: adminCreateContributionMessage,
|
||||
variables: {
|
||||
contributionId: this.contributionId,
|
||||
message: this.form.text,
|
||||
messageType: mType,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
this.$emit('get-list-contribution-messages', this.contributionId)
|
||||
this.$emit('update-status', this.contributionId)
|
||||
this.form.text = ''
|
||||
this.toastSuccess(this.$t('message.request'))
|
||||
this.loading = false
|
||||
})
|
||||
.catch((error) => {
|
||||
this.toastError(error.message)
|
||||
this.loading = false
|
||||
})
|
||||
} else {
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: adminUpdateContribution,
|
||||
variables: {
|
||||
id: this.contributionId,
|
||||
memo: this.form.memo,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
this.$emit('get-list-contribution-messages', this.contributionId)
|
||||
this.$emit('update-status', this.contributionId)
|
||||
this.toastSuccess(this.$t('message.request'))
|
||||
this.loading = false
|
||||
})
|
||||
.catch((error) => {
|
||||
this.toastError(error.message)
|
||||
this.loading = false
|
||||
})
|
||||
}
|
||||
},
|
||||
onReset(event) {
|
||||
this.form.text = ''
|
||||
},
|
||||
enableMemo() {
|
||||
this.chatOrMemo = 1
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
disabled() {
|
||||
return this.form.text === '' || this.loading
|
||||
return (
|
||||
(this.chatOrMemo === 0 && this.form.text === '') ||
|
||||
this.loading ||
|
||||
(this.chatOrMemo === 1 && this.form.memo.length < 5)
|
||||
)
|
||||
},
|
||||
moderatorDisabled() {
|
||||
return this.form.text === '' || this.loading || this.chatOrMemo === 1
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
<div v-if="contributionStatus === 'PENDING' || contributionStatus === 'IN_PROGRESS'">
|
||||
<contribution-messages-formular
|
||||
:contributionId="contributionId"
|
||||
:contributionMemo="contributionMemo"
|
||||
@get-list-contribution-messages="$apollo.queries.Messages.refetch()"
|
||||
@update-status="updateStatus"
|
||||
/>
|
||||
@ -33,6 +34,10 @@ export default {
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
contributionMemo: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
contributionStatus: {
|
||||
type: String,
|
||||
required: true,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="contribution-messages-list-item">
|
||||
<div class="contribution-messages-list-item clearfix">
|
||||
<div v-if="isModeratorMessage" class="text-right p-2 rounded-sm mb-3" :class="boxClass">
|
||||
<small class="ml-4" data-test="moderator-label">
|
||||
{{ $t('moderator.moderator') }}
|
||||
@ -11,7 +11,11 @@
|
||||
{{ message.userFirstName }} {{ message.userLastName }}
|
||||
</span>
|
||||
<b-avatar square variant="warning"></b-avatar>
|
||||
|
||||
<small v-if="isHistory">
|
||||
<hr />
|
||||
{{ $t('moderator.history') }}
|
||||
<hr />
|
||||
</small>
|
||||
<parse-message v-bind="message" data-test="moderator-message"></parse-message>
|
||||
<small v-if="isModeratorHiddenMessage">
|
||||
<hr />
|
||||
|
||||
@ -24,6 +24,13 @@
|
||||
</b-button>
|
||||
</div>
|
||||
</template>
|
||||
<template #cell(memo)="row">
|
||||
{{ row.value }}
|
||||
<small v-if="row.item.updatedBy > 0">
|
||||
<hr />
|
||||
{{ $t('moderator.memo-modified') }}
|
||||
</small>
|
||||
</template>
|
||||
<template #cell(editCreation)="row">
|
||||
<div v-if="!myself(row.item)">
|
||||
<b-button
|
||||
@ -104,6 +111,7 @@
|
||||
:contributionId="row.item.id"
|
||||
:contributionStatus="row.item.status"
|
||||
:contributionUserId="row.item.userId"
|
||||
:contributionMemo="row.item.memo"
|
||||
@update-status="updateStatus"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@ -30,6 +30,8 @@ export const adminListContributions = gql`
|
||||
contributionDate
|
||||
confirmedAt
|
||||
confirmedBy
|
||||
updatedAt
|
||||
updatedBy
|
||||
status
|
||||
messagesCount
|
||||
deniedAt
|
||||
|
||||
@ -109,9 +109,14 @@
|
||||
"request": "Die Anfrage wurde gesendet."
|
||||
},
|
||||
"moderator": {
|
||||
"chat": "Chat",
|
||||
"history": "Die Daten wurden geändert. Dies sind die alten Daten.",
|
||||
"moderator": "Moderator",
|
||||
"notice": "Moderator Notiz",
|
||||
"notice_tooltip": "Nur Moderatoren können die Nachricht sehen",
|
||||
"memo": "Memo",
|
||||
"memo-modify": "Memo bearbeiten",
|
||||
"memo-modified": "Memo vom Moderator bearbeitet",
|
||||
"request": "Diese Nachricht ist nur für die Moderatoren sichtbar!"
|
||||
},
|
||||
"name": "Name",
|
||||
|
||||
@ -109,9 +109,14 @@
|
||||
"request": "Request has been sent."
|
||||
},
|
||||
"moderator": {
|
||||
"chat": "Chat",
|
||||
"history": "The data has been changed. This is the old data.",
|
||||
"moderator": "Moderator",
|
||||
"notice": "Moderator note",
|
||||
"notice_tooltip": "Only moderators can see the message",
|
||||
"memo": "Memo",
|
||||
"memo-modify": "Modify Memo",
|
||||
"memo-modified": "Memo edited by moderator",
|
||||
"request": "This message is only visible to the moderators!"
|
||||
},
|
||||
"name": "Name",
|
||||
|
||||
@ -12,16 +12,16 @@ export class AdminUpdateContributionArgs {
|
||||
@IsPositive()
|
||||
id: number
|
||||
|
||||
@Field(() => Decimal)
|
||||
@Field(() => Decimal, { nullable: true })
|
||||
@IsPositiveDecimal()
|
||||
amount: Decimal
|
||||
amount?: Decimal | null
|
||||
|
||||
@Field(() => String)
|
||||
@Field(() => String, { nullable: true })
|
||||
@MaxLength(MEMO_MAX_CHARS)
|
||||
@MinLength(MEMO_MIN_CHARS)
|
||||
memo: string
|
||||
memo?: string | null
|
||||
|
||||
@Field(() => String)
|
||||
@Field(() => String, { nullable: true })
|
||||
@isValidDateString()
|
||||
creationDate: string
|
||||
creationDate?: string | null
|
||||
}
|
||||
|
||||
@ -256,10 +256,9 @@ export class ContributionResolver {
|
||||
])
|
||||
})
|
||||
const moderator = getUser(context)
|
||||
const { amount } = adminUpdateContributionArgs
|
||||
|
||||
const result = new AdminUpdateContribution()
|
||||
result.amount = amount
|
||||
result.amount = contribution.amount
|
||||
result.memo = contribution.memo
|
||||
result.date = contribution.contributionDate
|
||||
|
||||
@ -267,7 +266,7 @@ export class ContributionResolver {
|
||||
{ id: contribution.userId } as DbUser,
|
||||
moderator,
|
||||
contribution,
|
||||
amount,
|
||||
contribution.amount,
|
||||
)
|
||||
|
||||
return result
|
||||
|
||||
@ -12,8 +12,8 @@ export abstract class UnconfirmedContributionRole {
|
||||
|
||||
public constructor(
|
||||
protected self: Contribution,
|
||||
private updatedAmount: Decimal,
|
||||
private updatedCreationDate: Date,
|
||||
protected updatedAmount: Decimal,
|
||||
protected updatedCreationDate: Date,
|
||||
) {
|
||||
if (self.confirmedAt || self.deniedAt) {
|
||||
throw new LogError("this contribution isn't unconfirmed!")
|
||||
|
||||
@ -15,13 +15,17 @@ export class UnconfirmedContributionAdminRole extends UnconfirmedContributionRol
|
||||
private updateData: AdminUpdateContributionArgs,
|
||||
private moderator: User,
|
||||
) {
|
||||
super(contribution, updateData.amount, new Date(updateData.creationDate))
|
||||
super(
|
||||
contribution,
|
||||
updateData.amount ?? contribution.amount,
|
||||
updateData.creationDate ? new Date(updateData.creationDate) : contribution.contributionDate,
|
||||
)
|
||||
}
|
||||
|
||||
protected update(): void {
|
||||
this.self.amount = this.updateData.amount
|
||||
this.self.memo = this.updateData.memo
|
||||
this.self.contributionDate = new Date(this.updateData.creationDate)
|
||||
this.self.amount = this.updatedAmount
|
||||
this.self.memo = this.updateData.memo ?? this.self.memo
|
||||
this.self.contributionDate = this.updatedCreationDate
|
||||
this.self.contributionStatus = ContributionStatus.PENDING
|
||||
this.self.updatedAt = new Date()
|
||||
this.self.updatedBy = this.moderator.id
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user