removed IHttpContextAccessor as it shoudl not be used in Blazor, fixed form handling, added Reset button to consistent with other framework search options, used SharedLocalizer, removed unused localization keys

This commit is contained in:
sbwalker
2024-06-11 08:38:51 -04:00
parent 1d7fcfdaa1
commit b3706574de
5 changed files with 15 additions and 234 deletions

View File

@ -1,48 +0,0 @@
@namespace Oqtane.Modules.Admin.SearchResults
@inherits ModuleBase
@implements Oqtane.Interfaces.ISettingsControl
@inject ISettingService SettingService
@inject IStringLocalizer<Settings> Localizer
@inject IStringLocalizer<SharedResources> SharedLocalizer
<div class="container">
<div class="row mb-1 align-items-center">
<Label Class="col-sm-3" For="pageSize" ResourceKey="PageSize" ResourceType="@resourceType">Page Size:</Label>
<div class="col-sm-9">
<input name="pageSize" id="pageSize" class="form-control" type="number" @bind="_pageSize" />
</div>
</div>
</div>
@code {
private const string SearchDefaultPageSize = "10";
private string resourceType = "Oqtane.Modules.Admin.SearchResults.Settings, Oqtane.Client"; // for localization
private string _pageSize;
protected override void OnInitialized()
{
try
{
_pageSize = SettingService.GetSetting(ModuleState.Settings, "PageSize", SearchDefaultPageSize);
}
catch (Exception ex)
{
AddModuleMessage(ex.Message, MessageType.Error);
}
}
public async Task UpdateSettings()
{
try
{
var settings = await SettingService.GetModuleSettingsAsync(ModuleState.ModuleId);
settings = SettingService.SetSetting(settings, "PageSize", _pageSize);
await SettingService.UpdateModuleSettingsAsync(settings, ModuleState.ModuleId);
}
catch (Exception ex)
{
AddModuleMessage(ex.Message, MessageType.Error);
}
}
}