From 34621412d4aff7b34a735f3463cd4f1f6dfef916 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 26 Sep 2024 15:51:56 -0400 Subject: [PATCH] Disable filters on discover if allowFiltering is false (#208) --- src/app.postcss | 4 ++ src/lib/components/datatable/Row.svelte | 4 ++ src/lib/components/explorer/Explorer.svelte | 4 +- .../components/explorer/cell/Actions.svelte | 37 +++++++++++-------- src/lib/configuration.ts | 1 + tests/mock-data.ts | 13 +++++++ tests/routes/discover/test.ts | 36 ++++++++++++++++++ 7 files changed, 81 insertions(+), 18 deletions(-) diff --git a/src/app.postcss b/src/app.postcss index 2ef6e2b7..8e21870c 100644 --- a/src/app.postcss +++ b/src/app.postcss @@ -373,6 +373,10 @@ input.required:invalid, &:hover { @apply text-primary-600-300-token; } + + &:disabled { + @apply text-surface-500-400-token; + } } .dark .btn-icon-color { diff --git a/src/lib/components/datatable/Row.svelte b/src/lib/components/datatable/Row.svelte index b44bc782..3f45572e 100644 --- a/src/lib/components/datatable/Row.svelte +++ b/src/lib/components/datatable/Row.svelte @@ -59,4 +59,8 @@ .expandable-row { background-color: rgb(var(--color-surface-300)) !important; } + + tr:not(.expandable-row) td:last-child { + text-align: center; + } diff --git a/src/lib/components/explorer/Explorer.svelte b/src/lib/components/explorer/Explorer.svelte index f65416c1..77c1b90b 100644 --- a/src/lib/components/explorer/Explorer.svelte +++ b/src/lib/components/explorer/Explorer.svelte @@ -24,6 +24,7 @@ let searchInput = $page.url.searchParams.get('search') || $searchTerm || ''; const tableName = 'ExplorerTable'; $: tourEnabled = true; + $: isOpenAccess = $page.url.pathname.includes('/discover'); const additionalColumns = branding.explorePage.additionalColumns || []; @@ -31,7 +32,7 @@ ...additionalColumns, { dataElement: 'display', label: 'Variable Name', sort: false }, { dataElement: 'description', label: 'Variable Description', sort: false }, - { dataElement: 'id', label: 'Actions', class: 'w-36' }, + { dataElement: 'id', label: 'Actions', class: 'w-36 text-center' }, ]; const cellOverides = { id: Actions, @@ -83,7 +84,6 @@ unsubSelectedFacets && unsubSelectedFacets(); unsubSearchTerm && unsubSearchTerm(); }); - $: isOpenAccess = $page.url.pathname.includes('/discover');
diff --git a/src/lib/components/explorer/cell/Actions.svelte b/src/lib/components/explorer/cell/Actions.svelte index f4a06bb9..1398b9f2 100644 --- a/src/lib/components/explorer/cell/Actions.svelte +++ b/src/lib/components/explorer/cell/Actions.svelte @@ -5,6 +5,7 @@ import ExportStore from '$lib/stores/Export'; import { v4 as uuidv4 } from 'uuid'; import { features } from '$lib/configuration'; + import { page } from '$app/stores'; let { exports, addExport, removeExport } = ExportStore; export let data = {} as SearchResult; $: exportItem = { @@ -25,7 +26,7 @@ const insertInfoContent = updateActiveRow('info'); const insertFilterContent = updateActiveRow('filter'); - // const insertHierarchyContent = updateActiveRow('hierarchy'); + const insertHierarchyContent = updateActiveRow('hierarchy'); function insertExportContent() { if ($exports.includes(exportItem)) { @@ -34,8 +35,9 @@ addExport(exportItem); } } - + $: isOpenAccess = $page.url.pathname.includes('/discover'); $: isExported = $exports.map((exp) => exp.conceptPath).includes(exportItem.conceptPath); + $: shouldDisableFilter = isOpenAccess && !data.row.allowFiltering; - -{#if features.explorer.exportsEnableExport} +{#if features.explorer.enableHierarchy} + +{/if} +{#if features.explorer.exportsEnableExport && !isOpenAccess}