From 1afbf20b15484a949d3d796389ab71864cf6f4f1 Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Thu, 1 Jun 2023 17:28:51 +0200 Subject: [PATCH] CompanyInventoryList sorting and tagging --- .../CustomerInventoryListComponent.razor | 61 ++++++-- .../CustomerInventoryListComponent.razor.cs | 86 ++++++----- .../CustomerProductCheckListComponent.razor | 38 ++++- ...CustomerProductCheckListComponent.razor.cs | 75 +++++----- .../InfoColorPackageComponent.razor | 60 -------- .../InfoProcessStateComponent.razor | 2 + .../OfficeCountryCustomerListComponent.razor | 2 +- ...fficeCountryCustomerListComponent.razor.cs | 4 +- ...fficeCustomerInventoryListComponent.razor} | 31 +++- ...ceCustomerInventoryListComponent.razor.cs} | 78 +++++----- ...nent.razor => SearchPhraseComponent.razor} | 23 +-- ...zor.css => SearchPhraseComponent.razor.cs} | 31 +++- .../Components/WarehouseListComponent.razor | 102 -------------- .../WarehouseListComponent.razor.cs | 56 -------- Wonky.Client/Enums/ProductSort.cs | 6 +- Wonky.Client/Helpers/Utils.cs | 79 +++++++---- .../HttpInterceptorService.cs | 3 +- .../CrmCustomerHistoryRepository.cs | 97 ++++++------- .../ICrmCustomerHistoryRepository.cs | 12 +- .../Local.Services/AuthenticationService.cs | 13 +- .../Local.Services/IAuthenticationService.cs | 1 + .../Local.Services/RefreshTokenService.cs | 9 +- .../CustomerInventoryReorderOverlay.razor.cs | 2 +- .../CustomerInvoiceViewOverlay.razor.cs | 9 +- .../ProductSelectionOverlay.razor.cs | 28 ++-- ...OfficeCustomerActivityListOverlay.razor.cs | 2 + ...OfficeCustomerActivityViewOverlay.razor.cs | 3 + ... OfficeCustomerInventoryListOverlay.razor} | 33 ++++- ...ficeCustomerInventoryListOverlay.razor.cs} | 100 +++++++------ ...ceCustomerInventoryReorderOverlay.razor.cs | 5 + .../OfficeCustomerInvoiceViewOverlay.razor.cs | 4 + ...ceCustomerOrderInventoryListOverlay.razor} | 4 +- ...ustomerOrderInventoryListOverlay.razor.cs} | 9 +- ...ustomerOrderInventoryReorderOverlay.razor} | 0 ...omerOrderInventoryReorderOverlay.razor.cs} | 7 +- .../CatalogPagedOverlay.razor.cs | 6 +- .../ProductCheckConfirmationOverlay.razor.cs | 7 +- .../ProductHistoryOverlay.razor.cs | 18 +-- .../ProductPriceHistoryOverlay.razor.cs | 12 +- .../AdvisorCustomerInventoryListPage.razor | 7 +- .../AdvisorCustomerInventoryListPage.razor.cs | 5 +- .../Pages/AdvisorCustomerViewEditPage.razor | 7 +- Wonky.Client/Pages/InfoPage.razor | 10 +- .../Pages/OfficeOrderCreatePage.razor | 2 +- .../Pages/OfficeOrderCreatePage.razor.cs | 2 +- .../Pages/SupervisorDocumentNewPage.razor.cs | 20 +++ .../SupervisorDocumentViewEditPage.razor | 2 +- .../Pages/WarehouseOrderListPage.razor | 36 ----- .../Pages/WarehouseOrderListPage.razor.cs | 133 ------------------ .../Pages/WarehouseOrderViewPage.razor | 129 ----------------- .../Pages/WarehouseOrderViewPage.razor.cs | 103 -------------- Wonky.Client/Shared/AuthStateProvider.cs | 64 ++++++--- Wonky.Client/Shared/NavMenu.razor | 2 + Wonky.Client/wwwroot/appsettings.json | 8 +- Wonky.Client/wwwroot/css/app.css | 15 +- .../Views/ProductInventoryItemView.cs | 8 +- 56 files changed, 643 insertions(+), 1028 deletions(-) delete mode 100644 Wonky.Client/Components/InfoColorPackageComponent.razor rename Wonky.Client/Components/{OfficeInventoryListComponent.razor => OfficeCustomerInventoryListComponent.razor} (52%) rename Wonky.Client/Components/{OfficeInventoryListComponent.razor.cs => OfficeCustomerInventoryListComponent.razor.cs} (56%) rename Wonky.Client/Components/{InfoWarehouseComponent.razor => SearchPhraseComponent.razor} (68%) rename Wonky.Client/Components/{InfoColorPackageComponent.razor.css => SearchPhraseComponent.razor.cs} (56%) delete mode 100644 Wonky.Client/Components/WarehouseListComponent.razor delete mode 100644 Wonky.Client/Components/WarehouseListComponent.razor.cs rename Wonky.Client/OverlayOffice/{OfficeCustomerProductListOverlay.razor => OfficeCustomerInventoryListOverlay.razor} (61%) rename Wonky.Client/OverlayOffice/{OfficeCustomerProductListOverlay.razor.cs => OfficeCustomerInventoryListOverlay.razor.cs} (60%) rename Wonky.Client/OverlayOffice/{OfficeOrderInventoryListOverlay.razor => OfficeCustomerOrderInventoryListOverlay.razor} (83%) rename Wonky.Client/OverlayOffice/{OfficeOrderInventoryListOverlay.razor.cs => OfficeCustomerOrderInventoryListOverlay.razor.cs} (85%) rename Wonky.Client/OverlayOffice/{OfficeOrderInventoryReorderOverlay.razor => OfficeCustomerOrderInventoryReorderOverlay.razor} (100%) rename Wonky.Client/OverlayOffice/{OfficeOrderInventoryReorderOverlay.razor.cs => OfficeCustomerOrderInventoryReorderOverlay.razor.cs} (91%) delete mode 100644 Wonky.Client/Pages/WarehouseOrderListPage.razor delete mode 100644 Wonky.Client/Pages/WarehouseOrderListPage.razor.cs delete mode 100644 Wonky.Client/Pages/WarehouseOrderViewPage.razor delete mode 100644 Wonky.Client/Pages/WarehouseOrderViewPage.razor.cs diff --git a/Wonky.Client/Components/CustomerInventoryListComponent.razor b/Wonky.Client/Components/CustomerInventoryListComponent.razor index 66a06c79..63b80cd6 100644 --- a/Wonky.Client/Components/CustomerInventoryListComponent.razor +++ b/Wonky.Client/Components/CustomerInventoryListComponent.razor @@ -23,37 +23,74 @@
- - - -
-
+ @* + + + *@ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
- @foreach (var product in Inventory) + @foreach (var product in FilteredList) {
+
+
+ @product.LastInvoiceDate + @if (product.AgedProduct() && !product.Discontinued) + { + + Længe siden + Længe siden + + } +
+
@product.Description @if (product.Discontinued) { - Udgået - Produktet er udgået + + Udgået + Produktet er udgået + }
-
+
@product.Sku
-
+
@product.Quantity
- +
-
+
@if (product.Check) { diff --git a/Wonky.Client/Components/CustomerInventoryListComponent.razor.cs b/Wonky.Client/Components/CustomerInventoryListComponent.razor.cs index 20b5df32..4fe14beb 100644 --- a/Wonky.Client/Components/CustomerInventoryListComponent.razor.cs +++ b/Wonky.Client/Components/CustomerInventoryListComponent.razor.cs @@ -16,6 +16,7 @@ using Blazored.LocalStorage; using Microsoft.AspNetCore.Components; using Wonky.Client.Enums; +using Wonky.Client.Helpers; using Wonky.Client.Models; using Wonky.Entity.Views; @@ -24,71 +25,68 @@ namespace Wonky.Client.Components; public partial class CustomerInventoryListComponent { + // ##############################################3333############ [Inject] public ILocalStorageService Storage { get; set; } - // Parameters + [Inject] public ILogger Logger { get; set; } + + // ##############################################3333############ [Parameter] public List Inventory { get; set; } = new(); [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public EventCallback OnReorderSelected { get; set; } + // ##############################################3333############ // private variables - private bool Descending { get; set; } - - protected override void OnParametersSet() + private bool Descending { get; set; } = true; + private string SearchTerm { get; set; } = ""; + private List FilteredList { get; set; } + private ProductSort SortColumn { get; set; } = ProductSort.LastInvoiceDate; + + protected override void OnInitialized() { - if(Inventory.Any()) - Inventory = Inventory.OrderBy(x => x.Description).ToList(); + // sort base list + Inventory = Utils.SortInventory(Inventory, SortColumn, Descending); + // initialize FilteredList + FilterItems(SearchTerm); + } + + + private void SetSortOrder() + { + Descending = !Descending; + FilteredList = Utils.SortInventory(FilteredList, SortColumn, Descending); } + private void OnSearchChanged(string searchTerm) + { + // use search input to filter list + FilterItems(searchTerm); + } + + + private void FilterItems(string filter) + { + SearchTerm = filter; + FilteredList = string.IsNullOrWhiteSpace(filter) + ? Inventory + : Inventory.Where(i => i.Description.ToLower().Contains(filter.ToLower())).ToList(); + } + + private void SortProducts(ProductSort column) { - Descending = !Descending; - switch (column) - { - case ProductSort.Desc: - if (Descending) - { - Inventory = Inventory.OrderByDescending(x => x.Description).ToList(); - break; - } - Inventory = Inventory.OrderBy(x => x.Description).ToList(); - break; - case ProductSort.Sku: - if (Descending) - { - Inventory = Inventory.OrderByDescending(x => x.Sku).ToList(); - break; - } - Inventory = Inventory.OrderBy(x => x.Sku).ToList(); - break; - case ProductSort.Qty: - if (Descending) - { - Inventory = Inventory.OrderByDescending(x => x.Quantity).ToList(); - break; - } - Inventory = Inventory.OrderBy(x => x.Quantity).ToList(); - break; - case ProductSort.None: - Inventory = Inventory.OrderBy(x => x.Description).ToList(); - break; - case ProductSort.Abbr: - break; - default: - Inventory = Inventory.OrderBy(x => x.Description).ToList(); - break; - } + FilteredList = Utils.SortInventory(FilteredList, column, Descending); } private async Task CallShowReorderModal(string sku) { - await ProductCheck(sku); + await SetProductCheckmark(sku); await OnReorderSelected.InvokeAsync(sku); } - private async Task ProductCheck(string sku) + private async Task SetProductCheckmark(string sku) { var x = Inventory.First(x => x.Sku == sku); x.Check = !x.Check; diff --git a/Wonky.Client/Components/CustomerProductCheckListComponent.razor b/Wonky.Client/Components/CustomerProductCheckListComponent.razor index 84349acb..d83ec41b 100644 --- a/Wonky.Client/Components/CustomerProductCheckListComponent.razor +++ b/Wonky.Client/Components/CustomerProductCheckListComponent.razor @@ -22,24 +22,50 @@
-
Navn
+ @* +
Navn
Varenr
-
Antal
-
-
+ *@ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
@foreach (var product in Inventory) {
+
+ @product.LastInvoiceDate +
@product.Description
-
+
@product.Sku
-
+
@product.Quantity
diff --git a/Wonky.Client/Components/CustomerProductCheckListComponent.razor.cs b/Wonky.Client/Components/CustomerProductCheckListComponent.razor.cs index 67f31bba..3b94ee3e 100644 --- a/Wonky.Client/Components/CustomerProductCheckListComponent.razor.cs +++ b/Wonky.Client/Components/CustomerProductCheckListComponent.razor.cs @@ -13,9 +13,11 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // +using System.Security.Policy; using Blazored.LocalStorage; using Microsoft.AspNetCore.Components; using Wonky.Client.Enums; +using Wonky.Client.Helpers; using Wonky.Client.Models; using Wonky.Entity.Views; #pragma warning disable CS8618 @@ -27,57 +29,48 @@ public partial class CustomerProductCheckListComponent [Parameter] public string CompanyId { get; set; } = ""; [Inject] public ILocalStorageService Storage { get; set; } // private variables - private bool Descending { get; set; } - + private bool Descending { get; set; } = true; + private string SearchTerm { get; set; } = ""; + private List FilteredList { get; set; } = new(); + protected override void OnParametersSet() { - if(Inventory.Any()) - Inventory = Inventory.OrderBy(x => x.Description).ToList(); + Inventory = Utils.SortInventory(Inventory, ProductSort.LastInvoiceDate, Descending); + FilterItems(SearchTerm); } + + private void SetSortOrder() + { + Descending = !Descending; + FilteredList = Utils.SortInventory(FilteredList, ProductSort.LastInvoiceDate, Descending); + } + + + private void OnSearchChanged(string searchTerm) + { + FilterItems(searchTerm); + } + + + private void FilterItems(string filter) + { + SearchTerm = filter; + FilteredList = string.IsNullOrWhiteSpace(filter) + ? Inventory + : Inventory.Where(i => i.Description.ToLower().Contains(filter.ToLower())).ToList(); + } + + private void SortProducts(ProductSort column) { - Descending = !Descending; - switch (column) - { - case ProductSort.Desc: - if (Descending) - { - Inventory = Inventory.OrderByDescending(x => x.Description).ToList(); - break; - } - Inventory = Inventory.OrderBy(x => x.Description).ToList(); - break; - case ProductSort.Sku: - if (Descending) - { - Inventory = Inventory.OrderByDescending(x => x.Sku).ToList(); - break; - } - Inventory = Inventory.OrderBy(x => x.Sku).ToList(); - break; - case ProductSort.Qty: - if (Descending) - { - Inventory = Inventory.OrderByDescending(x => x.Quantity).ToList(); - break; - } - Inventory = Inventory.OrderBy(x => x.Quantity).ToList(); - break; - case ProductSort.None: - break; - case ProductSort.Abbr: - break; - default: - Inventory = Inventory.OrderByDescending(x => x.Quantity).ToList(); - break; - } + FilteredList = Utils.SortInventory(Inventory, column, Descending); } - private async Task ProductCheck(string sku) + + private void 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/Components/InfoColorPackageComponent.razor b/Wonky.Client/Components/InfoColorPackageComponent.razor deleted file mode 100644 index 9c19239d..00000000 --- a/Wonky.Client/Components/InfoColorPackageComponent.razor +++ /dev/null @@ -1,60 +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 - -

Pakning / Forsendelse

- - - - - - - - - - - - - - - - - - - - - - - - - -
SymbolBetydning
-
- -
-
Ubehandlet
-
- -
-
Varer er plukket
-
- -
-
Varer er pakket
-
- -
-
Varer er afsendt
\ No newline at end of file diff --git a/Wonky.Client/Components/InfoProcessStateComponent.razor b/Wonky.Client/Components/InfoProcessStateComponent.razor index 8c64b4ef..fb9072ac 100644 --- a/Wonky.Client/Components/InfoProcessStateComponent.razor +++ b/Wonky.Client/Components/InfoProcessStateComponent.razor @@ -36,6 +36,7 @@ Udskrevet + @* Plukket @@ -48,5 +49,6 @@ Leveret + *@ diff --git a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor index e0f62991..fb8e692b 100644 --- a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor +++ b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor @@ -70,7 +70,7 @@
- + } else { diff --git a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs index a01f8562..b6e2aa57 100644 --- a/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs +++ b/Wonky.Client/Components/OfficeCountryCustomerListComponent.razor.cs @@ -48,7 +48,7 @@ public partial class OfficeCountryCustomerListComponent // overlays private OfficeCustomerInvoiceListOverlay InvoiceListOverlay { get; set; } = new(); private OfficeCustomerActivityListOverlay ActivityListOverlay { get; set; } = new(); - private OfficeCustomerProductListOverlay ProductListOverlay { get; set; } = new(); + private OfficeCustomerInventoryListOverlay InventoryListOverlay { get; set; } = new(); // ****************************************************** // variables @@ -108,7 +108,7 @@ public partial class OfficeCountryCustomerListComponent SelectedCompany.HistorySync = newSyncDate; } ProductList = await HistoryRepo.GetInventory(SelectedCompany.CountryCode, SelectedCompany.CompanyId); - ProductListOverlay.Show(); + InventoryListOverlay.Show(); } private void ShowOrder(string companyId) diff --git a/Wonky.Client/Components/OfficeInventoryListComponent.razor b/Wonky.Client/Components/OfficeCustomerInventoryListComponent.razor similarity index 52% rename from Wonky.Client/Components/OfficeInventoryListComponent.razor rename to Wonky.Client/Components/OfficeCustomerInventoryListComponent.razor index b2190ce3..bf2361f1 100644 --- a/Wonky.Client/Components/OfficeInventoryListComponent.razor +++ b/Wonky.Client/Components/OfficeCustomerInventoryListComponent.razor @@ -24,11 +24,32 @@
-
Navn
-
Varenr
-
Antal
-
-
+ @*
Navn
*@ + @*
Varenr
*@ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
@foreach (var product in Inventory) diff --git a/Wonky.Client/Components/OfficeInventoryListComponent.razor.cs b/Wonky.Client/Components/OfficeCustomerInventoryListComponent.razor.cs similarity index 56% rename from Wonky.Client/Components/OfficeInventoryListComponent.razor.cs rename to Wonky.Client/Components/OfficeCustomerInventoryListComponent.razor.cs index ec610356..ccb46de0 100644 --- a/Wonky.Client/Components/OfficeInventoryListComponent.razor.cs +++ b/Wonky.Client/Components/OfficeCustomerInventoryListComponent.razor.cs @@ -15,72 +15,70 @@ using Blazored.LocalStorage; using Microsoft.AspNetCore.Components; +using Microsoft.VisualBasic.CompilerServices; using Wonky.Client.Enums; using Wonky.Client.Models; using Wonky.Entity.Views; +using Utils = Wonky.Client.Helpers.Utils; namespace Wonky.Client.Components; #pragma warning disable CS8618 -public partial class OfficeInventoryListComponent +public partial class OfficeCustomerInventoryListComponent { // ************************************************************* // Injections [Inject] public 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 bool Descending { get; set; } = true; + private string SearchTerm { get; set; } = ""; + private List FilteredList { get; set; } = new(); + private ProductSort SortColumn { get; set; } = ProductSort.LastInvoiceDate; + + protected override void OnParametersSet() { - if(Inventory.Any()) - Inventory = Inventory.OrderBy(x => x.Description).ToList(); + Inventory = Utils.SortInventory(Inventory, SortColumn, Descending); + FilterItems(SearchTerm); } + + + private void SetSortOrder() + { + Descending = !Descending; + FilteredList = Utils.SortInventory(FilteredList, SortColumn, Descending); + } + + + private void OnSearchChanged(string searchTerm) + { + FilterItems(searchTerm); + } + + + private void FilterItems(string filter) + { + SearchTerm = filter; + FilteredList = string.IsNullOrWhiteSpace(filter) + ? Inventory + : Inventory.Where(i => i.Description.ToLower().Contains(filter.ToLower())).ToList(); + } + private void SortProducts(ProductSort column) { - Descending = !Descending; - switch (column) - { - case ProductSort.Desc: - if (Descending) - { - Inventory = Inventory.OrderByDescending(x => x.Description).ToList(); - break; - } - Inventory = Inventory.OrderBy(x => x.Description).ToList(); - break; - case ProductSort.Sku: - if (Descending) - { - Inventory = Inventory.OrderByDescending(x => x.Sku).ToList(); - break; - } - Inventory = Inventory.OrderBy(x => x.Sku).ToList(); - break; - case ProductSort.Qty: - if (Descending) - { - Inventory = Inventory.OrderByDescending(x => x.Quantity).ToList(); - break; - } - Inventory = Inventory.OrderBy(x => x.Quantity).ToList(); - break; - case ProductSort.None: - break; - case ProductSort.Abbr: - break; - default: - Inventory = Inventory.OrderByDescending(x => x.Quantity).ToList(); - break; - } + FilteredList = Utils.SortInventory(FilteredList, column, Descending); } + private async Task CallShowReorderModal(string sku) { // await ProductCheck(sku); diff --git a/Wonky.Client/Components/InfoWarehouseComponent.razor b/Wonky.Client/Components/SearchPhraseComponent.razor similarity index 68% rename from Wonky.Client/Components/InfoWarehouseComponent.razor rename to Wonky.Client/Components/SearchPhraseComponent.razor index e9e0afc2..c241cd74 100644 --- a/Wonky.Client/Components/InfoWarehouseComponent.razor +++ b/Wonky.Client/Components/SearchPhraseComponent.razor @@ -13,20 +13,9 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] *@ -

Lager

- - - - - - - - - - - - - -
SymbolBetydning
- - Pakning / Forsendelse
\ No newline at end of file +
+ + +
+ diff --git a/Wonky.Client/Components/InfoColorPackageComponent.razor.css b/Wonky.Client/Components/SearchPhraseComponent.razor.cs similarity index 56% rename from Wonky.Client/Components/InfoColorPackageComponent.razor.css rename to Wonky.Client/Components/SearchPhraseComponent.razor.cs index 211a9cbf..1d679bf9 100644 --- a/Wonky.Client/Components/InfoColorPackageComponent.razor.css +++ b/Wonky.Client/Components/SearchPhraseComponent.razor.cs @@ -1,4 +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 // it under the terms of the GNU Affero General Public License as // published by the Free Software Foundation, either version 3 of the @@ -11,10 +11,27 @@ // // 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] -*/ -.pictogram { - max-width: 30px; -} -.color-code { - max-width: 30px; +// + +using System.Timers; +using Microsoft.AspNetCore.Components; +using Timer = System.Timers.Timer; + +namespace Wonky.Client.Components; + +public partial class SearchPhraseComponent +{ + private string SearchTerm { get; set; } = ""; + [Parameter] public EventCallback OnChanged { get; set; } + + private void ClearSearch() + { + SearchTerm = ""; + OnChanged.InvokeAsync(""); + } + + private void OnSearchChanged() + { + OnChanged.InvokeAsync(SearchTerm); + } } \ No newline at end of file diff --git a/Wonky.Client/Components/WarehouseListComponent.razor b/Wonky.Client/Components/WarehouseListComponent.razor deleted file mode 100644 index a11816dc..00000000 --- a/Wonky.Client/Components/WarehouseListComponent.razor +++ /dev/null @@ -1,102 +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 Wonky.Client.Enums - -@if (OrderList != null) -{ -
-
-
- - - - - - - - -
-
-
- -
-
- @if (ReadyToShip && Orders.Any()) - { - - } -
-
-
-
-
-
-

Modtager

-
-
-
Post By
-
-
-
Dato
-
-
-
Status
-
-
-
- @foreach (var order in Orders) - { -
-
-
- @order.Company.Name -
-
- @order.Company.ZipCode @order.Company.City -
-
- @order.OrderDate -
-
- @if (order.Express) - { - - } - @switch (order.ProcessStatusEnum.ToLower()) - { - case "none": - - Pluk varer - break; - case "picked": - Pak varer - break; - case "packed": - Afhent varer - break; - } -
-
-
- } -
-} \ No newline at end of file diff --git a/Wonky.Client/Components/WarehouseListComponent.razor.cs b/Wonky.Client/Components/WarehouseListComponent.razor.cs deleted file mode 100644 index 128baf16..00000000 --- a/Wonky.Client/Components/WarehouseListComponent.razor.cs +++ /dev/null @@ -1,56 +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.Enums; -using Wonky.Client.Models; -using Wonky.Entity.Views; - -namespace Wonky.Client.Components; - -public partial class WarehouseListComponent -{ - [Parameter] public string Header { get; set; } = ""; - [Parameter] public List OrderList { get; set; } = new(); - [Parameter] public bool ReadyToShip { get; set; } - [Parameter] public EventCallback OnGetStatus { get; set; } - [Parameter] public EventCallback OnSetShipped { get; set; } - [Parameter] public EventCallback OnQPak { get; set; } - - private List Orders { get; set; } = new(); - - protected override async Task OnParametersSetAsync() - { - while (OrderList == null) - await Task.Delay(500); - - Orders = OrderList; - } - - private async Task SetShipStatus() - { - await OnSetShipped.InvokeAsync(); - } - - private async Task GetWithStatus(ProcessStatus status) - { - await OnGetStatus.InvokeAsync(status); - } - - private async Task QuickPak(string orderId) - { - await OnQPak.InvokeAsync(orderId); - } -} \ No newline at end of file diff --git a/Wonky.Client/Enums/ProductSort.cs b/Wonky.Client/Enums/ProductSort.cs index 3fd7dba0..a2959dc0 100644 --- a/Wonky.Client/Enums/ProductSort.cs +++ b/Wonky.Client/Enums/ProductSort.cs @@ -18,9 +18,7 @@ namespace Wonky.Client.Enums; public enum ProductSort { - None, - Desc, + Description, Sku, - Qty, - Abbr + LastInvoiceDate } \ No newline at end of file diff --git a/Wonky.Client/Helpers/Utils.cs b/Wonky.Client/Helpers/Utils.cs index c6037ddc..3bf5528c 100644 --- a/Wonky.Client/Helpers/Utils.cs +++ b/Wonky.Client/Helpers/Utils.cs @@ -27,11 +27,37 @@ namespace Wonky.Client.Helpers; /// public static class Utils { + public static List SortInventory(IEnumerable inventory, + ProductSort column, bool descending) + { + return column switch + { + ProductSort.Description => descending + ? inventory.OrderByDescending(x => x.Description).ToList() + : inventory.OrderBy(x => x.Description).ToList(), + ProductSort.Sku => descending + ? inventory.OrderByDescending(x => x.Sku).ToList() + : inventory.OrderBy(x => x.Sku).ToList(), + ProductSort.LastInvoiceDate => descending + ? inventory.OrderByDescending(x => x.LastInvoiceDate).ToList() + : inventory.OrderBy(x => x.LastInvoiceDate).ToList(), + _ => inventory.OrderByDescending(x => x.LastInvoiceDate).ToList() + }; + } + + public static List GenerateVariantListDto(IEnumerable items) { - return items.Select(item => new ProductVariant { VariantId = item.VariantId, S5A = item.S5A, S9A = item.S9A }).ToList(); + return items.Select(item => new ProductVariant + { + VariantId = item.VariantId, + S5A = item.S5A, + S9A = item.S9A + }) + .ToList(); } - + + public static List GenerateRevListView(IEnumerable products) { var result = new List(); @@ -64,17 +90,19 @@ public static class Utils break; } } + result.Add(newDoc); } } + return result.OrderBy(x => x.VariantName).ToList(); } - - + + public static List GenerateDocListView(IEnumerable products) { var result = new List(); - + var docProducts = products.OrderBy(x => x.TradingName).ToList(); foreach (var product in docProducts) @@ -104,45 +132,47 @@ public static class Utils break; } } + result.Add(newDoc); } } + return result.OrderBy(x => x.VariantName).ToList(); } - - + + public static List ParseRecipientsFromString(string recipients) { var addresses = recipients .Replace(" ", ",") - .Replace(",,",",") + .Replace(",,", ",") .Split(","); - return (from address - in addresses - where IsValidEmail(address) + return (from address + in addresses + where IsValidEmail(address) select new EmailContact { Name = address, Email = address }).ToList(); } - + public static List MapSaveAssignedRoles(RoleAssignment model) { return new List() { - new (){ Name = "Admin", Assigned = model.Admin}, - new (){ Name = "Advisor", Assigned = model.Advisor}, - new (){ Name = "EDoc", Assigned = model.EDoc}, - new (){ Name = "EShop", Assigned = model.EShop}, - new (){ Name = "Management", Assigned = model.Management}, - new (){ Name = "Office", Assigned = model.Office}, - new (){ Name = "Supervisor", Assigned = model.Supervisor}, - new (){ Name = "Warehouse", Assigned = model.Warehouse} + new() { Name = "Admin", Assigned = model.Admin }, + new() { Name = "Advisor", Assigned = model.Advisor }, + new() { Name = "EDoc", Assigned = model.EDoc }, + new() { Name = "EShop", Assigned = model.EShop }, + new() { Name = "Management", Assigned = model.Management }, + new() { Name = "Office", Assigned = model.Office }, + new() { Name = "Supervisor", Assigned = model.Supervisor }, + new() { Name = "Warehouse", Assigned = model.Warehouse } }; } - + public static RoleAssignment MapEditAssignedRoles(UserManagerEditView model) { @@ -177,9 +207,10 @@ public static class Utils break; } } + return x; } - + public static string StringToDigits(string digitString) { @@ -195,7 +226,7 @@ public static class Utils return check.All(c => c is >= '0' and <= '9'); } - + public static bool Validate(ValidateType validateType, string toValidate) { return validateType switch @@ -231,7 +262,7 @@ public static class Utils { validConditions++; } - + return validConditions == 3; } diff --git a/Wonky.Client/HttpInterceptors/HttpInterceptorService.cs b/Wonky.Client/HttpInterceptors/HttpInterceptorService.cs index cc341ee6..3f2ac15c 100644 --- a/Wonky.Client/HttpInterceptors/HttpInterceptorService.cs +++ b/Wonky.Client/HttpInterceptors/HttpInterceptorService.cs @@ -69,7 +69,8 @@ public class HttpInterceptorService var absolutePath = e.Request.RequestUri.AbsolutePath; if (!absolutePath.Contains("token")) { - // call TryRefreshToken + // we are using the tryRefreshToken + // the service returns the current access token or a new token using refreshToken var token = await _refreshTokenService.TryRefreshToken(); if (!string.IsNullOrEmpty(token)) { diff --git a/Wonky.Client/HttpRepository/CrmCustomerHistoryRepository.cs b/Wonky.Client/HttpRepository/CrmCustomerHistoryRepository.cs index cd4d6711..c6348a7d 100644 --- a/Wonky.Client/HttpRepository/CrmCustomerHistoryRepository.cs +++ b/Wonky.Client/HttpRepository/CrmCustomerHistoryRepository.cs @@ -34,6 +34,7 @@ public class CrmCustomerHistoryRepository : ICrmCustomerHistoryRepository private readonly HttpClient _client; private readonly ApiConfig _api; + public CrmCustomerHistoryRepository( HttpClient client, ILogger logger, NavigationManager navigation, IOptions configuration) @@ -44,92 +45,80 @@ public class CrmCustomerHistoryRepository : ICrmCustomerHistoryRepository _api = configuration.Value; } - /// - /// Fetch Invoice LIst - /// - /// - /// + public async Task FetchInvoiceList(string companyId) { var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/invoices"); var content = await response.Content.ReadAsStringAsync(); - return response.IsSuccessStatusCode - ? JsonSerializer.Deserialize(content, _options) - : new InvoiceListView(); + if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content)) + { + return new InvoiceListView(); + } + return JsonSerializer.Deserialize(content, _options) ?? new InvoiceListView(); } - /// - /// Fetch given invoice for given customer - /// - /// - /// - /// + public async Task FetchInvoice(string companyId, string invoiceId) { - return await _client + var content = await _client .GetFromJsonAsync($"{_api.CrmCustomers}/{companyId}/invoices/{invoiceId}", _options); + return content ?? new InvoiceView(); } - /// - /// Fetch inventory from given customer - /// - /// - /// + public async Task> FetchInventory(string companyId) { var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/{_api.CrmInventoryExt}"); - if (!response.IsSuccessStatusCode) - return new List(); var content = await response.Content.ReadAsStringAsync(); - return string.IsNullOrWhiteSpace(content) - ? new List() - : JsonSerializer.Deserialize>(content, _options); + if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content)) + return new List(); + return JsonSerializer.Deserialize>(content, _options) ?? new List(); } - /// - /// Fetch History for given customer - /// - /// - /// - public async Task> FetchHistory(string companyId) + + public async Task> GetProductInvoiceLines(string companyId) { var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/{_api.CrmProductExt}"); - if (!response.IsSuccessStatusCode) - return new List(); var content = await response.Content.ReadAsStringAsync(); - return string.IsNullOrWhiteSpace(content) - ? new List() - : JsonSerializer.Deserialize>(content, _options); + if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content)) + { + return new List(); + } + return JsonSerializer.Deserialize>(content, _options) ?? new List(); } - /// - /// Fetch history for given customer and a given product - /// - /// - /// - /// - public async Task> FetchHistory(string companyId, string sku) + + public async Task> GetProductInvoiceLines(string companyId, int months) + { + var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/{_api.CrmProductExt}/statistic?months={months}"); + var content = await response.Content.ReadAsStringAsync(); + if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content)) + { + return new List(); + } + return JsonSerializer.Deserialize>(content, _options) ?? new List(); + } + + + public async Task> GetProductInvoiceLines(string companyId, string sku) { var response = await _client.GetAsync($"{_api.CrmCustomers}/{companyId}/{_api.CrmProductExt}/{sku}"); - if (!response.IsSuccessStatusCode) - return new List(); var content = await response.Content.ReadAsStringAsync(); - return string.IsNullOrWhiteSpace(content) - ? new List() - : JsonSerializer.Deserialize>(content, _options); + if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content)) + { + return new List(); + } + return JsonSerializer.Deserialize>(content, _options) ?? new List(); } - /// - /// RPC call to initiate remote server sync for given customer - /// - /// - /// - /// + public async Task InvoiceErpToCrmRpc(string companyId, string syncDate) { var x = await _client.GetAsync($"{_api.SyncRpc}/companies/{companyId}/invoices/{syncDate}"); if (!x.IsSuccessStatusCode) + { return string.Empty; + } return await x.Content.ReadAsStringAsync(); } } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/ICrmCustomerHistoryRepository.cs b/Wonky.Client/HttpRepository/ICrmCustomerHistoryRepository.cs index e3323d02..8bfb2ef1 100644 --- a/Wonky.Client/HttpRepository/ICrmCustomerHistoryRepository.cs +++ b/Wonky.Client/HttpRepository/ICrmCustomerHistoryRepository.cs @@ -49,15 +49,23 @@ public interface ICrmCustomerHistoryRepository /// /// /// - Task> FetchHistory(string companyId); + Task> GetProductInvoiceLines(string companyId); + /// + /// Fetch history for customer for the past months. A hard limit on 24 months is enforced by the backed + /// + /// + /// + /// + Task> GetProductInvoiceLines(string companyId, int months); + /// /// Fetch history for given customer and a given product /// /// /// /// - Task> FetchHistory(string companyId, string sku); + Task> GetProductInvoiceLines(string companyId, string sku); /// /// RPC call to initiate remote server sync for given customer diff --git a/Wonky.Client/Local.Services/AuthenticationService.cs b/Wonky.Client/Local.Services/AuthenticationService.cs index c9d2a05e..5ed028be 100644 --- a/Wonky.Client/Local.Services/AuthenticationService.cs +++ b/Wonky.Client/Local.Services/AuthenticationService.cs @@ -150,11 +150,22 @@ public class AuthenticationService : IAuthenticationService ((AuthStateProvider)_authStateProvider).NotifyUserLogout(); } + + public async Task AccessToken() + { + return await _infoService.GetAccessToken(); + } + + public async Task UserInfo(bool write = false) { + // use http to fetch userInfo for authenticated user var response = await _client.GetAsync(_apiConfig.Value.UserInfoAuth).ConfigureAwait(true); - var content = await response.Content.ReadAsStringAsync(); + if (!response.IsSuccessStatusCode || string.IsNullOrWhiteSpace(content)) + { + return new UserManagerEditView(); + } var userInfo = JsonSerializer.Deserialize(content, _options) ?? new UserManagerEditView(); if (write) { diff --git a/Wonky.Client/Local.Services/IAuthenticationService.cs b/Wonky.Client/Local.Services/IAuthenticationService.cs index a8a7233e..be7e66b5 100644 --- a/Wonky.Client/Local.Services/IAuthenticationService.cs +++ b/Wonky.Client/Local.Services/IAuthenticationService.cs @@ -23,6 +23,7 @@ public interface IAuthenticationService { Task Login(CredentialDto credentials); Task Logout(); + Task AccessToken(); Task RefreshToken(); Task UserInfo(bool write = false); } \ No newline at end of file diff --git a/Wonky.Client/Local.Services/RefreshTokenService.cs b/Wonky.Client/Local.Services/RefreshTokenService.cs index 43a440b2..868c6f93 100644 --- a/Wonky.Client/Local.Services/RefreshTokenService.cs +++ b/Wonky.Client/Local.Services/RefreshTokenService.cs @@ -39,14 +39,13 @@ public class RefreshTokenService var user = authState.User; var expClaim = user.FindFirst(c => c.Type.Contains("exp"))?.Value; - - //var expTime = DateTimeOffset.FromUnixTimeSeconds(Convert.ToInt64(expClaim)); + var expTime = DateTimeOffset.FromUnixTimeSeconds(Convert.ToInt64(expClaim)); var diff = expTime - DateTime.UtcNow; - return diff.TotalMinutes <= 2 - ? await _authService.RefreshToken() //.ConfigureAwait(true) - : string.Empty; + return diff.TotalMinutes <= 10 + ? await _authService.RefreshToken() + : await _authService.AccessToken(); } } \ No newline at end of file diff --git a/Wonky.Client/OverlayCustomer/CustomerInventoryReorderOverlay.razor.cs b/Wonky.Client/OverlayCustomer/CustomerInventoryReorderOverlay.razor.cs index 2bf29d5d..8a721859 100644 --- a/Wonky.Client/OverlayCustomer/CustomerInventoryReorderOverlay.razor.cs +++ b/Wonky.Client/OverlayCustomer/CustomerInventoryReorderOverlay.razor.cs @@ -47,7 +47,7 @@ public partial class CustomerInventoryReorderOverlay if (string.IsNullOrWhiteSpace(SalesItem.Sku)) return; - History = await HistoryRepo.FetchHistory(CompanyId, SalesItem.Sku); + History = await HistoryRepo.GetProductInvoiceLines(CompanyId, SalesItem.Sku); if (!History.Any()) await Task.Delay(1000); SelectedItem.Item = SalesItem; diff --git a/Wonky.Client/OverlayCustomer/CustomerInvoiceViewOverlay.razor.cs b/Wonky.Client/OverlayCustomer/CustomerInvoiceViewOverlay.razor.cs index 87b4a322..177e911a 100644 --- a/Wonky.Client/OverlayCustomer/CustomerInvoiceViewOverlay.razor.cs +++ b/Wonky.Client/OverlayCustomer/CustomerInvoiceViewOverlay.razor.cs @@ -24,10 +24,15 @@ namespace Wonky.Client.OverlayCustomer; public partial class CustomerInvoiceViewOverlay : IDisposable { - [Parameter] public string CompanyId { get; set; } = ""; - [Parameter] public string InvoiceId { get; set; } = ""; + // ############################################################## [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public ICrmCustomerHistoryRepository HistoryRepo { get; set; } + + // ############################################################## + [Parameter] public string CompanyId { get; set; } = ""; + [Parameter] public string InvoiceId { get; set; } = ""; + + // ############################################################## private string _modalDisplay = ""; private bool _showBackdrop; private InvoiceView Invoice { get; set; } = new(); diff --git a/Wonky.Client/OverlayDocuments/ProductSelectionOverlay.razor.cs b/Wonky.Client/OverlayDocuments/ProductSelectionOverlay.razor.cs index fefd0de9..c02ab6b1 100644 --- a/Wonky.Client/OverlayDocuments/ProductSelectionOverlay.razor.cs +++ b/Wonky.Client/OverlayDocuments/ProductSelectionOverlay.razor.cs @@ -31,22 +31,13 @@ public partial class ProductSelectionOverlay private List FilteredList { get; set; } = new(); private string SearchTerm { get; set; } = ""; + protected override void OnInitialized() { FilterItems(SearchTerm); } - - private void ClearSearch() - { - SearchTerm = ""; - FilterItems(SearchTerm); - } - - private void OnSearchChanged() - { - FilterItems(SearchTerm); - } - + + private async Task SelectItem(DocView item) { item.Added = !item.Added; @@ -54,6 +45,19 @@ public partial class ProductSelectionOverlay } + private void ClearSearch() + { + SearchTerm = ""; + FilterItems(SearchTerm); + } + + + private void OnSearchChanged() + { + FilterItems(SearchTerm); + } + + private void FilterItems(string filter) { SearchTerm = filter; diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerActivityListOverlay.razor.cs b/Wonky.Client/OverlayOffice/OfficeCustomerActivityListOverlay.razor.cs index 387a3e95..78d7058a 100644 --- a/Wonky.Client/OverlayOffice/OfficeCustomerActivityListOverlay.razor.cs +++ b/Wonky.Client/OverlayOffice/OfficeCustomerActivityListOverlay.razor.cs @@ -22,9 +22,11 @@ namespace Wonky.Client.OverlayOffice; public partial class OfficeCustomerActivityListOverlay { + // ############################################################## [Parameter] public CompanyDto Company { get; set; } = new(); [Parameter] public List ActivityList { get; set; } = new(); + // ############################################################## private string _modalDisplay = ""; private bool _showBackdrop; diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerActivityViewOverlay.razor.cs b/Wonky.Client/OverlayOffice/OfficeCustomerActivityViewOverlay.razor.cs index 9a92eda1..70b7c4f7 100644 --- a/Wonky.Client/OverlayOffice/OfficeCustomerActivityViewOverlay.razor.cs +++ b/Wonky.Client/OverlayOffice/OfficeCustomerActivityViewOverlay.razor.cs @@ -21,7 +21,10 @@ namespace Wonky.Client.OverlayOffice; public partial class OfficeCustomerActivityViewOverlay { + // ############################################################## [Parameter] public ReportItemView Activity { get; set; } = new(); + + // ############################################################## private string _modalDisplay = ""; private bool _showBackdrop; diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerProductListOverlay.razor b/Wonky.Client/OverlayOffice/OfficeCustomerInventoryListOverlay.razor similarity index 61% rename from Wonky.Client/OverlayOffice/OfficeCustomerProductListOverlay.razor rename to Wonky.Client/OverlayOffice/OfficeCustomerInventoryListOverlay.razor index 93dcb757..1bb8e7c8 100644 --- a/Wonky.Client/OverlayOffice/OfficeCustomerProductListOverlay.razor +++ b/Wonky.Client/OverlayOffice/OfficeCustomerInventoryListOverlay.razor @@ -30,11 +30,36 @@
-
Navn
+ @* +
Navn
Varenr
-
Antal
-
-
+ *@ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
@foreach (var product in Inventory) diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerProductListOverlay.razor.cs b/Wonky.Client/OverlayOffice/OfficeCustomerInventoryListOverlay.razor.cs similarity index 60% rename from Wonky.Client/OverlayOffice/OfficeCustomerProductListOverlay.razor.cs rename to Wonky.Client/OverlayOffice/OfficeCustomerInventoryListOverlay.razor.cs index 4017113e..78b7fa6e 100644 --- a/Wonky.Client/OverlayOffice/OfficeCustomerProductListOverlay.razor.cs +++ b/Wonky.Client/OverlayOffice/OfficeCustomerInventoryListOverlay.razor.cs @@ -16,6 +16,7 @@ using Microsoft.AspNetCore.Components; using Wonky.Client.Enums; +using Wonky.Client.Helpers; using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpRepository; using Wonky.Client.Models; @@ -26,81 +27,75 @@ using Wonky.Entity.Views; namespace Wonky.Client.OverlayOffice; -public partial class OfficeCustomerProductListOverlay : IDisposable +public partial class OfficeCustomerInventoryListOverlay : IDisposable { + // ############################################################## [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public ICountryCatalogRepository CatalogRepo { get; set; } - [Inject] public ILogger Logger { get; set; } + [Inject] public ILogger Logger { get; set; } + // ############################################################## + [Parameter] public CompanyDto Company { get; set; } = new(); + [Parameter] public List Inventory { get; set; } = new(); + + // ############################################################## private string _modalDisplay = ""; private bool _showBackdrop; private DraftItem DraftItem { get; set; } = new(); private SalesItemView SalesItem { get; set; } = new(); private OfficeCustomerInventoryReorderOverlay ReorderOverlay { get; set; } = new(); - private bool Descending { get; set; } + private bool Descending { get; set; } = true; + private string SearchTerm { get; set; } = ""; + private List FilteredList { get; set; } = new(); + private ProductSort SortColumn { get; set; } = ProductSort.LastInvoiceDate; + - [Parameter] public CompanyDto Company { get; set; } = new(); - [Parameter] public List Inventory { get; set; } = new(); - - protected override void OnParametersSet() - { - if(Inventory.Any()) - Inventory = Inventory.OrderBy(x => x.Description).ToList(); - } protected override void OnInitialized() { Interceptor.RegisterEvent(); Interceptor.RegisterBeforeSendEvent(); + Inventory = Utils.SortInventory(Inventory, SortColumn, Descending); + FilterItems(SearchTerm); StateHasChanged(); } + + private void OnSearchChanged(string searchTerm) + { + FilterItems(searchTerm); + } + + + private void SortProducts(ProductSort column) + { + Descending = !Descending; + FilteredList = Utils.SortInventory(FilteredList, column, Descending); + } + + + private void SetSortOrder() + { + Descending = !Descending; + FilteredList = Utils.SortInventory(FilteredList, SortColumn, Descending); + } + + + private void FilterItems(string filter) + { + SearchTerm = filter; + FilteredList = string.IsNullOrWhiteSpace(filter) + ? Inventory + : Inventory.Where(i => i.Description.ToLower().Contains(filter.ToLower())).ToList(); + } + + private async Task ShowSkuReorder(string sku) { SalesItem = await CatalogRepo.GetSalesItemSku(Company.CountryCode.ToLower(), sku); ReorderOverlay.Show(); } - - private void SortProducts(ProductSort column) - { - Descending = !Descending; - switch (column) - { - case ProductSort.Desc: - if (Descending) - { - Inventory = Inventory.OrderByDescending(x => x.Description).ToList(); - break; - } - Inventory = Inventory.OrderBy(x => x.Description).ToList(); - break; - case ProductSort.Sku: - if (Descending) - { - Inventory = Inventory.OrderByDescending(x => x.Sku).ToList(); - break; - } - Inventory = Inventory.OrderBy(x => x.Sku).ToList(); - break; - case ProductSort.Qty: - if (Descending) - { - Inventory = Inventory.OrderByDescending(x => x.Quantity).ToList(); - break; - } - - Inventory = Inventory.OrderBy(x => x.Quantity).ToList(); - break; - case ProductSort.None: - break; - case ProductSort.Abbr: - break; - default: - Inventory = Inventory.OrderByDescending(x => x.Quantity).ToList(); - break; - } - } public void Show() { _modalDisplay = "block;"; @@ -108,6 +103,7 @@ public partial class OfficeCustomerProductListOverlay : IDisposable StateHasChanged(); } + private void Hide() { _modalDisplay = "none;"; @@ -115,9 +111,9 @@ public partial class OfficeCustomerProductListOverlay : IDisposable 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 ac88d156..95bf9900 100644 --- a/Wonky.Client/OverlayOffice/OfficeCustomerInventoryReorderOverlay.razor.cs +++ b/Wonky.Client/OverlayOffice/OfficeCustomerInventoryReorderOverlay.razor.cs @@ -26,10 +26,15 @@ namespace Wonky.Client.OverlayOffice; public partial class OfficeCustomerInventoryReorderOverlay { + // ############################################################## [Parameter] public CompanyDto Company { get; set; } [Parameter] public SalesItemView SalesItem { get; set; } = new(); [Inject] public ICountryCustomerHistoryRepository HistoryRepo { get; set; } + + // ############################################################## [Parameter] public EventCallback OrderItemCallback { get; set; } + + // ############################################################## private List History { get; set; } = new(); private DraftItem SelectedItem { get; set; } = new(); private string ProductName { get; set; } = ""; diff --git a/Wonky.Client/OverlayOffice/OfficeCustomerInvoiceViewOverlay.razor.cs b/Wonky.Client/OverlayOffice/OfficeCustomerInvoiceViewOverlay.razor.cs index cd6e92c6..4fd4e14a 100644 --- a/Wonky.Client/OverlayOffice/OfficeCustomerInvoiceViewOverlay.razor.cs +++ b/Wonky.Client/OverlayOffice/OfficeCustomerInvoiceViewOverlay.razor.cs @@ -24,12 +24,16 @@ namespace Wonky.Client.OverlayOffice; public partial class OfficeCustomerInvoiceViewOverlay : IDisposable { + // ############################################################## [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string InvoiceId { get; set; } = ""; [Parameter] public string CountryCode { get; set; } = ""; + + // ############################################################## [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public ICountryCustomerHistoryRepository HistoryRepo { get; set; } + // ############################################################## private string _modalDisplay = ""; private bool _showBackdrop; private InvoiceView Invoice { get; set; } = new(); diff --git a/Wonky.Client/OverlayOffice/OfficeOrderInventoryListOverlay.razor b/Wonky.Client/OverlayOffice/OfficeCustomerOrderInventoryListOverlay.razor similarity index 83% rename from Wonky.Client/OverlayOffice/OfficeOrderInventoryListOverlay.razor rename to Wonky.Client/OverlayOffice/OfficeCustomerOrderInventoryListOverlay.razor index 06bde79e..8f80795f 100644 --- a/Wonky.Client/OverlayOffice/OfficeOrderInventoryListOverlay.razor +++ b/Wonky.Client/OverlayOffice/OfficeCustomerOrderInventoryListOverlay.razor @@ -23,7 +23,7 @@
@@ -33,4 +33,4 @@ } - \ No newline at end of file + \ No newline at end of file diff --git a/Wonky.Client/OverlayOffice/OfficeOrderInventoryListOverlay.razor.cs b/Wonky.Client/OverlayOffice/OfficeCustomerOrderInventoryListOverlay.razor.cs similarity index 85% rename from Wonky.Client/OverlayOffice/OfficeOrderInventoryListOverlay.razor.cs rename to Wonky.Client/OverlayOffice/OfficeCustomerOrderInventoryListOverlay.razor.cs index a6f0c2fc..0a12c58a 100644 --- a/Wonky.Client/OverlayOffice/OfficeOrderInventoryListOverlay.razor.cs +++ b/Wonky.Client/OverlayOffice/OfficeCustomerOrderInventoryListOverlay.razor.cs @@ -24,23 +24,26 @@ using Wonky.Entity.Views; namespace Wonky.Client.OverlayOffice; -public partial class OfficeOrderInventoryListOverlay : IDisposable +public partial class OfficeCustomerOrderInventoryListOverlay : IDisposable { + // ############################################################## [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public ICountryCatalogRepository CatalogRepo { get; set; } - [Inject] public ILogger Logger { get; set; } + [Inject] public ILogger Logger { get; set; } + // ############################################################## [Parameter] public CompanyDto Company { get; set; } = new(); [Parameter] public List Inventory { get; set; } = new(); [Parameter] public EventCallback OnSelected { get; set; } + // ############################################################## private string _modalDisplay = ""; private bool _showBackdrop; // private List ProductList { get; set; } = new(); private DraftItem DraftItem { get; set; } = new(); private SalesItemView SalesItem { get; set; } = new(); - private OfficeOrderInventoryReorderOverlay ReorderOverlay { get; set; } = new(); + private OfficeCustomerOrderInventoryReorderOverlay ReorderOverlay { get; set; } = new(); protected override void OnParametersSet() { diff --git a/Wonky.Client/OverlayOffice/OfficeOrderInventoryReorderOverlay.razor b/Wonky.Client/OverlayOffice/OfficeCustomerOrderInventoryReorderOverlay.razor similarity index 100% rename from Wonky.Client/OverlayOffice/OfficeOrderInventoryReorderOverlay.razor rename to Wonky.Client/OverlayOffice/OfficeCustomerOrderInventoryReorderOverlay.razor diff --git a/Wonky.Client/OverlayOffice/OfficeOrderInventoryReorderOverlay.razor.cs b/Wonky.Client/OverlayOffice/OfficeCustomerOrderInventoryReorderOverlay.razor.cs similarity index 91% rename from Wonky.Client/OverlayOffice/OfficeOrderInventoryReorderOverlay.razor.cs rename to Wonky.Client/OverlayOffice/OfficeCustomerOrderInventoryReorderOverlay.razor.cs index 119cba3c..74be9383 100644 --- a/Wonky.Client/OverlayOffice/OfficeOrderInventoryReorderOverlay.razor.cs +++ b/Wonky.Client/OverlayOffice/OfficeCustomerOrderInventoryReorderOverlay.razor.cs @@ -24,12 +24,17 @@ using Wonky.Entity.Views; namespace Wonky.Client.OverlayOffice; -public partial class OfficeOrderInventoryReorderOverlay +public partial class OfficeCustomerOrderInventoryReorderOverlay { + // ############################################################## [Inject] public ICountryCustomerHistoryRepository HistoryRepo { get; set; } + + // ############################################################## [Parameter] public CompanyDto Company { get; set; } = new(); [Parameter] public SalesItemView SalesItem { get; set; } = new(); [Parameter] public EventCallback OnSelected { get; set; } + + // ############################################################## private List? ProductHistory { get; set; } = new(); private DraftItem SelectedItem { get; set; } = new(); private string ProductName { get; set; } = ""; diff --git a/Wonky.Client/OverlayOrderCreate/CatalogPagedOverlay.razor.cs b/Wonky.Client/OverlayOrderCreate/CatalogPagedOverlay.razor.cs index 7360fedc..bb45b9ea 100644 --- a/Wonky.Client/OverlayOrderCreate/CatalogPagedOverlay.razor.cs +++ b/Wonky.Client/OverlayOrderCreate/CatalogPagedOverlay.razor.cs @@ -29,17 +29,17 @@ namespace Wonky.Client.OverlayOrderCreate; public partial class CatalogPagedOverlay : IDisposable { - // injections + // ############################################################## [Inject] public ICountryCatalogRepository CatalogRepo { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } [Inject] public UserPreferenceService PreferenceService { get; set; } [Inject] public ILogger Logger { get; set; } - // parameters + // ############################################################## [Parameter] public string CountryCode { get; set; } = ""; [Parameter] public EventCallback OnSelected { get; set; } - // variables + // ############################################################## private string _modalDisplay = ""; private bool _showBackdrop; private List Items { get; set; } = new(); diff --git a/Wonky.Client/OverlayOrderCreate/ProductCheckConfirmationOverlay.razor.cs b/Wonky.Client/OverlayOrderCreate/ProductCheckConfirmationOverlay.razor.cs index db5b8ff1..b3a780c5 100644 --- a/Wonky.Client/OverlayOrderCreate/ProductCheckConfirmationOverlay.razor.cs +++ b/Wonky.Client/OverlayOrderCreate/ProductCheckConfirmationOverlay.razor.cs @@ -21,12 +21,15 @@ namespace Wonky.Client.OverlayOrderCreate; public partial class ProductCheckConfirmationOverlay { - private string _modalDisplay = ""; - private bool _showBackdrop; + // ############################################################## [Parameter] public string BodyMessage { get; set; } = ""; [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public List Products { get; set; } = new(); [Parameter] public EventCallback OnOkClicked { get; set; } + + // ############################################################## + private string _modalDisplay = ""; + private bool _showBackdrop; public void Show() { diff --git a/Wonky.Client/OverlayOrderCreate/ProductHistoryOverlay.razor.cs b/Wonky.Client/OverlayOrderCreate/ProductHistoryOverlay.razor.cs index e9cf918c..7cc88047 100644 --- a/Wonky.Client/OverlayOrderCreate/ProductHistoryOverlay.razor.cs +++ b/Wonky.Client/OverlayOrderCreate/ProductHistoryOverlay.razor.cs @@ -24,10 +24,14 @@ namespace Wonky.Client.OverlayOrderCreate; public partial class ProductHistoryOverlay { - // [Parameter] public EventCallback OnSelected { get; set; } + // ############################################################## + [Inject] public ICrmCustomerHistoryRepository HistoryRepo { get; set; } + + // ############################################################## [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string ItemSku { get; set; } = ""; - [Inject] public ICrmCustomerHistoryRepository HistoryRepo { get; set; } + + // ############################################################## private List? History { get; set; } private string ProductName { get; set; } = ""; private string _modalDisplay = ""; @@ -35,18 +39,13 @@ public partial class ProductHistoryOverlay protected override async Task OnParametersSetAsync() { - History = await HistoryRepo.FetchHistory(CompanyId, ItemSku); + History = await HistoryRepo.GetProductInvoiceLines(CompanyId, ItemSku); if (History.Any()) { ProductName = History[0].Description; } } - - // private void SelectPrice(decimal price) - // { - // OnSelected.InvokeAsync(price); - // Hide(); - // } + public void Show() { @@ -55,6 +54,7 @@ public partial class ProductHistoryOverlay StateHasChanged(); } + private void Hide() { _modalDisplay = "none;"; diff --git a/Wonky.Client/OverlayOrderCreate/ProductPriceHistoryOverlay.razor.cs b/Wonky.Client/OverlayOrderCreate/ProductPriceHistoryOverlay.razor.cs index 2cd981be..3dee6aa6 100644 --- a/Wonky.Client/OverlayOrderCreate/ProductPriceHistoryOverlay.razor.cs +++ b/Wonky.Client/OverlayOrderCreate/ProductPriceHistoryOverlay.razor.cs @@ -24,10 +24,15 @@ namespace Wonky.Client.OverlayOrderCreate; public partial class ProductPriceHistoryOverlay { + // ############################################################## + [Inject] public ICrmCustomerHistoryRepository HistoryRepo { get; set; } + + // ############################################################## [Parameter] public EventCallback OnSelected { get; set; } [Parameter] public string CompanyId { get; set; } = ""; [Parameter] public string Sku { get; set; } = ""; - [Inject] public ICrmCustomerHistoryRepository HistoryRepo { get; set; } + + // ############################################################## private List? ProductHistory { get; set; } private string ProductName { get; set; } = ""; private string _modalDisplay = ""; @@ -38,19 +43,21 @@ public partial class ProductPriceHistoryOverlay if (string.IsNullOrWhiteSpace(Sku)) return; - ProductHistory = await HistoryRepo.FetchHistory(CompanyId, Sku); + ProductHistory = await HistoryRepo.GetProductInvoiceLines(CompanyId, Sku); if (ProductHistory.Any()) { ProductName = ProductHistory[0].Description; } } + private void SelectPrice(decimal price) { OnSelected.InvokeAsync(price); Hide(); } + public void Show() { _modalDisplay = "block;"; @@ -58,6 +65,7 @@ public partial class ProductPriceHistoryOverlay StateHasChanged(); } + private void Hide() { _modalDisplay = "none;"; diff --git a/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor b/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor index 98f3eb4e..0340e29d 100644 --- a/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor +++ b/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor @@ -22,7 +22,7 @@ Produkt oversigt for @Company.Name
-

Produkt oversigt @Company.Name

+

Produkt køb @Company.Name

Stamkort @@ -33,10 +33,9 @@
+ @if (Working) { -} - - +} \ No newline at end of file diff --git a/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor.cs b/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor.cs index 86795fa8..9758344d 100644 --- a/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor.cs +++ b/Wonky.Client/Pages/AdvisorCustomerInventoryListPage.razor.cs @@ -19,6 +19,8 @@ using System.Xml; using Blazored.LocalStorage; using Blazored.Toast.Services; using Microsoft.AspNetCore.Components; +using Wonky.Client.Enums; +using Wonky.Client.Helpers; using Wonky.Client.HttpInterceptors; using Wonky.Client.HttpRepository; using Wonky.Client.Models; @@ -65,7 +67,8 @@ public partial class AdvisorCustomerInventoryListPage : IDisposable Working = false; } - + + private async Task OnReorderCallback(string sku) { // fetch item from http repo diff --git a/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor b/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor index 0c6a4701..95adab3c 100644 --- a/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor +++ b/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor @@ -311,12 +311,9 @@
- @if (AppInfo!.Value!.Rc) + @if (UserInfo.CountryCode is "DK") { - @if (UserInfo.CountryCode is "DK") - { - Kemi Dokumentation - } + Kemi Dokumentation }
diff --git a/Wonky.Client/Pages/InfoPage.razor b/Wonky.Client/Pages/InfoPage.razor index 901f04b1..b8dd3a84 100644 --- a/Wonky.Client/Pages/InfoPage.razor +++ b/Wonky.Client/Pages/InfoPage.razor @@ -33,12 +33,11 @@
+ @*
-
- -
+ *@
@@ -48,12 +47,17 @@
+
+ +
+ @*
+ *@
diff --git a/Wonky.Client/Pages/OfficeOrderCreatePage.razor b/Wonky.Client/Pages/OfficeOrderCreatePage.razor index c186f267..f061df4f 100644 --- a/Wonky.Client/Pages/OfficeOrderCreatePage.razor +++ b/Wonky.Client/Pages/OfficeOrderCreatePage.razor @@ -245,4 +245,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs b/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs index d3cc4d4e..d824ee58 100644 --- a/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs +++ b/Wonky.Client/Pages/OfficeOrderCreatePage.razor.cs @@ -80,7 +80,7 @@ public partial class OfficeOrderCreatePage : IDisposable private CatalogPagedOverlay CatalogOverlay { get; set; } = new(); private OfficeCustomerInvoiceListOverlay InvoiceListOverlay { get; set; } = new(); private OfficeCustomerActivityListOverlay ActivityListOverlay { get; set; } = new(); - private OfficeOrderInventoryListOverlay InventoryListOverlay { get; set; } = new(); + private OfficeCustomerOrderInventoryListOverlay InventoryListOverlay { get; set; } = new(); // ############################################################# // lists diff --git a/Wonky.Client/Pages/SupervisorDocumentNewPage.razor.cs b/Wonky.Client/Pages/SupervisorDocumentNewPage.razor.cs index 4aec14f7..74ccad79 100644 --- a/Wonky.Client/Pages/SupervisorDocumentNewPage.razor.cs +++ b/Wonky.Client/Pages/SupervisorDocumentNewPage.razor.cs @@ -37,6 +37,7 @@ public partial class SupervisorDocumentNewPage : IDisposable [Inject] public ILogger Logger { get; set; } [Inject] public IToastService Toaster { get; set; } [Inject] public NavigationManager Navigator { get; set; } + [Inject] public ISystemSendMailService SendMail { get; set; } // ############################################################ @@ -102,6 +103,25 @@ public partial class SupervisorDocumentNewPage : IDisposable else { Toaster.ShowSuccess("Ok"); + var sendTo = new List + { + new () { Email = "paul@innotec.dk", Name = "Paul Vendelbo" }, + new () { Email = "eddie@innotec.dk", Name = "Eddie Broch" } + }; + var msg = new EmailMessage + { + Body = Document.Content, + Subject = Document.Description, + To = sendTo, + IsBodyHtml = false + }; + Toaster.ShowInfo("Sender email ..."); + var result = await SendMail.SendMail("system", msg); + if (result.IsSuccess) + { + Toaster.ClearAll(); + Toaster.ShowInfo("Email sendt."); + } Navigator.NavigateTo($"/supervisor/advisors/{AdvisorId}/documents"); } Toaster.ClearAll(); diff --git a/Wonky.Client/Pages/SupervisorDocumentViewEditPage.razor b/Wonky.Client/Pages/SupervisorDocumentViewEditPage.razor index 9aa38dcc..733f42f2 100644 --- a/Wonky.Client/Pages/SupervisorDocumentViewEditPage.razor +++ b/Wonky.Client/Pages/SupervisorDocumentViewEditPage.razor @@ -82,7 +82,7 @@