Skip to content

Commit

Permalink
frontend: search page now support pure addition modes
Browse files Browse the repository at this point in the history
  • Loading branch information
Synar committed Jul 2, 2024
1 parent 9ffc5fc commit 15b0b11
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions frontend/components/viewer/CommentAddForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@
</template>

<script setup lang="ts">
import type { EntityOrCommentData, Family, FormField, PublicEntity, PublicNewComment } from '~/lib'
import type { EntityOrCommentData, Family, FormField, PublicEntity, PublicNewComment, ViewerSearchedCachedEntity } from '~/lib'
import { isValidRichText, isValidText } from '~/lib/validation'
import state from '~/lib/viewer-state'
const formVisible = ref(false)
const props = defineProps<{
family: Family
entity: PublicEntity
entity: PublicEntity | ViewerSearchedCachedEntity
}>()
const processingRequest = ref(false)
Expand Down
14 changes: 9 additions & 5 deletions frontend/components/viewer/FullResult.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<div class="flex flex-col md:items-end gap-8">
<div class="flex flex-row-reverse md:flex-row gap-2">
<Button
v-if="state.permissions?.can_access_entity"
label="Voir en détail"
class="flex-auto md:flex-initial whitespace-nowrap"
@click="changeActiveEntity(props.entity)"
Expand All @@ -62,6 +63,11 @@
<AppIcon icon-name="eye" />
</template>
</Button>
<ViewerCommentAddForm
v-if="state.permissions?.can_add_comment && !state.permissions.can_access_entity"
:family="state.activeFamily"
:entity="props.entity"
/>
</div>
</div>
</div>
Expand All @@ -71,18 +77,16 @@
</template>
<script setup lang="ts">
import type { ViewerPaginatedCachedEntities } from '~/lib'
import type { ViewerSearchedCachedEntity } from '~/lib'
import state from '~/lib/viewer-state'
type ReceivedEntity = ViewerPaginatedCachedEntities['entities'][0]
const props = defineProps<{
entity: ReceivedEntity
entity: ViewerSearchedCachedEntity
}>()
const locations = computed(() => props.entity.locations.map(loc => [loc.x, loc.y]))
function changeActiveEntity(entity: ReceivedEntity) {
function changeActiveEntity(entity: ViewerSearchedCachedEntity) {
state.selectEntity(entity.entity_id)
}
</script>
Expand Down
2 changes: 2 additions & 0 deletions frontend/components/viewer/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
</Button>

<Button
v-if="state.permissions?.can_add_entity"
label="Ajouter"
severity="info"
@click="openAddModal()"
Expand Down Expand Up @@ -161,6 +162,7 @@
</Button>

<Button
v-if="state.permissions?.can_add_entity"
label="Ajouter"
severity="info"
@click="openAddModal()"
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/admin/access-tokens/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
id="list_entities"
v-model="editedAccessToken.permissions.can_list_entities"
label="Permission de lister les entités"
helper-text="Comprend le nom, la catégorie, les tags et la date de création de chaque entité"
helper-text="Comprend le nom, la catégorie, les tags, les parents, les adresses et la date de création de chaque entité"
/>

<AdminInputSwitchField
Expand Down
16 changes: 7 additions & 9 deletions frontend/pages/search/[token].vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
:show-search-button="false"
/>

<Card class="m-2 p-2">
<Card
v-if="state.permissions?.can_list_entities"
class="m-2 p-2"
>
<template #header>
<span class="text-2xl font-bold">
Recherche
Expand Down Expand Up @@ -151,18 +154,16 @@
</Card>

<Dialog
v-if="state.hasActiveEntity"
v-model:visible="state.hasActiveEntity"
maximizable
:style="{ width: '50rem' }"
:breakpoints="{ '1199px': '75vw', '575px': '90vw' }"
modal
dismissable-mask
>
<template #header>
<div
v-if="
state.activeEntity"
class="flex items-center gap-2"
>
<div class="flex items-center gap-2">
<CategoryTag :category="state.activeEntity!.category" />
<h3 class="grow font-bold text-lg m-0">
{{ state.activeEntity!.entity.display_name }}
Expand All @@ -177,7 +178,6 @@
/>
<ViewerCommonEntityDisplayer
v-if="state.activeEntity"
:entity="state.activeEntity!"
:categories="state.categories"
@entity-selected="displayEntityId"
Expand Down Expand Up @@ -216,8 +216,6 @@ const route = useRoute()
const token = route.params.token as string
try {
await state.bootstrapWithToken(token)
if (!state.permissions?.can_access_entity)
throw 'Unauthorized'
}
catch {
toast.add({
Expand Down

0 comments on commit 15b0b11

Please sign in to comment.