< Summary

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

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Selector()100%210%

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{
 8    private sealed record SortColumn(string Key, string Selector, string BaseText, OrderSortState Asc, OrderSortState De
 9
 10    private static readonly SortColumn[] Columns =
 11    [
 12        new("ShipmentNumberSort", "#thShipmentNumberSort a", "Номер заказа", OrderSortState.ShipmentNumberAsc, OrderSort
 13        new("DeliverySort", "#thDeliverySort a", "Доставка", OrderSortState.DeliveryAsc, OrderSortState.DeliveryDesc),
 14        new("OzonClient", "#thOzonClient a", "Клиент", OrderSortState.OzonClientAsc, OrderSortState.OzonClientDesc),
 15        new("DeliveryCitySort", "#thDeliveryCity a", "Город доставки", OrderSortState.DeliveryCityAsc, OrderSortState.De
 16        new("ProcessingDateSort", "#thProcessingDate a", "Принят", OrderSortState.ProcessingDateAsc, OrderSortState.Proc
 17        new("ShippingDateSort", "#thShippingDate a", "Дата отгр.", OrderSortState.ShippingDateAsc, OrderSortState.Shippi
 18        new("DeliveryPeriodSort", "#shipmentTable th[data-column=\"period\"] a[data-full-title=\"Срок доставки\"]", "Сро
 19        new("TimeLeftSort", "#shipmentTable th[data-column=\"period\"] a[data-full-title=\"Осталось\"]", "Остал.", Order
 20        new("ArticleSort", "#thArticle a", "Key", OrderSortState.ArticleAsc, OrderSortState.ArticleDesc),
 21        new("ManufacturerSort", "#thManufacturer a", "Производитель", OrderSortState.ManufacturerAsc, OrderSortState.Man
 22        new("ProductNameSort", "#thProductName a", "Наименование товара", OrderSortState.ProductNameAsc, OrderSortState.
 23        new("StatusSort", "#thStatusOzon a", "Статус клиента", OrderSortState.StatusAsc, OrderSortState.StatusDesc),
 24        new("AppStatusIdSort", "#thStatus a", "Статус", OrderSortState.AppStatusIdAsc, OrderSortState.AppStatusIdDesc),
 25        new("ShipmentWarehouseSort", "#thShipmentWarehouse a", "Склад", OrderSortState.ShipmentWarehouseIdAsc, OrderSort
 26        new("LastStatusChangeDateSort", "#shipmentTable a[data-full-title=\"Дата изменения статуса\"]", "Дата изм. стату
 27        new("SupplierSort", "#thSupplier a", "Поставщик", OrderSortState.SupplierAsc, OrderSortState.SupplierDesc),
 28        new("OrderNumberToSupplierSort", "#thOrderNumberToSupplierSort a", "Номер заказа п.", OrderSortState.OrderNumber
 29        new("CategorySort", "#thCategory a", "Категория", OrderSortState.CategoryAsc, OrderSortState.CategoryDesc),
 30        new("VolumeSort", "#thVolume a", "Объём", OrderSortState.VolumeAsc, OrderSortState.VolumeDesc),
 31        new("CurrentPriceSort", "#thCurrentPrice a", "Цена сайта", OrderSortState.CurrentPriceAsc, OrderSortState.Curren
 32        new("QuantitySort", "#thQuantity a", "Кол-во", OrderSortState.QuantityAsc, OrderSortState.QuantityDesc),
 33        new("PriceSort", "#thPrice a", "Цена", OrderSortState.PriceAsc, OrderSortState.PriceDesc),
 34        new("ShipmentAmountSort", "#thShipmentAmount a", "Сумма отпр.", OrderSortState.ShipmentAmountAsc, OrderSortState
 35        new("PurchasePriceSort", "#thPurchasePrice a", "Закупка", OrderSortState.PurchasePriceAsc, OrderSortState.Purcha
 36        new("CostPriceсеSort", "#thCostPriceсе a", "Себест.", OrderSortState.CostPriceAsc, OrderSortState.CostPriceDesc)
 37        new("OzonCommissionSort", "#thOzonCommission a", "Комиссия", OrderSortState.MinOzonCommissionAsc, OrderSortState
 38        new("ProfitSort", "#thProfit a", "Прибыль", OrderSortState.ProfitAsc, OrderSortState.ProfitDesc),
 39        new("DiscountSort", "#thDiscount a", "Наценка %", OrderSortState.DiscountAsc, OrderSortState.DiscountDesc),
 40    ];
 41
 42    public static IReadOnlyList<OrderIndexSortAjaxLink> Build(OrderSortState currentSort, IReadOnlyDictionary<string, Or
 43    {
 44        var result = new List<OrderIndexSortAjaxLink>(Columns.Length);
 45        foreach (var col in Columns)
 46        {
 47            if (!nextSortStates.TryGetValue(col.Key, out var nextSort))
 48            {
 49                continue;
 50            }
 51
 52            result.Add(new OrderIndexSortAjaxLink(
 53                col.Selector,
 54                nextSort.ToString(),
 55                FormatLabel(col.BaseText, currentSort, col.Asc, col.Desc)));
 56        }
 57
 58        return result;
 59    }
 60
 61    private static string FormatLabel(string text, OrderSortState current, OrderSortState asc, OrderSortState desc)
 62    {
 63        if (current == asc)
 64        {
 65            return text + "↑";
 66        }
 67
 68        if (current == desc)
 69        {
 70            return text + "↓";
 71        }
 72
 73        return text;
 74    }
 75}
 76
 077public sealed record OrderIndexSortAjaxLink(string Selector, string NextSort, string Label);

Methods/Properties

get_Selector()