87 lines
No EOL
2.9 KiB
C#
87 lines
No EOL
2.9 KiB
C#
// 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 Microsoft.VisualBasic.CompilerServices;
|
|
using Wonky.Client.Enums;
|
|
using Wonky.Client.Models;
|
|
using Wonky.Entity.Views;
|
|
using Utils = Wonky.Client.Helpers.Utils;
|
|
|
|
namespace Wonky.Client.OverlayOffice;
|
|
#pragma warning disable CS8618
|
|
|
|
public partial class OfficeCustomerInventoryListReorderComponent
|
|
{
|
|
// *************************************************************
|
|
// Injections
|
|
[Inject] public ILocalStorageService Storage { get; set; }
|
|
|
|
// *************************************************************
|
|
// Parameters
|
|
[Parameter] public List<ProductInventoryItemView> Inventory { get; set; } = new();
|
|
[Parameter] public string CompanyId { get; set; } = "";
|
|
[Parameter] public EventCallback<string> OnReorderSelected { get; set; }
|
|
|
|
// *************************************************************
|
|
// private variables
|
|
private bool Descending { get; set; } = true;
|
|
private string DisplayFilter { get; set; } = "";
|
|
private List<ProductInventoryItemView> DisplayList { get; set; } = new();
|
|
private SortColumn SortColumn { get; set; } = SortColumn.LastInvoiceDate;
|
|
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
Inventory = Utils.SortInventory(Inventory, SortColumn, Descending);
|
|
FilterItems(DisplayFilter);
|
|
}
|
|
|
|
|
|
private void SetSortOrder()
|
|
{
|
|
Descending = !Descending;
|
|
DisplayList = Utils.SortInventory(DisplayList, SortColumn, Descending);
|
|
}
|
|
|
|
|
|
private void OnSearchChanged(string searchTerm)
|
|
{
|
|
FilterItems(searchTerm);
|
|
}
|
|
|
|
|
|
private void FilterItems(string filter)
|
|
{
|
|
DisplayFilter = filter;
|
|
DisplayList = string.IsNullOrWhiteSpace(filter)
|
|
? Inventory
|
|
: Inventory.Where(i => i.Description.ToLower().Contains(filter.ToLower())).ToList();
|
|
}
|
|
|
|
|
|
private void SortProducts(SortColumn column)
|
|
{
|
|
SortColumn = column;
|
|
DisplayList = Utils.SortInventory(DisplayList, SortColumn, Descending);
|
|
}
|
|
|
|
|
|
private async Task CallShowReorderModal(string sku)
|
|
{
|
|
await OnReorderSelected.InvokeAsync(sku);
|
|
}
|
|
} |