< Summary

Information
Class: OzonOrdersWeb.Areas.Studio2.ViewHelpers.OrderIndexSortAjaxMeta
Assembly: OzonOrdersWeb
File(s): /home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/Areas/Studio2/ViewHelpers/OrderIndexSortAjaxMeta.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 45
Coverable lines: 45
Total lines: 77
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Key()100%210%
.cctor()100%210%
Build(...)0%2040%
FormatLabel(...)0%2040%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/OzonOrdersWeb/Areas/Studio2/ViewHelpers/OrderIndexSortAjaxMeta.cs

#LineLine coverage
 1using Services.FiltersServices.SortModels;
 2
 3namespace OzonOrdersWeb.Areas.Studio2.ViewHelpers;
 4
 5/// <summary>Метаданные ссылок сортировки для AJAX-обновления thead без full reload.</summary>
 6public static class OrderIndexSortAjaxMeta
 7{
 08    private sealed record SortColumn(string Key, string Selector, string BaseText, OrderSortState Asc, OrderSortState De
 9
 010    private static readonly SortColumn[] Columns =
 011    [
 012        new("ShipmentNumberSort", "#thShipmentNumberSort a", "Номер заказа", OrderSortState.ShipmentNumberAsc, OrderSort
 013        new("DeliverySort", "#thDeliverySort a", "Доставка", OrderSortState.DeliveryAsc, OrderSortState.DeliveryDesc),
 014        new("OzonClient", "#thOzonClient a", "Клиент", OrderSortState.OzonClientAsc, OrderSortState.OzonClientDesc),
 015        new("DeliveryCitySort", "#thDeliveryCity a", "Город доставки", OrderSortState.DeliveryCityAsc, OrderSortState.De
 016        new("ProcessingDateSort", "#thProcessingDate a", "Принят", OrderSortState.ProcessingDateAsc, OrderSortState.Proc
 017        new("ShippingDateSort", "#thShippingDate a", "Дата отгр.", OrderSortState.ShippingDateAsc, OrderSortState.Shippi
 018        new("DeliveryPeriodSort", "#shipmentTable th[data-column=\"period\"] a[data-full-title=\"Срок доставки\"]", "Сро
 019        new("TimeLeftSort", "#shipmentTable th[data-column=\"period\"] a[data-full-title=\"Осталось\"]", "Остал.", Order
 020        new("ArticleSort", "#thArticle a", "Key", OrderSortState.ArticleAsc, OrderSortState.ArticleDesc),
 021        new("ManufacturerSort", "#thManufacturer a", "Производитель", OrderSortState.ManufacturerAsc, OrderSortState.Man
 022        new("ProductNameSort", "#thProductName a", "Наименование товара", OrderSortState.ProductNameAsc, OrderSortState.
 023        new("StatusSort", "#thStatusOzon a", "Статус клиента", OrderSortState.StatusAsc, OrderSortState.StatusDesc),
 024        new("AppStatusIdSort", "#thStatus a", "Статус", OrderSortState.AppStatusIdAsc, OrderSortState.AppStatusIdDesc),
 025        new("ShipmentWarehouseSort", "#thShipmentWarehouse a", "Склад", OrderSortState.ShipmentWarehouseIdAsc, OrderSort
 026        new("LastStatusChangeDateSort", "#shipmentTable a[data-full-title=\"Дата изменения статуса\"]", "Дата изм. стату
 027        new("SupplierSort", "#thSupplier a", "Поставщик", OrderSortState.SupplierAsc, OrderSortState.SupplierDesc),
 028        new("OrderNumberToSupplierSort", "#thOrderNumberToSupplierSort a", "Номер заказа п.", OrderSortState.OrderNumber
 029        new("CategorySort", "#thCategory a", "Категория", OrderSortState.CategoryAsc, OrderSortState.CategoryDesc),
 030        new("VolumeSort", "#thVolume a", "Объём", OrderSortState.VolumeAsc, OrderSortState.VolumeDesc),
 031        new("CurrentPriceSort", "#thCurrentPrice a", "Цена сайта", OrderSortState.CurrentPriceAsc, OrderSortState.Curren
 032        new("QuantitySort", "#thQuantity a", "Кол-во", OrderSortState.QuantityAsc, OrderSortState.QuantityDesc),
 033        new("PriceSort", "#thPrice a", "Цена", OrderSortState.PriceAsc, OrderSortState.PriceDesc),
 034        new("ShipmentAmountSort", "#thShipmentAmount a", "Сумма отпр.", OrderSortState.ShipmentAmountAsc, OrderSortState
 035        new("PurchasePriceSort", "#thPurchasePrice a", "Закупка", OrderSortState.PurchasePriceAsc, OrderSortState.Purcha
 036        new("CostPriceсеSort", "#thCostPriceсе a", "Себест.", OrderSortState.CostPriceAsc, OrderSortState.CostPriceDesc)
 037        new("OzonCommissionSort", "#thOzonCommission a", "Комиссия", OrderSortState.MinOzonCommissionAsc, OrderSortState
 038        new("ProfitSort", "#thProfit a", "Прибыль", OrderSortState.ProfitAsc, OrderSortState.ProfitDesc),
 039        new("DiscountSort", "#thDiscount a", "Наценка %", OrderSortState.DiscountAsc, OrderSortState.DiscountDesc),
 040    ];
 41
 42    public static IReadOnlyList<OrderIndexSortAjaxLink> Build(OrderSortState currentSort, IReadOnlyDictionary<string, Or
 43    {
 044        var result = new List<OrderIndexSortAjaxLink>(Columns.Length);
 045        foreach (var col in Columns)
 46        {
 047            if (!nextSortStates.TryGetValue(col.Key, out var nextSort))
 48            {
 49                continue;
 50            }
 51
 052            result.Add(new OrderIndexSortAjaxLink(
 053                col.Selector,
 054                nextSort.ToString(),
 055                FormatLabel(col.BaseText, currentSort, col.Asc, col.Desc)));
 56        }
 57
 058        return result;
 59    }
 60
 61    private static string FormatLabel(string text, OrderSortState current, OrderSortState asc, OrderSortState desc)
 62    {
 063        if (current == asc)
 64        {
 065            return text + "↑";
 66        }
 67
 068        if (current == desc)
 69        {
 070            return text + "↓";
 71        }
 72
 073        return text;
 74    }
 75}
 76
 77public sealed record OrderIndexSortAjaxLink(string Selector, string NextSort, string Label);