diff --git a/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor b/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor index 6d8ba61f..a391a384 100644 --- a/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor +++ b/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor @@ -14,34 +14,11 @@ *@ @using Microsoft.AspNetCore.Authorization -@using Microsoft.AspNetCore.Components @using Wonky.Client.Components -@using Wonky.Entity.Configuration @attribute [Authorize(Roles = "Advisor")] @page "/advisor/customers/{CompanyId}" Stamkort for @Company.Name -@* -
-
-
-

Green LED

-
-
-
-

Yellow LED

-
-
-
-

Red LED

-
-
-
-

Blue LED

-
-
-*@ - @if (!string.IsNullOrWhiteSpace(Company.Account)) { @if (!string.IsNullOrWhiteSpace(Company.Blocked)) @@ -253,7 +230,7 @@
-
+
Stilling
Navn
@@ -267,7 +244,7 @@ { @foreach (var contact in Contacts) { -
+
@contact.JobTitle
@contact.FirstName @contact.LastName
@@ -318,7 +295,7 @@
- @if (AppInfo.Value.Rc) + @if (AppInfo!.Value!.Rc) { Kemi Dokumentation } @@ -333,5 +310,6 @@ - \ No newline at end of file + + \ No newline at end of file diff --git a/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor.cs index 6a9e48b7..3a0f864f 100644 --- a/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor.cs @@ -72,13 +72,13 @@ public partial class AdvisorCustomerViewEditPage : IDisposable private bool ErpEditDisabled { get; set; } = true; private bool VatEditDisabled { get; set; } = true; private List Contacts { get; set; } = new(); - private VatLookupDkModal VatLookupPopup { get; set; } = new(); - private ContactDto SelectedContact { get; set; } = new(); - private ContactDto DefaultContact { get; set; } = new(); - private ContactModal ContactPopup { get; set; } = new(); private UserManagerEditView UserInfo { get; set; } = new(); private string ToggleButtonText { get; set; } = ""; private bool Kanvas { get; set; } + private ContactDto SelectedContact { get; set; } = new(); + private ContactDto DefaultContact { get; set; } = new(); + private ContactViewEditModal ContactViewPopup { get; set; } = new(); + private VatLookupDkModal VatLookupPopup { get; set; } = new(); protected override async Task OnInitializedAsync() { @@ -88,6 +88,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable // initialize default contact DefaultContact = new ContactDto { CompanyId = CompanyId, ContactId = "", FirstName = "" }; + // setup form context ErpContext = new EditContext(Company); @@ -171,16 +172,19 @@ public partial class AdvisorCustomerViewEditPage : IDisposable Working = false; } + private void ToggleErpEdit() { ErpEditDisabled = !ErpEditDisabled; } + private void ToggleVatEdit() { VatEditDisabled = !VatEditDisabled; } + private async Task ToggleVisibility() { Company.IsHidden = Company.IsHidden == 0 ? 1 : 0; @@ -190,6 +194,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable await CustomerRepo.UpdateCrmData(CompanyId, Company); } + private async Task RequestErpUpdate() { if (Working) @@ -199,10 +204,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable Working = false; } - /// - /// Fetch contacts from backend - /// - /// + private async Task FetchContacts(string companyId) { // load contacts @@ -211,18 +213,13 @@ public partial class AdvisorCustomerViewEditPage : IDisposable Contacts = Contacts.OrderBy(x => x.FirstName).ToList(); } - /// - /// Show Vat Lookup modal - /// + private void OpenVatLookupModal() { VatLookupPopup.Show(); } - /// - /// Callback to update company properties - /// - /// + private void SelectedCompanyCallback(VirkRegInfo regInfo) { Logger.LogDebug("CrmCompanyView => SelectCompanyCallback => {}", JsonSerializer.Serialize(regInfo)); @@ -244,24 +241,22 @@ public partial class AdvisorCustomerViewEditPage : IDisposable Company.VatNumber = regInfo.VatNumber; } - /// - /// Open contact edit popup - /// - /// + private void OpenContactPopup(ContactDto contact) { // write contact to debug log - Logger.LogDebug("CompanyView => SaveContactCallback <= {}", JsonSerializer.Serialize(contact)); + Logger.LogDebug("CompanyView => OpenContactPopup => contact => {}", JsonSerializer.Serialize(contact)); + // object to pass on to the popup SelectedContact = contact; + + Logger.LogDebug("CompanyView => OpenContactPopup => SelectedContact => {}", JsonSerializer.Serialize(SelectedContact)); + // show the popup - ContactPopup.Show(); + ContactViewPopup.Show(); } - /// - /// Callback for writing contact to backend - /// - /// + private async Task WriteContactCallback(ContactDto contact) { Working = true; diff --git a/Wonky.Client/Pages/CrmCustomerWorkplaceViewEditPage.razor b/Wonky.Client/Pages/CrmCustomerWorkplaceViewEditPage.razor index d1e77113..eedebe08 100644 --- a/Wonky.Client/Pages/CrmCustomerWorkplaceViewEditPage.razor +++ b/Wonky.Client/Pages/CrmCustomerWorkplaceViewEditPage.razor @@ -122,7 +122,7 @@ - +
@@ -153,7 +153,7 @@ Kemisk Risiko Vurdering
-
@@ -177,4 +177,5 @@ } - \ No newline at end of file + + \ No newline at end of file diff --git a/Wonky.Client/Pages/CrmCustomerWorkplaceViewEditPage.razor.cs b/Wonky.Client/Pages/CrmCustomerWorkplaceViewEditPage.razor.cs index f9ab8fc5..293f6978 100644 --- a/Wonky.Client/Pages/CrmCustomerWorkplaceViewEditPage.razor.cs +++ b/Wonky.Client/Pages/CrmCustomerWorkplaceViewEditPage.razor.cs @@ -55,15 +55,16 @@ public partial class CrmCustomerWorkplaceViewEditPage : IDisposable private WorkplaceInventory WorkplaceInventory { get; set; } = new(); private List DocViews { get; set; } = new(); private ConfirmDeleteModal ConfirmDeleteWorkplace { get; set; } - private ConfirmDeleteModal ConfirmDeleteProduct { get; set; } + private ConfirmDeleteModal ConfirmDeleteVariant { get; set; } private string DeleteMessage { get; set; } = ""; private string LinkRecipients { get; set; } = ""; private const string CopyText = "Kopier"; private const string CopyStyle = "btn btn-primary"; - private const string SuccessText = "Kopieret"; - private const string SuccessStyle = "btn btn-success"; - private string _buttonText = CopyText; - private string _buttonStyle = CopyStyle; + private const string CopySuccessText = "Kopieret"; + private const string CopySuccessStyle = "btn btn-success"; + private string _copyButtonText = CopyText; + private string _copyButtonStyle = CopyStyle; + private DocView SelectedProduct { get; set; } = new(); protected override async Task OnInitializedAsync() @@ -136,23 +137,26 @@ public partial class CrmCustomerWorkplaceViewEditPage : IDisposable { await Clipboard.CopyToClipboard(Workplace.ShortUrl); - _buttonText = SuccessText; - _buttonStyle = SuccessStyle; + _copyButtonText = CopySuccessText; + _copyButtonStyle = CopySuccessStyle; StateHasChanged(); await Task.Delay(TimeSpan.FromSeconds(2)); - _buttonText = CopyText; - _buttonStyle = CopyStyle; + _copyButtonText = CopyText; + _copyButtonStyle = CopyStyle; } private async Task OnSubmitUpdate() { Working = true; + await Workplaces.UpdateWorkplace(CompanyId, Workplace); + Working = false; + Toaster.ShowSuccess("Arbejdssted er opdateret"); } @@ -160,43 +164,68 @@ public partial class CrmCustomerWorkplaceViewEditPage : IDisposable private void OnConfirmDeleteWorkplace() { DeleteMessage = $"Bekræft at du sletter
{Workplace.Name} fra {Workplace.CompanyName}?
AL INFORMATION slettes og handlingen er uigenkaldelig."; + Logger.LogDebug("ConfirmDeleteWorkplace"); + ConfirmDeleteWorkplace.Show(); } - + private async Task RemoveWorkplace() { Logger.LogDebug("DeleteWorkplace"); + Working = true; + await Workplaces.DeleteWorkplace(CompanyId, WorkplaceId); + Toaster.ShowInfo("Arbejdssted er slettet."); + Navigator.NavigateTo($"/advisor/customers/{CompanyId}/workplaces"); } - private async Task OnRemoveVariant(string productId, string variantId) + private void OnConfirmDeleteVariant(DocView selectedProduct) { - // delete the apb and apv - var product = WorkplaceInventory - .Products.First(x => x.ProductId == productId); - var variant = product.Variants.First(x => x.VariantId == variantId); - Logger.LogDebug("variant => {}", JsonSerializer.Serialize(variant, new JsonSerializerOptions(JsonSerializerDefaults.Web))); + SelectedProduct = selectedProduct; - foreach (var doc in variant.Docs) + DeleteMessage = $"Bekræft at du sletter
{selectedProduct.VariantName} fra {Workplace.CompanyName}?
AL INFORMATION slettes og handlingen er uigenkaldelig."; + + Logger.LogDebug("ConfirmDeleteProduct"); + + ConfirmDeleteVariant.Show(); + } + + + private async Task RemoveVariant() + { + if (Working) { - await WorkplaceRepo.DeleteWorkplaceDocuments(CompanyId, WorkplaceId, doc.DocumentId); + return; } + Working = true; + + var product = WorkplaceInventory + .Products + .First(x => x.ProductId == SelectedProduct.ProductId); + + await WorkplaceRepo + .DeleteWorkplaceDocuments(CompanyId, WorkplaceId, SelectedProduct.ApbDocId, SelectedProduct.ApvDocId); WorkplaceInventory.Products.Remove(product); + DocViews = GenerateDocumentListView(); + Toaster.ShowInfo("Produkt dokumenter er slettet."); + + Working = false; } private List GenerateDocumentListView() { var docViews = new List(); + var docProducts = WorkplaceInventory.Products.OrderBy(x => x.TradingName).ToList(); foreach (var product in docProducts) diff --git a/Wonky.Client/Shared/ContactModal.razor b/Wonky.Client/Shared/ContactViewEditModal.razor similarity index 66% rename from Wonky.Client/Shared/ContactModal.razor rename to Wonky.Client/Shared/ContactViewEditModal.razor index 8d78e3e8..6c0a53aa 100644 --- a/Wonky.Client/Shared/ContactModal.razor +++ b/Wonky.Client/Shared/ContactViewEditModal.razor @@ -24,54 +24,50 @@