From c461d4e26c4e3deb25803a6540aa177a16a7cf12 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Tue, 14 Feb 2023 12:41:27 +0100 Subject: [PATCH] WIP: intermediate production release v.0.116.1 --- .../OfficeCountryCustomerListComponent.razor | 10 +-- ...fficeCountryCustomerListComponent.razor.cs | 77 +++++++++++------ ...OfficeCustomerInventoryListComponent.razor | 82 ------------------ ...iceCustomerInventoryListComponent.razor.cs | 86 ------------------- Wonky.Client/Helpers/Utils.cs | 16 +++- .../ICountryActivityRepository.cs | 2 +- .../IOfficeCustomerHistoryRepository.cs | 8 +- .../CountryActivityRepository.cs | 2 +- .../CountryCustomerHistoryRepository.cs | 8 +- Wonky.Client/Models/VType.cs | 9 ++ .../OfficeCustomerActivityListOverlay.razor | 2 +- ...OfficeCustomerActivityListOverlay.razor.cs | 2 +- .../OfficeCustomerInventoryListOverlay.razor | 38 -------- ...fficeCustomerInventoryListOverlay.razor.cs | 85 ------------------ ...ceCustomerInventoryReorderOverlay.razor.cs | 15 ++-- .../OfficeCustomerInvoiceListOverlay.razor.cs | 6 +- .../OfficeCustomerProductListOverlay.razor | 57 ++++++++++-- .../OfficeCustomerProductListOverlay.razor.cs | 69 +++++++++++---- .../PriceCatalogOverlay.razor | 0 .../PriceCatalogOverlay.razor.cs | 4 +- .../ProductCheckConfirmationOverlay.razor | 0 .../ProductCheckConfirmationOverlay.razor.cs | 2 +- .../ProductHistoryOverlay.razor | 0 .../ProductHistoryOverlay.razor.cs | 8 +- .../ProductPriceHistoryOverlay.razor | 0 .../ProductPriceHistoryOverlay.razor.cs | 3 +- .../Pages/AdvisorActivityCreatePage.razor | 1 + .../Pages/AdvisorActivityCreatePage.razor.cs | 1 + .../Pages/OfficeOrderCreatePage.razor | 3 +- .../Pages/OfficeOrderCreatePage.razor.cs | 1 + .../Pages/SystemUserViewEditPage.razor.cs | 2 +- Wonky.Client/Wonky.Client.csproj | 4 + Wonky.Client/wwwroot/appsettings.json | 4 +- 33 files changed, 224 insertions(+), 383 deletions(-) delete mode 100644 Wonky.Client/Components/OfficeCustomerInventoryListComponent.razor delete mode 100644 Wonky.Client/Components/OfficeCustomerInventoryListComponent.razor.cs create mode 100644 Wonky.Client/Models/VType.cs delete mode 100644 Wonky.Client/OverlayOffice/OfficeCustomerInventoryListOverlay.razor delete mode 100644 Wonky.Client/OverlayOffice/OfficeCustomerInventoryListOverlay.razor.cs rename Wonky.Client/{Shared => OverlayOrderCreate}/PriceCatalogOverlay.razor (100%) rename Wonky.Client/{Shared => OverlayOrderCreate}/PriceCatalogOverlay.razor.cs (98%) rename Wonky.Client/{Shared => OverlayOrderCreate}/ProductCheckConfirmationOverlay.razor (100%) rename Wonky.Client/{Shared => OverlayOrderCreate}/ProductCheckConfirmationOverlay.razor.cs (97%) rename Wonky.Client/{Shared => OverlayOrderCreate}/ProductHistoryOverlay.razor (100%) rename Wonky.Client/{Shared => OverlayOrderCreate}/ProductHistoryOverlay.razor.cs (91%) rename Wonky.Client/{Shared => OverlayOrderCreate}/ProductPriceHistoryOverlay.razor (100%) rename Wonky.Client/{Shared => OverlayOrderCreate}/ProductPriceHistoryOverlay.razor.cs (97%) diff --git a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor index 23afd814..bfc296c5 100644 --- a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor +++ b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor @@ -58,10 +58,10 @@
- +
- + @* Bestilling *@
@@ -69,13 +69,13 @@ } + + + } else {
Ingen data
} - - - diff --git a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs index 296cddc4..a3df3331 100644 --- a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs +++ b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs @@ -13,68 +13,91 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // +using System.Reflection.Metadata.Ecma335; using Microsoft.AspNetCore.Components; +using Microsoft.VisualBasic.CompilerServices; using Wonky.Client.HttpInterfaces; using Wonky.Client.OverlayOffice; using Wonky.Entity.DTO; using Wonky.Entity.Views; +using Wonky.Client.Helpers; +using Wonky.Client.Models; +using Wonky.Client.Shared; +using Utils = Wonky.Client.Helpers.Utils; + #pragma warning disable CS8618 namespace Wonky.Client.Components { public partial class OfficeCountryCustomerListComponent { - [Parameter] public List CompanyList { get; set; } = new(); + // ****************************************************** + // parameters [Parameter] public string CountryCode { get; set; } = ""; - + [Parameter] public List CompanyList { get; set; } = new(); + // [Parameter] public EventCallback OnOrderItem { get; set; } + [CascadingParameter] public DraftStateProvider DraftProvider { get; set; } + + // ****************************************************** + // injects [Inject] public ICountryCustomerHistoryRepository HistoryRepo { get; set; } [Inject] public ICountryActivityRepository ActivityRepo { get; set; } - + + // ****************************************************** + // overlays private OfficeCustomerInvoiceListOverlay InvoiceListOverlay { get; set; } = new(); private OfficeCustomerActivityListOverlay ActivityListOverlay { get; set; } = new(); private OfficeCustomerProductListOverlay ProductListOverlay { get; set; } = new(); - - private string CompanyName { get; set; } = ""; - private string CompanyId { get; set; } = ""; - private string LastSync { get; set; } = ""; - - private InvoiceListView InvoiceViewList { get; set; } = new(); + + // ****************************************************** + // variables + private InvoiceListView InvoiceList { get; set; } = new(); private List ActivityList { get; set; } = new(); private List ProductList { get; set; } = new(); private CompanyDto SelectedCompany { get; set; } = new(); - private void OnInventoryCallback() - { - } - + // ****************************************************** + // functions private async Task ShowInvoiceList(string companyId) { + // check for console manipulation + if (!Utils.Validate(VType.Id, companyId)) return; + SelectedCompany = CompanyList.First(x => x.CompanyId == companyId); // call erp to crm sync before requesting invoices - // get company last sync from company list - SelectedCompany = CompanyList.Find(x => x.CompanyId == companyId); - var newSyncDate = await HistoryRepo.InvoiceErpToCrmRpc(CountryCode, companyId, SelectedCompany.HistorySync); + var newSyncDate = await HistoryRepo.RequestErpToCrmSync(CountryCode, companyId, SelectedCompany.HistorySync); await Task.Delay(500); - InvoiceViewList = await HistoryRepo.FetchInvoiceList(CountryCode, companyId); - SelectedCompany.HistorySync = newSyncDate; + InvoiceList = await HistoryRepo.RequestInvoiceList(CountryCode, companyId); + if(!string.IsNullOrWhiteSpace(newSyncDate)) SelectedCompany.HistorySync = newSyncDate; InvoiceListOverlay.Show(); } private async Task ShowActivityList(string companyId) { - // call erp to crm sync before requesting invoices - // get company last sync from company list - SelectedCompany = CompanyList.Find(x => x.CompanyId == companyId); - ActivityList = await ActivityRepo.GetCustomerActivities(companyId); + // check for console manipulation + if (!Utils.Validate(VType.Id, companyId)) return; + SelectedCompany = CompanyList.First(x => x.CompanyId == companyId); + ActivityList = await ActivityRepo.RequestActitivityList(companyId); ActivityListOverlay.Show(); } - private async Task ShowProductList(string companyId) + private async Task ShowInventory(string companyId) { - // call erp to crm sync before requesting invoices - // get company last sync from company list - SelectedCompany = CompanyList.Find(x => x.CompanyId == companyId); - ProductList = await HistoryRepo.FetchInventory(SelectedCompany.CountryCode, SelectedCompany.CompanyId); + // check for console manipulation + if (!Utils.Validate(VType.Id, companyId)) return; + SelectedCompany = CompanyList.First(x => x.CompanyId == companyId); + // call erp to crm sync before requesting products + var newSyncDate = await HistoryRepo.RequestErpToCrmSync(CountryCode, companyId, SelectedCompany.HistorySync); + await Task.Delay(500); + if(!string.IsNullOrWhiteSpace(newSyncDate)) SelectedCompany.HistorySync = newSyncDate; + ProductList = await HistoryRepo.RequestInventory(SelectedCompany.CountryCode, SelectedCompany.CompanyId); ProductListOverlay.Show(); } + + private async Task ShowOrder(string companyId) + { + // check for console manipulation + if (!Utils.Validate(VType.Id, companyId)) return; + SelectedCompany = CompanyList.First(x => x.CompanyId == companyId); + } } } \ No newline at end of file diff --git a/Wonky.Client/Components/OfficeCustomerInventoryListComponent.razor b/Wonky.Client/Components/OfficeCustomerInventoryListComponent.razor deleted file mode 100644 index 48babec6..00000000 --- a/Wonky.Client/Components/OfficeCustomerInventoryListComponent.razor +++ /dev/null @@ -1,82 +0,0 @@ - -@* -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ - -@using Wonky.Client.Models -@using System.ComponentModel.Design -
- - @if (Inventory.Any()) - { -
-
-
-
Navn
-
Varenr
-
Antal
-
-
-
-
- @foreach (var product in Inventory) - { -
-
-
-
- @product.Description - @if (product.Discontinued) - { - Udgået - Produktet er udgået - } -
-
-
- @product.Sku -
-
- @product.Quantity -
- -
- - @if (product.Check) - { - - } - else - { - - } -
-
-
- } -
- } - else - { -
Ingen data
- } -
\ No newline at end of file diff --git a/Wonky.Client/Components/OfficeCustomerInventoryListComponent.razor.cs b/Wonky.Client/Components/OfficeCustomerInventoryListComponent.razor.cs deleted file mode 100644 index e45c915b..00000000 --- a/Wonky.Client/Components/OfficeCustomerInventoryListComponent.razor.cs +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using Blazored.LocalStorage; -using Microsoft.AspNetCore.Components; -using Wonky.Client.Models; -using Wonky.Entity.Views; -#pragma warning disable CS8618 - -namespace Wonky.Client.Components; - -public partial class OfficeCustomerInventoryListComponent -{ - [Inject] private ILocalStorageService Storage { get; set; } - // Parameters - [Parameter] public List Inventory { get; set; } = new(); - [Parameter] public string CompanyId { get; set; } = ""; - [Parameter] public EventCallback OnReorderSelected { get; set; } - - // private variables - private bool Descending { get; set; } - - private void SortProducts(PSort column) - { - Descending = !Descending; - switch (column) - { - case PSort.Desc: - if (Descending) - { - Inventory = Inventory.OrderByDescending(x => x.Description).ToList(); - break; - } - Inventory = Inventory.OrderBy(x => x.Description).ToList(); - break; - case PSort.Sku: - if (Descending) - { - Inventory = Inventory.OrderByDescending(x => x.Sku).ToList(); - break; - } - Inventory = Inventory.OrderBy(x => x.Sku).ToList(); - break; - case PSort.Qty: - if (Descending) - { - Inventory = Inventory.OrderByDescending(x => x.Quantity).ToList(); - break; - } - Inventory = Inventory.OrderBy(x => x.Quantity).ToList(); - break; - case PSort.None: - break; - case PSort.Abbr: - break; - default: - Inventory = Inventory.OrderByDescending(x => x.Quantity).ToList(); - break; - } - } - - private async Task CallShowReorderModal(string sku) - { - await ProductCheck(sku); - await OnReorderSelected.InvokeAsync(sku); - } - - private async Task ProductCheck(string sku) - { - var x = Inventory.First(x => x.Sku == sku); - x.Check = !x.Check; - await Storage.SetItemAsync($"{CompanyId}-products", Inventory); - } -} \ No newline at end of file diff --git a/Wonky.Client/Helpers/Utils.cs b/Wonky.Client/Helpers/Utils.cs index c1897f50..3039f792 100644 --- a/Wonky.Client/Helpers/Utils.cs +++ b/Wonky.Client/Helpers/Utils.cs @@ -14,6 +14,7 @@ // using System.Net.Mail; +using Wonky.Client.Models; namespace Wonky.Client.Helpers; @@ -22,12 +23,25 @@ namespace Wonky.Client.Helpers; /// public static class Utils { + public static bool Validate(VType vType, string toValidate) + { + return vType switch + { + VType.ISODate => toValidate.Length == 10 && DateTime.TryParse(toValidate, out _), + VType.Id => Squid.TryDecode(toValidate, out _), + VType.Passwd => IsValidPasswd(toValidate), + VType.Email => IsValidEmail(toValidate), + _ => false + }; + } + /// /// validate password to contain a-z and A-Z and 0-9 /// /// + /// optional (default 10) /// - public static bool ValidatePasswd(string toValidate, int length) + public static bool IsValidPasswd(string toValidate, int length = 10) { if (toValidate.Length < length) return false; diff --git a/Wonky.Client/HttpInterfaces/ICountryActivityRepository.cs b/Wonky.Client/HttpInterfaces/ICountryActivityRepository.cs index 4880dbd9..3361b764 100644 --- a/Wonky.Client/HttpInterfaces/ICountryActivityRepository.cs +++ b/Wonky.Client/HttpInterfaces/ICountryActivityRepository.cs @@ -36,5 +36,5 @@ public interface ICountryActivityRepository /// /// /// - Task> GetCustomerActivities(string customerId); + Task> RequestActitivityList(string customerId); } \ No newline at end of file diff --git a/Wonky.Client/HttpInterfaces/IOfficeCustomerHistoryRepository.cs b/Wonky.Client/HttpInterfaces/IOfficeCustomerHistoryRepository.cs index c47344bd..17db42c5 100644 --- a/Wonky.Client/HttpInterfaces/IOfficeCustomerHistoryRepository.cs +++ b/Wonky.Client/HttpInterfaces/IOfficeCustomerHistoryRepository.cs @@ -28,7 +28,7 @@ public interface ICountryCustomerHistoryRepository /// /// /// - Task FetchInvoiceList(string countryCode, string companyId); + Task RequestInvoiceList(string countryCode, string companyId); /// /// Fetch given invoice for given customer @@ -43,7 +43,7 @@ public interface ICountryCustomerHistoryRepository /// /// /// - Task> FetchInventory(string countryCode, string companyId); + Task> RequestInventory(string countryCode, string companyId); /// /// Fetch History for given customer @@ -58,7 +58,7 @@ public interface ICountryCustomerHistoryRepository /// /// /// - Task> FetchHistory(string countryCode, string companyId, string sku); + Task> FetchHistorySku(string countryCode, string companyId, string sku); /// /// RPC call to initiate remote server sync for given customer @@ -66,5 +66,5 @@ public interface ICountryCustomerHistoryRepository /// /// /// - Task InvoiceErpToCrmRpc(string countryCode, string companyId, string syncDate); + Task RequestErpToCrmSync(string countryCode, string companyId, string syncDate); } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/CountryActivityRepository.cs b/Wonky.Client/HttpRepository/CountryActivityRepository.cs index 12a27a3a..1442f3fd 100644 --- a/Wonky.Client/HttpRepository/CountryActivityRepository.cs +++ b/Wonky.Client/HttpRepository/CountryActivityRepository.cs @@ -67,7 +67,7 @@ public class CountryActivityRepository : ICountryActivityRepository /// /// /// - public async Task> GetCustomerActivities(string customerId) + public async Task> RequestActitivityList(string customerId) { var response = await _client.GetAsync($"{_api.CrmActivities}/company/{customerId}"); var content = await response.Content.ReadAsStringAsync(); diff --git a/Wonky.Client/HttpRepository/CountryCustomerHistoryRepository.cs b/Wonky.Client/HttpRepository/CountryCustomerHistoryRepository.cs index 141f9724..d69683c8 100644 --- a/Wonky.Client/HttpRepository/CountryCustomerHistoryRepository.cs +++ b/Wonky.Client/HttpRepository/CountryCustomerHistoryRepository.cs @@ -52,7 +52,7 @@ public class CountryCustomerHistoryRepository : ICountryCustomerHistoryRepositor /// /// /// - public async Task FetchInvoiceList(string countryCode, string companyId) + public async Task RequestInvoiceList(string countryCode, string companyId) { var response = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/invoices"); @@ -89,7 +89,7 @@ public class CountryCustomerHistoryRepository : ICountryCustomerHistoryRepositor /// /// /// - public async Task> FetchInventory(string countryCode, string companyId) + public async Task> RequestInventory(string countryCode, string companyId) { var response = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/history/inventory"); if (!response.IsSuccessStatusCode) @@ -125,7 +125,7 @@ public class CountryCustomerHistoryRepository : ICountryCustomerHistoryRepositor /// /// /// - public async Task> FetchHistory(string countryCode, string companyId, string sku) + public async Task> FetchHistorySku(string countryCode, string companyId, string sku) { var response = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/history/products/{sku}"); if (!response.IsSuccessStatusCode) @@ -143,7 +143,7 @@ public class CountryCustomerHistoryRepository : ICountryCustomerHistoryRepositor /// /// /// - public async Task InvoiceErpToCrmRpc(string countryCode, string companyId, string syncDate) + public async Task RequestErpToCrmSync(string countryCode, string companyId, string syncDate) { var x = await _client.GetAsync($"{_api.OfficeCustomers}/{countryCode}/{companyId}/{_api.SyncRpcInvoiceExt}/{syncDate}"); if (!x.IsSuccessStatusCode) diff --git a/Wonky.Client/Models/VType.cs b/Wonky.Client/Models/VType.cs new file mode 100644 index 00000000..60a38984 --- /dev/null +++ b/Wonky.Client/Models/VType.cs @@ -0,0 +1,9 @@ +namespace Wonky.Client.Models; + +public enum VType +{ + Id, + ISODate, + Passwd, + Email +} \ No newline at end of file diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerActivityListOverlay.razor b/Wonky.Client/OverlayOffice/OfficeCustomerActivityListOverlay.razor index 7d48b883..37006fc8 100644 --- a/Wonky.Client/OverlayOffice/OfficeCustomerActivityListOverlay.razor +++ b/Wonky.Client/OverlayOffice/OfficeCustomerActivityListOverlay.razor @@ -25,7 +25,7 @@ diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerActivityListOverlay.razor.cs b/Wonky.Client/OverlayOffice/OfficeCustomerActivityListOverlay.razor.cs index 00cf24ec..f7de4fd8 100644 --- a/Wonky.Client/OverlayOffice/OfficeCustomerActivityListOverlay.razor.cs +++ b/Wonky.Client/OverlayOffice/OfficeCustomerActivityListOverlay.razor.cs @@ -23,7 +23,7 @@ namespace Wonky.Client.OverlayOffice; public partial class OfficeCustomerActivityListOverlay { [Parameter] public CompanyDto Company { get; set; } = new(); - [Parameter] public List Activities { get; set; } = new(); + [Parameter] public List ActivityList { get; set; } = new(); private string _modalDisplay = ""; private bool _showBackdrop; diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerInventoryListOverlay.razor b/Wonky.Client/OverlayOffice/OfficeCustomerInventoryListOverlay.razor deleted file mode 100644 index b4e116d7..00000000 --- a/Wonky.Client/OverlayOffice/OfficeCustomerInventoryListOverlay.razor +++ /dev/null @@ -1,38 +0,0 @@ -@* -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// -*@ -@using Wonky.Client.Components - - -@if (_showBackdrop) -{ - -} -@* reorder overlay *@ - \ No newline at end of file diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerInventoryListOverlay.razor.cs b/Wonky.Client/OverlayOffice/OfficeCustomerInventoryListOverlay.razor.cs deleted file mode 100644 index e74bd5af..00000000 --- a/Wonky.Client/OverlayOffice/OfficeCustomerInventoryListOverlay.razor.cs +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (C) 2022 FCS Frede's Computer Services. -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] -// - -using Microsoft.AspNetCore.Components; -using Wonky.Client.HttpInterceptors; -using Wonky.Client.HttpInterfaces; -using Wonky.Client.Models; -using Wonky.Entity.DTO; -using Wonky.Entity.Views; -#pragma warning disable CS8618 - -namespace Wonky.Client.OverlayOffice; - -public partial class OfficeCustomerInventoryListOverlay : IDisposable -{ - [Inject] private HttpInterceptorService Interceptor { get; set; } - [Inject] private ICountryCatalogRepository CatalogRepo { get; set; } - [Inject] private ILogger Logger { get; set; } - - - [Parameter] public string CompanyName { get; set; } = ""; - [Parameter] public string CompanyId { get; set; } = ""; - [Parameter] public string CountryCode { get; set; } = ""; - [Parameter] public List Inventory { get; set; } = new(); - [Parameter] public EventCallback OnInventorySelected { get; set; } - - - private string _modalDisplay = ""; - private bool _showBackdrop; - private CompanyDto _company { get; set; } = new(); - private List _inventory { get; set; } = new(); - private DraftItem DraftItem { get; set; } = new(); - private SalesItemView SalesItem { get; set; } = new(); - private OfficeCustomerInventoryReorderOverlay ReorderOverlay { get; set; } = new(); - - protected override void OnInitialized() - { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); - StateHasChanged(); - } - - private async Task OnReorderCallback(string sku) - { - SalesItem = await CatalogRepo.GetSalesItemSku(CountryCode.ToLower(), sku); - ReorderOverlay.Show(); - } - - private async Task OnSelectedItem(DraftItem draftItem) - { - await OnInventorySelected.InvokeAsync(draftItem); - Hide(); - } - - public void Show() - { - _modalDisplay = "block;"; - _showBackdrop = true; - StateHasChanged(); - } - - private void Hide() - { - _modalDisplay = "none;"; - _showBackdrop = false; - StateHasChanged(); - } - - public void Dispose() - { - Interceptor.DisposeEvent(); - } -} \ No newline at end of file diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerInventoryReorderOverlay.razor.cs b/Wonky.Client/OverlayOffice/OfficeCustomerInventoryReorderOverlay.razor.cs index 5f79f146..8f943d21 100644 --- a/Wonky.Client/OverlayOffice/OfficeCustomerInventoryReorderOverlay.razor.cs +++ b/Wonky.Client/OverlayOffice/OfficeCustomerInventoryReorderOverlay.razor.cs @@ -18,6 +18,7 @@ using System.Globalization; using Microsoft.AspNetCore.Components; using Wonky.Client.HttpInterfaces; using Wonky.Client.Models; +using Wonky.Entity.DTO; using Wonky.Entity.Views; #pragma warning disable CS8618 @@ -25,11 +26,11 @@ namespace Wonky.Client.OverlayOffice; public partial class OfficeCustomerInventoryReorderOverlay { - [Parameter] public string CompanyId { get; set; } = ""; + [Parameter] public CompanyDto Company { get; set; } [Parameter] public SalesItemView SalesItem { get; set; } = new(); [Inject] public ICountryCustomerHistoryRepository HistoryRepo { get; set; } - [Parameter] public EventCallback OnSelected { get; set; } - private List? History { get; set; } = new(); + [Parameter] public EventCallback OrderItemCallback { get; set; } + private List History { get; set; } = new(); private DraftItem SelectedItem { get; set; } = new(); private string ProductName { get; set; } = ""; private string _modalDisplay = ""; @@ -41,9 +42,9 @@ public partial class OfficeCustomerInventoryReorderOverlay if (string.IsNullOrWhiteSpace(SalesItem.Sku)) return; - History = await HistoryRepo.FetchHistory(CompanyId, SalesItem.Sku); - if (!History.Any()) - await Task.Delay(1000); + History = await HistoryRepo.FetchHistorySku(Company.CountryCode, Company.CompanyId, SalesItem.Sku); + // if (!History.Any()) + // await Task.Delay(500); SelectedItem.Item = SalesItem; SelectedItem.Discount = 0; SelectedItem.Quantity = 1; @@ -54,7 +55,7 @@ public partial class OfficeCustomerInventoryReorderOverlay private async Task SendToOrder(DraftItem item) { SelectedItem = new DraftItem(); - await OnSelected.InvokeAsync(item); + await OrderItemCallback.InvokeAsync(item); Hide(); } diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerInvoiceListOverlay.razor.cs b/Wonky.Client/OverlayOffice/OfficeCustomerInvoiceListOverlay.razor.cs index 3fc00c23..30040d02 100644 --- a/Wonky.Client/OverlayOffice/OfficeCustomerInvoiceListOverlay.razor.cs +++ b/Wonky.Client/OverlayOffice/OfficeCustomerInvoiceListOverlay.razor.cs @@ -24,7 +24,7 @@ namespace Wonky.Client.OverlayOffice; public partial class OfficeCustomerInvoiceListOverlay { - [Parameter] public InvoiceListView CustomerInvoices { get; set; } = new(); + [Parameter] public InvoiceListView InvoiceList { get; set; } = new(); [Parameter] public CompanyDto Company { get; set; } = new(); // dependency injection [Inject] private ILogger Logger { get; set; } @@ -39,8 +39,8 @@ public partial class OfficeCustomerInvoiceListOverlay // extract company from customer invoices Logger.LogDebug("CustomerInvoiceListOverlay => company => {}", JsonSerializer.Serialize(Company)); // if there is invoices -> order by document date - if (CustomerInvoices.Invoices.Any()) - Invoices = CustomerInvoices.Invoices.OrderByDescending(x => x.DocumentDate).ToList(); + if (InvoiceList.Invoices.Any()) + Invoices = InvoiceList.Invoices.OrderByDescending(x => x.DocumentDate).ToList(); Logger.LogDebug("invoices => {}", JsonSerializer.Serialize(Invoices)); } diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerProductListOverlay.razor b/Wonky.Client/OverlayOffice/OfficeCustomerProductListOverlay.razor index 5515667d..ab235610 100644 --- a/Wonky.Client/OverlayOffice/OfficeCustomerProductListOverlay.razor +++ b/Wonky.Client/OverlayOffice/OfficeCustomerProductListOverlay.razor @@ -14,7 +14,7 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // *@ -@using Wonky.Client.Components +@using Wonky.Client.Models @@ -34,5 +77,9 @@ { } -@* reorder overlay *@ - \ No newline at end of file +@* +reorder overlay +invoked by list component OnReorderSku=OnReorderCallback +*@ + + \ No newline at end of file diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerProductListOverlay.razor.cs b/Wonky.Client/OverlayOffice/OfficeCustomerProductListOverlay.razor.cs index ab97653a..d96a3c37 100644 --- a/Wonky.Client/OverlayOffice/OfficeCustomerProductListOverlay.razor.cs +++ b/Wonky.Client/OverlayOffice/OfficeCustomerProductListOverlay.razor.cs @@ -1,4 +1,3 @@ - // Copyright (C) 2022 FCS Frede's Computer Services. // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU Affero General Public License as @@ -20,6 +19,7 @@ using Wonky.Client.HttpInterfaces; using Wonky.Client.Models; using Wonky.Entity.DTO; using Wonky.Entity.Views; + #pragma warning disable CS8618 namespace Wonky.Client.OverlayOffice; @@ -29,52 +29,85 @@ public partial class OfficeCustomerProductListOverlay : IDisposable [Inject] private HttpInterceptorService Interceptor { get; set; } [Inject] private ICountryCatalogRepository CatalogRepo { get; set; } [Inject] private ILogger Logger { get; set; } - - [Parameter] public CompanyDto Company { get; set; } - [Parameter] public List ProductList { get; set; } = new(); - [Parameter] public EventCallback OnInventorySelected { get; set; } - + private string _modalDisplay = ""; private bool _showBackdrop; - private CompanyDto _company { get; set; } = new(); - private List _inventory { get; set; } = new(); private DraftItem DraftItem { get; set; } = new(); private SalesItemView SalesItem { get; set; } = new(); private OfficeCustomerInventoryReorderOverlay ReorderOverlay { get; set; } = new(); + private bool Descending { get; set; } + [Parameter] public CompanyDto Company { get; set; } = new(); + [Parameter] public List ProductList { get; set; } = new(); + protected override void OnInitialized() { Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); StateHasChanged(); } - - private async Task OnReorderCallback(string sku) + + private async Task ShowSkuReorder(string sku) { SalesItem = await CatalogRepo.GetSalesItemSku(Company.CountryCode.ToLower(), sku); ReorderOverlay.Show(); - } - - private async Task OnSelectedItem(DraftItem draftItem) - { - await OnInventorySelected.InvokeAsync(draftItem); - Hide(); } + private void SortProducts(PSort column) + { + Descending = !Descending; + switch (column) + { + case PSort.Desc: + if (Descending) + { + ProductList = ProductList.OrderByDescending(x => x.Description).ToList(); + break; + } + + ProductList = ProductList.OrderBy(x => x.Description).ToList(); + break; + case PSort.Sku: + if (Descending) + { + ProductList = ProductList.OrderByDescending(x => x.Sku).ToList(); + break; + } + + ProductList = ProductList.OrderBy(x => x.Sku).ToList(); + break; + case PSort.Qty: + if (Descending) + { + ProductList = ProductList.OrderByDescending(x => x.Quantity).ToList(); + break; + } + + ProductList = ProductList.OrderBy(x => x.Quantity).ToList(); + break; + case PSort.None: + break; + case PSort.Abbr: + break; + default: + ProductList = ProductList.OrderByDescending(x => x.Quantity).ToList(); + break; + } + } public void Show() { _modalDisplay = "block;"; _showBackdrop = true; StateHasChanged(); } - + private void Hide() { _modalDisplay = "none;"; _showBackdrop = false; StateHasChanged(); } - + public void Dispose() { Interceptor.DisposeEvent(); diff --git a/Wonky.Client/Shared/PriceCatalogOverlay.razor b/Wonky.Client/OverlayOrderCreate/PriceCatalogOverlay.razor similarity index 100% rename from Wonky.Client/Shared/PriceCatalogOverlay.razor rename to Wonky.Client/OverlayOrderCreate/PriceCatalogOverlay.razor diff --git a/Wonky.Client/Shared/PriceCatalogOverlay.razor.cs b/Wonky.Client/OverlayOrderCreate/PriceCatalogOverlay.razor.cs similarity index 98% rename from Wonky.Client/Shared/PriceCatalogOverlay.razor.cs rename to Wonky.Client/OverlayOrderCreate/PriceCatalogOverlay.razor.cs index 149131d7..7d1ab76a 100644 --- a/Wonky.Client/Shared/PriceCatalogOverlay.razor.cs +++ b/Wonky.Client/OverlayOrderCreate/PriceCatalogOverlay.razor.cs @@ -16,14 +16,14 @@ using Microsoft.AspNetCore.Components; using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpInterfaces; -using Wonky.Client.HttpRepository; using Wonky.Client.Models; using Wonky.Client.Services; using Wonky.Entity.Requests; using Wonky.Entity.Views; + #pragma warning disable CS8618 -namespace Wonky.Client.Shared; +namespace Wonky.Client.OverlayOrderCreate; public partial class PriceCatalogOverlay : IDisposable { diff --git a/Wonky.Client/Shared/ProductCheckConfirmationOverlay.razor b/Wonky.Client/OverlayOrderCreate/ProductCheckConfirmationOverlay.razor similarity index 100% rename from Wonky.Client/Shared/ProductCheckConfirmationOverlay.razor rename to Wonky.Client/OverlayOrderCreate/ProductCheckConfirmationOverlay.razor diff --git a/Wonky.Client/Shared/ProductCheckConfirmationOverlay.razor.cs b/Wonky.Client/OverlayOrderCreate/ProductCheckConfirmationOverlay.razor.cs similarity index 97% rename from Wonky.Client/Shared/ProductCheckConfirmationOverlay.razor.cs rename to Wonky.Client/OverlayOrderCreate/ProductCheckConfirmationOverlay.razor.cs index 334d41d1..be6e755b 100644 --- a/Wonky.Client/Shared/ProductCheckConfirmationOverlay.razor.cs +++ b/Wonky.Client/OverlayOrderCreate/ProductCheckConfirmationOverlay.razor.cs @@ -17,7 +17,7 @@ using Microsoft.AspNetCore.Components; using Wonky.Entity.Views; -namespace Wonky.Client.Shared; +namespace Wonky.Client.OverlayOrderCreate; public partial class ProductCheckConfirmationOverlay { diff --git a/Wonky.Client/Shared/ProductHistoryOverlay.razor b/Wonky.Client/OverlayOrderCreate/ProductHistoryOverlay.razor similarity index 100% rename from Wonky.Client/Shared/ProductHistoryOverlay.razor rename to Wonky.Client/OverlayOrderCreate/ProductHistoryOverlay.razor diff --git a/Wonky.Client/Shared/ProductHistoryOverlay.razor.cs b/Wonky.Client/OverlayOrderCreate/ProductHistoryOverlay.razor.cs similarity index 91% rename from Wonky.Client/Shared/ProductHistoryOverlay.razor.cs rename to Wonky.Client/OverlayOrderCreate/ProductHistoryOverlay.razor.cs index d2e87580..b3b52725 100644 --- a/Wonky.Client/Shared/ProductHistoryOverlay.razor.cs +++ b/Wonky.Client/OverlayOrderCreate/ProductHistoryOverlay.razor.cs @@ -15,16 +15,12 @@ // using Microsoft.AspNetCore.Components; -using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpInterfaces; -using Wonky.Client.HttpRepository; -using Wonky.Client.Models; -using Wonky.Client.Services; -using Wonky.Entity.Requests; using Wonky.Entity.Views; + #pragma warning disable CS8618 -namespace Wonky.Client.Shared; +namespace Wonky.Client.OverlayOrderCreate; public partial class ProductHistoryOverlay { diff --git a/Wonky.Client/Shared/ProductPriceHistoryOverlay.razor b/Wonky.Client/OverlayOrderCreate/ProductPriceHistoryOverlay.razor similarity index 100% rename from Wonky.Client/Shared/ProductPriceHistoryOverlay.razor rename to Wonky.Client/OverlayOrderCreate/ProductPriceHistoryOverlay.razor diff --git a/Wonky.Client/Shared/ProductPriceHistoryOverlay.razor.cs b/Wonky.Client/OverlayOrderCreate/ProductPriceHistoryOverlay.razor.cs similarity index 97% rename from Wonky.Client/Shared/ProductPriceHistoryOverlay.razor.cs rename to Wonky.Client/OverlayOrderCreate/ProductPriceHistoryOverlay.razor.cs index d5ed584b..1da80fc4 100644 --- a/Wonky.Client/Shared/ProductPriceHistoryOverlay.razor.cs +++ b/Wonky.Client/OverlayOrderCreate/ProductPriceHistoryOverlay.razor.cs @@ -17,9 +17,10 @@ using Microsoft.AspNetCore.Components; using Wonky.Client.HttpInterfaces; using Wonky.Entity.Views; + #pragma warning disable CS8618 -namespace Wonky.Client.Shared; +namespace Wonky.Client.OverlayOrderCreate; public partial class ProductPriceHistoryOverlay { diff --git a/Wonky.Client/Pages/AdvisorActivityCreatePage.razor b/Wonky.Client/Pages/AdvisorActivityCreatePage.razor index 9c6003e4..8d2527ed 100644 --- a/Wonky.Client/Pages/AdvisorActivityCreatePage.razor +++ b/Wonky.Client/Pages/AdvisorActivityCreatePage.razor @@ -18,6 +18,7 @@ @using Microsoft.AspNetCore.Authorization @using Wonky.Client.Components @using Wonky.Client.OverlayCustomer +@using Wonky.Client.OverlayOrderCreate @attribute [Authorize(Roles = "Advisor")] @page "/advisor/customers/{CompanyId}/activities/new" diff --git a/Wonky.Client/Pages/AdvisorActivityCreatePage.razor.cs b/Wonky.Client/Pages/AdvisorActivityCreatePage.razor.cs index a42565a0..90119069 100644 --- a/Wonky.Client/Pages/AdvisorActivityCreatePage.razor.cs +++ b/Wonky.Client/Pages/AdvisorActivityCreatePage.razor.cs @@ -25,6 +25,7 @@ using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpInterfaces; using Wonky.Client.Models; using Wonky.Client.OverlayCustomer; +using Wonky.Client.OverlayOrderCreate; using Wonky.Client.Services; using Wonky.Client.Shared; using Wonky.Entity.DTO; diff --git a/Wonky.Client/Pages/OfficeOrderCreatePage.razor b/Wonky.Client/Pages/OfficeOrderCreatePage.razor index f33f3ca6..cf41ecc3 100644 --- a/Wonky.Client/Pages/OfficeOrderCreatePage.razor +++ b/Wonky.Client/Pages/OfficeOrderCreatePage.razor @@ -16,8 +16,9 @@ *@ @using Wonky.Client.Components +@using Wonky.Client.OverlayOrderCreate @using Microsoft.AspNetCore.Authorization -@attribute [Authorize(Roles = "Admin,Office,Warehouse")] +@attribute [Authorize(Roles = "Admin,Office,Supervisor,Warehouse")] @page "/office/customers/{CountryCode}/{CompanyId}/order" Telefon Ordre - @Customer.Name - @Customer.Account diff --git a/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs b/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs index 3ee0add7..3acc69c1 100644 --- a/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs +++ b/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs @@ -20,6 +20,7 @@ using Microsoft.AspNetCore.Components.Forms; using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpInterfaces; using Wonky.Client.Models; +using Wonky.Client.OverlayOrderCreate; using Wonky.Client.Shared; using Wonky.Entity.DTO; using Wonky.Entity.Views; diff --git a/Wonky.Client/Pages/SystemUserViewEditPage.razor.cs b/Wonky.Client/Pages/SystemUserViewEditPage.razor.cs index 8b6e8bf4..bb9a28da 100644 --- a/Wonky.Client/Pages/SystemUserViewEditPage.razor.cs +++ b/Wonky.Client/Pages/SystemUserViewEditPage.razor.cs @@ -83,7 +83,7 @@ public partial class SystemUserViewEditPage : IDisposable private void PwValidationChanged(object sender, ValidationStateChangedEventArgs e) { PwInvalid = true; - if (!Utils.ValidatePasswd(Passwords.NewPassword, MinPwLength)) + if (!Utils.IsValidPasswd(Passwords.NewPassword, MinPwLength)) return; PasswdContext.OnFieldChanged -= PwHandleFieldChanged; diff --git a/Wonky.Client/Wonky.Client.csproj b/Wonky.Client/Wonky.Client.csproj index 88ccab29..2c8bdc79 100644 --- a/Wonky.Client/Wonky.Client.csproj +++ b/Wonky.Client/Wonky.Client.csproj @@ -3795,4 +3795,8 @@ + + + + diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 4a6ba8d8..9a35fa1d 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,7 +1,7 @@ { "appInfo": { "name": "Wonky Online", - "version": "0.116.0", + "version": "0.116.1", "rc": true, "sandBox": false, "image": "grumpy-coder.png" @@ -19,7 +19,7 @@ } }, "apiConfig": { - "baseUrl": "https://dev.innotec.dk", + "baseUrl": "https://zeta.innotec.dk", "catalog": "api/v2/catalog/country", "crmCustomers": "api/v2/crm/companies", "crmInventoryExt": "history/inventory",