mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-24 17:45:41 +00:00
2e82398e5c
* implement password score UI and functions * update strings tests to use `test`instead of `it` * update typing * refactor login/register UI+Logic * fix width on switches to properly display * fetch and store self in store * (WIP) unify card styles * update labels page * bump nuxt * use form area * use text area for description * unify confirm API * unify UI around pages * change header background height
66 lines
1.4 KiB
Vue
66 lines
1.4 KiB
Vue
<template>
|
|
<BaseModal v-model="modal">
|
|
<template #title> Create Label </template>
|
|
<form @submit.prevent="create">
|
|
<FormTextField
|
|
ref="locationNameRef"
|
|
v-model="form.name"
|
|
:trigger-focus="focused"
|
|
:autofocus="true"
|
|
label="Label Name"
|
|
/>
|
|
<FormTextArea v-model="form.description" label="Label Description" />
|
|
<div class="modal-action">
|
|
<BaseButton type="submit" :loading="loading"> Create </BaseButton>
|
|
</div>
|
|
</form>
|
|
</BaseModal>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
const props = defineProps({
|
|
modelValue: {
|
|
type: Boolean,
|
|
required: true,
|
|
},
|
|
});
|
|
|
|
const modal = useVModel(props, "modelValue");
|
|
const loading = ref(false);
|
|
const focused = ref(false);
|
|
const form = reactive({
|
|
name: "",
|
|
description: "",
|
|
color: "", // Future!
|
|
});
|
|
|
|
function reset() {
|
|
form.name = "";
|
|
form.description = "";
|
|
form.color = "";
|
|
focused.value = false;
|
|
modal.value = false;
|
|
loading.value = false;
|
|
}
|
|
|
|
whenever(
|
|
() => modal.value,
|
|
() => {
|
|
focused.value = true;
|
|
}
|
|
);
|
|
|
|
const api = useUserApi();
|
|
const toast = useNotifier();
|
|
|
|
async function create() {
|
|
const { error } = await api.labels.create(form);
|
|
if (error) {
|
|
toast.error("Couldn't create label");
|
|
return;
|
|
}
|
|
|
|
toast.success("Label created");
|
|
reset();
|
|
}
|
|
</script>
|