code cleanup namespace

This commit is contained in:
Frede Hundewadt 2023-05-07 15:34:54 +02:00
parent 135f4c5783
commit 6aa1df56a3
30 changed files with 113 additions and 98 deletions

View file

@ -18,8 +18,9 @@ using Wonky.Entity.Views;
namespace Wonky.Client.Components;
public partial class CatalogPrintComponent
public partial class PrintCatalogComponent
{
// ######################################################################3
[Parameter] public List<SalesItemView> ItemList { get; set; } = new();
[Parameter] public string CountryName { get; set; } = "";
}

View file

@ -20,18 +20,23 @@ using Wonky.Client.Local.Services;
namespace Wonky.Client.Components;
public partial class AdvisorActivityKmStartComponent
public partial class ReportActivityKmStartComponent
{
// ######################################################################3
[Inject] public UserPreferenceService PreferenceService { get; set; }
// ######################################################################3
private int KmMorning { get; set; }
private UserPreference Preferences { get; set; } = new();
protected override async Task OnInitializedAsync()
{
Preferences = await PreferenceService.GetProfile();
KmMorning = Preferences.KmMorning;
}
private async Task OnKmChanged()
{
await PreferenceService.SetKmMorning(KmMorning);

View file

@ -20,31 +20,19 @@ using Wonky.Client.Local.Services;
namespace Wonky.Client.Components;
public partial class CatalogSearchComponent : IDisposable
public partial class SearchCatalogColumnComponent : IDisposable
{
/// <summary>
/// User preference service
/// </summary>
// ######################################################################3
[Inject] public UserPreferenceService PreferenceService { get; set; }
/// <summary>
/// OnChanged event callback
/// </summary>
// ######################################################################3
[Parameter] public EventCallback<string> OnChanged { get; set; }
/// <summary>
/// User preferences
/// </summary>
// ######################################################################3
private UserPreference Profiles { get; set; } = new();
/// <summary>
/// Selected item
/// </summary>
private string SearchCol { get; set; } = "";
/// <summary>
/// Component initialization
/// </summary>
protected override async Task OnInitializedAsync()
{
PreferenceService.OnChange += ProfileServiceOnOnChange;
@ -53,10 +41,7 @@ public partial class CatalogSearchComponent : IDisposable
await OnChanged.InvokeAsync(SearchCol);
}
/// <summary>
/// OnSelectChanged event handler
/// </summary>
/// <param name="e"></param>
private async Task OnSelectChanged(ChangeEventArgs e)
{
var val = e.Value.ToString();
@ -65,19 +50,14 @@ public partial class CatalogSearchComponent : IDisposable
await PreferenceService.SetItemSearch(val);
}
/// <summary>
/// Preference update from profile service
/// </summary>
/// <param name="newUserPreference"></param>
private void ProfileServiceOnOnChange(UserPreference newUserPreference)
{
Profiles = newUserPreference;
StateHasChanged();
}
/// <summary>
/// Component dispose
/// </summary>
public void Dispose()
{
PreferenceService.OnChange -= ProfileServiceOnOnChange;

View file

@ -21,7 +21,7 @@ using Wonky.Client.Local.Services;
namespace Wonky.Client.Components;
public partial class CatalogGroupComponent
public partial class SearchCatalogGroupComponent
{
[Inject] public ILocalStorageService Storage { get; set; }
[Inject] public UserPreferenceService PreferenceService { get; set; }

View file

@ -19,7 +19,7 @@ using Timer = System.Timers.Timer;
namespace Wonky.Client.Components;
public partial class CatalogSearchPhraseComponent
public partial class SearchCatalogPhraseComponent
{
private Timer Timer { get; set; } = new();
private string SearchTerm { get; set; } = "";

View file

@ -20,31 +20,19 @@ using Wonky.Client.Local.Services;
namespace Wonky.Client.Components;
public partial class CatalogSortComponent : IDisposable
public partial class SearchCatalogSortColumnComponent : IDisposable
{
/// <summary>
/// User preference service
/// </summary>
// ######################################################################3
[Inject] public UserPreferenceService PreferenceService { get; set; }
/// <summary>
/// OnChanged callback function
/// </summary>
// ######################################################################3
[Parameter] public EventCallback<string> OnChanged { get; set; }
/// <summary>
/// User's preferences
/// </summary>
// ######################################################################3
private UserPreference _profiles = new();
/// <summary>
/// Item selected by user
/// </summary>
private string SortCol { get; set; }
/// <summary>
/// Component initialization
/// </summary>
protected override async Task OnInitializedAsync()
{
PreferenceService.OnChange += ProfileServiceOnOnChange;
@ -52,10 +40,7 @@ public partial class CatalogSortComponent : IDisposable
SortCol = _profiles.ItemSort;
}
/// <summary>
/// OnSelectChanged trigger
/// </summary>
/// <param name="e"></param>
private async Task OnSelectChanged(ChangeEventArgs e)
{
var val = e.Value.ToString();
@ -64,19 +49,14 @@ public partial class CatalogSortComponent : IDisposable
await PreferenceService.SetItemSort(val);
}
/// <summary>
/// Get updated settings from preference service
/// </summary>
/// <param name="newUserPreference"></param>
private void ProfileServiceOnOnChange(UserPreference newUserPreference)
{
_profiles = newUserPreference;
StateHasChanged();
}
/// <summary>
/// Component dispose
/// </summary>
public void Dispose()
{
PreferenceService.OnChange -= ProfileServiceOnOnChange;

View file

@ -22,20 +22,29 @@ using Wonky.Client.Local.Services;
namespace Wonky.Client.Components;
public partial class CustomerSearchColumnComponent : IDisposable
public partial class SearchCustomerColumnComponent : IDisposable
{
// ######################################################################3
[Inject] public ILocalStorageService Storage { get; set; }
[Inject] public UserPreferenceService PreferenceService { get; set; }
// ######################################################################3
[Parameter] public EventCallback<string> OnChanged { get; set; }
// ######################################################################3
private Dictionary<string, string> Items { get; set; } = new();
private UserPreference Profiles { get; set; } = new();
private string SearchCol { get; set; } = "name";
protected override async Task OnInitializedAsync()
{
PreferenceService.OnChange += ProfileServiceOnOnChange;
Profiles = await PreferenceService.GetProfile();
SearchCol = Profiles.CompanySearch;
}
private async Task OnSelectionChanged(ChangeEventArgs e)
{
var val = e.Value.ToString();
@ -43,11 +52,15 @@ public partial class CustomerSearchColumnComponent : IDisposable
await OnChanged.InvokeAsync(val);
await PreferenceService.SetCompanySearch(val);
}
private void ProfileServiceOnOnChange(UserPreference newUserPreference)
{
Profiles = newUserPreference;
StateHasChanged();
}
public void Dispose()
{
PreferenceService.OnChange -= ProfileServiceOnOnChange;

View file

@ -21,13 +21,19 @@ using Timer = System.Timers.Timer;
namespace Wonky.Client.Components;
public partial class CustomerSearchPhraseComponent
public partial class SearchCustomerPhraseComponent
{
// ######################################################################3
[Inject] public UserPreferenceService PreferenceService { get; set; }
// ######################################################################3
[Parameter] public EventCallback<string> OnChanged { get; set; }
// ######################################################################3
private Timer InputTimer { get; set; } = new();
private string SearchTerm { get; set; } = "";
private UserPreference Profiles { get; set; } = new ();
[Inject] public UserPreferenceService PreferenceService { get; set; }
[Parameter] public EventCallback<string> OnChanged { get; set; }
protected override async Task OnInitializedAsync()
{
@ -38,6 +44,7 @@ public partial class CustomerSearchPhraseComponent
await OnChanged.InvokeAsync(SearchTerm);
}
private async Task ClearSearch()
{
InputTimer.Dispose();
@ -45,7 +52,8 @@ public partial class CustomerSearchPhraseComponent
await PreferenceService.SetCompanyFilterPhrase(SearchTerm.Trim());
await OnChanged.InvokeAsync(SearchTerm);
}
private async Task OnSearchChanged()
{
await PreferenceService.SetCompanyFilterPhrase(SearchTerm.Trim());
@ -54,9 +62,9 @@ public partial class CustomerSearchPhraseComponent
InputTimer.AutoReset = false;
InputTimer.Elapsed += OnTimerElapsed;
InputTimer.Enabled = true;
}
private void OnTimerElapsed(object? sender, ElapsedEventArgs e)
{
InputTimer.Dispose();

View file

@ -22,20 +22,29 @@ using Wonky.Client.Local.Services;
namespace Wonky.Client.Components;
public partial class CustomerSortComponent : IDisposable
public partial class SearchCustomerSortColumnComponent : IDisposable
{
// ######################################################################3
[Inject] public ILocalStorageService Storage { get; set; }
[Inject] public UserPreferenceService PreferenceService { get; set; }
// ######################################################################3
[Parameter] public EventCallback<string> OnChanged { get; set; }
// ######################################################################3
private Dictionary<string, string> Items { get; set; } = new();
private UserPreference _profiles = new();
private string SortCol { get; set; } = "name";
protected override async Task OnInitializedAsync()
{
PreferenceService.OnChange += ProfileServiceOnOnChange;
_profiles = await PreferenceService.GetProfile();
SortCol = _profiles.CompanySort;
}
private async Task OnSelectionChanged(ChangeEventArgs e)
{
var val = e.Value.ToString();
@ -43,11 +52,15 @@ public partial class CustomerSortComponent : IDisposable
await OnChanged.InvokeAsync(val);
await PreferenceService.SetCompanySort(val);
}
private void ProfileServiceOnOnChange(UserPreference newUserPreference)
{
_profiles = newUserPreference;
StateHasChanged();
}
public void Dispose()
{
PreferenceService.OnChange -= ProfileServiceOnOnChange;

View file

@ -26,13 +26,13 @@
<div class="sticky-top bg-dark rounded-2 p-3">
<div class="row mb-2">
<div class="col-sm-2">
<CatalogSearchComponent OnChanged="SetSearchCol"/>
<SearchCatalogColumnComponent OnChanged="SetSearchCol"/>
</div>
<div class="col-sm-6">
<CatalogSearchPhraseComponent OnChanged="SetSearchPhrase"/>
<SearchCatalogPhraseComponent OnChanged="SetSearchPhrase"/>
</div>
<div class="col-sm-2">
<CatalogSortComponent OnChanged="SetSortCol"/>
<SearchCatalogSortColumnComponent OnChanged="SetSortCol"/>
</div>
<div class="col-sm-2">
<PageSizeComponent OnChanged="SetPageSize"/>

View file

@ -24,7 +24,7 @@
<WorkDateComponent OnWorkDateChangedCallback="GetWorkDateActivities"/>
</div>
<div class="col-sm-3">
<AdvisorActivityKmStartComponent/>
<ReportActivityKmStartComponent/>
</div>
<div class="col-sm-2 text-end">
@if (ReportExist)

View file

@ -22,13 +22,13 @@
<div class="sticky-top bg-dark text-light rounded-2 px-3">
<div class="row g-3">
<div class="col-sm-2">
<CustomerSearchColumnComponent OnChanged="SetSearchCol"/>
<SearchCustomerColumnComponent OnChanged="SetSearchCol"/>
</div>
<div class="col-sm-6">
<CustomerSearchPhraseComponent OnChanged="SetSearchPhrase"/>
<SearchCustomerPhraseComponent OnChanged="SetSearchPhrase"/>
</div>
<div class="col-sm-2">
<CustomerSortComponent OnChanged="SetSortCol"/>
<SearchCustomerSortColumnComponent OnChanged="SetSortCol"/>
</div>
<div class="col-sm-2">
<PageSizeComponent OnChanged="SetPageSize"/>

View file

@ -28,6 +28,7 @@ namespace Wonky.Client.Pages;
public partial class AdvisorCustomerPagedListPage : IDisposable
{
// ######################################################################3
[Inject] public ILocalStorageService Storage { get; set; }
[Inject] public UserPreferenceService PreferenceService { get; set; }
[Inject] public IAdvisorCustomerRepository CompanyRepo { get; set; }
@ -35,6 +36,7 @@ public partial class AdvisorCustomerPagedListPage : IDisposable
[Inject] public NavigationManager Navigator { get; set; }
[Inject] public IUserInfoService UserInfoService { get; set; }
// ######################################################################3
private List<CompanyDto> CompanyList { get; set; } = new();
private UserPreference Profile { get; set; } = new();
private UserManagerEditView UserInfo { get; set; } = new();
@ -47,12 +49,14 @@ public partial class AdvisorCustomerPagedListPage : IDisposable
private string ToggleHiddenText { get; set; } = "Inaktive";
private bool ShowHidden { get; set; }
protected override void OnParametersSet()
{
Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent();
}
protected override async Task OnInitializedAsync()
{
// set preferences
@ -65,14 +69,12 @@ public partial class AdvisorCustomerPagedListPage : IDisposable
// load saved search
SavedSearch = string.IsNullOrWhiteSpace(Profile.CompanyFilterPhrase) ? "" : Profile.CompanyFilterPhrase;
Paging.SearchTerm = SavedSearch;
await SetSearchPhrase(SavedSearch);
// get companies
await FetchCustomers();
Working = false;
}
private async Task ToggleFolded()
{
Working = true;

View file

@ -27,7 +27,7 @@
<WorkDateComponent OnWorkDateChangedCallback="SetWorkDateCallback"/>
</div>
<div class="col-sm-4 text-end">
<AdvisorActivityKmStartComponent/>
<ReportActivityKmStartComponent/>
</div>
</div>

View file

@ -26,16 +26,16 @@
<div class="sticky-top bg-dark rounded-2 px-3">
<div class="row g-3 mb-3">
<div class="col-sm-2">
<CatalogGroupComponent OnChanged="SetGroupCol"/>
<SearchCatalogGroupComponent OnChanged="SetGroupCol"/>
</div>
<div class="col-sm-2">
<CatalogSearchComponent OnChanged="SetSearchCol"/>
<SearchCatalogColumnComponent OnChanged="SetSearchCol"/>
</div>
<div class="col-sm-4">
<CatalogSearchPhraseComponent OnChanged="SetSearchPhrase"/>
<SearchCatalogPhraseComponent OnChanged="SetSearchPhrase"/>
</div>
<div class="col-sm-2">
<CatalogSortComponent OnChanged="SetSortCol"/>
<SearchCatalogSortColumnComponent OnChanged="SetSortCol"/>
</div>
<div class="col-sm-2">
<PageSizeComponent OnChanged="SetPageSize"/>

View file

@ -29,6 +29,7 @@ namespace Wonky.Client.Pages;
public partial class CatalogCountryPagedListPage : IDisposable
{
// ##############################################################
[Inject] public ILocalStorageService Storage { get; set; }
[Inject] public ICountryCatalogRepository Catalog { get; set; }
[Inject] public HttpInterceptorService Interceptor { get; set; }
@ -37,8 +38,10 @@ public partial class CatalogCountryPagedListPage : IDisposable
[Inject] public NavigationManager Navigator { get; set; }
[Inject] public IUserInfoService UserInfoService { get; set; }
// ##############################################################
[Parameter] public string CountryCode { get; set; } = "";
// ##############################################################
private List<SalesItemView> Items { get; set; } = new();
private MetaData PageData { get; set; } = new();
private CatalogPager Paging { get; set; } = new();
@ -47,6 +50,7 @@ public partial class CatalogCountryPagedListPage : IDisposable
private bool Working { get; set; }
private string CountryName { get; set; } = "";
protected override async Task OnInitializedAsync()
{
Profiles = await PreferenceService.GetProfile();
@ -70,9 +74,11 @@ public partial class CatalogCountryPagedListPage : IDisposable
}
CountryName = Utils.CountryName(CountryCode);
await GetCatalogPaged();
}
private async Task SetSearchPhrase(string searchTerm)
{
Items = new List<SalesItemView>();
@ -81,6 +87,7 @@ public partial class CatalogCountryPagedListPage : IDisposable
await GetCatalogPaged();
}
private async Task SetPageSize(string pageSize)
{
Items = new List<SalesItemView>();
@ -89,6 +96,7 @@ public partial class CatalogCountryPagedListPage : IDisposable
await GetCatalogPaged();
}
private async Task SetSearchCol(string columnName)
{
Items = new List<SalesItemView>();
@ -97,6 +105,7 @@ public partial class CatalogCountryPagedListPage : IDisposable
await GetCatalogPaged();
}
private async Task SetSortCol(string orderBy)
{
Items = new List<SalesItemView>();
@ -104,6 +113,7 @@ public partial class CatalogCountryPagedListPage : IDisposable
await GetCatalogPaged();
}
private async Task SetSelectedPage(int page)
{
Items = new List<SalesItemView>();
@ -111,6 +121,7 @@ public partial class CatalogCountryPagedListPage : IDisposable
await GetCatalogPaged();
}
private async Task SetGroupCol(string groupFilter)
{
Items = new List<SalesItemView>();
@ -119,6 +130,7 @@ public partial class CatalogCountryPagedListPage : IDisposable
await GetCatalogPaged();
}
private async Task GetCatalogPaged()
{
if (string.IsNullOrWhiteSpace(CountryCode))
@ -132,6 +144,7 @@ public partial class CatalogCountryPagedListPage : IDisposable
Working = false;
}
public void Dispose() => Interceptor.DisposeEvent();
}

View file

@ -21,7 +21,7 @@
<PageTitle>Udskriv Katalog for @CountryName</PageTitle>
<CatalogPrintComponent ItemList="Items" CountryName="@CountryName" />
<PrintCatalogComponent ItemList="Items" CountryName="@CountryName" />
@if (Working)
{

View file

@ -28,27 +28,27 @@
<div class="row mb-2">
<label class="col-md-3 col-form-label">Kunde søgning</label>
<div class="col-md-3">
<CustomerSearchColumnComponent />
<SearchCustomerColumnComponent />
</div>
</div>
<div class="row mb-2">
<label class="col-md-3 col-form-label">Kunde sortering</label>
<div class="col-md-3">
<CustomerSortComponent />
<SearchCustomerSortColumnComponent />
</div>
</div>
<div class="row mb-2">
<label class="col-md-3 col-form-label">Produkt søgning</label>
<div class="col-md-3">
<CatalogSearchComponent />
<SearchCatalogColumnComponent />
</div>
</div>
<div class="row mb-2">
<label class="col-md-3 col-form-label">Produkt sortering</label>
<div class="col-md-3">
<CatalogSortComponent />
<SearchCatalogSortColumnComponent />
</div>
</div>

View file

@ -25,13 +25,13 @@
<div class="sticky-top bg-dark text-light rounded-2 px-3">
<div class="row g-2">
<div class="col-sm-3">
<CustomerSearchColumnComponent OnChanged="SetSearchCol"/>
<SearchCustomerColumnComponent OnChanged="SetSearchCol"/>
</div>
<div class="col-sm-3">
<CustomerSearchPhraseComponent OnChanged="SetSearchPhrase"/>
<SearchCustomerPhraseComponent OnChanged="SetSearchPhrase"/>
</div>
<div class="col-sm-3">
<CustomerSortComponent OnChanged="SetSortCol"/>
<SearchCustomerSortColumnComponent OnChanged="SetSortCol"/>
</div>
<div class="col-sm-3">
<PageSizeComponent OnChanged="SetPageSize"/>

View file

@ -23,13 +23,13 @@
<div class="sticky-top bg-dark text-light rounded-2 px-3">
<div class="row g-3">
<div class="col-sm-2">
<CustomerSearchColumnComponent OnChanged="SetSearchCol" />
<SearchCustomerColumnComponent OnChanged="SetSearchCol" />
</div>
<div class="col-sm-6">
<CustomerSearchPhraseComponent OnChanged="SetSearchPhrase" />
<SearchCustomerPhraseComponent OnChanged="SetSearchPhrase" />
</div>
<div class="col-sm-2">
<CustomerSortComponent OnChanged="SetSortCol" />
<SearchCustomerSortColumnComponent OnChanged="SetSortCol" />
</div>
<div class="col-sm-2">
<PageSizeComponent OnChanged="SetPageSize" />

View file

@ -1,15 +1,15 @@
{
"appInfo": {
"name": "Wonky Online",
"version": "138.12",
"version": "139.0",
"rc": false,
"sandBox": false,
"image": "grumpy-coder.png"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"System": "Information",
"Default": "Debug",
"System": "Debug",
"Microsoft": "Information"
},
"Debug": {
@ -19,7 +19,7 @@
}
},
"apiConfig": {
"baseUrl": "https://eta.innotec.dk",
"baseUrl": "https://dev.innotec.dk",
"catalog": "api/v2/catalog/country",
"crmCustomers": "api/v2/crm/companies",
"crmInventoryExt": "history/inventory",