Skip to content

Commit

Permalink
fix: fixed issues #602, #604, #609
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo Biasi authored and sseppi committed Oct 16, 2024
1 parent 0d8942f commit a6876b3
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 10 deletions.
2 changes: 1 addition & 1 deletion databrowser/src/components/input/InputWithButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
:id="id"
ref="inputRef"
v-model="text"
class="grow border-none bg-transparent p-0 px-3 focus:ring-0"
class="w-full grow border-none bg-transparent p-0 px-3 focus:ring-0"
:placeholder="labelPlaceholder"
:disabled="disabled"
:data-test="`${id}-input`"
Expand Down
2 changes: 1 addition & 1 deletion databrowser/src/components/language/LanguagePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
-->

<template>
<div class="relative z-30 flex items-center">
<div class="z-9 relative flex items-center">
<ButtonLink
v-for="link in links"
:key="link.value"
Expand Down
13 changes: 9 additions & 4 deletions databrowser/src/components/svg/IconAdd.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ SPDX-License-Identifier: AGPL-3.0-or-later

<template>
<svg
width="14"
height="14"
viewBox="0 0 14 14"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
class="rotate-45"
>
<path d="M6 8H0V6H6V0H8V6H14V8H8V14H6V8Z" />
<path
d="M6 18L18 6M6 6l12 12"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
></path>
</svg>
</template>
37 changes: 34 additions & 3 deletions databrowser/src/domain/datasets/ui/header/DatasetHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
<header class="flex flex-wrap items-center py-2 text-xs md:py-0">
<!-- Dataset title -->
<div
class="mb-2 flex w-full items-center justify-between md:mb-0 md:w-auto"
class="mb-2 flex w-full items-center justify-between py-3 md:mb-0 md:w-auto"
>
<span
v-if="hasConfig"
Expand Down Expand Up @@ -58,6 +58,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
@overlay-click="handleInputSearchOpen(false)"
>
<InputSearch
v-if="isOnTableView"
id="search-dataset"
:class="[inputSearchOpen ? 'flex' : 'hidden md:flex']"
:model-value="searchfilter"
Expand All @@ -78,7 +79,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later
<div class="ml-auto flex gap-2">
<AddRecordButton
v-if="addRecordSupported"
class="mr-2 hidden md:flex"
class="mr-2 md:flex"
data-test="desktop-add-record-link"
/>

Expand Down Expand Up @@ -120,13 +121,15 @@ import { LocationQuery, useRoute, useRouter } from 'vue-router';
import { computeTableLocation } from '../../location/datasetViewLocation';
import { TourismMetaData } from '../../../metaDataConfig/tourism/types';
import { useDatasetViewStore } from '../../view/store/datasetViewStore';
import { useSessionStorage } from '@vueuse/core';

const { view } = storeToRefs(useDatasetViewStore());

const { t } = useI18n();

const router = useRouter();
const route = useRoute();
const SESSION_DATASET_KEY = 'currentDataset';

// Data fetch
const { metaDataDatasets } = useMetaDataDatasets();
Expand Down Expand Up @@ -186,6 +189,10 @@ const selectOptions = computed<GroupSelectOption[]>(() => {
return _options;
});

const isOnTableView = computed<boolean>(() => {
return route.fullPath.startsWith('/dataset/table/');
});

const handleInputSearchOpen = (state: boolean) => {
inputSearchOpen.value = state;
};
Expand All @@ -206,6 +213,7 @@ const handleDatasetChange = (value: string) => {
const domain = getDomainOfDataset(dataset);

router.push(computeTableLocation(domain, pathSegments, apiFilter));
setCurrentDataset(getDatasetSelectValue(dataset));
};

const getDomainOfDataset = (dataset: TourismMetaData) => {
Expand Down Expand Up @@ -283,6 +291,13 @@ const getCommonPrefixLength = (str1: string, str2: string): number => {
return i;
};

const setCurrentDataset = (dataset: string) => {
const currentSessionDataset = useSessionStorage(SESSION_DATASET_KEY, '');

currentDataset.value = dataset;
currentSessionDataset.value = dataset;
};

watch(
() => selectOptions.value,
(_options) => {
Expand All @@ -302,7 +317,23 @@ watch(

if (!dataset) return;

currentDataset.value = dataset;
const currentSessionDataset = useSessionStorage(SESSION_DATASET_KEY, '');
let sessionDataset = null;

if (currentSessionDataset.value) {
let [currentDatasetPath] = currentSessionDataset.value.split('?');
let [foundDatasetPath] = dataset.split('?');

if (currentDatasetPath === foundDatasetPath) {
sessionDataset = currentSessionDataset.value;
}
}

if (sessionDataset) {
currentDataset.value = currentSessionDataset.value;
} else {
setCurrentDataset(dataset);
}
}
);
</script>
2 changes: 1 addition & 1 deletion databrowser/src/domain/datasets/ui/toolBox/ToolBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ SPDX-License-Identifier: AGPL-3.0-or-later

<!-- ToolBox content -->
<div
class="absolute top-0 z-[1000] flex h-full flex-col overflow-x-auto bg-gray-50 transition-all md:relative"
class="absolute top-0 z-[10] flex h-full flex-col overflow-x-auto bg-gray-50 transition-all md:relative"
:class="{
'w-full md:w-1/3': toolBoxStore.visible,
'w-0 md:w-[4.5rem]': !toolBoxStore.visible,
Expand Down

0 comments on commit a6876b3

Please sign in to comment.