mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
fix linting, raise coverage
This commit is contained in:
parent
f8fca7ab0c
commit
3e894d36bd
@ -108,7 +108,6 @@
|
||||
"automaticContributions": "Automatische Beiträge",
|
||||
"logout": "Abmelden",
|
||||
"my-account": "Mein Konto",
|
||||
"open_creation": "Offene Schöpfungen",
|
||||
"statistic": "Statistik",
|
||||
"user_search": "Nutzersuche"
|
||||
},
|
||||
|
||||
@ -108,7 +108,6 @@
|
||||
"automaticContributions": "Automatic Contributions",
|
||||
"logout": "Logout",
|
||||
"my-account": "My Account",
|
||||
"open_creation": "Open creations",
|
||||
"statistic": "Statistic",
|
||||
"user_search": "User search"
|
||||
},
|
||||
|
||||
@ -5,7 +5,7 @@ import { toastErrorSpy } from '../../test/testSetup'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
const apolloQueryMock = jest.fn().mockResolvedValueOnce({
|
||||
const apolloQueryMock = jest.fn().mockResolvedValue({
|
||||
data: {
|
||||
listContributionLinks: {
|
||||
links: [
|
||||
@ -47,6 +47,7 @@ describe('ContributionLinks', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
|
||||
describe('apollo returns', () => {
|
||||
it('calls listContributionLinks', () => {
|
||||
expect(apolloQueryMock).toBeCalledWith(
|
||||
@ -57,7 +58,7 @@ describe('ContributionLinks', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe.skip('query transaction with error', () => {
|
||||
describe('query transaction with error', () => {
|
||||
beforeEach(() => {
|
||||
apolloQueryMock.mockRejectedValue({ message: 'OUCH!' })
|
||||
wrapper = Wrapper()
|
||||
|
||||
@ -71,305 +71,305 @@
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import Overlay from '../components/Overlay.vue'
|
||||
import OpenCreationsTable from '../components/Tables/OpenCreationsTable.vue'
|
||||
import { listAllContributions } from '../graphql/listAllContributions'
|
||||
import { adminDeleteContribution } from '../graphql/adminDeleteContribution'
|
||||
import { confirmContribution } from '../graphql/confirmContribution'
|
||||
import { denyContribution } from '../graphql/denyContribution'
|
||||
import Overlay from '../components/Overlay.vue'
|
||||
import OpenCreationsTable from '../components/Tables/OpenCreationsTable.vue'
|
||||
import { listAllContributions } from '../graphql/listAllContributions'
|
||||
import { adminDeleteContribution } from '../graphql/adminDeleteContribution'
|
||||
import { confirmContribution } from '../graphql/confirmContribution'
|
||||
import { denyContribution } from '../graphql/denyContribution'
|
||||
|
||||
const FILTER_TAB_MAP = [
|
||||
['IN_PROGRESS', 'PENDING'],
|
||||
['CONFIRMED'],
|
||||
['DENIED'],
|
||||
['DELETED'],
|
||||
['IN_PROGRESS', 'PENDING', 'CONFIRMED', 'DENIED', 'DELETED'],
|
||||
]
|
||||
const FILTER_TAB_MAP = [
|
||||
['IN_PROGRESS', 'PENDING'],
|
||||
['CONFIRMED'],
|
||||
['DENIED'],
|
||||
['DELETED'],
|
||||
['IN_PROGRESS', 'PENDING', 'CONFIRMED', 'DENIED', 'DELETED'],
|
||||
]
|
||||
|
||||
export default {
|
||||
name: 'CreationConfirm',
|
||||
components: {
|
||||
OpenCreationsTable,
|
||||
Overlay,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tabIndex: 0,
|
||||
items: [],
|
||||
overlay: false,
|
||||
item: {},
|
||||
variant: 'confirm',
|
||||
rows: 0,
|
||||
currentPage: 1,
|
||||
pageSize: 25,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
deleteCreation() {
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: adminDeleteContribution,
|
||||
variables: {
|
||||
id: this.item.id,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
this.overlay = false
|
||||
this.updatePendingCreations(this.item.id)
|
||||
this.toastSuccess(this.$t('creation_form.toasted_delete'))
|
||||
})
|
||||
.catch((error) => {
|
||||
this.overlay = false
|
||||
this.toastError(error.message)
|
||||
})
|
||||
},
|
||||
denyCreation() {
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: denyContribution,
|
||||
variables: {
|
||||
id: this.item.id,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
this.overlay = false
|
||||
this.updatePendingCreations(this.item.id)
|
||||
this.toastSuccess(this.$t('creation_form.toasted_denied'))
|
||||
})
|
||||
.catch((error) => {
|
||||
this.overlay = false
|
||||
this.toastError(error.message)
|
||||
})
|
||||
},
|
||||
confirmCreation() {
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: confirmContribution,
|
||||
variables: {
|
||||
id: this.item.id,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
this.overlay = false
|
||||
this.updatePendingCreations(this.item.id)
|
||||
this.toastSuccess(this.$t('creation_form.toasted_created'))
|
||||
})
|
||||
.catch((error) => {
|
||||
this.overlay = false
|
||||
this.toastError(error.message)
|
||||
})
|
||||
},
|
||||
updatePendingCreations(id) {
|
||||
this.items = this.items.filter((obj) => obj.id !== id)
|
||||
this.$store.commit('openCreationsMinus', 1)
|
||||
},
|
||||
showOverlay(item, variant) {
|
||||
this.overlay = true
|
||||
this.item = item
|
||||
this.variant = variant
|
||||
},
|
||||
updateStatus(id) {
|
||||
this.items.find((obj) => obj.id === id).messagesCount++
|
||||
this.items.find((obj) => obj.id === id).state = 'IN_PROGRESS'
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
statusFilter() {
|
||||
// console.log('statusFilter', this.statusFilter)
|
||||
this.$apollo.queries.ListAllContributions.refetch()
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
fields() {
|
||||
return [
|
||||
[
|
||||
{ key: 'bookmark', label: this.$t('delete') },
|
||||
{ key: 'deny', label: this.$t('deny') },
|
||||
{ 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: '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: 'confirm', label: this.$t('save') },
|
||||
],
|
||||
[
|
||||
{ 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: 'chatCreation', label: this.$t('chat') },
|
||||
],
|
||||
[
|
||||
{ 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') },
|
||||
],
|
||||
[],
|
||||
[
|
||||
{ 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: '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') },
|
||||
],
|
||||
][this.tabIndex]
|
||||
},
|
||||
statusFilter() {
|
||||
return FILTER_TAB_MAP[this.tabIndex]
|
||||
},
|
||||
overlayTitle() {
|
||||
return `overlay.${this.variant}.title`
|
||||
},
|
||||
overlayText() {
|
||||
return `overlay.${this.variant}.text`
|
||||
},
|
||||
overlayQuestion() {
|
||||
return `overlay.${this.variant}.question`
|
||||
},
|
||||
overlayBtnText() {
|
||||
return `overlay.${this.variant}.yes`
|
||||
},
|
||||
overlayEvent() {
|
||||
return this[`${this.variant}Creation`]
|
||||
},
|
||||
overlayIcon() {
|
||||
switch (this.variant) {
|
||||
case 'confirm':
|
||||
return 'success'
|
||||
case 'deny':
|
||||
return 'warning'
|
||||
case 'delete':
|
||||
return 'danger'
|
||||
default:
|
||||
return 'info'
|
||||
}
|
||||
},
|
||||
},
|
||||
apollo: {
|
||||
ListAllContributions: {
|
||||
query() {
|
||||
return listAllContributions
|
||||
},
|
||||
variables() {
|
||||
// may be at some point we need a pagination here
|
||||
return {
|
||||
currentPage: this.currentPage,
|
||||
pageSize: this.pageSize,
|
||||
statusFilter: this.statusFilter,
|
||||
}
|
||||
},
|
||||
update({ listAllContributions }) {
|
||||
this.rows = listAllContributions.contributionCount
|
||||
this.items = listAllContributions.contributionList
|
||||
},
|
||||
error({ message }) {
|
||||
this.toastError(message)
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
export default {
|
||||
name: 'CreationConfirm',
|
||||
components: {
|
||||
OpenCreationsTable,
|
||||
Overlay,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tabIndex: 0,
|
||||
items: [],
|
||||
overlay: false,
|
||||
item: {},
|
||||
variant: 'confirm',
|
||||
rows: 0,
|
||||
currentPage: 1,
|
||||
pageSize: 25,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
deleteCreation() {
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: adminDeleteContribution,
|
||||
variables: {
|
||||
id: this.item.id,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
this.overlay = false
|
||||
this.updatePendingCreations(this.item.id)
|
||||
this.toastSuccess(this.$t('creation_form.toasted_delete'))
|
||||
})
|
||||
.catch((error) => {
|
||||
this.overlay = false
|
||||
this.toastError(error.message)
|
||||
})
|
||||
},
|
||||
denyCreation() {
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: denyContribution,
|
||||
variables: {
|
||||
id: this.item.id,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
this.overlay = false
|
||||
this.updatePendingCreations(this.item.id)
|
||||
this.toastSuccess(this.$t('creation_form.toasted_denied'))
|
||||
})
|
||||
.catch((error) => {
|
||||
this.overlay = false
|
||||
this.toastError(error.message)
|
||||
})
|
||||
},
|
||||
confirmCreation() {
|
||||
this.$apollo
|
||||
.mutate({
|
||||
mutation: confirmContribution,
|
||||
variables: {
|
||||
id: this.item.id,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
this.overlay = false
|
||||
this.updatePendingCreations(this.item.id)
|
||||
this.toastSuccess(this.$t('creation_form.toasted_created'))
|
||||
})
|
||||
.catch((error) => {
|
||||
this.overlay = false
|
||||
this.toastError(error.message)
|
||||
})
|
||||
},
|
||||
updatePendingCreations(id) {
|
||||
this.items = this.items.filter((obj) => obj.id !== id)
|
||||
this.$store.commit('openCreationsMinus', 1)
|
||||
},
|
||||
showOverlay(item, variant) {
|
||||
this.overlay = true
|
||||
this.item = item
|
||||
this.variant = variant
|
||||
},
|
||||
updateStatus(id) {
|
||||
this.items.find((obj) => obj.id === id).messagesCount++
|
||||
this.items.find((obj) => obj.id === id).state = 'IN_PROGRESS'
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
statusFilter() {
|
||||
// console.log('statusFilter', this.statusFilter)
|
||||
this.$apollo.queries.ListAllContributions.refetch()
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
fields() {
|
||||
return [
|
||||
[
|
||||
{ key: 'bookmark', label: this.$t('delete') },
|
||||
{ key: 'deny', label: this.$t('deny') },
|
||||
{ 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: '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: 'confirm', label: this.$t('save') },
|
||||
],
|
||||
[
|
||||
{ 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: 'chatCreation', label: this.$t('chat') },
|
||||
],
|
||||
[
|
||||
{ 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') },
|
||||
],
|
||||
[],
|
||||
[
|
||||
{ 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: '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') },
|
||||
],
|
||||
][this.tabIndex]
|
||||
},
|
||||
statusFilter() {
|
||||
return FILTER_TAB_MAP[this.tabIndex]
|
||||
},
|
||||
overlayTitle() {
|
||||
return `overlay.${this.variant}.title`
|
||||
},
|
||||
overlayText() {
|
||||
return `overlay.${this.variant}.text`
|
||||
},
|
||||
overlayQuestion() {
|
||||
return `overlay.${this.variant}.question`
|
||||
},
|
||||
overlayBtnText() {
|
||||
return `overlay.${this.variant}.yes`
|
||||
},
|
||||
overlayEvent() {
|
||||
return this[`${this.variant}Creation`]
|
||||
},
|
||||
overlayIcon() {
|
||||
switch (this.variant) {
|
||||
case 'confirm':
|
||||
return 'success'
|
||||
case 'deny':
|
||||
return 'warning'
|
||||
case 'delete':
|
||||
return 'danger'
|
||||
default:
|
||||
return 'info'
|
||||
}
|
||||
},
|
||||
},
|
||||
apollo: {
|
||||
ListAllContributions: {
|
||||
query() {
|
||||
return listAllContributions
|
||||
},
|
||||
variables() {
|
||||
// may be at some point we need a pagination here
|
||||
return {
|
||||
currentPage: this.currentPage,
|
||||
pageSize: this.pageSize,
|
||||
statusFilter: this.statusFilter,
|
||||
}
|
||||
},
|
||||
update({ listAllContributions }) {
|
||||
this.rows = listAllContributions.contributionCount
|
||||
this.items = listAllContributions.contributionList
|
||||
},
|
||||
error({ message }) {
|
||||
this.toastError(message)
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
#overlay {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user