Rename ActivityButton to ActionButton - implement action button

Rename RPC variable to sync
Added force parameter to sync URL (TODO - make it work)
Add headers to modals to ensure the close button is pushed to the right
Make ConfirmDeleteModal a generic ConfirmActionModel
This commit is contained in:
Frede Hundewadt 2023-06-05 07:15:39 +02:00
parent 15dfabb36d
commit c523e9a475
18 changed files with 99 additions and 56 deletions

View file

@ -17,7 +17,7 @@ using Microsoft.AspNetCore.Components;
namespace Wonky.Client.Components;
public partial class ActivityButton
public partial class ActionButton
{
[Parameter]public string CompanyId { get; set; } = "";
[Parameter] public int Enabled { get; set; }

View file

@ -56,7 +56,7 @@
@company.City
</td>
<td class="align-middle">
<ActivityButton CompanyId="@company.CompanyId" ActionLink="/advisor/customers/$ID$/activities/new"
<ActionButton CompanyId="@company.CompanyId" ActionLink="/advisor/customers/$ID$/activities/new"
ButtonText="Besøg" ButtonType="primary" Enabled="@company.ValidVat"/>
</td>
</tr>

View file

@ -133,7 +133,7 @@ public class CountryCustomerHistoryRepository : ICountryCustomerHistoryRepositor
public async Task<string> RequestErpToCrmSync(string countryCode, string companyId, string syncDate)
{
var response = await _client
.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/{_api.SyncRpcInvoiceExt}/{syncDate}");
.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/{_api.SyncInvoice}/{syncDate}");
var content = await response.Content.ReadAsStringAsync();

View file

@ -112,13 +112,14 @@ public class CrmCustomerHistoryRepository : ICrmCustomerHistoryRepository
}
public async Task<string> InvoiceErpToCrmRpc(string companyId, string syncDate)
public async Task<string> GetRecycledInvoiceList(string companyId, string syncDate, bool force)
{
var x = await _client.GetAsync($"{_api.SyncRpc}/companies/{companyId}/invoices/{syncDate}");
if (!x.IsSuccessStatusCode)
var x = await _client.GetAsync($"{_api.SyncInvoice}/{companyId}/{syncDate}?force={force}");
var content = await x.Content.ReadAsStringAsync();
if (!x.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content))
{
return string.Empty;
}
return await x.Content.ReadAsStringAsync();
return content.Trim('"');
}
}

View file

@ -72,6 +72,7 @@ public interface ICrmCustomerHistoryRepository
/// </summary>
/// <param name="companyId"></param>
/// <param name="syncDate"></param>
/// <param name="force"></param>
/// <returns></returns>
Task<string> InvoiceErpToCrmRpc(string companyId, string syncDate);
Task<string> GetRecycledInvoiceList(string companyId, string syncDate, bool force);
}

View file

@ -17,13 +17,14 @@
<div class="modal-dialog modal-dialog-scrollable modal-fullscreen">
<div class="modal-content">
<div class="modal-header">
<h3>Besøg</h3>
<button type="button" class="btn btn-danger" @onclick="@Hide" data-bs-dismiss="modal" aria-label="Luk"><i class="bi-x-lg"></i></button>
</div>
<div class="modal-body">
<div class="card">
<div class="card-body">
<div class="card-title mb-2">
<h3>Besøg - @ReportItem.Company.Name</h3>
<h3>@ReportItem.Company.Name</h3>
</div>
<div class="row g-3">
<label for="date" class="col-form-label-sm col-sm-1">Dato</label>

View file

@ -20,10 +20,7 @@
<div class="modal-content">
<div class="modal-header">
@if (!string.IsNullOrWhiteSpace(Company.Name))
{
<h3 class="modal-title">@Company.Name - Faktura Oversigt</h3>
}
<h3 class="modal-title">@Company.Name - Faktura Oversigt</h3>
<button type="button" class="btn btn-danger" @onclick="@Hide" data-bs-dismiss="modal" aria-label="Luk"><i class="bi-x-lg"></i></button>
</div>
<div class="modal-body">

View file

@ -19,10 +19,7 @@
<div class="modal-dialog modal-dialog-scrollable modal-fullscreen">
<div class="modal-content">
<div class="modal-header">
@if (!string.IsNullOrWhiteSpace(Invoice.Company.Name))
{
<h3 class="modal-title">Faktura @Invoice.DocumentNumber</h3>
}
<h3 class="modal-title">Faktura @Invoice.DocumentNumber</h3>
<button type="button" class="btn btn-danger" @onclick="@Hide" data-bs-dismiss="modal" aria-label="Luk"><i class="bi-x-lg"></i></button>
</div>
<div class="modal-body">

View file

@ -282,7 +282,7 @@ public partial class AdvisorActivityCreatePage : IDisposable
// product inventory has not been updated
// request backend to sync ERP to CRM
Toaster.ShowInfo("Vent mens data synkroniseres ...");
var ts = await HistoryRepo.InvoiceErpToCrmRpc(CompanyId, Company.HistorySync);
var ts = await HistoryRepo.GetRecycledInvoiceList(CompanyId, Company.HistorySync, false);
await Task.Delay(250);
// save pDate
await Storage.SetItemAsync($"{CompanyId}-pDate", ts);

View file

@ -33,17 +33,13 @@
<span class="h3">@Company.Name</span> <span>(@Company.Account)</span>
</div>
</div>
<div class="col-sm-3 text-end">
@if (AppInfo!.Value!.Rc)
<div class="col-sm-5 text-end">
@if (UserInfo.CountryCode is "DK")
{
@if (UserInfo.CountryCode is "DK")
{
<a class="btn btn-secondary" href="/advisor/customers/@CompanyId/workplaces/new"><i class="bi-plus-lg"></i> Arbejdssted</a>
}
<a class="btn btn-secondary me-2" href="/advisor/customers/@CompanyId/workplaces/new"><i class="bi-plus-lg"></i> Arbejdssted</a>
}
</div>
<div class="col-sm-2 text-end">
<a class="btn btn-primary" href="/advisor/customers"><i class="bi-chevron-left"></i> Tilbage</a>
@* <button class="btn btn-secondary me-2" @onclick="@ConfirmReloadHistory" disabled="@Working"><i class="bi-recycle"></i> Varelinjer</button> *@
<a class="btn btn-primary me-2" href="/advisor/customers"><i class="bi-chevron-left"></i> Tilbage</a>
</div>
</div>
@ -129,7 +125,7 @@
</div>
<div class="col-sm-1">
<div class="led-box @(DateTime.Now < DateTime.Parse("2023-12-31") ? "inno-display" : "inno-hidden")">
<div class="led-red"></div>
<div class="led-yellow"></div>
</div>
</div>
}
@ -152,6 +148,7 @@
<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>
@* vat number*@
<hr class="mb-3"/>
<label for="vatNumber" class="col-sm-1 col-form-label-sm">ORG nr.</label>
<div class="col-sm-3">
<div class="input-group">
@ -195,27 +192,36 @@
<div class="col-sm-3">
@if (!Kanvas)
{
<a class="btn btn-danger d-block" href="/advisor/customers/@Company.CompanyId/invoices">Faktura</a>
<ActionButton ActionLink="@InvoiceLink"
ButtonText="Faktura"
ButtonType="danger"
Enabled="@EnableLink" />
}
</div>
<div class="col-sm-3">
@if (!Kanvas)
{
<a class="btn btn-warning d-block" href="/advisor/customers/@Company.CompanyId/activities">Tidl. Besøg</a>
<ActionButton ActionLink="@ActivityLink"
ButtonText="Tidl. Besøg"
ButtonType="warning"
Enabled="@EnableLink" />
}
</div>
<div class="col-sm-3">
@if (!Kanvas)
@if (!Kanvas )
{
<a class="btn btn-success d-block" href="/advisor/customers/@Company.CompanyId/history/inventory">Produkter</a>
<ActionButton ActionLink="@InventoryLink"
ButtonText="Produkter"
ButtonType="success"
Enabled="@EnableLink" />
}
</div>
<div class="col-sm-3">
<ActivityButton ActionLink="@ActionLink"
<ActionButton ActionLink="@NewActivityLink"
ButtonText="Nyt Besøg"
ButtonType="primary"
Enabled="@EnableActivity">
</ActivityButton>
</ActionButton>
</div>
</div>
@ -306,6 +312,7 @@
</div>
}
</EditForm>
<hr class="mb-3"/>
<div class="row pt-3 mb-5">
<div class="col-sm-4 d-grid">
<button type="button" class="btn btn-outline-dark" @onclick="@ToggleVisibility">@ToggleButtonText</button>
@ -328,4 +335,6 @@
@ref="VatLookupPopup" OnSelectedCompany="SelectedCompanyCallback"/>
<ContactViewEditModal SelectedContact="SelectedContact" CompanyName="@Company.Name"
@ref="ContactViewPopup" OnSaveClicked="WriteContactCallback" OnDeleteClicked="DeleteContactCallback"/>
@ref="ContactViewPopup" OnSaveClicked="WriteContactCallback" OnDeleteClicked="DeleteContactCallback"/>
<ConfirmActionModal BodyMessage="@RemoveHistoryWarning" OnOkClicked="ReloadHistory" @ref="ConfirmActionHistory" />

View file

@ -66,7 +66,6 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
private string CountryCode { get; set; } = "dk";
private string VisitState { get; set; } = "the-ugly";
private int EnableActivity { get; set; } = 1;
private string ActionLink { get; set; } = "";
private bool Working { get; set; } = true;
private bool CountryIsDk { get; set; } = true;
private bool ErpEditDisabled { get; set; } = true;
@ -79,6 +78,13 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
private ContactDto DefaultContact { get; set; } = new();
private ContactViewEditModal ContactViewPopup { get; set; } = new();
private VatLookupDkModal VatLookupPopup { get; set; } = new();
private string RemoveHistoryWarning { get; set; } = "";
private ConfirmActionModal ConfirmActionHistory { get; set; }
private string InventoryLink { get; set; } = "";
private string ActivityLink { get; set; } = "";
private string InvoiceLink { get; set; } = "";
private string NewActivityLink { get; set; } = "";
private int EnableLink { get; set; } = 1;
protected override async Task OnInitializedAsync()
{
@ -89,6 +95,12 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
// initialize default contact
DefaultContact = new ContactDto { CompanyId = CompanyId, ContactId = "", FirstName = "" };
// navigation button links
InventoryLink = $"/advisor/customers/{CompanyId}/history/inventory";
ActivityLink = $"/advisor/customers/{CompanyId}/activities";
InvoiceLink = $"/advisor/customers/{CompanyId}/invoices";
NewActivityLink = $"/advisor/customers/{CompanyId}/activities/new";
// setup form context
ErpContext = new EditContext(Company);
@ -114,9 +126,6 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
if (Company.Account.StartsWith("KANVAS"))
Kanvas = true;
// action link passed to activity button component
ActionLink = $"/advisor/customers/{CompanyId}/activities/new"; // used when drawing visit button
// only execute if the company a 'real' customer
if (!Kanvas)
{
@ -186,6 +195,34 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
VatEditDisabled = !VatEditDisabled;
}
private void ConfirmReloadHistory()
{
// $"Bekræft at du sletter<br/><strong>{Workplace.Name}</strong> fra <strong>{Workplace.CompanyName}</strong>?<br/>AL INFORMATION slettes og handlingen er uigenkaldelig.";
RemoveHistoryWarning = $"Denne process kan tage lang tid.<br/>Bekræft at al historik gendannes for<br/>{Company.Account} {Company.Name}";
ConfirmActionHistory.Show();
}
private async Task ReloadHistory()
{
if (Working)
return;
Toaster.ShowWarning("Vent venligst ....");
Working = true;
EnableLink = 0;
EnableActivity = 0;
var result = await HistoryRepo.GetRecycledInvoiceList(CompanyId, Company.HistorySync, true);
await Task.Delay(1000);
Working = false;
if (!string.IsNullOrWhiteSpace(result))
{
Toaster.ShowInfo("Historik gendannelse er færdig");
EnableLink = 1;
EnableActivity = 1;
}
}
private async Task ToggleVisibility()
{
@ -202,7 +239,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
if (Working)
return;
Working = true;
Company.HistorySync = await HistoryRepo.InvoiceErpToCrmRpc(CompanyId, Company.HistorySync);
Company.HistorySync = await HistoryRepo.GetRecycledInvoiceList(CompanyId, Company.HistorySync, false);
Working = false;
}

View file

@ -186,5 +186,5 @@
<WorkingThreeDots/>
}
<ConfirmDeleteModal BodyMessage="@DeleteMessage" OnOkClicked="RemoveWorkplace" @ref="ConfirmDeleteWorkplace"/>
<ConfirmDeleteModal BodyMessage="@DeleteMessage" OnOkClicked="RemoveVariant" @ref="ConfirmDeleteVariant"/>
<ConfirmActionModal BodyMessage="@DeleteMessage" OnOkClicked="RemoveWorkplace" @ref="ConfirmActionWorkplace"/>
<ConfirmActionModal BodyMessage="@DeleteMessage" OnOkClicked="RemoveVariant" @ref="ConfirmActionVariant"/>

View file

@ -54,7 +54,7 @@ public partial class AdvisorCustomerWorkplaceViewEditPage : IDisposable
private bool Working { get; set; } = true;
private WorkplaceDocInfo WorkplaceDocInfo { get; set; } = new();
private List<DocView> DocViews { get; set; } = new();
private ConfirmDeleteModal ConfirmDeleteWorkplace { get; set; }
private ConfirmActionModal ConfirmActionWorkplace { get; set; }
private string DeleteMessage { get; set; } = "";
private string LinkRecipients { get; set; } = "";
private const string CopyText = "Kopier";
@ -74,7 +74,7 @@ public partial class AdvisorCustomerWorkplaceViewEditPage : IDisposable
private string _linkButtonText = LinkText;
private string _linkButtonStyle = LinkStyle;
private ConfirmDeleteModal ConfirmDeleteVariant { get; set; }
private ConfirmActionModal ConfirmActionVariant { get; set; }
private DocView SelectedItem { get; set; } = new();
private bool OnlyOne { get; set; } = true;
@ -193,7 +193,7 @@ public partial class AdvisorCustomerWorkplaceViewEditPage : IDisposable
Logger.LogDebug("ConfirmDeleteWorkplace");
ConfirmDeleteWorkplace.Show();
ConfirmActionWorkplace.Show();
}
@ -204,7 +204,7 @@ public partial class AdvisorCustomerWorkplaceViewEditPage : IDisposable
Working = true;
await Workplaces.DeleteWorkplace(CompanyId, WorkplaceId);
Toaster.ShowInfo("Arbejdssted er slettet.");
Navigator.NavigateTo($"/advisor/customers/{CompanyId}/workplaces");
@ -217,7 +217,7 @@ public partial class AdvisorCustomerWorkplaceViewEditPage : IDisposable
DeleteMessage =
$"Bekræft at du sletter<br/><strong>{selectedItem.VariantName}</strong> fra <strong>{Workplace.CompanyName}</strong>?<br/>AL INFORMATION slettes og handlingen er uigenkaldelig.";
Logger.LogDebug("ConfirmDeleteProduct");
ConfirmDeleteVariant.Show();
ConfirmActionVariant.Show();
}

View file

@ -18,15 +18,15 @@
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header text-bg-danger">
<h2 class="modal-title">Bekræft Sletning</h2>
<h2 class="modal-title">Bekræft</h2>
<button type="button" class="btn btn-danger" @onclick="@Hide" data-bs-dismiss="modal" aria-label="Luk"><i class="bi-x-lg"></i></button>
</div>
<div class="modal-body">
@((MarkupString)BodyMessage)
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger me-auto" data-bs-dismiss="modal" @onclick="@OkSelected"><i class="border-danger"></i> OK </button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" @onclick="@CancelSelected"><i class="bi-x"></i> Afbryd </button>
<button type="button" class="btn btn-danger me-auto" data-bs-dismiss="modal" @onclick="@OkSelected"><i class="bi-check"></i> OK </button>
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" @onclick="@CancelSelected"><i class="bi-x-lg"></i> Afbryd </button>
</div>
</div>
</div>

View file

@ -18,7 +18,7 @@ using Microsoft.AspNetCore.Components;
namespace Wonky.Client.Shared;
public partial class ConfirmDeleteModal
public partial class ConfirmActionModal
{
private string _modalDisplay = "";
private bool _showBackdrop;

View file

@ -1,7 +1,7 @@
{
"appInfo": {
"name": "Wonky Online",
"version": "157.1",
"version": "158.0",
"rc": true,
"sandBox": false,
"image": "grumpy-coder.png"
@ -43,8 +43,8 @@
"serviceVatEu": "api/v2/services/vies",
"servicesVatNo": "api/v2/services/brReg",
"servicesAuth": "v2/token",
"syncRpc": "api/v2/rpc",
"syncRpcInvoiceExt": "invoices",
"sync": "api/v2/sync",
"syncInvoice": "api/v2/sync/invoices",
"systemDocStringUrl": "api/v2/admin/doc",
"systemLabels": "api/v2/admin/doc/labels",
"systemTexts": "api/v2/admin/doc/texts",

View file

@ -140,12 +140,12 @@ public class ApiConfig
/// <summary>
/// Base sync url
/// </summary>
public string SyncRpc { get; set; } = "";
public string Sync { get; set; } = "";
/// <summary>
/// Application uri for updating customer product sale request
/// </summary>
public string SyncRpcInvoiceExt { get; set; } = "";
public string SyncInvoice { get; set; } = "";
/// <summary>
/// Generic system string endpoint