toggle edit in customer view/edit page

This commit is contained in:
Frede Hundewadt 2023-02-26 09:17:59 +01:00
parent 1a0255a14a
commit 41eccd64bf
32 changed files with 1523 additions and 1483 deletions

View file

@ -26,8 +26,8 @@ using Wonky.Entity.Views;
#pragma warning disable CS8618 #pragma warning disable CS8618
namespace Wonky.Client.Components namespace Wonky.Client.Components;
{
public partial class AdvisorCustomerListComponent public partial class AdvisorCustomerListComponent
{ {
[Parameter] public List<CompanyDto> CompanyList { get; set; } = new(); [Parameter] public List<CompanyDto> CompanyList { get; set; } = new();
@ -53,4 +53,3 @@ namespace Wonky.Client.Components
InformationModal.Show(); InformationModal.Show();
} }
} }
}

View file

@ -17,8 +17,8 @@ using System.Timers;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Timer = System.Timers.Timer; using Timer = System.Timers.Timer;
namespace Wonky.Client.Components namespace Wonky.Client.Components;
{
public partial class CatalogSearchPhraseComponent public partial class CatalogSearchPhraseComponent
{ {
private Timer Timer { get; set; } = new(); private Timer Timer { get; set; } = new();
@ -48,4 +48,3 @@ namespace Wonky.Client.Components
Timer.Dispose(); Timer.Dispose();
} }
} }
}

View file

@ -19,8 +19,8 @@ using Wonky.Client.Services;
using Timer = System.Timers.Timer; using Timer = System.Timers.Timer;
#pragma warning disable CS8618 #pragma warning disable CS8618
namespace Wonky.Client.Components namespace Wonky.Client.Components;
{
public partial class CustomerSearchPhraseComponent public partial class CustomerSearchPhraseComponent
{ {
private Timer InputTimer { get; set; } = new(); private Timer InputTimer { get; set; } = new();
@ -63,4 +63,3 @@ namespace Wonky.Client.Components
OnChanged.InvokeAsync(SearchTerm); OnChanged.InvokeAsync(SearchTerm);
} }
} }
}

View file

@ -20,8 +20,8 @@ using Microsoft.AspNetCore.Components;
using Wonky.Client.Services; using Wonky.Client.Services;
#pragma warning disable CS8618 #pragma warning disable CS8618
namespace Wonky.Client.Components namespace Wonky.Client.Components;
{
public partial class CustomerSortComponent : IDisposable public partial class CustomerSortComponent : IDisposable
{ {
[Inject] public ILocalStorageService Storage { get; set; } [Inject] public ILocalStorageService Storage { get; set; }
@ -53,5 +53,3 @@ namespace Wonky.Client.Components
ProfileService.OnChange -= ProfileServiceOnOnChange; ProfileService.OnChange -= ProfileServiceOnOnChange;
} }
} }
}

View file

@ -27,8 +27,8 @@ using Utils = Wonky.Client.Helpers.Utils;
#pragma warning disable CS8618 #pragma warning disable CS8618
namespace Wonky.Client.Components namespace Wonky.Client.Components;
{
public partial class OfficeCountryCustomerListComponent public partial class OfficeCountryCustomerListComponent
{ {
// ****************************************************** // ******************************************************
@ -100,4 +100,3 @@ namespace Wonky.Client.Components
SelectedCompany = CompanyList.First(x => x.CompanyId == companyId); SelectedCompany = CompanyList.First(x => x.CompanyId == companyId);
} }
} }
}

View file

@ -20,35 +20,37 @@ using Microsoft.AspNetCore.Components;
using Wonky.Client.Services; using Wonky.Client.Services;
#pragma warning disable CS8618 #pragma warning disable CS8618
namespace Wonky.Client.Components namespace Wonky.Client.Components;
{
public partial class PageSizeComponent : IDisposable public partial class PageSizeComponent : IDisposable
{ {
[Inject] public ILocalStorageService Storage { get; set; } [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 _profiles = 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;
_profiles = await ProfileService.GetProfile(); Profile = await ProfileService.GetProfile();
PageSize = _profiles.PageSize; PageSize = Profile.PageSize;
} }
private async Task OnSelectChanged(ChangeEventArgs e) private async Task OnSelectChanged(ChangeEventArgs e)
{ {
var val = e.Value.ToString(); var val = e.Value?.ToString();
if (val == "-1") return; if (val == "-1") return;
var cVal = Convert.ToInt32(val);
if (cVal > 50) val = "50"; // mitigate variable manipulation
await OnChanged.InvokeAsync(val); await OnChanged.InvokeAsync(val);
await ProfileService.SetPageSize(val); await ProfileService.SetPageSize(val);
} }
private void ProfileServiceOnOnChange(UserProfile newUserProfile) private void ProfileServiceOnOnChange(UserProfile newUserProfile)
{ {
_profiles = newUserProfile; Profile = newUserProfile;
StateHasChanged(); StateHasChanged();
} }
@ -57,4 +59,3 @@ namespace Wonky.Client.Components
ProfileService.OnChange -= ProfileServiceOnOnChange; ProfileService.OnChange -= ProfileServiceOnOnChange;
} }
} }
}

View file

@ -19,8 +19,8 @@ using Microsoft.AspNetCore.Components;
using Wonky.Client.Features; using Wonky.Client.Features;
using Wonky.Entity.Requests; using Wonky.Entity.Requests;
namespace Wonky.Client.Components namespace Wonky.Client.Components;
{
public partial class PaginationComponent public partial class PaginationComponent
{ {
[Parameter] public MetaData MetaData { get; set; } = new(); [Parameter] public MetaData MetaData { get; set; } = new();
@ -59,4 +59,3 @@ namespace Wonky.Client.Components
await SelectedPage.InvokeAsync(link.Page); await SelectedPage.InvokeAsync(link.Page);
} }
} }
}

View file

@ -21,8 +21,8 @@ using Wonky.Client.HttpRepository;
using Wonky.Client.Shared; using Wonky.Client.Shared;
using Wonky.Entity.DTO; using Wonky.Entity.DTO;
namespace Wonky.Client.Components namespace Wonky.Client.Components;
{
public partial class TaskItemTableComponent public partial class TaskItemTableComponent
{ {
[Parameter] public List<TaskItemDto> TaskItemList { get; set; } = new(); [Parameter] public List<TaskItemDto> TaskItemList { get; set; } = new();
@ -74,4 +74,3 @@ namespace Wonky.Client.Components
await OnDeleteTask.InvokeAsync(_taskItemIdToDelete); await OnDeleteTask.InvokeAsync(_taskItemIdToDelete);
} }
} }
}

View file

@ -15,6 +15,7 @@
using System.Globalization; using System.Globalization;
using System.Text.Json;
using Blazored.LocalStorage; using Blazored.LocalStorage;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Forms; using Microsoft.AspNetCore.Components.Forms;
@ -69,8 +70,8 @@ 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)
{ {
var x = DateTime.TryParse(e.Value.ToString(), out var setDate); if (string.IsNullOrWhiteSpace(e.Value.ToString())) return;
if (x) if (DateTime.TryParse(e.Value.ToString(), out var setDate))
{ {
await UserProfile.SetWorkDate(setDate); await UserProfile.SetWorkDate(setDate);
await OnChangedCallback.InvokeAsync($"{setDate:yyyy-MM-dd}"); await OnChangedCallback.InvokeAsync($"{setDate:yyyy-MM-dd}");

View file

@ -26,8 +26,8 @@
using System.Diagnostics; using System.Diagnostics;
namespace Wonky.Client.Helpers namespace Wonky.Client.Helpers;
{
/// <summary> /// <summary>
/// Squid is guid string shortened and url safe /// Squid is guid string shortened and url safe
/// </summary> /// </summary>
@ -359,4 +359,3 @@ namespace Wonky.Client.Helpers
return oGuid == Guid.Empty ? Empty : new Squid(oGuid); return oGuid == Guid.Empty ? Empty : new Squid(oGuid);
} }
} }
}

View file

@ -23,8 +23,8 @@ using Wonky.Client.Services;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Toolbelt.Blazor; using Toolbelt.Blazor;
namespace Wonky.Client.HttpInterceptors namespace Wonky.Client.HttpInterceptors;
{
public class HttpInterceptorService public class HttpInterceptorService
{ {
private readonly HttpClientInterceptor _interceptor; private readonly HttpClientInterceptor _interceptor;
@ -122,5 +122,3 @@ namespace Wonky.Client.HttpInterceptors
// throw new HttpResponseException(message); // throw new HttpResponseException(message);
} }
} }
}

View file

@ -16,8 +16,8 @@
using System.Runtime.Serialization; using System.Runtime.Serialization;
namespace Wonky.Client.HttpInterceptors namespace Wonky.Client.HttpInterceptors;
{
[Serializable] [Serializable]
public class HttpResponseException : Exception public class HttpResponseException : Exception
{ {
@ -38,4 +38,3 @@ namespace Wonky.Client.HttpInterceptors
} }
} }
}

View file

@ -30,7 +30,7 @@
<div class="row g-3"> <div class="row g-3">
<label for="date" class="col-form-label-sm col-sm-1">Dato</label> <label for="date" class="col-form-label-sm col-sm-1">Dato</label>
<div class="col-sm-3"> <div class="col-sm-3">
<input id="date" class="form-control" type="text" value="@(DateTime.Parse(ReportItem.CreateTimestamp).ToShortDateString())" readonly/> <input id="date" class="form-control" type="text" value="@ReportItem.CreateTimestamp" readonly/>
</div> </div>
<label for="account" class="col-form-label-sm col-sm-1">Konto</label> <label for="account" class="col-form-label-sm col-sm-1">Konto</label>

View file

@ -49,7 +49,6 @@
<h3>Der kan ikke oprettes besøg når der findes rapport for @SelectedDate.ToShortDateString()</h3> <h3>Der kan ikke oprettes besøg når der findes rapport for @SelectedDate.ToShortDateString()</h3>
</div> </div>
</div> </div>
} }
else else
{ {
@ -360,7 +359,9 @@ else
***************** Confirm product check overlay button ***************************** ***************** Confirm product check overlay button *****************************
***************** Continue by submitton order to erp ***************************** ***************** Continue by submitton order to erp *****************************
*@ *@
<button type="button" class="btn btn-warning" @onclick="CallConfirmCheckOverlay" disabled="@(PoFormInvalid || Working)"><i class="bi-cloud-arrow-up"></i> @ButtonText</button> <button type="button" class="btn btn-warning" @onclick="CallConfirmCheckOverlay" disabled="@(PoFormInvalid || Working)">
<i class="bi-cloud-arrow-up"></i> @ButtonText
</button>
</div> </div>
</div> </div>
} }
@ -382,4 +383,3 @@ else
<CustomerInventoryListOverlay CompanyName="@Company.Name" CompanyId="@CompanyId" CountryCode="@Company.CountryCode" <CustomerInventoryListOverlay CompanyName="@Company.Name" CompanyId="@CompanyId" CountryCode="@Company.CountryCode"
OnSelected="OnInventoryCallback" Inventory="Inventory" @ref="InventoryListOverlay"/> OnSelected="OnInventoryCallback" Inventory="Inventory" @ref="InventoryListOverlay"/>

View file

@ -1,5 +1,4 @@
 // Copyright (C) 2022 FCS Frede's Computer Services.
// Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the // published by the Free Software Foundation, either version 3 of the
@ -30,6 +29,7 @@ using Wonky.Client.Services;
using Wonky.Client.Shared; using Wonky.Client.Shared;
using Wonky.Entity.DTO; using Wonky.Entity.DTO;
using Wonky.Entity.Views; using Wonky.Entity.Views;
#pragma warning disable CS8618 #pragma warning disable CS8618
namespace Wonky.Client.Pages; namespace Wonky.Client.Pages;
@ -49,18 +49,22 @@ public partial class AdvisorActivityCreatePage : IDisposable
[Inject] public IAdvisorActivityRepository ActivityRepo { get; set; } [Inject] public IAdvisorActivityRepository ActivityRepo { get; set; }
[Inject] public IAdvisorReportRepository ReportRepo { get; set; } [Inject] public IAdvisorReportRepository ReportRepo { get; set; }
[Inject] public IAdvisorCustomerHistoryRepository HistoryRepo { get; set; } [Inject] public IAdvisorCustomerHistoryRepository HistoryRepo { get; set; }
[Inject] public IUserInfoService UserInfoService { get; set; }
[Inject] public IUserInfoService UserService { get; set; }
// ************************************************************* // *************************************************************
// Parameters // Parameters
[CascadingParameter] private DraftStateProvider DraftProvider { get; set; } = new(); [CascadingParameter] private DraftStateProvider DraftProvider { get; set; } = new();
[Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string CompanyId { get; set; } = "";
// ************************************************************* // *************************************************************
// Variables // Variables
private readonly JsonSerializerOptions _options = new() { PropertyNameCaseInsensitive = true }; private readonly JsonSerializerOptions _options = new() { PropertyNameCaseInsensitive = true };
private SalesItemView SelectedItem { get; set; } = new(); private SalesItemView SelectedItem { get; set; } = new();
private UserProfile UserProfile { get; set; } = new(); private UserProfile UserProfile { get; set; } = new();
private ActivityDto Activity { get; set; } = new(); private ActivityDto Activity { get; set; } = new();
private CompanyDto Company = new(); private CompanyDto Company { get; set; } = new();
private EditContext? ActivityContext { get; set; } private EditContext? ActivityContext { get; set; }
private bool PoFormInvalid { get; set; } = true; private bool PoFormInvalid { get; set; } = true;
private bool ShowItem { get; set; } private bool ShowItem { get; set; }
@ -78,7 +82,9 @@ public partial class AdvisorActivityCreatePage : IDisposable
private string PromptDateConfirm { get; set; } = ""; private string PromptDateConfirm { get; set; } = "";
private string ButtonText { get; set; } = "Gem besøg"; private string ButtonText { get; set; } = "Gem besøg";
private bool OrgWarning { get; set; } private bool OrgWarning { get; set; }
private const string PromptDemoForgotten = "Har du glemt demo?"; private const string PromptDemoForgotten = "Har du glemt demo?";
// ************************************************************* // *************************************************************
// Overlays // Overlays
private PriceCatalogOverlay CatalogOverlay { get; set; } = new(); private PriceCatalogOverlay CatalogOverlay { get; set; } = new();
@ -88,7 +94,9 @@ public partial class AdvisorActivityCreatePage : IDisposable
private ProductCheckConfirmationOverlay ConfirmationCheckOverlay { get; set; } = new(); private ProductCheckConfirmationOverlay ConfirmationCheckOverlay { get; set; } = new();
private CustomerInvoiceListOverlay InvoiceListOverlay { get; set; } = new(); private CustomerInvoiceListOverlay InvoiceListOverlay { get; set; } = new();
private CustomerInventoryListOverlay InventoryListOverlay { get; set; } = new(); private CustomerInventoryListOverlay InventoryListOverlay { get; set; } = new();
private CustomerActivityListOverlay ActivityListOverlay { get; set; } = new(); private CustomerActivityListOverlay ActivityListOverlay { get; set; } = new();
// ************************************************************* // *************************************************************
// Lists // Lists
private List<ProductInventoryView> Inventory { get; set; } = new(); private List<ProductInventoryView> Inventory { get; set; } = new();
@ -110,11 +118,11 @@ public partial class AdvisorActivityCreatePage : IDisposable
// User Preferences // User Preferences
UserProfile = await ProfileService.GetProfile(); UserProfile = await ProfileService.GetProfile();
// User Info // User Info
SalesRep = await UserInfoService.GetUserInfo(); SalesRep = await UserService.GetUserInfo();
// Fetch Customer from http // Fetch Customer from http
Company = await CompanyRepo.GetCompanyById(CompanyId); Company = await CompanyRepo.GetCompanyById(CompanyId);
if (Company.HasFolded == 1) if (Company.HasFolded == 1)
// Company has shutdown activities // Company has shut down
Activity.OrderMessage = "BEMÆRK: CVR nummer er ophørt."; Activity.OrderMessage = "BEMÆRK: CVR nummer er ophørt.";
// variable to validate if customer needs phone number update // variable to validate if customer needs phone number update
@ -150,7 +158,10 @@ public partial class AdvisorActivityCreatePage : IDisposable
Activity.DlvZipCode = Company.ZipCode; Activity.DlvZipCode = Company.ZipCode;
Activity.DlvCity = Company.City; Activity.DlvCity = Company.City;
// Initialize date variable // Initialize date variable
SelectedDate = string.IsNullOrWhiteSpace(UserProfile.WorkDate) ? DateTime.Now : DateTime.Parse(UserProfile.WorkDate); Logger.LogDebug("AdvisorActivityCreatePage => DateTime parser => {}", UserProfile.WorkDate);
SelectedDate = string.IsNullOrWhiteSpace(UserProfile.WorkDate)
? DateTime.Now
: DateTime.Parse(UserProfile.WorkDate);
// raise flag if report is closed // raise flag if report is closed
ReportClosed = await ReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}"); ReportClosed = await ReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}");
// Ask for confirmation of date // Ask for confirmation of date
@ -160,6 +171,7 @@ public partial class AdvisorActivityCreatePage : IDisposable
PromptDateConfirm = $"Aktiviteter oprettes med dato {SelectedDate.ToShortDateString()}. Er dette OK?"; PromptDateConfirm = $"Aktiviteter oprettes med dato {SelectedDate.ToShortDateString()}. Er dette OK?";
ConfirmWorkDate.Show(); ConfirmWorkDate.Show();
} }
// Lines may already have been added from the company inventory page // Lines may already have been added from the company inventory page
if (DraftProvider.Draft.DraftType == "order") if (DraftProvider.Draft.DraftType == "order")
{ {
@ -168,6 +180,7 @@ public partial class AdvisorActivityCreatePage : IDisposable
Activity.ActivityStatusEnum = "order"; Activity.ActivityStatusEnum = "order";
PoFormInvalid = false; PoFormInvalid = false;
} }
Working = false; Working = false;
} }
@ -218,7 +231,8 @@ public partial class AdvisorActivityCreatePage : IDisposable
var iDate = await Storage.GetItemAsStringAsync($"{CompanyId}-iDate"); var iDate = await Storage.GetItemAsStringAsync($"{CompanyId}-iDate");
// if we have a list and iDate was today return the list // if we have a list and iDate was today return the list
if (!string.IsNullOrWhiteSpace(storage) && (!string.IsNullOrWhiteSpace(iDate) && DateTime.Parse(iDate.Replace("\"", "")) >= DateTime.Now)) if (!string.IsNullOrWhiteSpace(storage) && (!string.IsNullOrWhiteSpace(iDate) &&
DateTime.Parse(iDate.Replace("\"", "")) >= DateTime.Now))
{ {
Logger.LogDebug("fetching invoices from storage"); Logger.LogDebug("fetching invoices from storage");
Logger.LogDebug("storage contains <= {}", storage); Logger.LogDebug("storage contains <= {}", storage);
@ -242,7 +256,8 @@ public partial class AdvisorActivityCreatePage : IDisposable
if (OrgWarning) if (OrgWarning)
return; return;
OrgWarning = true; OrgWarning = true;
if (Company.CountryCode.ToLower() == "se" && VatUtils.SanitizeVatNumber(Activity.VatNumber).Length < 10 && Activity.ActivityStatusEnum == "order") if (Company.CountryCode.ToLower() == "se" && VatUtils.SanitizeVatNumber(Activity.VatNumber).Length < 10 &&
Activity.ActivityStatusEnum == "order")
{ {
Toaster.ShowWarning("Org nummer er ufuldstændig. Skal opdateres før bestilling kan sendes. ", "ADVARSEL"); Toaster.ShowWarning("Org nummer er ufuldstændig. Skal opdateres før bestilling kan sendes. ", "ADVARSEL");
} }
@ -275,7 +290,9 @@ public partial class AdvisorActivityCreatePage : IDisposable
{ {
Working = true; Working = true;
// pop a message // pop a message
Toaster.ShowError("Produkt gennemgang mangler. Vent mens produkt oversigt indlæses. Gå ikke væk fra siden!", "Produkt check ..."); Toaster.ShowError(
"Produkt gennemgang mangler. Vent mens produkt oversigt indlæses. Gå ikke væk fra siden!",
"Produkt check ...");
// product inventory has not been updated // product inventory has not been updated
// send rpc call to sync ERP to CRM // send rpc call to sync ERP to CRM
Toaster.ShowInfo("Vent mens data synkroniseres ...", "ERP til CRM ..."); Toaster.ShowInfo("Vent mens data synkroniseres ...", "ERP til CRM ...");
@ -314,8 +331,8 @@ public partial class AdvisorActivityCreatePage : IDisposable
{ {
item.Check = false; item.Check = false;
} }
await Storage.SetItemAsync($"{CompanyId}-products", CheckList);
await Storage.SetItemAsync($"{CompanyId}-products", CheckList);
} }
private async Task WorkDateConfirmCallback() private async Task WorkDateConfirmCallback()
@ -376,6 +393,7 @@ public partial class AdvisorActivityCreatePage : IDisposable
Toaster.ShowError("Kunde adresse er ufuldstændig."); Toaster.ShowError("Kunde adresse er ufuldstændig.");
return; return;
} }
// validate org number // validate org number
// - this is a required input // - this is a required input
// - must validate according to country rules. // - must validate according to country rules.
@ -384,6 +402,7 @@ public partial class AdvisorActivityCreatePage : IDisposable
Toaster.ShowError("Firma registreringsnummer er ikke korrekt."); Toaster.ShowError("Firma registreringsnummer er ikke korrekt.");
return; return;
} }
// validate input according to status // validate input according to status
switch (Activity.ActivityStatusEnum) switch (Activity.ActivityStatusEnum)
{ {
@ -400,6 +419,7 @@ public partial class AdvisorActivityCreatePage : IDisposable
Toaster.ShowError("Ved tilbud skal en gyldig email adresse angives."); Toaster.ShowError("Ved tilbud skal en gyldig email adresse angives.");
return; return;
} }
// raise working flag // raise working flag
Working = true; Working = true;
@ -412,6 +432,7 @@ public partial class AdvisorActivityCreatePage : IDisposable
Activity.OrderMessage = $"Telefonnr. opdateret.\n{Activity.OrderMessage}"; Activity.OrderMessage = $"Telefonnr. opdateret.\n{Activity.OrderMessage}";
await CompanyRepo.UpdateErpData(Company.CompanyId, Company); await CompanyRepo.UpdateErpData(Company.CompanyId, Company);
} }
// begin assembling activity // begin assembling activity
Activity.ActivityDate = $"{SelectedDate:yyyy-MM-dd}"; Activity.ActivityDate = $"{SelectedDate:yyyy-MM-dd}";
Activity.OurRef = Activity.ActivityTypeEnum switch Activity.OurRef = Activity.ActivityTypeEnum switch
@ -443,6 +464,7 @@ public partial class AdvisorActivityCreatePage : IDisposable
.ToList(); .ToList();
Activity.Lines = lines; Activity.Lines = lines;
} }
// debug logging // debug logging
Logger.LogDebug("CrmNewActivityPage => \n {}", JsonSerializer.Serialize(Activity)); Logger.LogDebug("CrmNewActivityPage => \n {}", JsonSerializer.Serialize(Activity));
// post to api // post to api
@ -458,6 +480,7 @@ public partial class AdvisorActivityCreatePage : IDisposable
Navigator.NavigateTo($"/advisor/customers"); Navigator.NavigateTo($"/advisor/customers");
return; return;
} }
// lower working flag // lower working flag
Working = false; Working = false;
// show error message // show error message
@ -507,7 +530,8 @@ public partial class AdvisorActivityCreatePage : IDisposable
private void HandleFieldChanged(object sender, FieldChangedEventArgs e) private void HandleFieldChanged(object sender, FieldChangedEventArgs e)
{ {
Logger.LogDebug("ActivityNewPage => HandleFieldChanged => ActivityStatusEnum <= '{}'", Activity.ActivityStatusEnum); Logger.LogDebug("ActivityNewPage => HandleFieldChanged => ActivityStatusEnum <= '{}'",
Activity.ActivityStatusEnum);
DraftProvider.Draft.DraftType = Activity.ActivityStatusEnum; DraftProvider.Draft.DraftType = Activity.ActivityStatusEnum;
if (Activity.ActivityStatusEnum == "noSale") if (Activity.ActivityStatusEnum == "noSale")
{ {
@ -532,6 +556,7 @@ public partial class AdvisorActivityCreatePage : IDisposable
PoFormInvalid = true; PoFormInvalid = true;
return; return;
} }
PoFormInvalid = !ActivityContext.Validate(); PoFormInvalid = !ActivityContext.Validate();
StateHasChanged(); StateHasChanged();
} }

View file

@ -1,4 +1,3 @@
// Copyright (C) 2022 FCS Frede's Computer Services. // Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
@ -14,6 +13,7 @@
// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html]
// //
using System.Diagnostics.CodeAnalysis;
using System.Text.Json; using System.Text.Json;
using Blazored.Toast.Services; using Blazored.Toast.Services;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
@ -21,6 +21,7 @@ using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpRepository; using Wonky.Client.HttpRepository;
using Wonky.Client.Services; using Wonky.Client.Services;
using Wonky.Entity.Views; using Wonky.Entity.Views;
#pragma warning disable CS8618 #pragma warning disable CS8618
namespace Wonky.Client.Pages; namespace Wonky.Client.Pages;
@ -45,7 +46,9 @@ public partial class AdvisorActivityTodayListPage : IDisposable
Interceptor.RegisterEvent(); Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent(); Interceptor.RegisterBeforeSendEvent();
UserProfile = await ProfileService.GetProfile(); UserProfile = await ProfileService.GetProfile();
SelectedDate = string.IsNullOrWhiteSpace(UserProfile.WorkDate) ? DateTime.Now : DateTime.Parse(UserProfile.WorkDate); SelectedDate = string.IsNullOrWhiteSpace(UserProfile.WorkDate)
? DateTime.Now
: DateTime.Parse(UserProfile.WorkDate);
ReportExist = await ReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}"); ReportExist = await ReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}");
await GetActivities($"{SelectedDate:yyyy-MM-dd}"); await GetActivities($"{SelectedDate:yyyy-MM-dd}");
Working = false; Working = false;
@ -68,5 +71,4 @@ public partial class AdvisorActivityTodayListPage : IDisposable
{ {
Interceptor.DisposeEvent(); Interceptor.DisposeEvent();
} }
} }

View file

@ -23,7 +23,6 @@
@page "/advisor/customers/{CompanyId}/quotes/{OrderId}" @page "/advisor/customers/{CompanyId}/quotes/{OrderId}"
<PageTitle>@ReportItem.Company.Name @ReportItem.OrderDate</PageTitle> <PageTitle>@ReportItem.Company.Name @ReportItem.OrderDate</PageTitle>
@* <ReportItemComponent ReportItem="@_item" /> *@
<table class="table table-sm table-striped d-print-table"> <table class="table table-sm table-striped d-print-table">
<thead> <thead>
@ -124,7 +123,9 @@
{ {
<tr> <tr>
<td colspan="4"></td> <td colspan="4"></td>
<td colspan="2"><h5 class="fw-bold text-center"><i class="bi-lightning-charge the-fast" style="font-size: 2rem;"></i> HASTER</h5></td> <td colspan="2">
<h5 class="fw-bold text-center"><i class="bi-lightning-charge the-fast" style="font-size: 2rem;"></i> HASTER</h5>
</td>
</tr> </tr>
} }
</tbody> </tbody>

View file

@ -1,4 +1,3 @@
// Copyright (C) 2022 FCS Frede's Computer Services. // Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
@ -22,6 +21,7 @@ using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpRepository; using Wonky.Client.HttpRepository;
using Wonky.Entity.DTO; using Wonky.Entity.DTO;
using Wonky.Entity.Views; using Wonky.Entity.Views;
#pragma warning disable CS8618 #pragma warning disable CS8618
namespace Wonky.Client.Pages; namespace Wonky.Client.Pages;
@ -42,6 +42,7 @@ public partial class AdvisorActivityViewEditPage : IDisposable
private int GraceTime { get; set; } = 60; private int GraceTime { get; set; } = 60;
private bool Working { get; set; } = true; private bool Working { get; set; } = true;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
Interceptor.RegisterEvent(); Interceptor.RegisterEvent();

View file

@ -1,4 +1,3 @@
// Copyright (C) 2022 FCS Frede's Computer Services. // Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
@ -20,6 +19,7 @@ using Wonky.Client.HttpInterceptors;
using Wonky.Client.HttpRepository; using Wonky.Client.HttpRepository;
using Wonky.Entity.DTO; using Wonky.Entity.DTO;
using Wonky.Entity.Views; using Wonky.Entity.Views;
#pragma warning disable CS8618 #pragma warning disable CS8618
namespace Wonky.Client.Pages; namespace Wonky.Client.Pages;

View file

@ -14,7 +14,6 @@
// //
using System.Text.Json; using System.Text.Json;
using System.Xml;
using Blazored.LocalStorage; using Blazored.LocalStorage;
using Blazored.Toast.Services; using Blazored.Toast.Services;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
@ -27,11 +26,11 @@ using Wonky.Client.Services;
using Wonky.Client.Shared; using Wonky.Client.Shared;
using Wonky.Entity.DTO; using Wonky.Entity.DTO;
using Wonky.Entity.Models; using Wonky.Entity.Models;
using Wonky.Entity.Views;
#pragma warning disable CS8618 #pragma warning disable CS8618
namespace Wonky.Client.Pages namespace Wonky.Client.Pages;
{
public partial class AdvisorCustomerCreatePage : IDisposable public partial class AdvisorCustomerCreatePage : IDisposable
{ {
[Inject] public IToastService Toaster { get; set; } [Inject] public IToastService Toaster { get; set; }
@ -185,4 +184,3 @@ namespace Wonky.Client.Pages
CompanyContext.OnValidationStateChanged -= ValidationChanged; CompanyContext.OnValidationStateChanged -= ValidationChanged;
} }
} }
}

View file

@ -34,20 +34,23 @@
<div class="col-sm-2"> <div class="col-sm-2">
<PageSizeComponent OnChanged="SetPageSize"/> <PageSizeComponent OnChanged="SetPageSize"/>
</div> </div>
<div class="col-sm-3"> <div class="col-sm-2 mx-auto">
<button type button class="btn btn-warning @(ShowFolded ? "active" : "")" <button type button class="btn btn-warning @(ShowFolded ? "active" : "")"
data-bs-toggle="button" aria-pressed="@ShowFolded" @onclick="OnFoldedClick"> data-bs-toggle="button" aria-pressed="@ShowFolded" @onclick="ToggleFolded">
@ButtonFoldedText @ToggleFoldedText
</button>
<button type button class="btn btn-warning @(@ShowHidden ? "active" : "")"
data-bs-toggle="button" aria-pressed="@ShowHidden" @onclick="OnHiddenClick">
@ButtonHiddenText
</button> </button>
</div> </div>
<div class="col-sm-7"> <div class="col-sm-2 mx-auto">
<button type button class="btn btn-warning @(@ShowHidden ? "active" : "")"
data-bs-toggle="button" aria-pressed="@ShowHidden" @onclick="ToggleHidden">
@ToggleHiddenText
</button>
</div>
<div class="col-sm-5">
<PaginationComponent MetaData="PageData" Spread="2" SelectedPage="SelectedPage"/> <PaginationComponent MetaData="PageData" Spread="2" SelectedPage="SelectedPage"/>
</div> </div>
<div class="col-sm-2 text-end"> <div class="col-sm-1">@* placeholder *@</div>
<div class="col-sm-2 mx-auto">
<a class="btn btn-success text-nowrap" href="/advisor/customers/new">Opret kunde <i class="bi-plus"></i></a> <a class="btn btn-success text-nowrap" href="/advisor/customers/new">Opret kunde <i class="bi-plus"></i></a>
</div> </div>
</div> </div>
@ -59,4 +62,3 @@
{ {
<WorkingThreeDots/> <WorkingThreeDots/>
} }

View file

@ -1,4 +1,3 @@
// Copyright (C) 2022 FCS Frede's Computer Services. // Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
@ -22,10 +21,11 @@ using Wonky.Client.Services;
using Wonky.Entity.DTO; using Wonky.Entity.DTO;
using Wonky.Entity.Requests; using Wonky.Entity.Requests;
using Wonky.Entity.Views; using Wonky.Entity.Views;
#pragma warning disable CS8618 #pragma warning disable CS8618
namespace Wonky.Client.Pages namespace Wonky.Client.Pages;
{
public partial class AdvisorCustomerListPage : IDisposable public partial class AdvisorCustomerListPage : IDisposable
{ {
[Inject] public ILocalStorageService Storage { get; set; } [Inject] public ILocalStorageService Storage { get; set; }
@ -36,58 +36,59 @@ namespace Wonky.Client.Pages
[Inject] public IUserInfoService UserInfoService { get; set; } [Inject] public IUserInfoService UserInfoService { get; set; }
private List<CompanyDto> CompanyList { get; set; } = new(); private List<CompanyDto> CompanyList { get; set; } = new();
private UserProfile Profiles { get; set; } = new(); private UserProfile Profile { get; set; } = new();
private UserManagerEditView XUserInfo { get; set; } = new(); private UserManagerEditView UserInfo { get; set; } = new();
private string SavedSearch { get; set; } = ""; private string SavedSearch { get; set; } = "";
private bool Working { get; set; } = true; private bool Working { get; set; } = true;
private MetaData PageData { get; set; } = new(); private MetaData PageData { get; set; } = new();
private CustomerPaging Paging { get; set; } = new(); private CustomerPaging Paging { get; set; } = new();
private string ButtonFoldedText { get; set; } = "Vis Ophørte"; private string ToggleFoldedText { get; set; } = "Vis Lukkede";
private bool ShowFolded { get; set; } private bool ShowFolded { get; set; }
private string ButtonHiddenText { get; set; } = "Vis Skjulte"; private string ToggleHiddenText { get; set; } = "Inkl. Skjulte";
private bool ShowHidden { get; set; } private bool ShowHidden { get; set; }
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
Interceptor.RegisterEvent(); Interceptor.RegisterEvent();
Interceptor.RegisterBeforeSendEvent(); Interceptor.RegisterBeforeSendEvent();
} }
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
// set preferences // set preferences
Profiles = await ProfileService.GetProfile(); Profile = await ProfileService.GetProfile();
XUserInfo = await UserInfoService.GetUserInfo(); UserInfo = await UserInfoService.GetUserInfo();
Paging.OrderBy = Profiles.CompanySort; Paging.OrderBy = Profile.CompanySort;
Paging.SearchColumn = Profiles.CompanySearch; Paging.SearchColumn = Profile.CompanySearch;
Paging.PageSize = Convert.ToInt32(Profiles.PageSize); Paging.PageSize = Convert.ToInt32(Profile.PageSize);
Paging.HasFolded = ShowFolded ? 1 : 0; Paging.HasFolded = ShowFolded ? 1 : 0;
// load saved search // load saved search
SavedSearch = string.IsNullOrWhiteSpace(Profiles.CompanyFilterPhrase) ? "" : Profiles.CompanyFilterPhrase; SavedSearch = string.IsNullOrWhiteSpace(Profile.CompanyFilterPhrase) ? "" : Profile.CompanyFilterPhrase;
Paging.SearchTerm = SavedSearch; Paging.SearchTerm = SavedSearch;
// get companies // get companies
await FetchCustomers(); await FetchCustomers();
Working = false; Working = false;
} }
private async Task OnFoldedClick() private async Task ToggleFolded()
{ {
Working = true; Working = true;
ShowFolded = !ShowFolded; ShowFolded = !ShowFolded;
ButtonFoldedText = ShowFolded ? "Vis Aktive" : "Vis Ophørte"; ToggleFoldedText = ShowFolded ? "Normal Visning" : "Vis Lukkede";
CompanyList = new List<CompanyDto>(); CompanyList = new List<CompanyDto>();
Paging.PageNumber = 1; Paging.PageNumber = 1;
Paging.HasFolded = ShowFolded ? 1 : 0; Paging.HasFolded = ShowFolded ? 1 : 0;
await FetchCustomers(); await FetchCustomers();
} }
private async Task OnHiddenClick() private async Task ToggleHidden()
{ {
Working = true; Working = true;
ShowHidden = !ShowHidden; ShowHidden = !ShowHidden;
ButtonHiddenText = ShowHidden ? "Vis Normale" : "Vis skjulte"; ToggleHiddenText = ShowHidden ? "Normal Visning" : "Inkl. Skjulte";
CompanyList = new List<CompanyDto>(); CompanyList = new List<CompanyDto>();
Paging.PageNumber = 1; Paging.PageNumber = 1;
Paging.IsHidden = ShowHidden ? 1 : 0; Paging.IsHidden = ShowHidden ? 1 : 0;
@ -108,6 +109,7 @@ namespace Wonky.Client.Pages
Paging.PageNumber = 1; Paging.PageNumber = 1;
await FetchCustomers(); await FetchCustomers();
} }
private async Task SetPageSize(string pageSize) private async Task SetPageSize(string pageSize)
{ {
CompanyList = new List<CompanyDto>(); CompanyList = new List<CompanyDto>();
@ -163,6 +165,3 @@ namespace Wonky.Client.Pages
public void Dispose() => Interceptor.DisposeEvent(); public void Dispose() => Interceptor.DisposeEvent();
} }
}

View file

@ -36,85 +36,86 @@
// erp context // erp context
<EditForm EditContext="ErpContext"> <EditForm EditContext="ErpContext">
<DataAnnotationsValidator/> <DataAnnotationsValidator/>
<div class="row g-3"> <div class="row g-1">
@* Company Name *@ @* Company Name *@
<label for="name" class="col-sm-1 col-form-label-sm">Navn</label> <label for="name" class="col-sm-1 col-form-label-sm">Navn</label>
<div class="col-sm-5"> <div class="col-sm-5">
<InputText id="name" class="form-control" @bind-Value="Company.Name"/> <InputText id="name" class="form-control" @bind-Value="Company.Name" readonly="@(ErpEditDisabled)"/>
<ValidationMessage For="@(() => Company.Name)"></ValidationMessage> <ValidationMessage For="@(() => Company.Name)"></ValidationMessage>
</div> </div>
@* Company Attention *@ @* Company Attention *@
<label for="attention" class="col-sm-1 col-form-label-sm">Att.</label> <label for="attention" class="col-sm-1 col-form-label-sm">Att.</label>
<div class="col-sm-5"> <div class="col-sm-5">
<InputText id="attention" class="form-control" @bind-Value="Company.Attention"/> <InputText id="attention" class="form-control" @bind-Value="Company.Attention" readonly="@(ErpEditDisabled)"/>
<ValidationMessage For="@(() => Company.Attention)"></ValidationMessage> <ValidationMessage For="@(() => Company.Attention)"></ValidationMessage>
</div> </div>
@* Address 1 *@ @* Address 1 *@
<label for="address1" class="col-sm-1 col-form-label-sm">Adresse</label> <label for="address1" class="col-sm-1 col-form-label-sm">Adresse</label>
<div class="col-sm-5"> <div class="col-sm-5">
<InputText id="address1" class="form-control" @bind-Value="Company.Address1"/> <InputText id="address1" class="form-control" @bind-Value="Company.Address1" readonly="@(ErpEditDisabled)"/>
<ValidationMessage For="@(() => Company.Address1)"></ValidationMessage> <ValidationMessage For="@(() => Company.Address1)"></ValidationMessage>
</div> </div>
@* Address 2 *@ @* Address 2 *@
<label for="address2" class="col-sm-1 col-form-label-sm">Adresse</label> <label for="address2" class="col-sm-1 col-form-label-sm">Adresse</label>
<div class="col-sm-5"> <div class="col-sm-5">
<InputText id="address2" class="form-control" @bind-Value="Company.Address2"/> <InputText id="address2" class="form-control" @bind-Value="Company.Address2" readonly="@(ErpEditDisabled)"/>
<ValidationMessage For="@(() => Company.Address2)"></ValidationMessage> <ValidationMessage For="@(() => Company.Address2)"></ValidationMessage>
</div> </div>
@* Post Code *@ @* Post Code *@
<label for="zipCode" class="col-sm-1 col-form-label-sm">PostNr</label> <label for="zipCode" class="col-sm-1 col-form-label-sm">PostNr</label>
<div class="col-sm-2"> <div class="col-sm-2">
<InputText id="zipCode" class="form-control" @bind-Value="Company.ZipCode"/> <InputText id="zipCode" class="form-control" @bind-Value="Company.ZipCode" readonly="@(ErpEditDisabled)"/>
<ValidationMessage For="@(() => Company.ZipCode)"></ValidationMessage> <ValidationMessage For="@(() => Company.ZipCode)"></ValidationMessage>
</div> </div>
@* City Name *@ @* City Name *@
<label for="city" class="col-sm-1 col-form-label-sm">Bynavn</label> <label for="city" class="col-sm-1 col-form-label-sm">Bynavn</label>
<div class="col-sm-8"> <div class="col-sm-8">
<InputText id="city" class="form-control" @bind-Value="Company.City"/> <InputText id="city" class="form-control" @bind-Value="Company.City" readonly="@(ErpEditDisabled)"/>
<ValidationMessage For="@(() => Company.City)"></ValidationMessage> <ValidationMessage For="@(() => Company.City)"></ValidationMessage>
</div> </div>
@* Phone *@ @* Phone *@
<label for="phone" class="col-sm-1 col-form-label-sm">Telefon</label> <label for="phone" class="col-sm-1 col-form-label-sm">Telefon</label>
<div class="col-sm-3"> <div class="col-sm-2">
<InputText id="phone" class="form-control" @bind-Value="Company.Phone"/> <InputText id="phone" class="form-control" @bind-Value="Company.Phone" readonly="@(ErpEditDisabled)"/>
<ValidationMessage For="@(() => Company.Phone)"></ValidationMessage> <ValidationMessage For="@(() => Company.Phone)"></ValidationMessage>
</div> </div>
@* Mobile *@ @* Mobile *@
<label for="mobile" class="col-sm-1 col-form-label-sm">Mobil</label> <label for="mobile" class="col-sm-1 col-form-label-sm">Mobil</label>
<div class="col-sm-3"> <div class="col-sm-2">
<InputText id="mobile" class="form-control" @bind-Value="Company.Mobile"/> <InputText id="mobile" class="form-control" @bind-Value="Company.Mobile" readonly="@(ErpEditDisabled)"/>
<ValidationMessage For="@(() => Company.Mobile)"></ValidationMessage> <ValidationMessage For="@(() => Company.Mobile)"></ValidationMessage>
</div> </div>
<div class="col-sm-4 d-grid mx-auto">
<button type="button" class="btn btn-danger" @onclick="ToggleVisibility">@ToggleButtonText</button>
</div>
@* Email *@ @* Email *@
<label for="email" class="col-sm-1 col-form-label-sm">Epost</label> <label for="email" class="col-sm-1 col-form-label-sm">Epost</label>
<div class="col-sm-5"> <div class="col-sm-5">
<InputText id="email" class="form-control" @bind-Value="Company.Email"/> <InputText id="email" class="form-control" @bind-Value="Company.Email" readonly="@(ErpEditDisabled)"/>
<ValidationMessage For="@(() => Company.Email)"></ValidationMessage> <ValidationMessage For="@(() => Company.Email)"></ValidationMessage>
</div> </div>
<div class="col-sm-3 d-grid mx-auto"> <div class="col-sm-4">@* ---- placeholder --- *@</div>
<button type="button" class="btn btn-primary d-block" disabled="@(Company.HasFolded == 0 || Company.Name == "ERROR")" onclick="@ForceActivity">Aktiver besøg</button> <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>
<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")"><i class="bi-cloud-arrow-up"></i> STAM data </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>
<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> </div>
<hr class="mb-3"/>
<div class="row">
@* vat number*@ @* vat number*@
<label for="vatNumber" class="col-sm-2 col-form-label-sm">CVR/Org nr.</label> <label for="vatNumber" class="col-sm-1 col-form-label-sm">CVR/Org nr.</label>
<div class="col-sm-4"> <div class="col-sm-3">
<div class="input-group"> <div class="input-group">
<span class="input-group-text"> <span class="input-group-text">
<DisplayStateComponent StateClass="@VatState"/> <DisplayStateComponent StateClass="@VatState"/>
</span> </span>
<InputText id="vatNumber" class="form-control" @bind-Value="Company.VatNumber"/> <InputText id="vatNumber" class="form-control" @bind-Value="Company.VatNumber" readonly="@(VatEditDisabled)"/>
<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)
@ -132,7 +133,7 @@
</div> </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"><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>
</div> </div>
</div> </div>
@ -240,6 +241,11 @@
<InputTextArea id="crmNotes" class="form-control" @bind-Value="Company.CrmNotes"/> <InputTextArea id="crmNotes" class="form-control" @bind-Value="Company.CrmNotes"/>
</div> </div>
</div> </div>
<div class="row pt-3">
<div class="col-sm-3 d-grid">
<button type="button" class="btn btn-danger" @onclick="ToggleVisibility">@ToggleButtonText</button>
</div>
</div>
</EditForm> </EditForm>
} }

View file

@ -1,4 +1,3 @@
// Copyright (C) 2022 FCS Frede's Computer Services. // Copyright (C) 2022 FCS Frede's Computer Services.
// This program is free software: you can redistribute it and/or modify // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as // it under the terms of the GNU Affero General Public License as
@ -28,7 +27,7 @@ using Wonky.Client.Services;
using Wonky.Client.Shared; using Wonky.Client.Shared;
using Wonky.Entity.DTO; using Wonky.Entity.DTO;
using Wonky.Entity.Models; using Wonky.Entity.Models;
using Wonky.Entity.Views;
#pragma warning disable CS8618 #pragma warning disable CS8618
namespace Wonky.Client.Pages; namespace Wonky.Client.Pages;
@ -63,6 +62,8 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
private string ActionLink { get; set; } = ""; private string ActionLink { get; set; } = "";
private bool Working { get; set; } = true; private bool Working { get; set; } = true;
private bool CountryIsDk { get; set; } = true; private bool CountryIsDk { get; set; } = true;
private bool ErpEditDisabled { get; set; } = true;
private bool VatEditDisabled { get; set; } = true;
private List<ContactDto> Contacts { get; set; } = new(); private List<ContactDto> Contacts { get; set; } = new();
private VatLookupDkModal VatLookupPopup { get; set; } = new(); private VatLookupDkModal VatLookupPopup { get; set; } = new();
private ContactDto SelectedContact { get; set; } = new(); private ContactDto SelectedContact { get; set; } = new();
@ -96,7 +97,8 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
Company = await CustomerRepo.GetCompanyById(CompanyId); Company = await CustomerRepo.GetCompanyById(CompanyId);
Logger.LogDebug("company => {}", JsonSerializer.Serialize(Company)); Logger.LogDebug("company => {}", JsonSerializer.Serialize(Company));
ToggleButtonText = Company.IsHidden == 0 ? "Skjul kunde" : "Vis kunde"; // toggle view button text
ToggleButtonText = Company.IsHidden == 0 ? "Udelad kunde i oversigt" : "Brug Normal Visning";
CurrentVat = Company.VatNumber; CurrentVat = Company.VatNumber;
Company.CountryCode = UserInfo.CountryCode.ToLower(); Company.CountryCode = UserInfo.CountryCode.ToLower();
// internal flag // internal flag
@ -137,6 +139,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
// vat state css class // vat state css class
VatState = Company.ValidVat == 1 ? "the-good" : "no-vat"; // assign css class VatState = Company.ValidVat == 1 ? "the-good" : "no-vat"; // assign css class
} }
// create search address from address // create search address from address
if (CountryIsDk) if (CountryIsDk)
CompanyVatAddress = PrepareVatAddress(Company); CompanyVatAddress = PrepareVatAddress(Company);
@ -149,13 +152,25 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
await RequestErpUpdate(); await RequestErpUpdate();
} }
private void ToggleErpEdit()
{
ErpEditDisabled = !ErpEditDisabled;
}
private void ToggleVatEdit()
{
VatEditDisabled = !VatEditDisabled;
}
private async Task ToggleVisibility() private async Task ToggleVisibility()
{ {
Company.IsHidden = Company.IsHidden == 0 ? 1 : 0; Company.IsHidden = Company.IsHidden == 0 ? 1 : 0;
ToggleButtonText = Company.IsHidden == 0 ? "Skjul kunde" : "Vis kunde"; // toggle view button text
ToggleButtonText = Company.IsHidden == 0 ? "Udelad kunde i oversigt" : "Brug Normal Visning";
Logger.LogDebug("ToggleVisibility => Company.IsHidden == {}", Company.IsHidden); Logger.LogDebug("ToggleVisibility => Company.IsHidden == {}", Company.IsHidden);
await CustomerRepo.UpdateCrmData(CompanyId, Company); await CustomerRepo.UpdateCrmData(CompanyId, Company);
} }
private async Task RequestErpUpdate() private async Task RequestErpUpdate()
{ {
if (Working) if (Working)
@ -206,6 +221,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
Company.ZipCode = regInfo.ZipCode; Company.ZipCode = regInfo.ZipCode;
Company.City = regInfo.City; Company.City = regInfo.City;
} }
Company.VatNumber = regInfo.VatNumber; Company.VatNumber = regInfo.VatNumber;
} }
@ -247,6 +263,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
// send put request to backend // send put request to backend
await AdvisorContactRepo.UpdateContact(contact); await AdvisorContactRepo.UpdateContact(contact);
} }
// reset selected contact // reset selected contact
SelectedContact = new ContactDto(); SelectedContact = new ContactDto();
// reload contacts from backend // reload contacts from backend
@ -290,6 +307,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
Company = result; Company = result;
StateHasChanged(); StateHasChanged();
} }
Working = false; Working = false;
Toaster.ClearAll(); Toaster.ClearAll();
} }
@ -302,6 +320,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
{ {
if (Working) if (Working)
return; return;
ErpEditDisabled = true;
Working = true; Working = true;
Toaster.ShowInfo("Vent venligst ...", "OPDATERER STAM DATA"); Toaster.ShowInfo("Vent venligst ...", "OPDATERER STAM DATA");
var result = await CustomerRepo.UpdateErpData(CompanyId, Company); var result = await CustomerRepo.UpdateErpData(CompanyId, Company);
@ -310,6 +329,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
Company = result; Company = result;
StateHasChanged(); StateHasChanged();
} }
Working = false; Working = false;
Toaster.ClearAll(); Toaster.ClearAll();
} }
@ -326,8 +346,10 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
Toaster.ShowError($"Moms Nummer ugyldigt"); Toaster.ShowError($"Moms Nummer ugyldigt");
return; return;
} }
if (Working) if (Working)
return; return;
VatEditDisabled = true;
Working = true; Working = true;
Toaster.ShowInfo("Vent venligst ...", "OPDATERER MOMS NUMMER"); Toaster.ShowInfo("Vent venligst ...", "OPDATERER MOMS NUMMER");
var result = await CustomerRepo.UpdateCompanyVat(CompanyId, Company.VatNumber); var result = await CustomerRepo.UpdateCompanyVat(CompanyId, Company.VatNumber);
@ -336,6 +358,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
Company = result; Company = result;
StateHasChanged(); StateHasChanged();
} }
Toaster.ClearAll(); Toaster.ClearAll();
Working = false; Working = false;
} }
@ -359,6 +382,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
HouseNumber = Regex.Replace(model.Address1[pos1..], "[^0-9]", "").Trim() HouseNumber = Regex.Replace(model.Address1[pos1..], "[^0-9]", "").Trim()
}; };
} }
// process address2 // process address2
var pos2 = model.Address2.IndexOfAny(digits); var pos2 = model.Address2.IndexOfAny(digits);
if (pos2 > 0) if (pos2 > 0)
@ -370,6 +394,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
HouseNumber = Regex.Replace(model.Address2[pos2..], "[^0-9]", "").Trim() HouseNumber = Regex.Replace(model.Address2[pos2..], "[^0-9]", "").Trim()
}; };
} }
// return empty model // return empty model
return new VatAddress(); return new VatAddress();
} }
@ -398,6 +423,7 @@ public partial class AdvisorCustomerViewEditPage : IDisposable
ValidVat = true; ValidVat = true;
EnableActivity = 1; EnableActivity = 1;
} }
StateHasChanged(); StateHasChanged();
} }

View file

@ -16,8 +16,8 @@
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
namespace Wonky.Client.Pages namespace Wonky.Client.Pages;
{
public partial class ErrorReportPage public partial class ErrorReportPage
{ {
[Parameter] [Parameter]
@ -25,4 +25,3 @@ namespace Wonky.Client.Pages
[Parameter] public string ErrorDescription { get; set; } = ""; [Parameter] public string ErrorDescription { get; set; } = "";
} }
}

View file

@ -24,8 +24,8 @@ using Wonky.Entity.Requests;
using Wonky.Entity.Views; using Wonky.Entity.Views;
#pragma warning disable CS8618 #pragma warning disable CS8618
namespace Wonky.Client.Pages namespace Wonky.Client.Pages;
{
public partial class OfficeCountryCustomerListPage : IDisposable public partial class OfficeCountryCustomerListPage : IDisposable
{ {
[Parameter] public string CountryCode { get; set; } = ""; [Parameter] public string CountryCode { get; set; } = "";
@ -141,6 +141,3 @@ namespace Wonky.Client.Pages
public void Dispose() => Interceptor.DisposeEvent(); public void Dispose() => Interceptor.DisposeEvent();
} }
}

View file

@ -24,8 +24,8 @@ using Wonky.Entity.Configuration;
using Wonky.Entity.DTO; using Wonky.Entity.DTO;
using Wonky.Entity.Views; using Wonky.Entity.Views;
namespace Wonky.Client.Services namespace Wonky.Client.Services;
{
public class AuthenticationService : IAuthenticationService public class AuthenticationService : IAuthenticationService
{ {
private readonly JsonSerializerOptions _options = new() { PropertyNameCaseInsensitive = true }; private readonly JsonSerializerOptions _options = new() { PropertyNameCaseInsensitive = true };
@ -142,5 +142,3 @@ namespace Wonky.Client.Services
return userInfo ?? new UserManagerEditView(); return userInfo ?? new UserManagerEditView();
} }
} }
}

View file

@ -17,8 +17,8 @@
using Wonky.Entity.DTO; using Wonky.Entity.DTO;
using Wonky.Entity.Views; using Wonky.Entity.Views;
namespace Wonky.Client.Services namespace Wonky.Client.Services;
{
public interface IAuthenticationService public interface IAuthenticationService
{ {
Task<AuthResponseView> Login(CredentialDto credentials); Task<AuthResponseView> Login(CredentialDto credentials);
@ -26,5 +26,3 @@ namespace Wonky.Client.Services
Task<string> RefreshToken(); Task<string> RefreshToken();
Task<UserManagerEditView> UserInfo(bool write = false); Task<UserManagerEditView> UserInfo(bool write = false);
} }
}

View file

@ -22,8 +22,8 @@ using Wonky.Client.Services;
using Wonky.Entity.DTO; using Wonky.Entity.DTO;
using Wonky.Entity.Views; using Wonky.Entity.Views;
namespace Wonky.Client.Shared namespace Wonky.Client.Shared;
{
public class AuthStateProvider : AuthenticationStateProvider public class AuthStateProvider : AuthenticationStateProvider
{ {
private readonly HttpClient _client; private readonly HttpClient _client;
@ -103,5 +103,3 @@ namespace Wonky.Client.Shared
NotifyAuthenticationStateChanged(authState); NotifyAuthenticationStateChanged(authState);
} }
} }
}

View file

@ -1,7 +1,7 @@
{ {
"appInfo": { "appInfo": {
"name": "Wonky Online", "name": "Wonky Online",
"version": "0.117.1", "version": "0.118.0",
"rc": true, "rc": true,
"sandBox": false, "sandBox": false,
"image": "grumpy-coder.png" "image": "grumpy-coder.png"
@ -19,7 +19,7 @@
} }
}, },
"apiConfig": { "apiConfig": {
"baseUrl": "https://dev.innotec.dk", "baseUrl": "https://zeta.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",