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"
|
||||
:name="$t('form.time')"
|
||||
:label="$t('form.time')"
|
||||
placeholder="1"
|
||||
:rules="{ required: true, gddCreationTime: [1, validMaxTime] }"
|
||||
placeholder="0.5"
|
||||
:rules="{
|
||||
required: true,
|
||||
min: 0.5,
|
||||
max: validMaxTime,
|
||||
gddCreationTime: [0.5, validMaxTime],
|
||||
}"
|
||||
:validMaxTime="validMaxTime"
|
||||
@updateAmount="updateAmount"
|
||||
></input-time>
|
||||
<!-- <validation-provider
|
||||
:rules="{
|
||||
@ -148,6 +155,9 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
updateAmount(amount) {
|
||||
this.form.amount = (amount * 20).toFixed(2).toString()
|
||||
},
|
||||
// numberFormat(value) {
|
||||
// return value.replace(PATTERN_NON_DIGIT, '')
|
||||
// },
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<div class="input-amount">
|
||||
<validation-provider
|
||||
v-if="typ === 'TransactionsForm'"
|
||||
tag="div"
|
||||
:rules="rules"
|
||||
:name="name"
|
||||
@ -20,11 +21,24 @@
|
||||
@focus="amountFocused = true"
|
||||
@blur="normalizeAmount(valid)"
|
||||
></b-form-input>
|
||||
|
||||
<b-form-invalid-feedback v-bind="ariaMsg">
|
||||
{{ errors[0] }}
|
||||
</b-form-invalid-feedback>
|
||||
</b-form-group>
|
||||
</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>
|
||||
</template>
|
||||
<script>
|
||||
@ -64,9 +78,10 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
normalizeAmount(isValid) {
|
||||
// console.log('inputAmount normalize')
|
||||
this.amountFocused = false
|
||||
if (!isValid) return
|
||||
this.amountValue = Number(this.currentValue.replace(',', '.'))
|
||||
this.amountValue = this.currentValue.replace(',', '.')
|
||||
if (this.typ === 'TransactionForm') {
|
||||
this.currentValue = this.$n(this.amountValue, 'ungroupedDecimal')
|
||||
}
|
||||
|
||||
@ -15,6 +15,10 @@
|
||||
:placeholder="placeholder"
|
||||
type="number"
|
||||
:state="validated ? valid : false"
|
||||
step="0.5"
|
||||
min="0"
|
||||
:max="validMaxTime"
|
||||
|
||||
></b-form-input>
|
||||
<b-form-invalid-feedback v-bind="ariaMsg">
|
||||
{{ errors[0] }}
|
||||
@ -35,6 +39,7 @@ export default {
|
||||
label: { type: String, required: true, default: 'Time' },
|
||||
placeholder: { type: String, required: true, default: 'Time' },
|
||||
value: { type: Number, required: true, default: 0 },
|
||||
validMaxTime: { type: Number, required: true, default: 0 },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@ -52,22 +57,22 @@ export default {
|
||||
},
|
||||
value() {
|
||||
// console.log('value', this.value)
|
||||
// console.log('value !== currentValue', this.value !== this.currentValue)
|
||||
// this.value = Number(this.value)
|
||||
if (Number(this.value) !== this.currentValue) this.currentValue = this.value
|
||||
this.currentValue = Number(this.currentValue)
|
||||
// this.value = Number(this.value)
|
||||
// console.log('value', typeof(this.value))
|
||||
// console.log('currentValue', typeof(this.currentValue))
|
||||
// console.log('currentValue', this.currentValue)
|
||||
// console.log('value', typeof this.value)
|
||||
// console.log('currentValue', typeof this.currentValue)
|
||||
// console.log('!==', this.value !== this.currentValue)
|
||||
|
||||
if (this.value !== this.currentValue) this.currentValue = this.value
|
||||
this.$emit('updateAmount', this.currentValue)
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
// normalizeTime(isValid) {
|
||||
// this.timeFocused = false
|
||||
// if (!isValid) return
|
||||
// // this.timeValue = Number(this.currentValue.replace(',', '.'))
|
||||
// this.currentValue = this.timeValue
|
||||
// },
|
||||
normalizeTime(isValid) {
|
||||
this.timeFocused = false
|
||||
if (!isValid) return
|
||||
this.timeValue = Number(this.currentValue.replace(',', '.'))
|
||||
this.currentValue = this.timeValue
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -56,6 +56,7 @@ export const loadAllRules = (i18nCallback) => {
|
||||
|
||||
extend('gddCreationTime', {
|
||||
validate(value, { min, max }) {
|
||||
value = value.replace(',', '.')
|
||||
// console.log(value)
|
||||
// console.log(min)
|
||||
// console.log(max)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user