mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
add new input component, time, hour in contributions
This commit is contained in:
parent
292829503e
commit
569ca948cc
@ -42,7 +42,13 @@
|
|||||||
:placeholder="$t('contribution.yourActivity')"
|
:placeholder="$t('contribution.yourActivity')"
|
||||||
:rules="{ required: true, min: 5, max: 255 }"
|
:rules="{ required: true, min: 5, max: 255 }"
|
||||||
/>
|
/>
|
||||||
|
<input-time
|
||||||
|
v-model="form.time"
|
||||||
|
:name="$t('form.time')"
|
||||||
|
:label="$t('form.time')"
|
||||||
|
placeholder="1"
|
||||||
|
:rules="{ required: true, gddCreationTime: [1, validMaxTime] }"
|
||||||
|
></input-time>
|
||||||
<!-- <validation-provider
|
<!-- <validation-provider
|
||||||
:rules="{
|
:rules="{
|
||||||
min: minlength,
|
min: minlength,
|
||||||
@ -67,7 +73,7 @@
|
|||||||
v-model="form.amount"
|
v-model="form.amount"
|
||||||
:name="$t('form.amount')"
|
:name="$t('form.amount')"
|
||||||
:label="$t('form.amount')"
|
:label="$t('form.amount')"
|
||||||
:placeholder="'20'"
|
placeholder="20"
|
||||||
:rules="{ required: true, gddSendAmount: [20, validMaxGDD] }"
|
:rules="{ required: true, gddSendAmount: [20, validMaxGDD] }"
|
||||||
typ="ContributionForm"
|
typ="ContributionForm"
|
||||||
></input-amount>
|
></input-amount>
|
||||||
@ -113,6 +119,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
import InputTime from '@/components/Inputs/InputTime.vue'
|
||||||
import InputAmount from '@/components/Inputs/InputAmount.vue'
|
import InputAmount from '@/components/Inputs/InputAmount.vue'
|
||||||
import InputTextarea from '@/components/Inputs/InputTextarea.vue'
|
import InputTextarea from '@/components/Inputs/InputTextarea.vue'
|
||||||
|
|
||||||
@ -121,6 +128,7 @@ const PATTERN_NON_DIGIT = /\D/g
|
|||||||
export default {
|
export default {
|
||||||
name: 'ContributionForm',
|
name: 'ContributionForm',
|
||||||
components: {
|
components: {
|
||||||
|
InputTime,
|
||||||
InputAmount,
|
InputAmount,
|
||||||
InputTextarea,
|
InputTextarea,
|
||||||
},
|
},
|
||||||
@ -136,7 +144,7 @@ export default {
|
|||||||
minlength: 5,
|
minlength: 5,
|
||||||
maxlength: 255,
|
maxlength: 255,
|
||||||
maximalDate: new Date(),
|
maximalDate: new Date(),
|
||||||
form: this.value, // includes 'id'
|
form: this.value, // includes 'id' and time
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -154,6 +162,7 @@ export default {
|
|||||||
this.form.id = null
|
this.form.id = null
|
||||||
this.form.date = ''
|
this.form.date = ''
|
||||||
this.form.memo = ''
|
this.form.memo = ''
|
||||||
|
this.form.time = 0
|
||||||
this.form.amount = ''
|
this.form.amount = ''
|
||||||
},
|
},
|
||||||
// textForMonth(date, availableAmount) {
|
// textForMonth(date, availableAmount) {
|
||||||
@ -180,6 +189,11 @@ export default {
|
|||||||
validMaxGDD() {
|
validMaxGDD() {
|
||||||
return Number(this.isThisMonth ? this.maxGddThisMonth : this.maxGddLastMonth)
|
return Number(this.isThisMonth ? this.maxGddThisMonth : this.maxGddLastMonth)
|
||||||
},
|
},
|
||||||
|
validMaxTime() {
|
||||||
|
console.log(this.validMaxGDD)
|
||||||
|
console.log(this.validMaxGDD / 20)
|
||||||
|
return Number(this.validMaxGDD / 20)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
73
frontend/src/components/Inputs/InputTime.vue
Normal file
73
frontend/src/components/Inputs/InputTime.vue
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
<template>
|
||||||
|
<div class="input-time">
|
||||||
|
<validation-provider
|
||||||
|
tag="div"
|
||||||
|
:rules="rules"
|
||||||
|
:name="name"
|
||||||
|
v-slot="{ errors, valid, validated, ariaInput, ariaMsg }"
|
||||||
|
>
|
||||||
|
<b-form-group :label="label" :label-for="labelFor">
|
||||||
|
<b-form-input
|
||||||
|
v-model="currentValue"
|
||||||
|
v-bind="ariaInput"
|
||||||
|
:id="labelFor"
|
||||||
|
:name="name"
|
||||||
|
:placeholder="placeholder"
|
||||||
|
type="number"
|
||||||
|
:state="validated ? valid : false"
|
||||||
|
></b-form-input>
|
||||||
|
<b-form-invalid-feedback v-bind="ariaMsg">
|
||||||
|
{{ errors[0] }}
|
||||||
|
</b-form-invalid-feedback>
|
||||||
|
</b-form-group>
|
||||||
|
</validation-provider>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'InputTime',
|
||||||
|
props: {
|
||||||
|
rules: {
|
||||||
|
type: Object,
|
||||||
|
default: () => {},
|
||||||
|
},
|
||||||
|
name: { type: String, required: true, default: 'Time' },
|
||||||
|
label: { type: String, required: true, default: 'Time' },
|
||||||
|
placeholder: { type: String, required: true, default: 'Time' },
|
||||||
|
value: { type: Number, required: true, default: 0 },
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
currentValue: 0,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
labelFor() {
|
||||||
|
return this.name + '-input-field'
|
||||||
|
},
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
currentValue() {
|
||||||
|
this.$emit('input', this.currentValue)
|
||||||
|
},
|
||||||
|
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))
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// normalizeTime(isValid) {
|
||||||
|
// this.timeFocused = false
|
||||||
|
// if (!isValid) return
|
||||||
|
// // this.timeValue = Number(this.currentValue.replace(',', '.'))
|
||||||
|
// this.currentValue = this.timeValue
|
||||||
|
// },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@ -151,6 +151,7 @@
|
|||||||
"to": "bis",
|
"to": "bis",
|
||||||
"to1": "an",
|
"to1": "an",
|
||||||
"validation": {
|
"validation": {
|
||||||
|
"gddCreationTime": "Das Feld {_field_} muss eine Zahl zwischen {min} und {max} mit höchstens zwei Nachkommastellen sein",
|
||||||
"gddSendAmount": "Das Feld {_field_} muss eine Zahl zwischen {min} und {max} mit höchstens zwei Nachkommastellen sein",
|
"gddSendAmount": "Das Feld {_field_} muss eine Zahl zwischen {min} und {max} mit höchstens zwei Nachkommastellen sein",
|
||||||
"is-not": "Du kannst dir selbst keine Gradidos überweisen",
|
"is-not": "Du kannst dir selbst keine Gradidos überweisen",
|
||||||
"usernmae-regex": "Der Username muss mit einem Buchstaben beginnen, auf den mindestens zwei alpha-numerische Zeichen folgen müssen.",
|
"usernmae-regex": "Der Username muss mit einem Buchstaben beginnen, auf den mindestens zwei alpha-numerische Zeichen folgen müssen.",
|
||||||
|
|||||||
@ -81,6 +81,7 @@ export default {
|
|||||||
id: null,
|
id: null,
|
||||||
date: '',
|
date: '',
|
||||||
memo: '',
|
memo: '',
|
||||||
|
time: 0,
|
||||||
amount: '',
|
amount: '',
|
||||||
},
|
},
|
||||||
updateAmount: '',
|
updateAmount: '',
|
||||||
|
|||||||
@ -54,6 +54,25 @@ export const loadAllRules = (i18nCallback) => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
extend('gddCreationTime', {
|
||||||
|
validate(value, { min, max }) {
|
||||||
|
console.log(value)
|
||||||
|
console.log(min)
|
||||||
|
console.log(max)
|
||||||
|
console.log(typeof(value))
|
||||||
|
console.log(typeof(min))
|
||||||
|
console.log(typeof(max))
|
||||||
|
// value = value.replace(',', '.')
|
||||||
|
return Number(value) >= min && Number(value) <= max
|
||||||
|
},
|
||||||
|
params: ['min', 'max'],
|
||||||
|
message: (_, values) => {
|
||||||
|
// values.min = values.min
|
||||||
|
// values.max = values.max
|
||||||
|
return i18nCallback.t('form.validation.gddCreationTime', values)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
extend('is_not', {
|
extend('is_not', {
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user