mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
pattern in data for ContributionForm
This commit is contained in:
parent
68e24a5973
commit
85804a1cfa
@ -36,7 +36,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
text: '',
|
||||
text: ''
|
||||
},
|
||||
}
|
||||
},
|
||||
@ -47,7 +47,7 @@ export default {
|
||||
mutation: adminCreateContributionMessage,
|
||||
variables: {
|
||||
contributionId: this.contributionId,
|
||||
message: this.form.text.replace(/(<([^>]+)>)/gi, ''),
|
||||
message: this.clearTextFromHtml,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
@ -65,6 +65,9 @@ export default {
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
clearTextFromHtml(){
|
||||
return this.form.text.replace(/(<([^>]+)>)/gi, '')
|
||||
},
|
||||
disabled() {
|
||||
if (this.form.text !== '') {
|
||||
return false
|
||||
|
||||
@ -36,7 +36,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
form: {
|
||||
text: '',
|
||||
text: ''
|
||||
},
|
||||
}
|
||||
},
|
||||
@ -47,7 +47,7 @@ export default {
|
||||
mutation: createContributionMessage,
|
||||
variables: {
|
||||
contributionId: this.contributionId,
|
||||
message: this.form.text.replace(/(<([^>]+)>)/gi, ''),
|
||||
message: this.clearTextFromHtml,
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
@ -65,6 +65,9 @@ export default {
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
clearTextFromHtml(){
|
||||
return this.form.text.replace(/(<([^>]+)>)/gi, '')
|
||||
},
|
||||
disabled() {
|
||||
if (this.form.text !== '') {
|
||||
return false
|
||||
|
||||
@ -98,17 +98,19 @@ export default {
|
||||
minlength: 5,
|
||||
maxlength: 255,
|
||||
maximalDate: new Date(),
|
||||
form: this.value, // includes 'id'
|
||||
form: this.value, // includes 'id',
|
||||
patternStripHtml: new RegExp(/(<([^>]+)>)/gi),
|
||||
patternNonDigit: new RegExp(/\D/g)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
numberFormat(value) {
|
||||
return value.replace(/\D/g, '')
|
||||
return value.replace(this.patternNonDigit, '')
|
||||
},
|
||||
submit() {
|
||||
this.form.amount = this.numberFormat(this.form.amount)
|
||||
this.form.amount = this.form.amount.replace(this.patternNonDigit, '')
|
||||
// spreading is needed for testing
|
||||
this.form.memo = this.form.memo.replace(/(<([^>]+)>)/gi, '')
|
||||
this.form.memo = this.memoStripHtml
|
||||
this.$emit(this.form.id ? 'update-contribution' : 'set-contribution', { ...this.form })
|
||||
this.reset()
|
||||
},
|
||||
@ -128,6 +130,9 @@ export default {
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
memoStripHtml() {
|
||||
return this.form.memo.replace(this.patternStripHtml)
|
||||
},
|
||||
minimalDate() {
|
||||
// sets the date to the 1st of the previous month
|
||||
let date = new Date(this.maximalDate) // has to be a new object, because of 'setMonth' changes the objects date
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user