Skip to content

Commit 566cfe5

Browse files
committed
#2310 add placeholder during search load
1 parent 0413bab commit 566cfe5

File tree

7 files changed

+64
-30
lines changed

7 files changed

+64
-30
lines changed

Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI.Svelte/src/app.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
%sveltekit.head%
88
</head>
99
<body data-theme="bexis2theme">
10-
<div id="taginfo" dataset="7" withMinor="false">
11-
<div id="curation" dataset-id="0">
12-
%sveltekit.body%
13-
</div>
10+
<div id="search" search_result_presentation="cards">
11+
<div id="taginfo" dataset="7" withMinor="false">
12+
<div id="curation" dataset-id="0">
13+
%sveltekit.body%
14+
</div>
15+
</div>
1416
</div>
1517
</body>
1618
</html>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<script>
2+
3+
</script>
4+
5+
<div class="flex flex-col gap-4 grow min-w-[500px]">
6+
<p class="text-muted text-sm">
7+
...loading
8+
</p>
9+
10+
<div class="placeholder animate-pulse h-36 w-full p-4 px-5 border rounded-md "/>
11+
<div class="placeholder animate-pulse h-36 w-full p-4 px-5 border rounded-md "/>
12+
<div class="placeholder animate-pulse h-36 w-full p-4 px-5 border rounded-md "/>
13+
<div class="placeholder animate-pulse h-36 w-full p-4 px-5 border rounded-md "/>
14+
</div>
15+

Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI.Svelte/src/lib/components/Search.svelte

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
import { RadioGroup, RadioItem, SlideToggle } from '@skeletonlabs/skeleton';
88
9-
import { Api, Facets, Page, pageContentLayoutType, Table } from '@bexis2/bexis2-core-ui';
9+
import { Api, Facets, Page, pageContentLayoutType, Table, TablePlaceholder } from '@bexis2/bexis2-core-ui';
1010
import type { Columns, FacetGroup, linkType, TableConfig } from '@bexis2/bexis2-core-ui';
1111
1212
import Cards from '$lib/components/Cards.svelte';
@@ -17,6 +17,7 @@
1717
import { convertTableData } from '$lib/helpers';
1818
import { onMount } from 'svelte';
1919
import { writable } from 'svelte/store';
20+
import CardsPlaceHolder from './CardsPlaceHolder.svelte';
2021
2122
export let controller: string = 'search';
2223
@@ -26,7 +27,10 @@
2627
let currentCategory = 'All';
2728
let q = '';
2829
29-
let currentView: 'table' | 'cards' = 'table';
30+
// get data from parent
31+
let container = document.getElementById('search');
32+
let currentView:string = ""+container?.getAttribute('search_result_presentation'); //'table' | 'cards' = 'table';
33+
3034
3135
let facetsRef: any;
3236
@@ -399,29 +403,13 @@
399403
}));
400404
};
401405
402-
const load = async (input: string) => {
403-
const data = [
404-
{ Text: 'a', Value: 'a' },
405-
{ Text: 'b', Value: 'b' },
406-
{ Text: 'c', Value: 'c' },
407-
{ Text: 'd', Value: 'd' },
408-
{ Text: 'e', Value: 'e' },
409-
{ Text: 'f', Value: 'f' },
410-
{ Text: 'g', Value: 'g' }
411-
];
412-
413-
return data.map((item: any) => ({
414-
label: item.Text,
415-
value: item.Value
416-
}));
417-
};
418-
419406
const handleAutoCompleteSelect = async (e: { detail: { value: string; label: string } }) => {
420407
q = e.detail.value;
421408
422409
return null;
423410
};
424411
412+
425413
onMount(async () => {
426414
await handleSearch(true);
427415
});
@@ -450,6 +438,8 @@
450438
on:showMoreSelect={handleShowMoreSelect}
451439
on:showMoreOpenChange={handleShowMoreOpenChange}
452440
/>
441+
{:else}
442+
<TablePlaceholder cols={1} rows={12}/>
453443
{/if}
454444
</div>
455445
</div>
@@ -586,14 +576,25 @@
586576
</div>
587577
</div>
588578
<div class="pt-8">
579+
589580
{#if config}
590581
<div class:hidden={currentView === 'cards'} class="">
591582
<Table {config} />
592583
</div>
584+
<div class:hidden={currentView === 'table'}>
585+
<Cards store={placeholderStore} {authorLabel} />
586+
</div>
587+
{:else}
588+
589+
{#if currentView === 'table'}
590+
<TablePlaceholder cols={6} rows={10}/>
593591
{/if}
594-
<div class:hidden={currentView === 'table'}>
595-
<Cards store={placeholderStore} {authorLabel} />
596-
</div>
592+
{#if currentView === 'cards'}
593+
<CardsPlaceHolder />
594+
{/if}
595+
596+
{/if}
597+
597598
</div>
598599
</div>
599600
</Pane>

Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI.Svelte/src/routes/search/+page.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
const controller = 'search';
66
7+
78
const links: linkType[] = [
89
{ label: 'Public Search', url: '/ddm/publicsearch' },
910
{ label: 'Manual', url: '/home/docs/Search%20and%20Download%20Data/' }

Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI/Controllers/SearchController.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using Vaiona.IoC;
1616
using Vaiona.Web.Extensions;
1717
using Vaiona.Web.Mvc.Models;
18+
using Vaiona.Web.Mvc.Modularity;
1819
using SearchCriteria = BExIS.Utils.Models.SearchCriteria;
1920

2021
namespace BExIS.Modules.Ddm.UI.Controllers
@@ -32,6 +33,9 @@ public ActionResult Index()
3233
ViewData["app"] = SvelteHelper.GetApp(module);
3334
ViewData["start"] = SvelteHelper.GetStart(module);
3435

36+
var settings = ModuleManager.GetModuleSettings("DDM");
37+
ViewData["search_result_presentation"] = settings.GetValueByKey("search_result_presentation").ToString();
38+
3539
return View();
3640
}
3741

Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI/Ddm.Settings.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@
4545
"type": "Boolean",
4646
"description": "If set to true, the minor version tag can be assigned to dataset versions to display changes in more detail."
4747
},
48+
{
49+
"key": "search_result_presentation",
50+
"title": "Search Result Presentation",
51+
"value": "table",
52+
"description": "Select the initial display format for all user search results across the system. This setting establishes the global baseline for result presentation.",
53+
"type": "String",
54+
"options": [
55+
"table",
56+
"cards"
57+
]
58+
},
4859
{
4960
"key": "data_aggreement",
5061
"title": "Data Aggreement by download",

Console/BExIS.Web.Shell/Areas/DDM/BExIS.Modules.Ddm.UI/Views/Search/Index.cshtml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
ViewBag.Title = "Search";
33
Layout = "~/Themes/Default/Layouts/_svelteLayout.cshtml";
44

5-
bool isTemplateRequired = false;
5+
string search_result_presentation = "";
66

7-
if (ViewData["isTemplateRequired"] != null)
7+
if (ViewData["search_result_presentation"] != null)
88
{
9-
isTemplateRequired = (bool)ViewData["isTemplateRequired"];
9+
search_result_presentation = ViewData["search_result_presentation"].ToString();
1010
}
1111

1212
}
1313

14-
<div id="search">
14+
<div id="search" search_result_presentation="@search_result_presentation" >
1515
@Html.Partial("_sveltePage")
1616
</div>

0 commit comments

Comments
 (0)