-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
21 changed files
with
1,408 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
<template> | ||
<ModalDialog v-model="isOpened"> | ||
<form | ||
method="dialog" | ||
:class="$style.content" | ||
@submit="handleSubmit" | ||
> | ||
<div :class="$style.header"> | ||
Add new equipment type | ||
</div> | ||
|
||
<input | ||
required | ||
autofocus | ||
placeholder="Sleeping bag" | ||
v-model="typeName" | ||
:class="$style.input" | ||
:maxlength="limits.maxEquipmentTypeNameLength" | ||
type="text" | ||
/> | ||
|
||
<div :class="$style.buttons"> | ||
<PerdButton | ||
secondary | ||
type="button" | ||
@click="handleCancelClick" | ||
> | ||
Cancel | ||
</PerdButton> | ||
|
||
<PerdButton> | ||
Add type | ||
</PerdButton> | ||
</div> | ||
</form> | ||
</ModalDialog> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { limits } from '~~/constants'; | ||
import PerdButton from '~/components/PerdButton.vue' | ||
import ModalDialog from './ModalDialog.vue' | ||
type Emits = (event: 'submit', typeName: string) => void | ||
const emit = defineEmits<Emits>() | ||
const typeName = ref('') | ||
const isOpened = defineModel<boolean>({ | ||
required: true | ||
}) | ||
function handleCancelClick() { | ||
isOpened.value = false | ||
} | ||
function handleSubmit(event: Event) { | ||
if (typeName.value !== '') { | ||
emit('submit', typeName.value) | ||
} | ||
} | ||
// Reset form when dialog is opened | ||
watch(isOpened, (value) => { | ||
if (value) { | ||
typeName.value = '' | ||
} | ||
}) | ||
</script> | ||
|
||
<style module> | ||
.content { | ||
display: grid; | ||
row-gap: var(--spacing-24); | ||
background-color: var(--dialog-color-background); | ||
padding: var(--dialog-padding); | ||
border-radius: var(--dialog-border-radius); | ||
border: 1px solid var(--dialog-color-border); | ||
} | ||
.header { | ||
font-size: var(--font-size-20); | ||
font-weight: var(--font-weight-medium); | ||
text-align: center; | ||
} | ||
.input { | ||
text-align: center; | ||
} | ||
.input::placeholder { | ||
user-select: none; | ||
} | ||
.buttons { | ||
display: grid; | ||
grid-auto-flow: column; | ||
column-gap: var(--spacing-16); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
interface EquipmentType { | ||
readonly id: number | ||
readonly name: string | ||
} | ||
|
||
export default async function useEquipmentTypesData() { | ||
const types = ref<EquipmentType[]>([]) | ||
|
||
const sortedTypes = computed( | ||
() => types.value.sort((typeA, typeB) => typeA.name.localeCompare(typeB.name)) | ||
) | ||
|
||
const { data } = await useFetch('/api/equipment/type') | ||
|
||
if (data.value !== undefined) { | ||
types.value = data.value | ||
} | ||
|
||
function addType(type: EquipmentType) { | ||
types.value.push(type) | ||
} | ||
|
||
return { | ||
addType, | ||
types: sortedTypes | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.