diff --git a/backend/src/graphql/model/Contribution.ts b/backend/src/graphql/model/Contribution.ts
index 13c2d40d7..aa878990c 100644
--- a/backend/src/graphql/model/Contribution.ts
+++ b/backend/src/graphql/model/Contribution.ts
@@ -15,6 +15,7 @@ export class Contribution {
this.deletedAt = contribution.deletedAt
this.confirmedAt = contribution.confirmedAt
this.confirmedBy = contribution.confirmedBy
+ this.contributionDate = contribution.contributionDate
}
@Field(() => Number)
@@ -43,6 +44,9 @@ export class Contribution {
@Field(() => Number, { nullable: true })
confirmedBy: number | null
+
+ @Field(() => Date)
+ contributionDate: Date
}
@ObjectType()
diff --git a/database/entity/0039-contributions_table/User.ts b/database/entity/0039-contributions_table/User.ts
new file mode 100644
index 000000000..147ae6f6f
--- /dev/null
+++ b/database/entity/0039-contributions_table/User.ts
@@ -0,0 +1,83 @@
+import {
+ BaseEntity,
+ Entity,
+ PrimaryGeneratedColumn,
+ Column,
+ DeleteDateColumn,
+ OneToMany,
+ JoinColumn,
+} from 'typeorm'
+import { Contribution } from '../Contribution'
+
+@Entity('users', { engine: 'InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci' })
+export class User extends BaseEntity {
+ @PrimaryGeneratedColumn('increment', { unsigned: true })
+ id: number
+
+ @Column({ name: 'public_key', type: 'binary', length: 32, default: null, nullable: true })
+ pubKey: Buffer
+
+ @Column({ name: 'privkey', type: 'binary', length: 80, default: null, nullable: true })
+ privKey: Buffer
+
+ @Column({ length: 255, unique: true, nullable: false, collation: 'utf8mb4_unicode_ci' })
+ email: string
+
+ @Column({
+ name: 'first_name',
+ length: 255,
+ nullable: true,
+ default: null,
+ collation: 'utf8mb4_unicode_ci',
+ })
+ firstName: string
+
+ @Column({
+ name: 'last_name',
+ length: 255,
+ nullable: true,
+ default: null,
+ collation: 'utf8mb4_unicode_ci',
+ })
+ lastName: string
+
+ @DeleteDateColumn()
+ deletedAt: Date | null
+
+ @Column({ type: 'bigint', default: 0, unsigned: true })
+ password: BigInt
+
+ @Column({ name: 'email_hash', type: 'binary', length: 32, default: null, nullable: true })
+ emailHash: Buffer
+
+ @Column({ name: 'created', default: () => 'CURRENT_TIMESTAMP', nullable: false })
+ createdAt: Date
+
+ @Column({ name: 'email_checked', type: 'bool', nullable: false, default: false })
+ emailChecked: boolean
+
+ @Column({ length: 4, default: 'de', collation: 'utf8mb4_unicode_ci', nullable: false })
+ language: string
+
+ @Column({ name: 'is_admin', type: 'datetime', nullable: true, default: null })
+ isAdmin: Date | null
+
+ @Column({ name: 'referrer_id', type: 'int', unsigned: true, nullable: true, default: null })
+ referrerId?: number | null
+
+ @Column({ name: 'publisher_id', default: 0 })
+ publisherId: number
+
+ @Column({
+ type: 'text',
+ name: 'passphrase',
+ collation: 'utf8mb4_unicode_ci',
+ nullable: true,
+ default: null,
+ })
+ passphrase: string
+
+ @OneToMany(() => Contribution, (contribution) => contribution.user)
+ @JoinColumn({ name: 'user_id' })
+ contributions?: Contribution[]
+}
diff --git a/frontend/src/components/Contributions/ContributionForm.vue b/frontend/src/components/Contributions/ContributionForm.vue
index ecacfcafc..12714268e 100644
--- a/frontend/src/components/Contributions/ContributionForm.vue
+++ b/frontend/src/components/Contributions/ContributionForm.vue
@@ -74,7 +74,7 @@
- {{ id === null ? $t('contribution.submit') : $t('form.edit') }}
+ {{ value.id ? $t('form.edit') : $t('contribution.submit') }}
@@ -89,8 +89,6 @@ export default {
},
data() {
return {
- maxGddLastMonth: this.$store.state.creation[1],
- maxGddThisMonth: this.$store.state.creation[2],
minlength: 50,
maxlength: 255,
maximalDate: new Date(),
@@ -100,10 +98,10 @@ export default {
},
methods: {
submit() {
- if (this.id === null) {
- this.$emit('set-contribution', this.form)
+ if (this.value.id) {
+ this.$emit('update-contribution', this.form)
} else {
- this.$emit('edit-contribution', this.form)
+ this.$emit('set-contribution', this.form)
}
this.reset()
},
@@ -137,20 +135,36 @@ export default {
// new Date().getMonth === 1 If the current month is January, then one year must be gone back in the previous month
const obj = {
monthAndYear: this.$d(new Date(this.minimalDate), 'monthAndYear'),
- creation: this.$store.state.creation[1],
+ creation: this.id
+ ? this.$store.state.creation[1] + this.form.amount
+ : this.$store.state.creation[1],
}
return this.$t('contribution.formText.openAmountForMonth', obj)
},
thisMonthObject() {
const obj = {
monthAndYear: this.$d(new Date(), 'monthAndYear'),
- creation: this.$store.state.creation[2],
+ creation: this.id
+ ? parseInt(this.$store.state.creation[2]) + parseInt(this.form.amount)
+ : this.$store.state.creation[2],
}
return this.$t('contribution.formText.openAmountForMonth', obj)
},
isThisMonth() {
return new Date(this.form.date).getMonth() === new Date().getMonth()
},
+ maxGddLastMonth() {
+ // When edited, the amount is added back on top of the amount
+ return this.id
+ ? parseInt(this.$store.state.creation[1]) + parseInt(this.form.amount)
+ : this.$store.state.creation[1]
+ },
+ maxGddThisMonth() {
+ // When edited, the amount is added back on top of the amount
+ return this.id
+ ? parseInt(this.$store.state.creation[2]) + parseInt(this.form.amount)
+ : this.$store.state.creation[2]
+ },
},
}
diff --git a/frontend/src/components/Contributions/ContributionList.vue b/frontend/src/components/Contributions/ContributionList.vue
index 64fb61450..4e8c68eb7 100644
--- a/frontend/src/components/Contributions/ContributionList.vue
+++ b/frontend/src/components/Contributions/ContributionList.vue
@@ -1,7 +1,11 @@
-
+
{{ $d(new Date(date), 'short') }}
{{ memo }}
-
@@ -54,6 +58,9 @@ export default {
createdAt: {
type: String,
},
+ contributionDate: {
+ type: String,
+ },
deletedAt: {
type: String,
},
@@ -83,13 +90,21 @@ export default {
date() {
if (this.deletedAt) return this.deletedAt
if (this.confirmedAt) return this.confirmedAt
- return this.createdAt
+ return this.contributionDate
},
},
methods: {
updateContributionForm(item) {
this.$emit('update-contribution-form', item)
},
+ deleteContribution(id) {
+ this.boxOne = ''
+ this.$bvModal.msgBoxConfirm('Delete Contribution! Are you sure?').then((value) => {
+ this.$emit('delete-contribution', {
+ id: id,
+ })
+ })
+ },
},
}
diff --git a/frontend/src/graphql/mutations.js b/frontend/src/graphql/mutations.js
index 4e2e2b2e2..ec1f5a410 100644
--- a/frontend/src/graphql/mutations.js
+++ b/frontend/src/graphql/mutations.js
@@ -113,3 +113,9 @@ export const updateContribution = gql`
}
}
`
+
+export const deleteContribution = gql`
+ mutation($id: Int!) {
+ deleteContribution(id: $id)
+ }
+`
diff --git a/frontend/src/graphql/queries.js b/frontend/src/graphql/queries.js
index c2ecfb00e..b74770227 100644
--- a/frontend/src/graphql/queries.js
+++ b/frontend/src/graphql/queries.js
@@ -182,8 +182,10 @@ export const listContributions = gql`
amount
memo
createdAt
+ contributionDate
confirmedAt
confirmedBy
+ deletedAt
}
}
}
@@ -200,6 +202,7 @@ export const listAllContributions = gql`
amount
memo
createdAt
+ contributionDate
confirmedAt
confirmedBy
}
diff --git a/frontend/src/pages/Community.vue b/frontend/src/pages/Community.vue
index e87cba63f..860be3af8 100644
--- a/frontend/src/pages/Community.vue
+++ b/frontend/src/pages/Community.vue
@@ -6,6 +6,7 @@
@@ -36,7 +37,7 @@