page size fix when navigating from customer card to list

This commit is contained in:
Frede Hundewadt 2023-02-28 10:59:28 +01:00
parent 5c51b2d8ca
commit a1b67a8b6e
6 changed files with 32 additions and 22 deletions

View file

@ -24,20 +24,22 @@ namespace Wonky.Client.Components;
public partial class PageSizeComponent : IDisposable public partial class PageSizeComponent : IDisposable
{ {
[Inject] public ILocalStorageService Storage { get; set; }
[Inject] public UserProfileService ProfileService { get; set; } [Inject] public UserProfileService ProfileService { get; set; }
[Parameter] public EventCallback<string> OnChanged { get; set; } [Parameter] public EventCallback<string> OnChanged { get; set; }
private Dictionary<string, string> Items { get; set; } = new(); private Dictionary<string, string> Items { get; set; } = new();
private UserProfile Profile { get; set; } = new(); private UserProfile Profile { get; set; } = new();
private string PageSize { get; set; } private string PageSize { get; set; }
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
ProfileService.OnChange += ProfileServiceOnOnChange; ProfileService.OnChange += ProfileServiceOnOnChange;
Profile = await ProfileService.GetProfile(); Profile = await ProfileService.GetProfile();
PageSize = Profile.PageSize; PageSize = Profile.PageSize;
await OnChanged.InvokeAsync(PageSize);
} }
private async Task OnSelectChanged(ChangeEventArgs e) private async Task OnSelectChanged(ChangeEventArgs e)
{ {
var val = e.Value?.ToString(); var val = e.Value?.ToString();
@ -51,6 +53,7 @@ public partial class PageSizeComponent : IDisposable
private void ProfileServiceOnOnChange(UserProfile newUserProfile) private void ProfileServiceOnOnChange(UserProfile newUserProfile)
{ {
Profile = newUserProfile; Profile = newUserProfile;
PageSize = Profile.PageSize;
StateHasChanged(); StateHasChanged();
} }

View file

@ -70,7 +70,7 @@ public partial class WorkDateComponent : IDisposable
/// <param name="e"></param> /// <param name="e"></param>
private async Task OnDateChanged(ChangeEventArgs e) private async Task OnDateChanged(ChangeEventArgs e)
{ {
if (string.IsNullOrWhiteSpace(e.Value.ToString())) return;
if (DateTime.TryParse(e.Value.ToString(), out var setDate)) if (DateTime.TryParse(e.Value.ToString(), out var setDate))
{ {
await UserProfile.SetWorkDate(setDate); await UserProfile.SetWorkDate(setDate);

View file

@ -33,9 +33,11 @@ public partial class PriceCatalogOverlay : IDisposable
[Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public UserProfileService ProfileService { get; set; } [Inject] public UserProfileService ProfileService { get; set; }
[Inject] public ILogger<PriceCatalogOverlay> Logger { get; set; } [Inject] public ILogger<PriceCatalogOverlay> Logger { get; set; }
// parameters // parameters
[Parameter] public string CountryCode { get; set; } = ""; [Parameter] public string CountryCode { get; set; } = "";
[Parameter] public EventCallback<SelectedSku> OnSelected { get; set; } [Parameter] public EventCallback<SelectedSku> OnSelected { get; set; }
// variables // variables
private string _modalDisplay = ""; private string _modalDisplay = "";
private bool _showBackdrop; private bool _showBackdrop;
@ -50,7 +52,7 @@ public partial class PriceCatalogOverlay : IDisposable
Interceptor.RegisterBeforeSendEvent(); Interceptor.RegisterBeforeSendEvent();
await GetSalesItems(); await GetSalesItems();
} }
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
_userProfile = await ProfileService.GetProfile(); _userProfile = await ProfileService.GetProfile();
@ -58,7 +60,7 @@ public partial class PriceCatalogOverlay : IDisposable
_pager.SearchColumn = _userProfile.ItemSearch; _pager.SearchColumn = _userProfile.ItemSearch;
_pager.PageSize = Convert.ToInt32(_userProfile.PageSize); _pager.PageSize = Convert.ToInt32(_userProfile.PageSize);
} }
private async Task GetSalesItems() private async Task GetSalesItems()
{ {
var pagingResponse = await CatalogRepo.GetSalesItemsPaged(CountryCode, _pager); var pagingResponse = await CatalogRepo.GetSalesItemsPaged(CountryCode, _pager);
@ -68,7 +70,7 @@ public partial class PriceCatalogOverlay : IDisposable
MetaInfo = pagingResponse.MetaData; MetaInfo = pagingResponse.MetaData;
Logger.LogDebug("PriceCatalogOverlay => Items <= {}", JsonSerializer.Serialize(Items)); Logger.LogDebug("PriceCatalogOverlay => Items <= {}", JsonSerializer.Serialize(Items));
} }
private void SelectItem(string itemId, string quantity, string rate) private void SelectItem(string itemId, string quantity, string rate)
{ {
OnSelected.InvokeAsync(new SelectedSku { Quantity = quantity, Rate = rate, ItemId = itemId }); OnSelected.InvokeAsync(new SelectedSku { Quantity = quantity, Rate = rate, ItemId = itemId });
@ -80,7 +82,8 @@ public partial class PriceCatalogOverlay : IDisposable
Items = new List<SalesItemView>(); Items = new List<SalesItemView>();
_pager.PageNumber = page; _pager.PageNumber = page;
await GetSalesItems(); await GetSalesItems();
} }
private async Task SetSearchPhrase(string searchTerm) private async Task SetSearchPhrase(string searchTerm)
{ {
Items = new List<SalesItemView>(); Items = new List<SalesItemView>();
@ -88,7 +91,7 @@ public partial class PriceCatalogOverlay : IDisposable
_pager.SearchTerm = searchTerm; _pager.SearchTerm = searchTerm;
await GetSalesItems(); await GetSalesItems();
} }
private async Task SetPageSize(string pageSize) private async Task SetPageSize(string pageSize)
{ {
Items = new List<SalesItemView>(); Items = new List<SalesItemView>();
@ -111,20 +114,20 @@ public partial class PriceCatalogOverlay : IDisposable
_pager.OrderBy = orderBy; _pager.OrderBy = orderBy;
await GetSalesItems(); await GetSalesItems();
} }
public void Show() public void Show()
{ {
_modalDisplay = "block;"; _modalDisplay = "block;";
_showBackdrop = true; _showBackdrop = true;
StateHasChanged(); StateHasChanged();
} }
private void Hide() private void Hide()
{ {
_modalDisplay = "none;"; _modalDisplay = "none;";
_showBackdrop = false; _showBackdrop = false;
StateHasChanged(); StateHasChanged();
} }
public void Dispose() => Interceptor.DisposeEvent(); public void Dispose() => Interceptor.DisposeEvent();
} }

View file

@ -29,13 +29,15 @@ namespace Wonky.Client.Pages;
public partial class AdvisorCustomerInvoiceListPage : IDisposable public partial class AdvisorCustomerInvoiceListPage : IDisposable
{ {
[Parameter] public string CompanyId { get; set; } = "";
[Inject] public IAdvisorCustomerRepository CompanyRepo { get; set; } [Inject] public IAdvisorCustomerRepository CompanyRepo { get; set; }
[Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; }
[Inject] public IAdvisorCustomerHistoryRepository HistoryRepo { get; set; } [Inject] public IAdvisorCustomerHistoryRepository HistoryRepo { get; set; }
[Inject] public IToastService Toaster { get; set; } [Inject] public IToastService Toaster { get; set; }
[Inject] public ILocalStorageService Storage { get; set; } [Inject] public ILocalStorageService Storage { get; set; }
[Inject] public ILogger<AdvisorCustomerInvoiceListPage> Logger { get; set; } [Inject] public ILogger<AdvisorCustomerInvoiceListPage> Logger { get; set; }
[Parameter] public string CompanyId { get; set; } = "";
private InvoiceListView CompanyInvoices { get; set; } = new(); private InvoiceListView CompanyInvoices { get; set; } = new();
private CompanyDto Company { get; set; } = new(); private CompanyDto Company { get; set; } = new();
private CustomerInvoiceViewOverlay CustomerInvoiceView { get; set; } = new(); private CustomerInvoiceViewOverlay CustomerInvoiceView { get; set; } = new();

View file

@ -92,12 +92,14 @@
<ValidationMessage For="@(() => Company.Email)"></ValidationMessage> <ValidationMessage For="@(() => Company.Email)"></ValidationMessage>
</div> </div>
<div class="col-sm-4">@* ---- placeholder --- *@</div> <div class="col-sm-4">@* ---- placeholder --- *@</div>
<div class="col-sm-2 d-grid mx-auto"> @* Force enable visit *@
<button type="button" class="btn btn-edit" @onclick="ToggleErpEdit"><i class="bi-pencil"></i> STAM data</button>
</div>
<div class="col-sm-3 d-grid mx-auto"> <div class="col-sm-3 d-grid mx-auto">
<button type="button" class="btn btn-primary d-block" disabled="@(Company.HasFolded == 0 || Company.Name == "ERROR")" @onclick="ForceActivity">Aktiver besøg</button> <button type="button" class="btn btn-primary d-block" disabled="@(Company.HasFolded == 0 || Company.Name == "ERROR")" @onclick="ForceActivity">Aktiver besøg</button>
</div> </div>
@* Enable edit/save *@
<div class="col-sm-2 d-grid mx-auto">
<button type="button" class="btn btn-edit" @onclick="ToggleErpEdit"><i class="bi-pencil"></i> STAM data</button>
</div>
<div class="col-sm-3 d-grid mx-auto"> <div class="col-sm-3 d-grid mx-auto">
<button type="button" class="btn btn-danger d-block" onclick="@UpdateErpData" disabled="@(Working || Company.Name == "ERROR" || ErpEditDisabled)"><i class="bi-cloud-arrow-up"></i> STAM data </button> <button type="button" class="btn btn-danger d-block" onclick="@UpdateErpData" disabled="@(Working || Company.Name == "ERROR" || ErpEditDisabled)"><i class="bi-cloud-arrow-up"></i> STAM data </button>
</div> </div>
@ -112,10 +114,6 @@
<ValidationMessage For="@(() => Company.VatNumber)"></ValidationMessage> <ValidationMessage For="@(() => Company.VatNumber)"></ValidationMessage>
</div> </div>
</div> </div>
<div class="col-sm-2 d-grid mx-auto">
<button type="button" class="btn btn-edit" @onclick="ToggleVatEdit"><i class="bi-pencil"></i> Moms/Org Nr.</button>
</div>
@* vat lookup *@ @* vat lookup *@
<div class="col-sm-3 d-grid mx-auto"> <div class="col-sm-3 d-grid mx-auto">
@switch (CountryCode) @switch (CountryCode)
@ -131,6 +129,10 @@
break; break;
} }
</div> </div>
@* Enable edit/save *@
<div class="col-sm-2 d-grid mx-auto">
<button type="button" class="btn btn-edit" @onclick="ToggleVatEdit"><i class="bi-pencil"></i> Moms/Org Nr.</button>
</div>
@* save vat number *@ @* save vat number *@
<div class="col-sm-3 d-grid mx-auto"> <div class="col-sm-3 d-grid mx-auto">
<button type="button" class="btn btn-warning d-block" @onclick="UpdateVatNumber" disabled="@(VatEditDisabled)"><i class="bi-cloud-arrow-up"></i> Moms/Org Nr.</button> <button type="button" class="btn btn-warning d-block" @onclick="UpdateVatNumber" disabled="@(VatEditDisabled)"><i class="bi-cloud-arrow-up"></i> Moms/Org Nr.</button>

View file

@ -1,7 +1,7 @@
{ {
"appInfo": { "appInfo": {
"name": "Wonky Online", "name": "Wonky Online",
"version": "0.118.0", "version": "0.118.4",
"rc": true, "rc": true,
"sandBox": false, "sandBox": false,
"image": "grumpy-coder.png" "image": "grumpy-coder.png"
@ -19,7 +19,7 @@
} }
}, },
"apiConfig": { "apiConfig": {
"baseUrl": "https://zeta.innotec.dk", "baseUrl": "https://dev.innotec.dk",
"catalog": "api/v2/catalog/country", "catalog": "api/v2/catalog/country",
"crmCustomers": "api/v2/crm/companies", "crmCustomers": "api/v2/crm/companies",
"crmInventoryExt": "history/inventory", "crmInventoryExt": "history/inventory",