mirror of
https://github.com/IT4Change/gradido.git
synced 2026-03-01 12:44:43 +00:00
move date pick logic by contribution state into backend
This commit is contained in:
parent
4d1eaba6cf
commit
8b8e6cfa0d
@ -99,9 +99,6 @@
|
|||||||
</BButton>
|
</BButton>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #cell(closed)="row">
|
|
||||||
{{ formatDateOrDash(getClosedDate(row.item)) }}
|
|
||||||
</template>
|
|
||||||
<template #row-details="row">
|
<template #row-details="row">
|
||||||
<row-details
|
<row-details
|
||||||
:row="row"
|
:row="row"
|
||||||
@ -214,16 +211,6 @@ export default {
|
|||||||
if (item.contributionStatus === 'IN_PROGRESS') return 'table-primary'
|
if (item.contributionStatus === 'IN_PROGRESS') return 'table-primary'
|
||||||
if (item.contributionStatus === 'PENDING') return 'table-primary'
|
if (item.contributionStatus === 'PENDING') return 'table-primary'
|
||||||
},
|
},
|
||||||
getClosedDate(item) {
|
|
||||||
if (item.contributionStatus === 'CONFIRMED') {
|
|
||||||
return item.confirmedAt
|
|
||||||
} else if (item.contributionStatus === 'DENIED') {
|
|
||||||
return item.deniedAt
|
|
||||||
} else if (item.contributionStatus === 'DELETED') {
|
|
||||||
return item.deletedAt
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
},
|
|
||||||
updateStatus(id) {
|
updateStatus(id) {
|
||||||
this.$emit('update-status', id)
|
this.$emit('update-status', id)
|
||||||
},
|
},
|
||||||
@ -251,22 +238,18 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
isAddCommentToMemo(item) {
|
isAddCommentToMemo(item) {
|
||||||
return (
|
return item.closedBy > 0 || item.moderatorId > 0 || item.updatedBy > 0
|
||||||
item.updatedBy > 0 ||
|
|
||||||
item.confirmedBy > 0 ||
|
|
||||||
item.deletedBy > 0 ||
|
|
||||||
item.deniedBy > 0 ||
|
|
||||||
item.moderatorId > 0
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
getMemoComment(item) {
|
getMemoComment(item) {
|
||||||
let comment = ''
|
let comment = ''
|
||||||
if (item.confirmedBy > 0) {
|
if (item.closedBy > 0) {
|
||||||
comment = this.$t('contribution.confirmedBy', { name: item.confirmedByUserName })
|
if (item.contributionStatus === 'CONFIRMED') {
|
||||||
} else if (item.deletedBy > 0) {
|
comment = this.$t('contribution.confirmedBy', { name: item.closedByUserName })
|
||||||
comment = this.$t('contribution.deletedBy', { name: item.deletedByUserName })
|
} else if (item.contributionStatus === 'DENIED') {
|
||||||
} else if (item.deniedBy > 0) {
|
comment = this.$t('contribution.deniedBy', { name: item.closedByUserName })
|
||||||
comment = this.$t('contribution.deniedBy', { name: item.deniedByUserName })
|
} else if (item.contributionStatus === 'DELETED') {
|
||||||
|
comment = this.$t('contribution.deletedBy', { name: item.closedByUserName })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.updatedBy > 0) {
|
if (item.updatedBy > 0) {
|
||||||
|
|||||||
@ -19,22 +19,16 @@ query adminListContributions(
|
|||||||
}
|
}
|
||||||
amount
|
amount
|
||||||
memo
|
memo
|
||||||
createdAt
|
closedAt
|
||||||
|
closedBy
|
||||||
|
closedByUserName
|
||||||
contributionDate
|
contributionDate
|
||||||
confirmedAt
|
createdAt
|
||||||
confirmedBy
|
|
||||||
confirmedByUserName
|
|
||||||
updatedAt
|
updatedAt
|
||||||
updatedBy
|
updatedBy
|
||||||
updatedByUserName
|
updatedByUserName
|
||||||
contributionStatus
|
contributionStatus
|
||||||
messagesCount
|
messagesCount
|
||||||
deniedAt
|
|
||||||
deniedBy
|
|
||||||
deniedByUserName
|
|
||||||
deletedAt
|
|
||||||
deletedBy
|
|
||||||
deletedByUserName
|
|
||||||
moderatorId
|
moderatorId
|
||||||
moderatorUserName
|
moderatorUserName
|
||||||
userId
|
userId
|
||||||
|
|||||||
@ -154,9 +154,9 @@ const baseFields = {
|
|||||||
class: 'no-select',
|
class: 'no-select',
|
||||||
formatter: formatDateOrDash,
|
formatter: formatDateOrDash,
|
||||||
},
|
},
|
||||||
confirmedAt: {
|
closedAt: {
|
||||||
key: 'confirmedAt',
|
key: 'closedAt',
|
||||||
label: t('contributions.confirms'),
|
label: t('contributions.closed'),
|
||||||
class: 'no-select',
|
class: 'no-select',
|
||||||
formatter: formatDateOrDash,
|
formatter: formatDateOrDash,
|
||||||
},
|
},
|
||||||
@ -185,7 +185,7 @@ const fields = computed(
|
|||||||
baseFields.memo,
|
baseFields.memo,
|
||||||
baseFields.contributionDate,
|
baseFields.contributionDate,
|
||||||
baseFields.createdAt,
|
baseFields.createdAt,
|
||||||
baseFields.confirmedAt,
|
baseFields.closedAt,
|
||||||
{ key: 'chatCreation', label: t('details') },
|
{ key: 'chatCreation', label: t('details') },
|
||||||
],
|
],
|
||||||
// denied contributions
|
// denied contributions
|
||||||
@ -196,11 +196,7 @@ const fields = computed(
|
|||||||
baseFields.memo,
|
baseFields.memo,
|
||||||
baseFields.contributionDate,
|
baseFields.contributionDate,
|
||||||
baseFields.createdAt,
|
baseFields.createdAt,
|
||||||
{
|
baseFields.closedAt,
|
||||||
key: 'deniedAt',
|
|
||||||
label: t('contributions.denied'),
|
|
||||||
formatter: formatDateOrDash,
|
|
||||||
},
|
|
||||||
{ key: 'chatCreation', label: t('details') },
|
{ key: 'chatCreation', label: t('details') },
|
||||||
],
|
],
|
||||||
// deleted contributions
|
// deleted contributions
|
||||||
@ -211,11 +207,7 @@ const fields = computed(
|
|||||||
baseFields.memo,
|
baseFields.memo,
|
||||||
baseFields.contributionDate,
|
baseFields.contributionDate,
|
||||||
baseFields.createdAt,
|
baseFields.createdAt,
|
||||||
{
|
baseFields.closedAt,
|
||||||
key: 'deletedAt',
|
|
||||||
label: t('contributions.deleted'),
|
|
||||||
formatter: formatDateOrDash,
|
|
||||||
},
|
|
||||||
{ key: 'chatCreation', label: t('details') },
|
{ key: 'chatCreation', label: t('details') },
|
||||||
],
|
],
|
||||||
// all contributions
|
// all contributions
|
||||||
@ -227,11 +219,7 @@ const fields = computed(
|
|||||||
baseFields.memo,
|
baseFields.memo,
|
||||||
baseFields.contributionDate,
|
baseFields.contributionDate,
|
||||||
baseFields.createdAt,
|
baseFields.createdAt,
|
||||||
{
|
baseFields.closedAt,
|
||||||
key: 'closed',
|
|
||||||
label: t('contributions.closed'),
|
|
||||||
class: 'no-select',
|
|
||||||
},
|
|
||||||
{ key: 'chatCreation', label: t('details') },
|
{ key: 'chatCreation', label: t('details') },
|
||||||
],
|
],
|
||||||
][tabIndex.value],
|
][tabIndex.value],
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
import { ContributionStatus } from '@enum/ContributionStatus'
|
||||||
import { Contribution as DbContribution } from 'database'
|
import { Contribution as DbContribution } from 'database'
|
||||||
import { Field, Int, ObjectType } from 'type-graphql'
|
import { Field, Int, ObjectType } from 'type-graphql'
|
||||||
import { UnconfirmedContribution } from './UnconfirmedContribution'
|
import { UnconfirmedContribution } from './UnconfirmedContribution'
|
||||||
@ -19,8 +20,28 @@ export class Contribution extends UnconfirmedContribution {
|
|||||||
this.updatedAt = dbContribution.updatedAt
|
this.updatedAt = dbContribution.updatedAt
|
||||||
this.updatedBy = dbContribution.updatedBy
|
this.updatedBy = dbContribution.updatedBy
|
||||||
this.resubmissionAt = dbContribution.resubmissionAt
|
this.resubmissionAt = dbContribution.resubmissionAt
|
||||||
|
if( ContributionStatus.CONFIRMED === dbContribution.contributionStatus) {
|
||||||
|
this.closedAt = dbContribution.confirmedAt
|
||||||
|
this.closedBy = dbContribution.confirmedBy
|
||||||
|
} else if (ContributionStatus.DELETED === dbContribution.contributionStatus) {
|
||||||
|
this.closedAt = dbContribution.deletedAt
|
||||||
|
this.closedBy = dbContribution.deletedBy
|
||||||
|
} else if (ContributionStatus.DENIED === dbContribution.contributionStatus ) {
|
||||||
|
this.closedAt = dbContribution.deniedAt
|
||||||
|
this.closedBy = dbContribution.deniedBy
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Field(() => Date, { nullable: true })
|
||||||
|
closedAt?: Date | null
|
||||||
|
|
||||||
|
@Field(() => Int, { nullable: true })
|
||||||
|
closedBy?: number | null
|
||||||
|
|
||||||
|
@Field(() => String, { nullable: true })
|
||||||
|
closedByUserName?: string | null
|
||||||
|
|
||||||
@Field(() => Date)
|
@Field(() => Date)
|
||||||
createdAt: Date
|
createdAt: Date
|
||||||
|
|
||||||
@ -36,27 +57,18 @@ export class Contribution extends UnconfirmedContribution {
|
|||||||
@Field(() => Int, { nullable: true })
|
@Field(() => Int, { nullable: true })
|
||||||
confirmedBy: number | null
|
confirmedBy: number | null
|
||||||
|
|
||||||
@Field(() => String, { nullable: true })
|
|
||||||
confirmedByUserName?: string | null
|
|
||||||
|
|
||||||
@Field(() => Date, { nullable: true })
|
@Field(() => Date, { nullable: true })
|
||||||
deniedAt: Date | null
|
deniedAt: Date | null
|
||||||
|
|
||||||
@Field(() => Int, { nullable: true })
|
@Field(() => Int, { nullable: true })
|
||||||
deniedBy: number | null
|
deniedBy: number | null
|
||||||
|
|
||||||
@Field(() => String, { nullable: true })
|
|
||||||
deniedByUserName?: string | null
|
|
||||||
|
|
||||||
@Field(() => Date, { nullable: true })
|
@Field(() => Date, { nullable: true })
|
||||||
deletedAt: Date | null
|
deletedAt: Date | null
|
||||||
|
|
||||||
@Field(() => Int, { nullable: true })
|
@Field(() => Int, { nullable: true })
|
||||||
deletedBy: number | null
|
deletedBy: number | null
|
||||||
|
|
||||||
@Field(() => String, { nullable: true })
|
|
||||||
deletedByUserName?: string | null
|
|
||||||
|
|
||||||
@Field(() => Date, { nullable: true })
|
@Field(() => Date, { nullable: true })
|
||||||
updatedAt: Date | null
|
updatedAt: Date | null
|
||||||
|
|
||||||
|
|||||||
@ -372,27 +372,24 @@ export class ContributionResolver {
|
|||||||
},
|
},
|
||||||
countOnly,
|
countOnly,
|
||||||
)
|
)
|
||||||
|
console.log(dbContributions)
|
||||||
const result = new ContributionListResult(count, dbContributions)
|
const result = new ContributionListResult(count, dbContributions)
|
||||||
|
|
||||||
const uniqueUserIds = new Set<number>()
|
const uniqueUserIds = new Set<number>()
|
||||||
const addIfExist = (userId?: number | null) => (userId ? uniqueUserIds.add(userId) : null)
|
const addIfExist = (userId?: number | null) => (userId ? uniqueUserIds.add(userId) : null)
|
||||||
|
|
||||||
for (const contribution of result.contributionList) {
|
for (const contribution of result.contributionList) {
|
||||||
addIfExist(contribution.confirmedBy)
|
|
||||||
addIfExist(contribution.updatedBy)
|
addIfExist(contribution.updatedBy)
|
||||||
addIfExist(contribution.moderatorId)
|
addIfExist(contribution.moderatorId)
|
||||||
addIfExist(contribution.deletedBy)
|
addIfExist(contribution.closedBy)
|
||||||
addIfExist(contribution.deniedBy)
|
|
||||||
}
|
}
|
||||||
const users = await findUserNamesByIds(Array.from(uniqueUserIds))
|
const users = await findUserNamesByIds(Array.from(uniqueUserIds))
|
||||||
const getNameById = (userId?: number | null) => (userId ? (users.get(userId) ?? null) : null)
|
const getNameById = (userId?: number | null) => (userId ? (users.get(userId) ?? null) : null)
|
||||||
|
|
||||||
for (const contribution of result.contributionList) {
|
for (const contribution of result.contributionList) {
|
||||||
contribution.confirmedByUserName = getNameById(contribution.confirmedBy)
|
|
||||||
contribution.updatedByUserName = getNameById(contribution.updatedBy)
|
contribution.updatedByUserName = getNameById(contribution.updatedBy)
|
||||||
contribution.moderatorUserName = getNameById(contribution.moderatorId)
|
contribution.moderatorUserName = getNameById(contribution.moderatorId)
|
||||||
contribution.deletedByUserName = getNameById(contribution.deletedBy)
|
contribution.closedByUserName = getNameById(contribution.closedBy)
|
||||||
contribution.deniedByUserName = getNameById(contribution.deniedBy)
|
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user