Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
chamilo-lms/assets/vue/components/personalfile/Form.vue

74 lines
1.4 KiB

<template>
<q-form>
<q-input
id="item_title"
v-model="item.title"
:error="v$.item.title.$error"
:error-message="titleErrors"
:placeholder="$t('Title')"
@blur="v$.item.title.$touch()"
@input="v$.item.title.$touch()"
/>
<slot></slot>
</q-form>
</template>
<script>
import has from "lodash/has"
import useVuelidate from "@vuelidate/core"
import { required } from "@vuelidate/validators"
export default {
name: "PersonalFileForm",
setup() {
return { v$: useVuelidate() }
},
props: {
values: {
type: Object,
required: true,
},
errors: {
type: Object,
default: () => {},
},
initialValues: {
type: Object,
default: () => {},
},
},
data() {
return {
title: null,
parentResourceNodeId: null,
}
},
computed: {
item() {
return this.initialValues || this.values
},
titleErrors() {
const errors = []
if (!this.v$.item.title.$dirty) return errors
has(this.violations, "title") && errors.push(this.violations.title)
if (this.v$.item.title.required) {
return this.$t("Field is required")
}
return errors
},
violations() {
return this.errors || {}
},
},
validations: {
item: {
title: {
required,
},
parentResourceNodeId: {},
},
},
}
</script>