Skip to content

Commit

Permalink
Fix unit siblings widget logic
Browse files Browse the repository at this point in the history
  • Loading branch information
bkis committed Jun 26, 2023
1 parent 9e2db19 commit 906f38b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Tekst-API/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
},
{
"description": "ID of node for which siblings to get associated units for",
"required": true,
"required": false,
"schema": {
"title": "Parentnodeid",
"type": "string",
Expand Down
10 changes: 7 additions & 3 deletions Tekst-API/tekst/routers/browse.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ async def get_unit_siblings(
Query(description="ID of layer the requested units belong to"),
],
parent_node_id: Annotated[
PyObjectId,
PyObjectId | None,
Query(description="ID of node for which siblings to get associated units for"),
],
] = None,
) -> list[dict]:
"""
Returns a list of all data layer units belonging to the data layer
Expand All @@ -56,7 +56,11 @@ async def get_unit_siblings(
detail=f"Layer with ID {layer_id} could not be found.",
)

nodes = await NodeDocument.find(NodeDocument.parent_id == parent_node_id).to_list()
nodes = await NodeDocument.find(
NodeDocument.text_id == layer.text_id,
NodeDocument.level == layer.level,
NodeDocument.parent_id == parent_node_id,
).to_list()

units = await UnitBaseDocument.find(
UnitBaseDocument.layer_id == layer_id,
Expand Down
6 changes: 3 additions & 3 deletions Tekst-Web/src/components/browse/UnitHeaderWidgetBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import { useBrowseStore } from '@/stores';
interface Props {
layer: Record<string, any>;
style?: CSSProperties;
showMergeWidget?: boolean;
showSiblingsWidget?: boolean;
showDeactivateWidget?: boolean;
}
withDefaults(defineProps<Props>(), {
showDeactivateWidget: true,
showMergeWidget: true,
showSiblingsWidget: true,
});
const browse = useBrowseStore();
Expand All @@ -36,7 +36,7 @@ const browse = useBrowseStore();
</template>
<!-- generic unit widgets -->
<UnitSiblingsWidget
v-if="(showMergeWidget ?? true) && browse.level >= layer.level - 1"
v-if="(showSiblingsWidget ?? true) && browse.level >= layer.level - 1"
:layer="layer"
/>
<LayerInfoWidget :layer="layer" />
Expand Down
13 changes: 7 additions & 6 deletions Tekst-Web/src/components/browse/widgets/UnitSiblingsWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ async function handleClick() {
units.value = await browseApi
.getUnitSiblings({
layerId: props.layer.id,
parentNodeId: browse.nodePath[props.layer.level - 1].id,
parentNodeId: browse.nodePath[props.layer.level - 1]?.id,
})
.then((resp) => resp.data);
} catch {
} catch(e) {
console.error(e)
message.error(t('errors.unexpected'));
showModal.value = false;
} finally {
Expand All @@ -46,7 +47,7 @@ async function handleClick() {

<template>
<UnitContainerHeaderWidget
:title="$t('browse.units.widgets.mergeWidget.title')"
:title="$t('browse.units.widgets.siblingsWidget.title')"
:iconComponent="MergeRound"
@click="handleClick"
/>
Expand All @@ -68,11 +69,11 @@ async function handleClick() {
v-if="!loading && units.length"
:layer="{ ...layer, units: units }"
:show-deactivate-widget="false"
:show-merge-widget="false"
:show-siblings-widget="false"
/>
</div>

<div class="merge-location"><LocationLabel :maxLevel="layer.level - 1" /></div>
<div class="parent-location"><LocationLabel :maxLevel="layer.level - 1" /></div>

<n-spin v-if="loading" style="margin: 3rem 0 2rem 0; width: 100%" />

Expand Down Expand Up @@ -104,7 +105,7 @@ async function handleClick() {
flex-grow: 2;
}
.merge-location {
.parent-location {
font-size: var(--app-ui-font-size-large);
opacity: 0.6;
margin-bottom: 1rem;
Expand Down
2 changes: 1 addition & 1 deletion Tekst-Web/src/i18n/translations/deDE.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ browse:
deactivateWidget:
title: Diese Datenschicht ausblenden
message: Die Datenschicht "{layerTitle}" wurde ausgeblendet. Sie können sie wieder aktivieren, indem Sie die Datenschichten-Auswahl rechts in der Toolbar benutzen.
mergeWidget:
siblingsWidget:
title: Zusammengeführte Ansicht mit allen Daten der übergeordneten Fundstelle öffnen

forms:
Expand Down
2 changes: 1 addition & 1 deletion Tekst-Web/src/i18n/translations/enUS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ browse:
deactivateWidget:
title: Hide this data layer
message: The data layer "{layerTitle}" has been hidden. You can activate it again using the data layer selection tool to the right side of the toolbar.
mergeWidget:
siblingsWidget:
title: Open merged view with all data of the parent location

forms:
Expand Down
12 changes: 5 additions & 7 deletions Tekst-Web/src/openapi/api.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 906f38b

Please sign in to comment.