removed obsolete test page - add price select to history popup

This commit is contained in:
Frede Hundewadt 2022-08-07 07:58:09 +02:00
parent acb9312c90
commit 263a33a22a
7 changed files with 152 additions and 229 deletions

View file

@ -22,6 +22,7 @@
<PriceListModal OnSelected="SelectSku" @ref="_priceListModal"/>
<ProductHistoryModal CompanyId="@CompanyId" ItemSku="@_selectedItem.Sku" @ref="_historyModal"/>
<ProductPriceHistoryModal OnSelected="SelectPrice" CompanyId="@CompanyId" ItemSku="@_selectedItem.Sku" @ref="_priceHistoryModal"/>
<div class="row align-items-center bg-dark text-white rounded-3 p-3">
<div class="col-9">
@ -150,7 +151,7 @@ else
<div class="accordion-body">
<div class="row">
<div class="col">
@* Order draft lines *@
@* Order draft lines -----------------------------------------------------*@
<table class="sticky-top table table-hover table-striped table-bordered">
<thead>
<tr class="bg-dark text-white">
@ -208,7 +209,7 @@ else
</div>
<div class="row">
<div class="col">
@* draft line *@
@* draft line ----------------------------------------------------- *@
@if (!string.IsNullOrWhiteSpace(_selectedItem.Name) && ShowItem)
{
<table id="draft-line" class="table table-bordered">
@ -233,9 +234,14 @@ else
<td class="align-middle">
<div class="input-group">
<input type="number" class="form-control" @bind-value="@Price"/>
<button class="btn btn-warning btn-sm" type="button" @onclick="CallPriceHistoryModal">
<i class="oi oi-list"></i>
</button>
@*
<button class="btn btn-info btn-sm" type="button" @onclick="CallHistoryModal">
<i class="oi oi-list"></i>
</button>
*@
</div>
</td>
<td class="align-middle">

View file

@ -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)
{

View file

@ -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")]
<div class="row">
<div class="col">
@* Order draft lines *@
<table class="sticky-top table table-hover table-striped table-bordered">
<thead>
<tr class="bg-dark text-white">
<th scope="col" colspan="6">
Ordrekladde <span class="mx-2 draft-expires-msg">Global kladde (udløber efter @(DraftStateProvider.Draft.TimeToLiveInSeconds / 60)m inaktivitet)</span>
</th>
<th scope="col" class="text-end">
<button type="button" class="btn btn-danger btn-sm" @onclick="@DeleteDraft" disabled="@(DraftStateProvider.Draft.Items.Count == 0)">Slet kladde</button>
</th>
</tr>
<tr class="bg-dark opacity-75 text-white">
<th scope="col">Navn</th>
<th scope="col" class="text-nowrap">Varenr</th>
<th scope="col" class="text-end">Antal</th>
<th scope="col" class="text-end">Enhedspris</th>
<th scope="col" class="text-end">Linjesum</th>
<th scope="col" class="text-end">SAS</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
@if (DraftStateProvider != null && DraftStateProvider.Draft.Items.Count > 0)
{
@foreach (var cartItem in DraftStateProvider.Draft.Items)
{
<tr>
<td class="align-middle">@cartItem.Item.Name</td>
<td class="align-middle">@cartItem.Item.Sku</td>
<td class="align-middle text-end">@cartItem.Quantity</td>
<td class="align-middle text-end">@cartItem.Price</td>
<td class="align-middle text-end">@cartItem.LineTotal</td>
<td class="align-middle text-center">
<input type="checkbox" checked="@cartItem.Sas" disabled/>
</td>
<td class="align-middle text-end">
<button type="button" class="btn btn-danger" @onclick="@(() => RemoveItem(cartItem))">Slet Linje</button>
</td>
</tr>
}
}
<tr>
<td colspan="3"></td>
<td class="align-middle text-black text-end fw-bold">Total</td>
<td class="align-middle text-black text-end fw-bold">@DraftStateProvider.Draft.Total</td>
<td></td>
<td class="align-middle text-end"><button class="btn btn-primary" type="button" @onclick="CallPriceListModal"><i class="oi oi-plus"></i></button></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col">
@* draft line *@
@if (_selectedItem != null && ShowItem)
{
<table id="draft-line" class="table table-bordered">
<thead>
<tr class="bg-dark text-white">
<th scope="col" colspan="6">Kladdelinje</th>
</tr>
<tr>
<th scope="col">Antal</th>
<th scope="col">Pris</th>
<th scope="col">Rabat</th>
<th class="align-content-center justify-content-center" scope="col">SAS</th>
<th scope="col">Varenr.</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<tr>
<td class="align-middle">
<input type="number" class="form-control" @bind-value="@Quantity"/>
</td>
<td class="align-middle">
<input type="number" class="form-control" @bind-value="@Price"/>
</td>
<td class="align-middle">
<input type="number" class="form-control" @bind-value="@Discount"/>
</td>
<td class="align-middle align-content-center justify-content-center">
<input type="checkbox" class="form-check" @bind-value="@Sas"/>
</td>
<td class="align-middle">@_selectedItem.Sku</td>
<td class="align-middle">
<button type="button" class="btn btn-warning text-nowrap d-block" @onclick="@(() => AddItem(_selectedItem))">bestil @Quantity stk @_selectedItem.Name</button>
</td>
</tr>
</tbody>
</table>
}
</div>
</div>

View file

@ -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();
}
}

View file

@ -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
<div class="modal" tabindex="-1" role="dialog" style="display:@_modalDisplay">
<div class="modal-dialog modal-dialog-scrollable modal-lg modal-xl">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">@ProductName</h5>
<button type="button" class="btn-close" @onclick="Hide" data-bs-dismiss="modal" aria-label="Luk"></button>
</div>
<div class="modal-body">
@if (!string.IsNullOrWhiteSpace(ProductName))
{
<table class="table table-striped">
<thead>
<tr>
<th scope="col">Dato</th>
<th scope="col">Antal</th>
<th scope="col">Rabat</th>
<th scope="col">Pris</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
@foreach (var entry in History)
{
<tr>
<td>@entry.DeliveryDate</td>
<td>@entry.Quantity</td>
<td>@entry.Discount</td>
<td>@entry.Price</td>
<td>
<button type="button" class="btn btn-primary" data-bs-dismiss="modal" @onclick="() => SelectPrice(entry.Price)">Overfør</button>
</td>
</tr>
}
</tbody>
</table>
}
else
{
<h3>Ingen data</h3>
}
</div>
</div>
</div>
</div>
@if (_showBackdrop)
{
<div class="modal-backdrop fade show"></div>
}

View file

@ -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<decimal> OnSelected { get; set; }
[Parameter] public string CompanyId { get; set; } = "";
[Parameter] public string ItemSku { get; set; } = "";
[Inject] public IHistoryHttpRepository _historyRepo { get; set; }
private List<ProductHistoryView> 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();
}
}

View file

@ -1,7 +1,7 @@
{
"appInfo": {
"name": "Wonky Client",
"version": "0.10.64",
"version": "0.10.66",
"rc": true,
"sandBox": false,
"image": "grumpy-coder.png"