web: validate form and add number input

Co-authored-by: Schmackofatz <Schmackofatz@gmail.com>
This commit is contained in:
Mika 2024-07-10 19:02:53 +02:00
parent 813260d029
commit 0f2280005f
2 changed files with 167 additions and 154 deletions

View file

@ -1,10 +1,6 @@
<template> <template>
<div> <div>
<v-toolbar <v-toolbar color="main" dark prominent>
color="main"
dark
prominent
>
<img src="../assets/turbologo.svg" alt="logo" class="logo" width="75" /> <img src="../assets/turbologo.svg" alt="logo" class="logo" width="75" />
<v-spacer></v-spacer> <v-spacer></v-spacer>
<!-- Create, Delete, Edit --> <!-- Create, Delete, Edit -->
@ -12,14 +8,9 @@
<v-btn icon class="mr-3" @click="add = true"> <v-btn icon class="mr-3" @click="add = true">
<Plus /> <Plus />
</v-btn> </v-btn>
<v-dialog <v-dialog v-model="add" width="600" persistent>
v-model="add" <v-card max-width="600">
width="600" <v-form>
persistent
>
<v-card
max-width="600"
>
<v-card-title> <v-card-title>
<span class="headline">Add License</span> <span class="headline">Add License</span>
</v-card-title> </v-card-title>
@ -34,12 +25,13 @@
variant="outlined" variant="outlined"
required required
clearable clearable
:rules="licenseNameRules"
class="mb-3"
></v-text-field> ></v-text-field>
<div> <div>
<div class="mb-3"> <div class="mb-3">
<v-menu> <v-menu>
<template v-slot:activator="{ props }"> <template v-slot:activator="{ props }">
<v-text-field <v-text-field
v-bind="props" v-bind="props"
label="Start Date (optional)" label="Start Date (optional)"
@ -80,19 +72,23 @@
</v-menu> </v-menu>
</div> </div>
</div> </div>
<v-text-field <v-number-input
label="Amount (optional)" label="Amount (optional)"
v-model="addAmount"
variant="outlined" variant="outlined"
clearable clearable
></v-text-field> :min="0"
v-model="addAmount"
>
</v-number-input>
<v-text-field <v-text-field
label="Notes (optional)" label="Notes (optional)"
v-model="addNotes" v-model="addNotes"
variant="outlined" variant="outlined"
clearable clearable
></v-text-field> ></v-text-field>
<span class="dialogNote "> all fields marked with * are required </span> <span class="dialogNote">
all fields marked with * are required
</span>
</div> </div>
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
@ -113,16 +109,15 @@
</v-col> </v-col>
</v-row> </v-row>
</v-card-actions> </v-card-actions>
</v-form>
</v-card> </v-card>
</v-dialog> </v-dialog>
<v-btn icon class="mr-3"> <v-btn icon class="mr-3">
<Pencil /> <Pencil />
</v-btn> </v-btn>
</div> </div>
<!-- Search --> <!-- Search -->
<v-text-field <v-text-field
class="compact-form mr-2" class="compact-form mr-2"
@ -142,31 +137,46 @@
</v-btn> </v-btn>
</v-toolbar> </v-toolbar>
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { store } from '@/store'; import { store } from "@/store";
import { Plus, LogOut, Pencil, CalendarCheck, CalendarX } from 'lucide-vue-next'; import {
import { computed, ref } from 'vue'; Plus,
LogOut,
Pencil,
CalendarCheck,
CalendarX,
} from "lucide-vue-next";
import { computed, ref } from "vue";
function handlelogout() { function handlelogout() {
console.log('logout'); console.log("logout");
store.setToken(null); store.setToken(null);
} }
const add = ref(false); const add = ref(false);
// References for Add License Dialog // References for Add License Dialog
const addLicenseName = ref(''); const addLicenseName = ref<string>("");
const addAmount = ref(''); const licenseNameRules = [
const addNotes = ref(''); (value: string) => {
if (value) return true;
return "YOU MUST ENTER A LICENSE NAME";
},
];
const addAmount = ref<number | undefined>();
const addNotes = ref<string | undefined>("");
// Date Picker // Date Picker
const addStartDate = ref<Date | undefined>(); const addStartDate = ref<Date | undefined>();
const addStartDateDisplay = computed<string>(() => addStartDate.value ? addStartDate.value.toLocaleDateString() : ""); const addStartDateDisplay = computed<string>(() =>
addStartDate.value ? addStartDate.value.toLocaleDateString() : ""
);
const addStopDate = ref<Date | undefined>(); const addStopDate = ref<Date | undefined>();
const addStopDateDisplay = computed<string>(() => addStopDate.value ? addStopDate.value.toLocaleDateString(): ""); const addStopDateDisplay = computed<string>(() =>
addStopDate.value ? addStopDate.value.toLocaleDateString() : ""
);
</script> </script>
<style scoped> <style scoped>
@ -175,9 +185,8 @@ const addStopDateDisplay = computed<string>(() => addStopDate.value ? addStopDat
margin-left: 10px; margin-left: 10px;
} }
.dialogNote{ .dialogNote {
font-size: 13px; font-size: 13px;
color: grey; color: grey;
} }
</style> </style>

View file

@ -5,11 +5,12 @@
*/ */
// Styles // Styles
import '@mdi/font/css/materialdesignicons.css' import "@mdi/font/css/materialdesignicons.css";
import 'vuetify/styles' import "vuetify/styles";
// Composables // Composables
import { createVuetify } from 'vuetify' import { createVuetify } from "vuetify";
import { VNumberInput } from "vuetify/labs/components";
// https://vuetifyjs.com/en/introduction/why-vuetify/#feature-guides // https://vuetifyjs.com/en/introduction/why-vuetify/#feature-guides
export default createVuetify({ export default createVuetify({
@ -18,14 +19,17 @@ export default createVuetify({
light: { light: {
dark: false, dark: false,
colors: { colors: {
main: '#024950', main: "#024950",
darker: '#003135', darker: "#003135",
contrast: '#964734', contrast: "#964734",
accent: '#0FA4AF', accent: "#0FA4AF",
accentLigher: '#AFDDE5', accentLigher: "#AFDDE5",
backdrop: '#e3e3e3', backdrop: "#e3e3e3",
},
}
}, },
}, },
}) },
},
components: {
VNumberInput,
},
});