diff --git a/admin/src/components/Tables/OpenCreationsTable.vue b/admin/src/components/Tables/OpenCreationsTable.vue
index aa5e88dc5..3b5dc8600 100644
--- a/admin/src/components/Tables/OpenCreationsTable.vue
+++ b/admin/src/components/Tables/OpenCreationsTable.vue
@@ -142,6 +142,10 @@ export default {
type: Array,
required: true,
},
+ filterTab: {
+ type: String,
+ required: true,
+ },
},
data() {
return {
@@ -170,7 +174,7 @@ export default {
rowItem.creation = newCreation
},
updateState(id) {
- this.$emit('update-state', id)
+ if (this.filterTab === 'open') this.$emit('update-state', id)
},
reActive() {
alert('reActive Contribution')
diff --git a/admin/src/pages/CreationConfirm.spec.js b/admin/src/pages/CreationConfirm.spec.js
index d47233ded..717f542b7 100644
--- a/admin/src/pages/CreationConfirm.spec.js
+++ b/admin/src/pages/CreationConfirm.spec.js
@@ -2,7 +2,7 @@ import { mount } from '@vue/test-utils'
import CreationConfirm from './CreationConfirm.vue'
import { adminDeleteContribution } from '../graphql/adminDeleteContribution'
import { denyContribution } from '../graphql/denyContribution'
-import { listUnconfirmedContributions } from '../graphql/listUnconfirmedContributions'
+import { listAllContributions } from '../graphql/listAllContributions'
import { confirmContribution } from '../graphql/confirmContribution'
import { toastErrorSpy, toastSuccessSpy } from '../../test/testSetup'
import VueApollo from 'vue-apollo'
@@ -38,50 +38,68 @@ const mocks = {
const defaultData = () => {
return {
- listUnconfirmedContributions: [
- {
- id: 1,
- firstName: 'Bibi',
- lastName: 'Bloxberg',
- userId: 99,
- email: 'bibi@bloxberg.de',
- amount: 500,
- memo: 'Danke für alles',
- date: new Date(),
- moderator: 1,
- state: 'PENDING',
- creation: [500, 500, 500],
- messageCount: 0,
- },
- {
- id: 2,
- firstName: 'Räuber',
- lastName: 'Hotzenplotz',
- userId: 100,
- email: 'raeuber@hotzenplotz.de',
- amount: 1000000,
- memo: 'Gut Ergattert',
- date: new Date(),
- moderator: 1,
- state: 'PENDING',
- creation: [500, 500, 500],
- messageCount: 0,
- },
- ],
+ listAllContributions: {
+ contributionCount: 2,
+ contributionList: [
+ {
+ id: 1,
+ firstName: 'Bibi',
+ lastName: 'Bloxberg',
+ userId: 99,
+ email: 'bibi@bloxberg.de',
+ amount: 500,
+ memo: 'Danke für alles',
+ date: new Date(),
+ moderator: 1,
+ state: 'PENDING',
+ creation: [500, 500, 500],
+ messagesCount: 0,
+ deniedBy: null,
+ deniedAt: null,
+ confirmedBy: null,
+ confirmedAt: null,
+ contributionDate: new Date(),
+ deletedBy: null,
+ deletedAt: null,
+ createdAt: new Date(),
+ },
+ {
+ id: 2,
+ firstName: 'Räuber',
+ lastName: 'Hotzenplotz',
+ userId: 100,
+ email: 'raeuber@hotzenplotz.de',
+ amount: 1000000,
+ memo: 'Gut Ergattert',
+ date: new Date(),
+ moderator: 1,
+ state: 'PENDING',
+ creation: [500, 500, 500],
+ messagesCount: 0,
+ deniedBy: null,
+ deniedAt: null,
+ confirmedBy: null,
+ confirmedAt: null,
+ contributionDate: new Date(),
+ deletedBy: null,
+ deletedAt: null,
+ createdAt: new Date(),
+ },
+ ],
+ },
}
}
describe('CreationConfirm', () => {
let wrapper
-
- const listUnconfirmedContributionsMock = jest.fn()
const adminDeleteContributionMock = jest.fn()
const adminDenyContributionMock = jest.fn()
const confirmContributionMock = jest.fn()
mockClient.setRequestHandler(
- listUnconfirmedContributions,
- listUnconfirmedContributionsMock
+ listAllContributions,
+ jest
+ .fn()
.mockRejectedValueOnce({ message: 'Ouch!' })
.mockResolvedValue({ data: defaultData() }),
)
@@ -125,11 +143,11 @@ describe('CreationConfirm', () => {
})
it('has two pending creations', () => {
- expect(wrapper.vm.pendingCreations).toHaveLength(2)
+ expect(wrapper.find('[data-test="tab-1"]').find('tbody').findAll('tr')).toHaveLength(2)
})
})
- describe('store', () => {
+ describe.skip('store', () => {
it('commits resetOpenCreations to store', () => {
expect(storeCommitMock).toBeCalledWith('resetOpenCreations')
})
diff --git a/admin/src/pages/CreationConfirm.vue b/admin/src/pages/CreationConfirm.vue
index 6054c658e..2b9f47cce 100644
--- a/admin/src/pages/CreationConfirm.vue
+++ b/admin/src/pages/CreationConfirm.vue
@@ -3,56 +3,43 @@
-
+
{{ $t('contributions.open') }}
{{ $store.state.openCreations }}
-
-
-
- {{ $t('contributions.confirms') }}
-
-
-
- {{ $t('contributions.denied') }}
-
-
-
- {{ $t('contributions.deleted') }}
- {{ $t('contributions.all') }}
-
-
+ :title="$t('contributions.confirms')"
+ @click="listContributions('confirmed')"
+ data-test="confirmed"
+ />
+
+
+
+ {{ contributionFilter }}
+
+
obj.id !== id)
+ this.items = this.items.filter((obj) => obj.id !== id)
this.$store.commit('openCreationsMinus', 1)
},
showOverlay(item, variant) {
@@ -184,142 +172,163 @@ export default {
this.variant = variant
},
updateState(id) {
- this.pendingCreations.find((obj) => obj.id === id).messagesCount++
- this.pendingCreations.find((obj) => obj.id === id).state = 'IN_PROGRESS'
+ this.items.find((obj) => obj.id === id).messagesCount++
+ this.items.find((obj) => obj.id === id).state = 'IN_PROGRESS'
},
},
computed: {
fields() {
- return [
- { key: 'bookmark', label: this.$t('delete') },
- { key: 'email', label: this.$t('e_mail') },
- { key: 'firstName', label: this.$t('firstname') },
- { key: 'lastName', label: this.$t('lastname') },
- {
- key: 'amount',
- label: this.$t('creation'),
- formatter: (value) => {
- return value + ' GDD'
+ if (this.filterTab === 'open') {
+ return [
+ { key: 'bookmark', label: this.$t('delete') },
+ { key: 'email', label: this.$t('e_mail') },
+ { key: 'firstName', label: this.$t('firstname') },
+ { key: 'lastName', label: this.$t('lastname') },
+ {
+ key: 'amount',
+ label: this.$t('creation'),
+ formatter: (value) => {
+ return value + ' GDD'
+ },
},
- },
- { key: 'memo', label: this.$t('text'), class: 'text-break' },
- {
- key: 'date',
- label: this.$t('date'),
- formatter: (value) => {
- return this.$d(new Date(value), 'short')
+ { key: 'memo', label: this.$t('text'), class: 'text-break' },
+ {
+ key: 'contributionDate',
+ label: this.$t('created'),
+ formatter: (value) => {
+ return this.$d(new Date(value), 'short')
+ },
},
- },
- { key: 'moderator', label: this.$t('moderator') },
- { key: 'editCreation', label: this.$t('edit') },
- { key: 'deny', label: this.$t('deny') },
- { key: 'confirm', label: this.$t('save') },
- ]
+ { key: 'moderator', label: this.$t('moderator') },
+ { key: 'editCreation', label: this.$t('edit') },
+ { key: 'deny', label: this.$t('deny') },
+ { key: 'confirm', label: this.$t('save') },
+ ]
+ }
+ if (this.filterTab === 'all') {
+ return [
+ { key: 'state', label: 'state' },
+ { key: 'firstName', label: this.$t('firstname') },
+ { key: 'lastName', label: this.$t('lastname') },
+ {
+ key: 'amount',
+ label: this.$t('creation'),
+ formatter: (value) => {
+ return value + ' GDD'
+ },
+ },
+ { key: 'memo', label: this.$t('text'), class: 'text-break' },
+ {
+ key: 'contributionDate',
+ label: this.$t('created'),
+ formatter: (value) => {
+ return this.$d(new Date(value), 'short')
+ },
+ },
+ {
+ key: 'createdAt',
+ label: this.$t('createdAt'),
+ formatter: (value) => {
+ return this.$d(new Date(value), 'short')
+ },
+ },
+ { key: 'chatCreation', label: this.$t('chat') },
+ ]
+ }
+ if (this.filterTab === 'denied') {
+ return [
+ { key: 'reActive', label: 'reActive' },
+ { key: 'firstName', label: this.$t('firstname') },
+ { key: 'lastName', label: this.$t('lastname') },
+ {
+ key: 'amount',
+ label: this.$t('creation'),
+ formatter: (value) => {
+ return value + ' GDD'
+ },
+ },
+ { key: 'memo', label: this.$t('text'), class: 'text-break' },
+ {
+ key: 'contributionDate',
+ label: this.$t('created'),
+ formatter: (value) => {
+ return this.$d(new Date(value), 'short')
+ },
+ },
+ {
+ key: 'createdAt',
+ label: this.$t('createdAt'),
+ formatter: (value) => {
+ return this.$d(new Date(value), 'short')
+ },
+ },
+ {
+ key: 'deniedAt',
+ label: this.$t('contributions.denied'),
+ formatter: (value) => {
+ return this.$d(new Date(value), 'short')
+ },
+ },
+ { key: 'deniedBy', label: this.$t('mod') },
+ { key: 'chatCreation', label: this.$t('chat') },
+ ]
+ }
+ if (this.filterTab === 'confirmed') {
+ return [
+ { key: 'firstName', label: this.$t('firstname') },
+ { key: 'lastName', label: this.$t('lastname') },
+ {
+ key: 'amount',
+ label: this.$t('creation'),
+ formatter: (value) => {
+ return value + ' GDD'
+ },
+ },
+ { key: 'memo', label: this.$t('text'), class: 'text-break' },
+ {
+ key: 'contributionDate',
+ label: this.$t('created'),
+ formatter: (value) => {
+ return this.$d(new Date(value), 'short')
+ },
+ },
+ {
+ key: 'createdAt',
+ label: this.$t('createdAt'),
+ formatter: (value) => {
+ return this.$d(new Date(value), 'short')
+ },
+ },
+ {
+ key: 'confirmedAt',
+ label: this.$t('contributions.confirms'),
+ formatter: (value) => {
+ return this.$d(new Date(value), 'short')
+ },
+ },
+ { key: 'confirmedBy', label: this.$t('mod') },
+ { key: 'chatCreation', label: this.$t('chat') },
+ ]
+ }
+ return []
},
- fieldsAllContributions() {
- return [
- { key: 'state', label: 'state' },
- { key: 'firstName', label: this.$t('firstname') },
- { key: 'lastName', label: this.$t('lastname') },
- {
- key: 'amount',
- label: this.$t('creation'),
- formatter: (value) => {
- return value + ' GDD'
- },
- },
- { key: 'memo', label: this.$t('text'), class: 'text-break' },
- {
- key: 'contributionDate',
- label: this.$t('created'),
- formatter: (value) => {
- return this.$d(new Date(value), 'short')
- },
- },
- {
- key: 'createdAt',
- label: this.$t('createdAt'),
- formatter: (value) => {
- return this.$d(new Date(value), 'short')
- },
- },
- { key: 'chatCreation', label: this.$t('chat') },
- ]
- },
- fieldsDeniedContributions() {
- return [
- { key: 'reActive', label: 'reActive' },
- { key: 'firstName', label: this.$t('firstname') },
- { key: 'lastName', label: this.$t('lastname') },
- {
- key: 'amount',
- label: this.$t('creation'),
- formatter: (value) => {
- return value + ' GDD'
- },
- },
- { key: 'memo', label: this.$t('text'), class: 'text-break' },
- {
- key: 'contributionDate',
- label: this.$t('created'),
- formatter: (value) => {
- return this.$d(new Date(value), 'short')
- },
- },
- {
- key: 'createdAt',
- label: this.$t('createdAt'),
- formatter: (value) => {
- return this.$d(new Date(value), 'short')
- },
- },
- {
- key: 'deniedAt',
- label: this.$t('contributions.denied'),
- formatter: (value) => {
- return this.$d(new Date(value), 'short')
- },
- },
- { key: 'deniedBy', label: this.$t('mod') },
- { key: 'chatCreation', label: this.$t('chat') },
- ]
- },
- fieldsConfirmContributions() {
- return [
- { key: 'firstName', label: this.$t('firstname') },
- { key: 'lastName', label: this.$t('lastname') },
- {
- key: 'amount',
- label: this.$t('creation'),
- formatter: (value) => {
- return value + ' GDD'
- },
- },
- { key: 'memo', label: this.$t('text'), class: 'text-break' },
- {
- key: 'contributionDate',
- label: this.$t('created'),
- formatter: (value) => {
- return this.$d(new Date(value), 'short')
- },
- },
- {
- key: 'createdAt',
- label: this.$t('createdAt'),
- formatter: (value) => {
- return this.$d(new Date(value), 'short')
- },
- },
- {
- key: 'confirmedAt',
- label: this.$t('contributions.confirms'),
- formatter: (value) => {
- return this.$d(new Date(value), 'short')
- },
- },
- { key: 'confirmedBy', label: this.$t('mod') },
- { key: 'chatCreation', label: this.$t('chat') },
- ]
+ contributionFilter() {
+ if (this.filterTab === 'open') {
+ return ['IN_PROGRESS', 'PENDING']
+ }
+ if (this.filterTab === 'all') {
+ return ['IN_PROGRESS', 'PENDING', 'CONFIRMED', 'DENIED']
+ }
+ if (this.filterTab === 'denied') {
+ return ['DENIED']
+ }
+ if (this.filterTab === 'confirmed') {
+ return ['CONFIRMED']
+ }
+ if (this.filterTab === 'deleted') {
+ return ['DELETED']
+ }
+ return ['IN_PROGRESS', 'PENDING']
},
overlayTitle() {
return `overlay.${this.variant}.title`
@@ -364,7 +373,7 @@ export default {
},
update({ listAllContributions }) {
this.rows = listAllContributions.contributionCount
- this.allCreations = listAllContributions.contributionList
+ this.items = listAllContributions.contributionList
},
error({ message }) {
this.toastError(message)