optimize Pager search to remove redundant AllowSearch parameter and avoid consuming memory when not in use

This commit is contained in:
sbwalker 2023-10-12 11:10:14 -04:00
parent 6140743769
commit b77e72880b
10 changed files with 12 additions and 17 deletions

View File

@ -29,7 +29,7 @@
</div> </div>
</div> </div>
<Pager Items="@_files" AllowSearch="True" SearchProperties="Name"> <Pager Items="@_files" SearchProperties="Name">
<Header> <Header>
<th style="width: 1px;">&nbsp;</th> <th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th> <th style="width: 1px;">&nbsp;</th>

View File

@ -15,7 +15,7 @@ else
<br /> <br />
<br /> <br />
<Pager Items="@_jobs" AllowSearch="True" SearchProperties="Name"> <Pager Items="@_jobs" SearchProperties="Name">
<Header> <Header>
<th style="width: 1px;">&nbsp;</th> <th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th> <th style="width: 1px;">&nbsp;</th>

View File

@ -14,7 +14,7 @@ else
{ {
<ActionLink Action="Add" Text="Add Language" ResourceKey="AddLanguage" /> <ActionLink Action="Add" Text="Add Language" ResourceKey="AddLanguage" />
<Pager Items="@_languages" AllowSearch="True" SearchProperties="Name,Code"> <Pager Items="@_languages" SearchProperties="Name,Code">
<Header> <Header>
<th style="width: 1px;">&nbsp;</th> <th style="width: 1px;">&nbsp;</th>
<th>@SharedLocalizer["Name"]</th> <th>@SharedLocalizer["Name"]</th>

View File

@ -9,7 +9,7 @@
{ {
<ActionLink Action="Add" Text="Add Page" ResourceKey="AddPage" /> <ActionLink Action="Add" Text="Add Page" ResourceKey="AddPage" />
<Pager Items="@PageState.Pages.Where(item => !item.IsDeleted)" AllowSearch="True" SearchProperties="Name"> <Pager Items="@PageState.Pages.Where(item => !item.IsDeleted)" SearchProperties="Name">
<Header> <Header>
<th style="width: 1px;">&nbsp;</th> <th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th> <th style="width: 1px;">&nbsp;</th>

View File

@ -12,7 +12,7 @@ else
{ {
<ActionLink Action="Add" Text="Add Profile" Security="SecurityAccessLevel.Edit" ResourceKey="AddProfile" /> <ActionLink Action="Add" Text="Add Profile" Security="SecurityAccessLevel.Edit" ResourceKey="AddProfile" />
<Pager Items="@_profiles" AllowSearch="True" SearchProperties="Title,Category"> <Pager Items="@_profiles" SearchProperties="Title,Category">
<Header> <Header>
<th style="width: 1px;">&nbsp;</th> <th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th> <th style="width: 1px;">&nbsp;</th>

View File

@ -12,7 +12,7 @@ else
{ {
<ActionLink Action="Add" Text="Add Role" Security="SecurityAccessLevel.Edit" ResourceKey="AddRole" /> <ActionLink Action="Add" Text="Add Role" Security="SecurityAccessLevel.Edit" ResourceKey="AddRole" />
<Pager Items="@_roles" AllowSearch="True" SearchProperties="Name"> <Pager Items="@_roles" SearchProperties="Name">
<Header> <Header>
<th style="width: 1px;">&nbsp;</th> <th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th> <th style="width: 1px;">&nbsp;</th>

View File

@ -14,7 +14,7 @@ else
{ {
<ActionLink Action="Add" Text="Add Site" ResourceKey="AddSite" /> <ActionLink Action="Add" Text="Add Site" ResourceKey="AddSite" />
<Pager Items="@_sites" AllowSearch="True" SearchProperties="Name"> <Pager Items="@_sites" SearchProperties="Name">
<Header> <Header>
<th style="width: 1px;">&nbsp;</th> <th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th> <th style="width: 1px;">&nbsp;</th>

View File

@ -28,7 +28,7 @@ else
</div> </div>
</div> </div>
<br/> <br/>
<Pager Items="@_urlMappings" AllowSearch="True" SearchProperties="Url"> <Pager Items="@_urlMappings" SearchProperties="Url">
<Header> <Header>
<th style="width: 1px;">&nbsp;</th> <th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th> <th style="width: 1px;">&nbsp;</th>

View File

@ -20,7 +20,7 @@ else
<ActionLink Action="Add" Text="Add User" Security="SecurityAccessLevel.Edit" ResourceKey="AddUser" />&nbsp; <ActionLink Action="Add" Text="Add User" Security="SecurityAccessLevel.Edit" ResourceKey="AddUser" />&nbsp;
<ActionLink Text="Import Users" Class="btn btn-secondary ms-2" Action="Users" Security="SecurityAccessLevel.Admin" ResourceKey="ImportUsers"/> <ActionLink Text="Import Users" Class="btn btn-secondary ms-2" Action="Users" Security="SecurityAccessLevel.Admin" ResourceKey="ImportUsers"/>
<Pager Items="@users" RowClass="align-middle" AllowSearch="True" SearchProperties="Username,Email,DisplayName"> <Pager Items="@users" RowClass="align-middle" SearchProperties="Username,Email,DisplayName">
<Header> <Header>
<th style="width: 1px;">&nbsp;</th> <th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th> <th style="width: 1px;">&nbsp;</th>

View File

@ -6,7 +6,7 @@
@if (ItemList != null) @if (ItemList != null)
{ {
@if (AllowSearch == "True") @if (!string.IsNullOrEmpty(SearchProperties))
{ {
<div class="input-group my-3"> <div class="input-group my-3">
<input id="search" class="form-control" placeholder=@string.Format(Localizer["SearchPlaceholder"], SearchProperties) @bind="@_search" /> <input id="search" class="form-control" placeholder=@string.Format(Localizer["SearchPlaceholder"], SearchProperties) @bind="@_search" />
@ -234,9 +234,6 @@
[Parameter] [Parameter]
public Action<int> OnPageChange { get; set; } // a method to be executed in the calling component when the page changes public Action<int> OnPageChange { get; set; } // a method to be executed in the calling component when the page changes
[Parameter]
public string AllowSearch { get; set; } // allow user to search items
[Parameter] [Parameter]
public string SearchProperties { get; set; } // comma delimited list of property names to include in search public string SearchProperties { get; set; } // comma delimited list of property names to include in search
@ -249,8 +246,6 @@
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
AllItems = Items;
if (string.IsNullOrEmpty(Format)) if (string.IsNullOrEmpty(Format))
{ {
Format = "Table"; Format = "Table";
@ -297,9 +292,9 @@
} }
} }
if (string.IsNullOrEmpty(AllowSearch) || string.IsNullOrEmpty(SearchProperties)) if (!string.IsNullOrEmpty(SearchProperties))
{ {
AllowSearch = "False"; AllItems = Items; // only used in search
} }
if (!string.IsNullOrEmpty(PageSize)) if (!string.IsNullOrEmpty(PageSize))