123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- <template>
- <v-container fluid>
- <v-row>
- <v-col :cols=10>
- <h1>Project Creation</h1>
- </v-col>
- <v-col :cols=2 >
- <v-btn :to = "{ name: 'projects' }" block color="error">
- <v-icon>mdi-reply</v-icon> Back
- </v-btn>
- </v-col>
- </v-row>
- <v-card outlined elevation="2" max-width=80% class="mx-auto">
- <v-card-title>New Project</v-card-title>
- <v-card-text>
- <v-container fluid>
- <v-form
- @submit.prevent="create"
- ref="form"
- >
- <v-row>
- <v-col cols=12 sm=12>
- <v-text-field
- v-model="project.name"
- name="name"
- label="Project Name"
- :error-messages="nameErrors"
- required>
- </v-text-field>
- </v-col>
- </v-row>
- <v-row>
- <v-col cols=12 sm=12>
- <v-textarea
- v-model="project.description"
- name="description"
- label="Project Description"
- :error-messages="descErrors"
- auto-grow
- rows="3"
- row-height="25"
- required>
- </v-textarea>
- </v-col>
- </v-row>
- <v-row>
- <v-col cols=12 sm=12>
- <v-select
- v-model="project.model"
- name="model"
- label="Model"
- :error-messages="modelErrors"
- :items="data.models"
- :hint="modelHint"
- item-text="name"
- item-value="id"
- persistent-hint
- return-object
- required>
- </v-select>
- </v-col>
- </v-row>
- <v-row>
- <v-col cols=12 sm=12 class="d-flex align-end flex-column">
- <v-btn
- type="submit"
- color="primary"
- >
- Create
- </v-btn>
- </v-col>
- </v-row>
- </v-form>
- </v-container>
- </v-card-text>
- </v-card>
- </v-container>
- </template>
- <script>
- import Project from '@/store/models/project';
- import { validationMixin } from 'vuelidate';
- import { required, minLength } from 'vuelidate/lib/validators';
- import { mapState } from 'vuex'
- export default {
- name: 'CreateProject',
- mixins: [validationMixin],
- validations: {
- project: {
- name: { required, minLength: minLength(5) },
- description: { required },
- model: { required },
- }
- },
- data () {
- return {
- project: new Project(),
- }
- },
- computed: {
- nameErrors () {
- const errors = [];
- if (!this.$v.project.name.$dirty) return errors
- !this.$v.project.name.minLength && errors.push('Name must be at least 5 characters long')
- !this.$v.project.name.required && errors.push('Name is required')
- return errors;
- },
- descErrors () {
- const errors = [];
- if (!this.$v.project.description.$dirty) return errors
- !this.$v.project.description.required && errors.push('Description is required')
- return errors;
- },
- modelErrors () {
- const errors = [];
- if (!this.$v.project.model.$dirty) return errors
- !this.$v.project.model.required && errors.push('Model selection is required')
- return errors;
- },
- modelHint() {
- return this.project.model?.description
- },
- ...mapState(['data'])
- },
- methods: {
- create() {
- this.$v.$touch();
- if (!this.$v.$invalid) {
- console.log("Creating project:", this.project);
- }
- }
- },
- created () {
- this.$store.dispatch('data/getModels')
- this.$store.dispatch('data/getLabelProviders')
- },
- }
- </script>
- <style scoped>
- </style>
|