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

View file

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

View file

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

View file

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

View file

@ -92,12 +92,14 @@
<ValidationMessage For="@(() => Company.Email)"></ValidationMessage>
</div>
<div class="col-sm-4">@* ---- placeholder --- *@</div>
<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>
@* Force enable visit *@
<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>
</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">
<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>
@ -112,10 +114,6 @@
<ValidationMessage For="@(() => Company.VatNumber)"></ValidationMessage>
</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 *@
<div class="col-sm-3 d-grid mx-auto">
@switch (CountryCode)
@ -131,6 +129,10 @@
break;
}
</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 *@
<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>

View file

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