|
| 1 | +<template> |
| 2 | + <DialogModal |
| 3 | + :confirm-button-label="isExist ? $t('common.edit') : $t('common.add')" |
| 4 | + :cancel-button-label="$t('common.cancel')" |
| 5 | + :asyncing="loading" |
| 6 | + :disabled="loading || !isValid" |
| 7 | + @close="$emit('close')" |
| 8 | + @submit="$emit('submit')" |
| 9 | + > |
| 10 | + <template #header> |
| 11 | + {{ isExist ? $t('location.edit-location-point') : $t('location.add-location-point') }} |
| 12 | + </template> |
| 13 | + |
| 14 | + <template #body> |
| 15 | + <div class="location-type-ctn"> |
| 16 | + <div class="location-type-label"> |
| 17 | + {{ $t('location.location-type-label') }} |
| 18 | + </div> |
| 19 | + <GroupButton v-model="form.type" :options="locationTypeOptions" /> |
| 20 | + </div> |
| 21 | + |
| 22 | + <TextInput v-model="form.title" :errors="errors.title" :label="$t('common.title')" /> |
| 23 | + |
| 24 | + <TextInput |
| 25 | + v-model="form.description" |
| 26 | + :errors="errors.description" |
| 27 | + input-type="textarea" |
| 28 | + :label="$t('common.description')" |
| 29 | + class="description-input" |
| 30 | + /> |
| 31 | + </template> |
| 32 | + |
| 33 | + <template v-if="isExist" #extra-buttons> |
| 34 | + <LpiButton |
| 35 | + class="delete-button" |
| 36 | + :label="$t('common.delete')" |
| 37 | + :btn-icon="loading ? 'LoaderSimple' : null" |
| 38 | + @click="$emit('delete')" |
| 39 | + /> |
| 40 | + </template> |
| 41 | + </DialogModal> |
| 42 | +</template> |
| 43 | + |
| 44 | +<script setup lang="ts"> |
| 45 | +import DialogModal from '@/components/base/modal/DialogModal.vue' |
| 46 | +import TextInput from '@/components/base/form/TextInput.vue' |
| 47 | +import GroupButton from '@/components/base/button/GroupButton.vue' |
| 48 | +import LpiButton from '@/components/base/button/LpiButton.vue' |
| 49 | +import { LocationForm } from '@/models/location.model' |
| 50 | +import { useLocationForm } from '@/form/location' |
| 51 | +
|
| 52 | +withDefaults( |
| 53 | + defineProps<{ |
| 54 | + loading?: boolean |
| 55 | + }>(), |
| 56 | + { |
| 57 | + loading: false, |
| 58 | + } |
| 59 | +) |
| 60 | +defineEmits(['submit', 'close', 'delete']) |
| 61 | +const { t } = useNuxtI18n() |
| 62 | +
|
| 63 | +const model = defineModel<LocationForm>() |
| 64 | +const { form, isValid, errors } = useLocationForm({ model }) |
| 65 | +const isExist = computed(() => !!form.value.id) |
| 66 | +
|
| 67 | +const locationTypeOptions = computed(() => [ |
| 68 | + { |
| 69 | + value: 'team', |
| 70 | + label: t('location.team'), |
| 71 | + }, |
| 72 | + { |
| 73 | + value: 'impact', |
| 74 | + label: t('location.impact'), |
| 75 | + }, |
| 76 | + { |
| 77 | + value: 'address', |
| 78 | + label: t('location.address'), |
| 79 | + }, |
| 80 | +]) |
| 81 | +</script> |
| 82 | + |
| 83 | +<style lang="scss" scoped> |
| 84 | +.new-coords { |
| 85 | + text-align: center; |
| 86 | + font-style: italic; |
| 87 | + font-weight: normal; |
| 88 | +} |
| 89 | +
|
| 90 | +.description-input { |
| 91 | + margin-top: $space-m; |
| 92 | +} |
| 93 | +
|
| 94 | +.location-type-ctn { |
| 95 | + margin: $space-m 0; |
| 96 | +
|
| 97 | + .location-type-label { |
| 98 | + font-size: $font-size-s; |
| 99 | + color: $primary-dark; |
| 100 | + font-weight: bold; |
| 101 | + margin-bottom: $space-2xs; |
| 102 | + } |
| 103 | +} |
| 104 | +
|
| 105 | +.delete-button { |
| 106 | + color: $white; |
| 107 | + background: $salmon; |
| 108 | +} |
| 109 | +</style> |
0 commit comments