mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
add time in contribution form
This commit is contained in:
parent
439bd3d447
commit
a5ae7f4419
@ -46,8 +46,15 @@
|
|||||||
v-model="form.time"
|
v-model="form.time"
|
||||||
:name="$t('form.time')"
|
:name="$t('form.time')"
|
||||||
:label="$t('form.time')"
|
:label="$t('form.time')"
|
||||||
placeholder="1"
|
placeholder="0.5"
|
||||||
:rules="{ required: true, gddCreationTime: [1, validMaxTime] }"
|
:rules="{
|
||||||
|
required: true,
|
||||||
|
min: 0.5,
|
||||||
|
max: validMaxTime,
|
||||||
|
gddCreationTime: [0.5, validMaxTime],
|
||||||
|
}"
|
||||||
|
:validMaxTime="validMaxTime"
|
||||||
|
@updateAmount="updateAmount"
|
||||||
></input-time>
|
></input-time>
|
||||||
<!-- <validation-provider
|
<!-- <validation-provider
|
||||||
:rules="{
|
:rules="{
|
||||||
@ -148,6 +155,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
updateAmount(amount) {
|
||||||
|
this.form.amount = (amount * 20).toFixed(2).toString()
|
||||||
|
},
|
||||||
// numberFormat(value) {
|
// numberFormat(value) {
|
||||||
// return value.replace(PATTERN_NON_DIGIT, '')
|
// return value.replace(PATTERN_NON_DIGIT, '')
|
||||||
// },
|
// },
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="input-amount">
|
<div class="input-amount">
|
||||||
<validation-provider
|
<validation-provider
|
||||||
|
v-if="typ === 'TransactionsForm'"
|
||||||
tag="div"
|
tag="div"
|
||||||
:rules="rules"
|
:rules="rules"
|
||||||
:name="name"
|
:name="name"
|
||||||
@ -20,11 +21,24 @@
|
|||||||
@focus="amountFocused = true"
|
@focus="amountFocused = true"
|
||||||
@blur="normalizeAmount(valid)"
|
@blur="normalizeAmount(valid)"
|
||||||
></b-form-input>
|
></b-form-input>
|
||||||
|
|
||||||
<b-form-invalid-feedback v-bind="ariaMsg">
|
<b-form-invalid-feedback v-bind="ariaMsg">
|
||||||
{{ errors[0] }}
|
{{ errors[0] }}
|
||||||
</b-form-invalid-feedback>
|
</b-form-invalid-feedback>
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
</validation-provider>
|
</validation-provider>
|
||||||
|
<b-input-group v-else append="GDD" :label="label" :label-for="labelFor">
|
||||||
|
|
||||||
|
<b-form-input
|
||||||
|
v-model="currentValue"
|
||||||
|
:id="labelFor"
|
||||||
|
:name="name"
|
||||||
|
:placeholder="placeholder"
|
||||||
|
type="text"
|
||||||
|
readonly
|
||||||
|
trim
|
||||||
|
></b-form-input>
|
||||||
|
</b-input-group>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
@ -64,9 +78,10 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
normalizeAmount(isValid) {
|
normalizeAmount(isValid) {
|
||||||
|
// console.log('inputAmount normalize')
|
||||||
this.amountFocused = false
|
this.amountFocused = false
|
||||||
if (!isValid) return
|
if (!isValid) return
|
||||||
this.amountValue = Number(this.currentValue.replace(',', '.'))
|
this.amountValue = this.currentValue.replace(',', '.')
|
||||||
if (this.typ === 'TransactionForm') {
|
if (this.typ === 'TransactionForm') {
|
||||||
this.currentValue = this.$n(this.amountValue, 'ungroupedDecimal')
|
this.currentValue = this.$n(this.amountValue, 'ungroupedDecimal')
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,6 +15,10 @@
|
|||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
type="number"
|
type="number"
|
||||||
:state="validated ? valid : false"
|
:state="validated ? valid : false"
|
||||||
|
step="0.5"
|
||||||
|
min="0"
|
||||||
|
:max="validMaxTime"
|
||||||
|
|
||||||
></b-form-input>
|
></b-form-input>
|
||||||
<b-form-invalid-feedback v-bind="ariaMsg">
|
<b-form-invalid-feedback v-bind="ariaMsg">
|
||||||
{{ errors[0] }}
|
{{ errors[0] }}
|
||||||
@ -35,6 +39,7 @@ export default {
|
|||||||
label: { type: String, required: true, default: 'Time' },
|
label: { type: String, required: true, default: 'Time' },
|
||||||
placeholder: { type: String, required: true, default: 'Time' },
|
placeholder: { type: String, required: true, default: 'Time' },
|
||||||
value: { type: Number, required: true, default: 0 },
|
value: { type: Number, required: true, default: 0 },
|
||||||
|
validMaxTime: { type: Number, required: true, default: 0 },
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -52,22 +57,22 @@ export default {
|
|||||||
},
|
},
|
||||||
value() {
|
value() {
|
||||||
// console.log('value', this.value)
|
// console.log('value', this.value)
|
||||||
// console.log('value !== currentValue', this.value !== this.currentValue)
|
// console.log('currentValue', this.currentValue)
|
||||||
// this.value = Number(this.value)
|
// console.log('value', typeof this.value)
|
||||||
if (Number(this.value) !== this.currentValue) this.currentValue = this.value
|
// console.log('currentValue', typeof this.currentValue)
|
||||||
this.currentValue = Number(this.currentValue)
|
// console.log('!==', this.value !== this.currentValue)
|
||||||
// this.value = Number(this.value)
|
|
||||||
// console.log('value', typeof(this.value))
|
if (this.value !== this.currentValue) this.currentValue = this.value
|
||||||
// console.log('currentValue', typeof(this.currentValue))
|
this.$emit('updateAmount', this.currentValue)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
// normalizeTime(isValid) {
|
normalizeTime(isValid) {
|
||||||
// this.timeFocused = false
|
this.timeFocused = false
|
||||||
// if (!isValid) return
|
if (!isValid) return
|
||||||
// // this.timeValue = Number(this.currentValue.replace(',', '.'))
|
this.timeValue = Number(this.currentValue.replace(',', '.'))
|
||||||
// this.currentValue = this.timeValue
|
this.currentValue = this.timeValue
|
||||||
// },
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -56,6 +56,7 @@ export const loadAllRules = (i18nCallback) => {
|
|||||||
|
|
||||||
extend('gddCreationTime', {
|
extend('gddCreationTime', {
|
||||||
validate(value, { min, max }) {
|
validate(value, { min, max }) {
|
||||||
|
value = value.replace(',', '.')
|
||||||
// console.log(value)
|
// console.log(value)
|
||||||
// console.log(min)
|
// console.log(min)
|
||||||
// console.log(max)
|
// console.log(max)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user