pattern const added

This commit is contained in:
ogerly 2022-10-14 13:31:34 +02:00
parent 67dbbfae48
commit 90dfd1063b
3 changed files with 13 additions and 8 deletions

View File

@ -25,6 +25,8 @@
<script>
import { adminCreateContributionMessage } from '@/graphql/adminCreateContributionMessage'
const STRIP_HTML_PATTERN = /(<([^>]+)>)/gi
export default {
name: 'ContributionMessagesFormular',
props: {
@ -66,7 +68,7 @@ export default {
},
computed: {
clearTextFromHtml() {
return this.form.text.replace(/(<([^>]+)>)/gi, '')
return this.form.text.replace(STRIP_HTML_PATTERN, '')
},
disabled() {
if (this.form.text !== '') {

View File

@ -25,6 +25,8 @@
<script>
import { createContributionMessage } from '../../graphql/mutations.js'
const STRIP_HTML_PATTERN = /(<([^>]+)>)/gi
export default {
name: 'ContributionMessagesFormular',
props: {
@ -66,7 +68,7 @@ export default {
},
computed: {
clearTextFromHtml() {
return this.form.text.replace(/(<([^>]+)>)/gi, '')
return this.form.text.replace(STRIP_HTML_PATTERN, '')
},
disabled() {
if (this.form.text !== '') {

View File

@ -87,6 +87,9 @@
</div>
</template>
<script>
const PATTERN_STRIP_HTML = /(<([^>]+)>)/gi
const PATTERN_NON_DIGIT = /\D/g
export default {
name: 'ContributionForm',
props: {
@ -98,17 +101,15 @@ export default {
minlength: 5,
maxlength: 255,
maximalDate: new Date(),
form: this.value, // includes 'id',
patternStripHtml: new RegExp(/(<([^>]+)>)/gi),
patternNonDigit: new RegExp(/\D/g),
form: this.value, // includes 'id'
}
},
methods: {
numberFormat(value) {
return value.replace(this.patternNonDigit, '')
return value.replace(PATTERN_NON_DIGIT, '')
},
submit() {
this.form.amount = this.form.amount.replace(this.patternNonDigit, '')
this.form.amount = this.form.amount.replace(PATTERN_NON_DIGIT, '')
// spreading is needed for testing
this.form.memo = this.memoStripHtml
this.$emit(this.form.id ? 'update-contribution' : 'set-contribution', { ...this.form })
@ -131,7 +132,7 @@ export default {
},
computed: {
memoStripHtml() {
return this.form.memo.replace(this.patternStripHtml)
return this.form.memo.replace(PATTERN_STRIP_HTML, '')
},
minimalDate() {
// sets the date to the 1st of the previous month