mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
localized message
This commit is contained in:
parent
a1b1142128
commit
3b9a553513
@ -249,9 +249,7 @@ describe('Community', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('toasts an info', () => {
|
it('toasts an info', () => {
|
||||||
expect(toastInfoSpy).toBeCalledWith(
|
expect(toastInfoSpy).toBeCalledWith('contribution.alert.answerQuestionToast')
|
||||||
'contribution.alert.answerQuestionToast',
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -48,258 +48,258 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import OpenCreationsAmount from '@/components/Contributions/OpenCreationsAmount.vue'
|
import OpenCreationsAmount from '@/components/Contributions/OpenCreationsAmount.vue'
|
||||||
import ContributionForm from '@/components/Contributions/ContributionForm.vue'
|
import ContributionForm from '@/components/Contributions/ContributionForm.vue'
|
||||||
import ContributionList from '@/components/Contributions/ContributionList.vue'
|
import ContributionList from '@/components/Contributions/ContributionList.vue'
|
||||||
import { createContribution, updateContribution, deleteContribution } from '@/graphql/mutations'
|
import { createContribution, updateContribution, deleteContribution } from '@/graphql/mutations'
|
||||||
import { listContributions, listAllContributions, openCreations } from '@/graphql/queries'
|
import { listContributions, listAllContributions, openCreations } from '@/graphql/queries'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Community',
|
name: 'Community',
|
||||||
components: {
|
components: {
|
||||||
ContributionForm,
|
ContributionForm,
|
||||||
ContributionList,
|
ContributionList,
|
||||||
OpenCreationsAmount,
|
OpenCreationsAmount,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
hashLink: '',
|
hashLink: '',
|
||||||
tabLinkHashes: ['#edit', '#my', '#all'],
|
tabLinkHashes: ['#edit', '#my', '#all'],
|
||||||
tabIndex: 0,
|
tabIndex: 0,
|
||||||
items: [],
|
items: [],
|
||||||
itemsAll: [],
|
itemsAll: [],
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 25,
|
pageSize: 25,
|
||||||
currentPageAll: 1,
|
currentPageAll: 1,
|
||||||
pageSizeAll: 25,
|
pageSizeAll: 25,
|
||||||
contributionCount: 0,
|
contributionCount: 0,
|
||||||
contributionCountAll: 0,
|
contributionCountAll: 0,
|
||||||
form: {
|
form: {
|
||||||
id: null,
|
id: null,
|
||||||
date: '',
|
date: '',
|
||||||
memo: '',
|
memo: '',
|
||||||
hours: 0,
|
hours: 0,
|
||||||
amount: '',
|
amount: '',
|
||||||
},
|
},
|
||||||
updateAmount: '',
|
updateAmount: '',
|
||||||
maximalDate: new Date(),
|
maximalDate: new Date(),
|
||||||
openCreations: [],
|
openCreations: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.tabIndex = this.tabLinkHashes.findIndex((hashLink) => hashLink === this.$route.hash)
|
this.tabIndex = this.tabLinkHashes.findIndex((hashLink) => hashLink === this.$route.hash)
|
||||||
this.hashLink = this.$route.hash
|
this.hashLink = this.$route.hash
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
apollo: {
|
apollo: {
|
||||||
OpenCreations: {
|
OpenCreations: {
|
||||||
query() {
|
query() {
|
||||||
return openCreations
|
return openCreations
|
||||||
},
|
},
|
||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
variables() {
|
variables() {
|
||||||
return {}
|
return {}
|
||||||
},
|
},
|
||||||
update({ openCreations }) {
|
update({ openCreations }) {
|
||||||
this.openCreations = openCreations
|
this.openCreations = openCreations
|
||||||
},
|
},
|
||||||
error({ message }) {
|
error({ message }) {
|
||||||
this.toastError(message)
|
this.toastError(message)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ListAllContributions: {
|
ListAllContributions: {
|
||||||
query() {
|
query() {
|
||||||
return listAllContributions
|
return listAllContributions
|
||||||
},
|
},
|
||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
variables() {
|
variables() {
|
||||||
return {
|
return {
|
||||||
currentPage: this.currentPageAll,
|
currentPage: this.currentPageAll,
|
||||||
pageSize: this.pageSizeAll,
|
pageSize: this.pageSizeAll,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
update({ listAllContributions }) {
|
update({ listAllContributions }) {
|
||||||
this.contributionCountAll = listAllContributions.contributionCount
|
this.contributionCountAll = listAllContributions.contributionCount
|
||||||
this.itemsAll = listAllContributions.contributionList
|
this.itemsAll = listAllContributions.contributionList
|
||||||
},
|
},
|
||||||
error({ message }) {
|
error({ message }) {
|
||||||
this.toastError(message)
|
this.toastError(message)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ListContributions: {
|
ListContributions: {
|
||||||
query() {
|
query() {
|
||||||
return listContributions
|
return listContributions
|
||||||
},
|
},
|
||||||
fetchPolicy: 'network-only',
|
fetchPolicy: 'network-only',
|
||||||
variables() {
|
variables() {
|
||||||
return {
|
return {
|
||||||
currentPage: this.currentPage,
|
currentPage: this.currentPage,
|
||||||
pageSize: this.pageSize,
|
pageSize: this.pageSize,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
update({ listContributions }) {
|
update({ listContributions }) {
|
||||||
this.contributionCount = listContributions.contributionCount
|
this.contributionCount = listContributions.contributionCount
|
||||||
this.items = listContributions.contributionList
|
this.items = listContributions.contributionList
|
||||||
if (this.items.find((item) => item.state === 'IN_PROGRESS')) {
|
if (this.items.find((item) => item.state === 'IN_PROGRESS')) {
|
||||||
this.tabIndex = 1
|
this.tabIndex = 1
|
||||||
if (this.$route.hash !== '#my') {
|
if (this.$route.hash !== '#my') {
|
||||||
this.$router.push({ path: '/community#my' })
|
this.$router.push({ path: '/community#my' })
|
||||||
}
|
}
|
||||||
this.toastInfo(this.$t('contribution.alert.answerQuestionToast'))
|
this.toastInfo(this.$t('contribution.alert.answerQuestionToast'))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error({ message }) {
|
error({ message }) {
|
||||||
this.toastError(message)
|
this.toastError(message)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
$route(to, from) {
|
$route(to, from) {
|
||||||
this.tabIndex = this.tabLinkHashes.findIndex((hashLink) => hashLink === to.hash)
|
this.tabIndex = this.tabLinkHashes.findIndex((hashLink) => hashLink === to.hash)
|
||||||
this.hashLink = to.hash
|
this.hashLink = to.hash
|
||||||
this.closeAllOpenCollapse()
|
this.closeAllOpenCollapse()
|
||||||
},
|
},
|
||||||
tabIndex(num) {
|
tabIndex(num) {
|
||||||
if (num !== 0) {
|
if (num !== 0) {
|
||||||
this.form = {
|
this.form = {
|
||||||
id: null,
|
id: null,
|
||||||
date: new Date(),
|
date: new Date(),
|
||||||
memo: '',
|
memo: '',
|
||||||
hours: 0,
|
hours: 0,
|
||||||
amount: '',
|
amount: '',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
minimalDate() {
|
minimalDate() {
|
||||||
const date = new Date(this.maximalDate)
|
const date = new Date(this.maximalDate)
|
||||||
return new Date(date.setMonth(date.getMonth() - 1, 1))
|
return new Date(date.setMonth(date.getMonth() - 1, 1))
|
||||||
},
|
},
|
||||||
isThisMonth() {
|
isThisMonth() {
|
||||||
const formDate = new Date(this.form.date)
|
const formDate = new Date(this.form.date)
|
||||||
return (
|
return (
|
||||||
formDate.getFullYear() === this.maximalDate.getFullYear() &&
|
formDate.getFullYear() === this.maximalDate.getFullYear() &&
|
||||||
formDate.getMonth() === this.maximalDate.getMonth()
|
formDate.getMonth() === this.maximalDate.getMonth()
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
amountToAdd() {
|
amountToAdd() {
|
||||||
// when existing contribution is edited, the amount is added back on top of the amount
|
// when existing contribution is edited, the amount is added back on top of the amount
|
||||||
if (this.form.id) return parseInt(this.updateAmount)
|
if (this.form.id) return parseInt(this.updateAmount)
|
||||||
return 0
|
return 0
|
||||||
},
|
},
|
||||||
maxForMonths() {
|
maxForMonths() {
|
||||||
const formDate = new Date(this.form.date)
|
const formDate = new Date(this.form.date)
|
||||||
if (this.openCreations && this.openCreations.length)
|
if (this.openCreations && this.openCreations.length)
|
||||||
return this.openCreations.slice(1).map((creation) => {
|
return this.openCreations.slice(1).map((creation) => {
|
||||||
if (creation.year === formDate.getFullYear() && creation.month === formDate.getMonth())
|
if (creation.year === formDate.getFullYear() && creation.month === formDate.getMonth())
|
||||||
return parseInt(creation.amount) + this.amountToAdd
|
return parseInt(creation.amount) + this.amountToAdd
|
||||||
return parseInt(creation.amount)
|
return parseInt(creation.amount)
|
||||||
})
|
})
|
||||||
return [0, 0]
|
return [0, 0]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
closeAllOpenCollapse() {
|
closeAllOpenCollapse() {
|
||||||
this.$el.querySelectorAll('.collapse.show').forEach((value) => {
|
this.$el.querySelectorAll('.collapse.show').forEach((value) => {
|
||||||
this.$root.$emit('bv::toggle::collapse', value.id)
|
this.$root.$emit('bv::toggle::collapse', value.id)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
refetchData() {
|
refetchData() {
|
||||||
this.$apollo.queries.ListAllContributions.refetch()
|
this.$apollo.queries.ListAllContributions.refetch()
|
||||||
this.$apollo.queries.ListContributions.refetch()
|
this.$apollo.queries.ListContributions.refetch()
|
||||||
this.$apollo.queries.OpenCreations.refetch()
|
this.$apollo.queries.OpenCreations.refetch()
|
||||||
},
|
},
|
||||||
saveContribution(data) {
|
saveContribution(data) {
|
||||||
this.$apollo
|
this.$apollo
|
||||||
.mutate({
|
.mutate({
|
||||||
fetchPolicy: 'no-cache',
|
fetchPolicy: 'no-cache',
|
||||||
mutation: createContribution,
|
mutation: createContribution,
|
||||||
variables: {
|
variables: {
|
||||||
creationDate: data.date,
|
creationDate: data.date,
|
||||||
memo: data.memo,
|
memo: data.memo,
|
||||||
amount: data.amount,
|
amount: data.amount,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
this.toastSuccess(this.$t('contribution.submitted'))
|
this.toastSuccess(this.$t('contribution.submitted'))
|
||||||
this.refetchData()
|
this.refetchData()
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
this.toastError(err.message)
|
this.toastError(err.message)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateContribution(data) {
|
updateContribution(data) {
|
||||||
this.$apollo
|
this.$apollo
|
||||||
.mutate({
|
.mutate({
|
||||||
fetchPolicy: 'no-cache',
|
fetchPolicy: 'no-cache',
|
||||||
mutation: updateContribution,
|
mutation: updateContribution,
|
||||||
variables: {
|
variables: {
|
||||||
contributionId: data.id,
|
contributionId: data.id,
|
||||||
creationDate: data.date,
|
creationDate: data.date,
|
||||||
memo: data.memo,
|
memo: data.memo,
|
||||||
amount: data.amount,
|
amount: data.amount,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
this.toastSuccess(this.$t('contribution.updated'))
|
this.toastSuccess(this.$t('contribution.updated'))
|
||||||
this.refetchData()
|
this.refetchData()
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
this.toastError(err.message)
|
this.toastError(err.message)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
deleteContribution(data) {
|
deleteContribution(data) {
|
||||||
this.$apollo
|
this.$apollo
|
||||||
.mutate({
|
.mutate({
|
||||||
fetchPolicy: 'no-cache',
|
fetchPolicy: 'no-cache',
|
||||||
mutation: deleteContribution,
|
mutation: deleteContribution,
|
||||||
variables: {
|
variables: {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
this.toastSuccess(this.$t('contribution.deleted'))
|
this.toastSuccess(this.$t('contribution.deleted'))
|
||||||
this.refetchData()
|
this.refetchData()
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
this.toastError(err.message)
|
this.toastError(err.message)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateListAllContributions(pagination) {
|
updateListAllContributions(pagination) {
|
||||||
this.currentPageAll = pagination.currentPage
|
this.currentPageAll = pagination.currentPage
|
||||||
this.pageSizeAll = pagination.pageSize
|
this.pageSizeAll = pagination.pageSize
|
||||||
this.$apollo.queries.ListAllContributions.refetch()
|
this.$apollo.queries.ListAllContributions.refetch()
|
||||||
},
|
},
|
||||||
updateListContributions(pagination) {
|
updateListContributions(pagination) {
|
||||||
this.currentPage = pagination.currentPage
|
this.currentPage = pagination.currentPage
|
||||||
this.pageSize = pagination.pageSize
|
this.pageSize = pagination.pageSize
|
||||||
this.$apollo.queries.ListContributions.refetch()
|
this.$apollo.queries.ListContributions.refetch()
|
||||||
},
|
},
|
||||||
updateContributionForm(item) {
|
updateContributionForm(item) {
|
||||||
this.form.id = item.id
|
this.form.id = item.id
|
||||||
this.form.date = item.contributionDate
|
this.form.date = item.contributionDate
|
||||||
this.form.memo = item.memo
|
this.form.memo = item.memo
|
||||||
this.form.amount = item.amount
|
this.form.amount = item.amount
|
||||||
this.form.hours = item.amount / 20
|
this.form.hours = item.amount / 20
|
||||||
this.updateAmount = item.amount
|
this.updateAmount = item.amount
|
||||||
this.$router.push({ path: '#edit' })
|
this.$router.push({ path: '#edit' })
|
||||||
this.tabIndex = 0
|
this.tabIndex = 0
|
||||||
},
|
},
|
||||||
updateTransactions(pagination) {
|
updateTransactions(pagination) {
|
||||||
this.$emit('update-transactions', pagination)
|
this.$emit('update-transactions', pagination)
|
||||||
},
|
},
|
||||||
updateState(id) {
|
updateState(id) {
|
||||||
this.items.find((item) => item.id === id).state = 'PENDING'
|
this.items.find((item) => item.id === id).state = 'PENDING'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.updateTransactions(0)
|
this.updateTransactions(0)
|
||||||
this.tabIndex = 1
|
this.tabIndex = 1
|
||||||
this.$router.push({ path: '/community#my' })
|
this.$router.push({ path: '/community#my' })
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.tab-content {
|
.tab-content {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user