Skip to content

Commit

Permalink
frontend: various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ElysaSrc committed Jun 19, 2024
1 parent d515d4c commit 8943e96
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 21 deletions.
26 changes: 14 additions & 12 deletions frontend/components/viewer/EntityAddForm.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
<template>
<Button
label="Ajouter"
severity="info"
@click="formVisible = true"
>
<template #icon>
<AppIcon
icon-name="addEntity"
/>
</template>
</Button>

<Dialog
v-model:visible="formVisible"
modal
Expand Down Expand Up @@ -131,6 +119,20 @@ import { useToast } from 'primevue/usetoast'
import type { Category, EntityOrCommentData, Family, FormField, PublicNewComment, PublicNewEntity } from '~/lib'
import state from '~/lib/viewer-state'
defineExpose({ open, close, toggle })
function open() {
formVisible.value = true
}
function close() {
formVisible.value = false
}
function toggle() {
formVisible.value = !formVisible.value
}
const formVisible = ref(false)
const props = defineProps<{
Expand Down
51 changes: 42 additions & 9 deletions frontend/components/viewer/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,23 @@
</template>
</Button>

<ViewerEntityAddForm
:family="state.activeFamily"
:categories="state.categories.filter(category => category.family_id == state.activeFamily.id)"
/>
<Button
label="Ajouter"
severity="info"
@click="openAddModal()"
>
<template #icon>
<AppIcon
icon-name="addEntity"
/>
</template>
</Button>

<Button
v-if="props.showCategorySwitcher"
label="Filtres"
severity="primary"
@click="filterPopupVisible = true"
@click="openFilterPopup()"
>
<template #icon>
<AppIcon
Expand Down Expand Up @@ -108,10 +115,17 @@
</template>
</Button>

<ViewerEntityAddForm
:family="state.activeFamily"
:categories="state.categories.filter(category => category.family_id == state.activeFamily.id)"
/>
<Button
label="Ajouter"
severity="info"
@click="openAddModal()"
>
<template #icon>
<AppIcon
icon-name="addEntity"
/>
</template>
</Button>

<Button
v-if="props.showCategorySwitcher"
Expand Down Expand Up @@ -280,6 +294,12 @@
>
<ViewerInformation />
</Dialog>

<ViewerEntityAddForm
ref="entityAddForm"
:family="state.activeFamily"
:categories="state.categories.filter(category => category.family_id == state.activeFamily.id)"
/>
</template>

<script setup lang="ts">
Expand All @@ -290,6 +310,7 @@ import defaultLogo from '~/assets/logo_square.svg'
import type { Result as NominatimResult } from '~/lib/nominatim'
import { freeFormSearch } from '~/lib/nominatim'
import type { ViewerCachedEntity, ViewerPaginatedCachedEntitiesWithLocation } from '~/lib'
import type { ViewerEntityAddForm } from '#build/components'
const oneSearchMade = ref(false)
Expand All @@ -305,6 +326,8 @@ const props = withDefaults(defineProps<Props>(), {
showFamilySwitcher: true,
})
const entityAddForm = ref<typeof ViewerEntityAddForm>()
const emit = defineEmits<{
filtersChanged: []
locationChosen: [Coordinate]
Expand Down Expand Up @@ -349,6 +372,16 @@ async function searchEntity() {
currentEntitiesResults.value = await state.searchEntitiesWithLocations(entitySearch.value)
}
function openFilterPopup() {
filterPopupVisible.value = true
overflowPanel!.value!.hide()
}
function openAddModal() {
entityAddForm.value!.open()
overflowPanel.value!.hide()
}
function locationChosen(result: NominatimResult) {
const gpsCoordinates: Coordinate = [result.lon, result.lat]
emit('locationChosen', gpsCoordinates)
Expand Down

0 comments on commit 8943e96

Please sign in to comment.