created working variable callback instead of layout

This commit is contained in:
Frede Hundewadt 2023-09-12 06:59:44 +02:00
parent 4a1c05be49
commit 156ec9c558
10 changed files with 36 additions and 86 deletions

View file

@ -18,10 +18,6 @@
@using Wonky.Client.Helpers; @using Wonky.Client.Helpers;
@using Wonky.Client.OverlayOffice @using Wonky.Client.OverlayOffice
@if (Working)
{
<WorkingThreeDots />
}
@if (CompanyList.Any()) @if (CompanyList.Any())
{ {
<div class="row mt-2 d-flex g-3"> <div class="row mt-2 d-flex g-3">
@ -88,6 +84,9 @@
<div class="col"> <div class="col">
<a class="btn btn-sm btn-primary" href="/office/customers/@company.CountryCode.ToLower()/@company.CompanyId/order">Bestilling</a> <a class="btn btn-sm btn-primary" href="/office/customers/@company.CountryCode.ToLower()/@company.CompanyId/order">Bestilling</a>
</div> </div>
<div class="col">
<button class="btn btn-sm btn-secondary" @onclick="() => RequestBusinessCentralData(company.CompanyId, true)">BC<i class="bi-database-down"></i></button>
</div>
</div> </div>
</div> </div>
</div> </div>

View file

@ -48,6 +48,8 @@ public partial class OfficeCountryCustomerListComponent : IDisposable
// [Parameter] public EventCallback<DraftItem> OnOrderItem { get; set; } // [Parameter] public EventCallback<DraftItem> OnOrderItem { get; set; }
[CascadingParameter] public DraftStateProvider DraftProvider { get; set; } [CascadingParameter] public DraftStateProvider DraftProvider { get; set; }
[Parameter] public EventCallback<bool> SetWorking { get; set; }
// ****************************************************** // ******************************************************
// overlays // overlays
private OfficeCustomerInvoiceListOverlay InvoiceListOverlay { get; set; } = new(); private OfficeCustomerInvoiceListOverlay InvoiceListOverlay { get; set; } = new();
@ -70,46 +72,53 @@ public partial class OfficeCountryCustomerListComponent : IDisposable
} }
private async Task ShowInvoiceList(string companyId) private async Task RequestBusinessCentralData(string companyId, bool force)
{ {
Working = true; await SetWorking.InvokeAsync(true);
SelectedCompany = CompanyList.First(x => x.CompanyId == companyId); SelectedCompany = CompanyList.First(x => x.CompanyId == companyId);
// call erp to crm sync before requesting invoices // call erp to crm sync before requesting invoices
await Task.Delay(500); await Task.Delay(500);
var newSyncDate = await HistoryRepo.RequestErpToCrmSync(companyId, SelectedCompany.HistorySync, false); var newSyncDate = await HistoryRepo.RequestErpToCrmSync(companyId, SelectedCompany.HistorySync, force);
while (string.IsNullOrEmpty(newSyncDate)) while (string.IsNullOrWhiteSpace(newSyncDate))
{ {
await Task.Delay(500); await Task.Delay(500);
} }
await SetWorking.InvokeAsync(false);
}
private async Task ShowInvoiceList(string companyId)
{
await SetWorking.InvokeAsync(true);
SelectedCompany = CompanyList.First(x => x.CompanyId == companyId);
// call erp to crm sync before requesting invoices
await Task.Delay(500);
await RequestBusinessCentralData(companyId, false);
InvoiceList = await HistoryRepo.GetInvoiceList(CountryCode, companyId); InvoiceList = await HistoryRepo.GetInvoiceList(CountryCode, companyId);
InvoiceListOverlay.Show(); InvoiceListOverlay.Show();
Working = false; await SetWorking.InvokeAsync(false);
} }
private async Task ShowActivityList(string companyId) private async Task ShowActivityList(string companyId)
{ {
Working = true; await SetWorking.InvokeAsync(true);
SelectedCompany = CompanyList.First(x => x.CompanyId == companyId); SelectedCompany = CompanyList.First(x => x.CompanyId == companyId);
await Task.Delay(500); await Task.Delay(500);
ActivityList = await ActivityRepo.GetActivityList(companyId); ActivityList = await ActivityRepo.GetActivityList(companyId);
await Task.Delay(500); await Task.Delay(500);
ActivityListOverlay.Show(); ActivityListOverlay.Show();
Working = false; await SetWorking.InvokeAsync(false);
} }
private async Task ShowInventory(string companyId) private async Task ShowInventory(string companyId)
{ {
Working = true; await SetWorking.InvokeAsync(true);
SelectedCompany = CompanyList.First(x => x.CompanyId == companyId); SelectedCompany = CompanyList.First(x => x.CompanyId == companyId);
Logger.LogDebug("SelectedCompany => {}", JsonSerializer.Serialize(SelectedCompany)); Logger.LogDebug("SelectedCompany => {}", JsonSerializer.Serialize(SelectedCompany));
await Task.Delay(500); await Task.Delay(500);
var newSyncDate = await HistoryRepo.RequestErpToCrmSync(companyId, SelectedCompany.HistorySync, true); await RequestBusinessCentralData(companyId, false);
while (string.IsNullOrEmpty(newSyncDate))
{
await Task.Delay(500);
}
// request inventory // request inventory
await Task.Delay(500); await Task.Delay(500);
ProductInventory = await HistoryRepo.GetInventory(SelectedCompany.CountryCode, SelectedCompany.CompanyId); ProductInventory = await HistoryRepo.GetInventory(SelectedCompany.CountryCode, SelectedCompany.CompanyId);
@ -117,11 +126,11 @@ public partial class OfficeCountryCustomerListComponent : IDisposable
Logger.LogDebug("ProductInventory => {}", JsonSerializer.Serialize(ProductInventory)); Logger.LogDebug("ProductInventory => {}", JsonSerializer.Serialize(ProductInventory));
// show the overlay // show the overlay
InventoryListOverlay.Show(); InventoryListOverlay.Show();
Working = false; await SetWorking.InvokeAsync(false);
} }
private void ShowOrder(string companyId) private void CreateNewCustomerOrder(string companyId)
{ {
SelectedCompany = CompanyList.First(x => x.CompanyId == companyId); SelectedCompany = CompanyList.First(x => x.CompanyId == companyId);
} }

View file

@ -1,59 +0,0 @@
@using Wonky.Entity.DTO
@using Wonky.Client.Helpers
<div class="card">
<div class="card-header fw-bold @(Company.HasFolded == 1 ? "alert alert-dark" : "alert alert-success")">
@Company.Name @(Company.HasFolded == 1 ? "(OPHØRT)" : "")
</div>
<div class="card-body">
<table class="table">
<tr>
<th scope="row">Konto</th>
<td>@Company.Account</td>
<th scope="row">Org Nr.</th>
<td>@(string.IsNullOrWhiteSpace(Company.VatNumber) ? "mangler" : Company.VatNumber) </td>
</tr>
<tr>
<th scope="row">Telefon</th>
<td colspan="3">@Company.Phone</td>
</tr>
<tr>
<th scope="row">Adresse</th>
<td colspan="3">@Company.Address1 @(string.IsNullOrWhiteSpace(Company.Address2) ? "" : ",") @Company.Address2</td>
</tr>
<tr>
<th scope="row">Post By</th>
<td colspan="3">@Company.CountryCode.ToUpper()-@Company.ZipCode @Company.City</td>
</tr>
<tr>
<th scope="row">
Sælgernr.
</th>
<td>
@Company.SalesRep
</td>
</tr>
<tr>
<th scope="row">Sidst besøgt</th>
<td>
@(Mapper.MapVisitState(Company.LastVisit) == "the-draw" ? "?" : Company.LastVisit)
</td>
</tr>
<tr>
<th scope="row">Næste besøg</th>
<td>
@(Mapper.MapVisitState(Company.LastVisit) == "the-draw" ? "?" : Company.NextVisit)
</td>
</tr>
</table>
</div>
</div>
@code {
[Parameter] public CompanyDto Company { get; set; } = new();
[Parameter] public EventCallback<string> OnReloadHistory { get; set; }
}

View file

@ -31,7 +31,7 @@
<div class="row mb-2"> <div class="row mb-2">
<h2 class="text-center">Piktogrammer</h2> <h2 class="text-center">Piktogrammer</h2>
<div class="col-sm-12 col-md-6"> <div class="col-sm-12 col-md-6">
<InfoColorCustomerComponent/> <InfoColorComponent/>
</div> </div>
@* @*
<div class="col-sm-12 col-md-6"> <div class="col-sm-12 col-md-6">

View file

@ -47,7 +47,7 @@
<div class="col-sm-1">@*placeholder*@</div> <div class="col-sm-1">@*placeholder*@</div>
<div class="col-sm-2"> <div class="col-sm-2">
<div class="busy-signal" style="display:@(Working ? "block" : "none")"> <div class="busy-signal" style="display:@(Working ? "block" : "none")">
<div class="spinner-grow text-info" role="status"> <div class="spinner-grow inno" role="status">
<span class="visually-hidden">Loading...</span> <span class="visually-hidden">Loading...</span>
</div> </div>
</div> </div>
@ -55,7 +55,7 @@
</div> </div>
</div> </div>
<OfficeCountryCustomerListComponent CompanyList="Companies" CountryCode="@CountryCode" /> <OfficeCountryCustomerListComponent CompanyList="Companies" CountryCode="@CountryCode" SetWorking="SetWorking" />
@if (Paging.PageSize > 10) @if (Paging.PageSize > 10)
{ {

View file

@ -76,9 +76,9 @@ public partial class OfficeCustomerCountryPagedListPage : IDisposable
} }
private async Task GetProductHistory(string companyId) private void SetWorking(bool working)
{ {
await Task.Delay(1); Working = working;
} }
private async Task FetchCustomers() private async Task FetchCustomers()

View file

@ -1,7 +1,7 @@
{ {
"appInfo": { "appInfo": {
"name": "Wonky Online", "name": "Wonky Online",
"version": "238.0", "version": "240.0",
"rc": true, "rc": true,
"sandBox": true, "sandBox": true,
"image": "grumpy-coder.png", "image": "grumpy-coder.png",

View file

@ -6,6 +6,7 @@
.draft-expires-msg { .draft-expires-msg {
font-size: 0.8em; font-size: 0.8em;
} }
.busy-signal { .busy-signal {
float: right; float: right;
z-index: 100; z-index: 100;