From 263a33a22a0b7521adf6722a0aa77b774a1df55b Mon Sep 17 00:00:00 2001 From: Frede Hundewadt <22748698+fhdk@users.noreply.github.com> Date: Sun, 7 Aug 2022 07:58:09 +0200 Subject: [PATCH] removed obsolete test page - add price select to history popup --- Wonky.Client/Pages/ActivityNewVisitPage.razor | 10 +- .../Pages/ActivityNewVisitPage.razor.cs | 18 ++- .../Pages/XTestPriceListPopupPage.razor | 118 ------------------ .../Pages/XTestPriceListPopupPage.razor.cs | 102 --------------- .../Shared/ProductPriceHistoryModal.razor | 66 ++++++++++ .../Shared/ProductPriceHistoryModal.razor.cs | 65 ++++++++++ Wonky.Client/wwwroot/appsettings.json | 2 +- 7 files changed, 152 insertions(+), 229 deletions(-) delete mode 100644 Wonky.Client/Pages/XTestPriceListPopupPage.razor delete mode 100644 Wonky.Client/Pages/XTestPriceListPopupPage.razor.cs create mode 100644 Wonky.Client/Shared/ProductPriceHistoryModal.razor create mode 100644 Wonky.Client/Shared/ProductPriceHistoryModal.razor.cs diff --git a/Wonky.Client/Pages/ActivityNewVisitPage.razor b/Wonky.Client/Pages/ActivityNewVisitPage.razor index 4608ffec..ccd8f845 100644 --- a/Wonky.Client/Pages/ActivityNewVisitPage.razor +++ b/Wonky.Client/Pages/ActivityNewVisitPage.razor @@ -22,6 +22,7 @@ +
@@ -150,7 +151,7 @@ else
- @* Order draft lines *@ + @* Order draft lines -----------------------------------------------------*@ @@ -208,7 +209,7 @@ else
- @* draft line *@ + @* draft line ----------------------------------------------------- *@ @if (!string.IsNullOrWhiteSpace(_selectedItem.Name) && ShowItem) {
@@ -233,9 +234,14 @@ else
+ + @* + *@
diff --git a/Wonky.Client/Pages/ActivityNewVisitPage.razor.cs b/Wonky.Client/Pages/ActivityNewVisitPage.razor.cs index d0591a33..f5fb2714 100644 --- a/Wonky.Client/Pages/ActivityNewVisitPage.razor.cs +++ b/Wonky.Client/Pages/ActivityNewVisitPage.razor.cs @@ -49,6 +49,7 @@ public partial class ActivityNewVisitPage : IDisposable private readonly JsonSerializerOptions? _options = new JsonSerializerOptions{PropertyNameCaseInsensitive = true}; private PriceListModal _priceListModal { get; set; } private ProductHistoryModal _historyModal { get; set; } + private ProductPriceHistoryModal _priceHistoryModal { get; set; } private SalesItemView _selectedItem { get; set; } = new(); private Preferences _prefs { get; set; } = new(); private ActivityDto _draft { get; set; } = new(); @@ -142,7 +143,7 @@ public partial class ActivityNewVisitPage : IDisposable { _priceListModal.Show(); } - + private async Task SelectSku(SelectedSku sku) { // fetch selected item @@ -160,11 +161,16 @@ public partial class ActivityNewVisitPage : IDisposable _historyModal.Show(); } - // private void SelectPrice(decimal price) - // { - // Price = price.ToString("N2"); - // StateHasChanged(); - // } + private void CallPriceHistoryModal() + { + _priceHistoryModal.Show(); + } + + private void SelectPrice(decimal price) + { + Price = price.ToString("N2"); + StateHasChanged(); + } private async Task SetWorkDate(string workDate) { diff --git a/Wonky.Client/Pages/XTestPriceListPopupPage.razor b/Wonky.Client/Pages/XTestPriceListPopupPage.razor deleted file mode 100644 index 78cf4464..00000000 --- a/Wonky.Client/Pages/XTestPriceListPopupPage.razor +++ /dev/null @@ -1,118 +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] -// -*@ - -@page "/xtest" -@using Microsoft.AspNetCore.Authorization -@attribute [Authorize(Roles = "Advisor")] - -
-
- @* Order draft lines *@ - - - - - - - - - - - - - - - - - - @if (DraftStateProvider != null && DraftStateProvider.Draft.Items.Count > 0) - { - @foreach (var cartItem in DraftStateProvider.Draft.Items) - { - - - - - - - - - - } - } - - - - - - - - -
- Ordrekladde Global kladde (udløber efter @(DraftStateProvider.Draft.TimeToLiveInSeconds / 60)m inaktivitet) - - -
NavnVarenrAntalEnhedsprisLinjesumSAS
@cartItem.Item.Name@cartItem.Item.Sku@cartItem.Quantity@cartItem.Price@cartItem.LineTotal - - - -
Total@DraftStateProvider.Draft.Total
-
-
-
-
- @* draft line *@ - @if (_selectedItem != null && ShowItem) - { - - - - - - - - - - - - - - - - - - - - - - - - -
Kladdelinje
AntalPrisRabatSASVarenr.
- - - - - - - - @_selectedItem.Sku - -
- } -
-
\ No newline at end of file diff --git a/Wonky.Client/Pages/XTestPriceListPopupPage.razor.cs b/Wonky.Client/Pages/XTestPriceListPopupPage.razor.cs deleted file mode 100644 index a7826425..00000000 --- a/Wonky.Client/Pages/XTestPriceListPopupPage.razor.cs +++ /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 System.Globalization; -using System.Text.Json; -using Wonky.Client.HttpInterceptors; -using Wonky.Client.HttpRepository; -using Wonky.Client.Models; -using Microsoft.AspNetCore.Components; -using Wonky.Client.Shared; -using Wonky.Entity.Views; - -namespace Wonky.Client.Pages; - -public partial class XTestPriceListPopupPage : IDisposable -{ - [Inject] private ISalesItemHttpRepository _itemRepo { get; set; } - [Inject] private HttpInterceptorService _interceptor { get; set; } - [CascadingParameter] DraftStateProvider DraftStateProvider { get; set; } - private string Quantity = "1"; - private string Price = "0"; - private string Discount = "0"; - private bool ShowItem { get; set; } - private bool Sas { get; set; } - private SalesItemView _selectedItem { get; set; } = new(); - private PriceListModal _priceList = new(); - private SelectedSku _sku { get; set; } = new(); - - protected override async Task OnInitializedAsync() - { - _interceptor.RegisterEvent(); - _interceptor.RegisterBeforeSendEvent(); - } - - private void CallPriceListModal() - { - _priceList.Show(); - } - - private async Task SelectSku(SelectedSku sku) - { - ShowItem = true; - Console.WriteLine($"XTextPriceList => sku: {JsonSerializer.Serialize(sku)}"); - _selectedItem = await _itemRepo.GetSalesItem(sku.ItemId); - Price = sku.Rate; - Quantity = sku.Quantity; - } - - private async Task DeleteDraft() - { - await DraftStateProvider.DeleteDraftAsync(); - } - - private async Task AddItem(SalesItemView salesItem) - { - ShowItem = false; - // create a new cart item - var item = new DraftItem - { - Item = salesItem, - Quantity = Convert.ToInt32(Quantity), - Price = Convert.ToDecimal(Price, CultureInfo.InvariantCulture), - Discount = Convert.ToDecimal(Discount, CultureInfo.InvariantCulture), - Sas = Sas - }; - // reset internals to initial state - Sas = false; - Quantity = "1"; - Price = "0"; - Discount = "0"; - // add it to the cart - DraftStateProvider.Draft.Items.Add(item); - // save the item using the CartStateProvider's save method - await DraftStateProvider.SaveChangesAsync(); - } - - private async Task RemoveItem(DraftItem item) - { - // remove item - DraftStateProvider.Draft.Items.Remove(item); - // save the remaining draft - await DraftStateProvider.SaveChangesAsync(); - } - - - public void Dispose() - { - _interceptor.DisposeEvent(); - } -} \ No newline at end of file diff --git a/Wonky.Client/Shared/ProductPriceHistoryModal.razor b/Wonky.Client/Shared/ProductPriceHistoryModal.razor new file mode 100644 index 00000000..bb4276bb --- /dev/null +++ b/Wonky.Client/Shared/ProductPriceHistoryModal.razor @@ -0,0 +1,66 @@ +@* +// 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 +@using Wonky.Client.Helpers + +@if (_showBackdrop) +{ + +} \ No newline at end of file diff --git a/Wonky.Client/Shared/ProductPriceHistoryModal.razor.cs b/Wonky.Client/Shared/ProductPriceHistoryModal.razor.cs new file mode 100644 index 00000000..bc332ffd --- /dev/null +++ b/Wonky.Client/Shared/ProductPriceHistoryModal.razor.cs @@ -0,0 +1,65 @@ +// 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.HttpRepository; +using Wonky.Client.Models; +using Wonky.Client.Services; +using Wonky.Entity.Requests; +using Wonky.Entity.Views; + +namespace Wonky.Client.Shared; + +public partial class ProductPriceHistoryModal +{ + [Parameter] public EventCallback OnSelected { get; set; } + [Parameter] public string CompanyId { get; set; } = ""; + [Parameter] public string ItemSku { get; set; } = ""; + [Inject] public IHistoryHttpRepository _historyRepo { get; set; } + private List History { get; set; } + private string ProductName { get; set; } = ""; + private string _modalDisplay = ""; + private bool _showBackdrop; + + protected override async Task OnParametersSetAsync() + { + History = await _historyRepo.FetchHistory(CompanyId, ItemSku); + if (History.Any()) + { + ProductName = History[0].Description; + } + } + + private void SelectPrice(decimal price) + { + OnSelected.InvokeAsync(price); + Hide(); + } + + public void Show() + { + _modalDisplay = "block;"; + _showBackdrop = true; + StateHasChanged(); + } + + private void Hide() + { + _modalDisplay = "none;"; + _showBackdrop = false; + StateHasChanged(); + } +} \ No newline at end of file diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 6b1b70b0..ef87324d 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,7 +1,7 @@ { "appInfo": { "name": "Wonky Client", - "version": "0.10.64", + "version": "0.10.66", "rc": true, "sandBox": false, "image": "grumpy-coder.png"