Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/development' into f…
Browse files Browse the repository at this point in the history
…eature/custom-theme-primary-color

# Conflicts:
#	WoWsShipBuilder.Common/Features/ShipComparison/ShipComparison.razor
  • Loading branch information
iTTou committed May 19, 2024
2 parents 901c54e + dbbf143 commit 704b3e9
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,10 @@
</CellTemplate>
</TemplateColumn>

<TemplateColumn ID="@($"{dataSectionString}_{columnTitleCanHit}")" Hidden="@element.IsColumnHidden.Invoke(dataSectionString, columnTitleCanHit)" T="GridDataWrapper" Title="@columnTitleCanHit" HeaderClass="column-text-center" CellClass="column-text-center" SortBy="@(x=> !x.TorpedoBombers.WeaponCanHit.Any() ? 0 : x.TorpedoBombers.WeaponCanHit.First().Count)">
<TemplateColumn ID="@($"{dataSectionString}_{columnTitleCanHit}")" Hidden="@element.IsColumnHidden.Invoke(dataSectionString, columnTitleCanHit)" T="GridDataWrapper" Title="@columnTitleCanHit" HeaderClass="column-text-center" CellClass="column-text-center" SortBy="@(x => !x.TorpedoBombers.WeaponCanHit.Any() ? 0 : x.TorpedoBombers.WeaponCanHit.First().Count)">
<HeaderTemplate>

</HeaderTemplate>
<CellTemplate>
@if (context.Item.TorpedoBombers.WeaponCanHit.Any())
{
Expand All @@ -304,8 +307,8 @@
var classes = torps[i];
if (classes.IsEmpty && context.Item.TorpedoBombers.WeaponDamage.Any())
{
<MudStack row Justify="Justify.Center" AlignItems="AlignItems.Center">
@foreach (var shipClass in Enum.GetValues(typeof(ShipClass)).Cast<ShipClass>().ToList())
<MudStack row Justify="Justify.Center" AlignItems="AlignItems.Center" Style="padding: inherit">
@foreach (var shipClass in Enum.GetValues(typeof(ShipClass)).Cast<ShipClass>().Where(x => x != ShipClass.Auxiliary))
{
<MudIcon ViewBox="0 0 22 10" Icon="@($"<path d=\"{ClassToPathHelper.GetSvgPathFromClass(shipClass)}\"/>")"/>
}
Expand All @@ -317,13 +320,14 @@
}
else if (!classes.IsEmpty)
{
<MudStack Row Justify="Justify.Center" AlignItems="AlignItems.Center">
<MudStack Row Justify="Justify.Center" AlignItems="AlignItems.Center" Style="padding: inherit">
@foreach (var shipClass in classes)
{
<MudIcon ViewBox="0 0 22 10" Icon="@($"<path d=\"{ClassToPathHelper.GetSvgPathFromClass(shipClass)}\"/>")"/>
}
</MudStack>
}

if (i < torps.Count - 1)
{
<MudDivider Class="my-1"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,8 @@
var classes = torps[i];
if (classes.IsEmpty && context.Item.Torpedo.Damage.Any())
{
<MudStack row Justify="Justify.Center" AlignItems="AlignItems.Center">
@foreach (var shipClass in Enum.GetValues(typeof(ShipClass)).Cast<ShipClass>().ToList())
<MudStack row Justify="Justify.Center" AlignItems="AlignItems.Center" Style="padding: inherit">
@foreach (var shipClass in Enum.GetValues(typeof(ShipClass)).Cast<ShipClass>().Where(x => x != ShipClass.Auxiliary))
{
<MudIcon ViewBox="0 0 22 10" Icon="@($"<path d=\"{ClassToPathHelper.GetSvgPathFromClass(shipClass)}\"/>")"/>
}
Expand All @@ -465,7 +465,7 @@
}
else if (!classes.IsEmpty)
{
<MudStack Row Justify="Justify.Center" AlignItems="AlignItems.Center">
<MudStack Row Justify="Justify.Center" AlignItems="AlignItems.Center" Style="padding: inherit">
@foreach (var shipClass in classes)
{
<MudIcon ViewBox="0 0 22 10" Icon="@($"<path d=\"{ClassToPathHelper.GetSvgPathFromClass(shipClass)}\"/>")"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
@foreach (var (section, columns) in switchesLayout)
{
<MudPaper Outlined Elevation="0" @key="@(section.AsString())">
<MudStack Justify="Justify.Center" AlignItems="AlignItems.Center">
<MudStack Justify="Justify.Center" AlignItems="AlignItems.Center" Spacing="0">
<MudText Typo="Typo.body2" Align="Align.Center" Style="font-weight: bold">
@(section.Localize(Localizer).ToUpper())
</MudText>
@foreach (var column in columns)
{
<MudSwitch @bind-Checked="@(switchesLayout[section][column.Key])" Label="@column.Key" LabelPosition="LabelPosition.End" Size="Size.Medium" Color="Color.Primary" @key="@($"{section}_{column}")" Style="width: 100%; white-space: nowrap" Class="ml-1"/>
<MudSwitch @bind-Value="@(switchesLayout[section][column.Key])" Label="@column.Key" LabelPosition="LabelPosition.End" Size="Size.Medium" Color="Color.Primary" @key="@($"{section}_{column}")" Style="width: 100%; white-space: nowrap" Class="ml-2 mr-n2"/>
}
</MudStack>
</MudPaper>
Expand Down Expand Up @@ -43,11 +43,11 @@
{
base.OnInitialized();

foreach (string key in HiddenColumns.Keys)
foreach (var key in HiddenColumns.Keys)
{
string[] split = key.Split('_');
var split = key.Split('_');
var section = Enum.Parse<ShipComparisonDataSections>(split[0]);
if (switchesLayout.TryGetValue(section, out Dictionary<string, bool>? dataSection))
if (switchesLayout.TryGetValue(section, out var dataSection))
{
dataSection.Add(split[1], !HiddenColumns[key]);
}
Expand Down
29 changes: 17 additions & 12 deletions WoWsShipBuilder.Common/Features/ShipComparison/ShipComparison.razor
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
@using static WoWsShipBuilder.Features.ShipComparison.GridSections.AerialTorpedoesFragment
@using static WoWsShipBuilder.Features.ShipComparison.GridSections.BombersFragment
@using static WoWsShipBuilder.Features.ShipComparison.GridSections.BombsFragment
@using System.Collections.Immutable
@using WoWsShipBuilder.Infrastructure.ApplicationTheme
@using WoWsShipBuilder.Features.Navigation

@inherits ReactiveComponentBase<ShipComparisonViewModel>
Expand Down Expand Up @@ -140,10 +138,10 @@
</MudPaper>
</MudStack>

<MudDataGrid @ref="dataGrid" T="GridDataWrapper" ServerData="@ReloadData" DragDropColumnReordering DragIndicatorSize="Size.Small" ApplyDropClassesOnDragStarted Groupable="false" SortMode="SortMode.Multiple" Hideable ShowColumnOptions="false" Filterable="false" ShowFilterIcons="false" FilterMode="DataGridFilterMode.Simple" Hover Outlined Bordered Dense Breakpoint="Breakpoint.None" Virtualize ColumnResizeMode="ResizeMode.Column" Style="overflow-y: hidden">
<MudDataGrid @ref="dataGrid" T="GridDataWrapper" ServerData="@ReloadData" DragDropColumnReordering DragIndicatorSize="Size.Small" ApplyDropClassesOnDragStarted Groupable="false" SortMode="SortMode.Multiple" Hideable ShowColumnOptions="false" Filterable="false" ShowFilterIcons="false" FilterMode="DataGridFilterMode.Simple" Hover Outlined Bordered Dense Breakpoint="Breakpoint.None" Virtualize ColumnResizeMode="ResizeMode.Column" Style="overflow-y: hidden" Class="data-grid-text-wrap">
<ToolBarContent>
<MudTextField T="string" Class="ml-0 mr-auto mt-n3" ValueChanged="Search" Placeholder="@Localizer.GetAppLocalization(nameof(Translation.ShipSelectionWindow_SearchShip)).Localization" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Clearable="true" Immediate="true" DebounceInterval="150" Style="width: 40%"/>
<MudButton OnClick="@(async () => await OpenHideColumnsDialog())" DisableElevation="true" Variant="Variant.Text" StartIcon="@Icons.Material.Outlined.Settings" Size="Size.Small" Color="Color.Secondary" Style="margin-top: -13px" Class="mx-auto">
<MudTextField T="string" Class="ml-0 mr-auto mt-n4" ValueChanged="Search" Placeholder="@Localizer.GetAppLocalization(nameof(Translation.ShipSelectionWindow_SearchShip)).Localization" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Clearable="true" Immediate="true" DebounceInterval="150" Style="width: 40%"/>
<MudButton OnClick="@(async () => await OpenHideColumnsDialog())" DisableElevation="true" Variant="Variant.Outlined" StartIcon="@Icons.Material.Outlined.Settings" Size="Size.Small" Color="Color.Secondary" Style="margin-top: -9px; height: 40px; border-color: var(--mud-palette-lines-inputs);" Class="mx-auto">
@($"{Localizer.SimpleAppLocalization(nameof(Translation.ShipComparison_HideColumns))} : {hiddenColumns.Count(x => x.Value)}")
</MudButton>
@if (ViewModel.SelectedDataSection is not (ShipComparisonDataSections.MainBattery or ShipComparisonDataSections.SecondaryBattery))
Expand All @@ -155,7 +153,7 @@
<MudNumericField Value="@(ViewModel.SelectedDataSection == ShipComparisonDataSections.SecondaryBattery ? ViewModel.SecondaryBatteryFiringRange : ViewModel.MainBatteryFiringRange)" ValueChanged="@(async range => await UpdateRange(range))" Label="@($"{Localizer.GetAppLocalization(nameof(Translation.ShipStats_Range)).Localization} ({Localizer.GetAppLocalization(nameof(Translation.Unit_KM)).Localization})")" Class="mud-data-grid-range-selector" Variant="Variant.Outlined" Immediate="true" T="double" DebounceInterval="500" Margin="Margin.Dense" Min="1" Max="50" Step="0.5"/>
}
<MudNumericField Value="@pageSize" ValueChanged="@(async size => await ChangePageSize(size))" Label="@($"{Localizer.SimpleAppLocalization(nameof(Translation.ShipComparison_Display))}:")" Class="mud-data-grid-range-selector" Variant="Variant.Outlined" Immediate T="int" DebounceInterval="500" Margin="Margin.Dense" Min="@MinPageSize" Max="@MaxPageSize"/>
<MudDataGridPager T="GridDataWrapper" Class="mr-n1" Style="margin-top: -14px; height: 45px; border-top: hidden !important;" DisableRowsPerPage InfoFormat="@GetPagerInfoFormatString()"/>
<MudDataGridPager T="GridDataWrapper" Class="mr-n1" Style="margin-top: -10px; height: 45px; border-top: hidden !important;" DisableRowsPerPage InfoFormat="@GetPagerInfoFormatString()"/>
</ToolBarContent>
<Columns>
<TemplateColumn T="GridDataWrapper" ShowColumnOptions="false" Hideable="false" Filterable="false" DragAndDropEnabled="false" StickyLeft SortBy="@(x => !ViewModel.SelectedShipList.ContainsKey(x.Id))" HeaderStyle="width:70px; background-clip: padding-box; background-color: var(--mud-palette-surface);" CellStyle="@($"width:70px; {StickyColumnsBackgroundColor}")" Resizable="false" HeaderClass="column-text-center" CellClass="column-text-center">
Expand Down Expand Up @@ -198,7 +196,7 @@
</ChildContent>
<TooltipContent>
<MudPaper Outlined Class="pa-2">
<MudText>@($"{Localizer.SimpleAppLocalization(context.Item.ShipCategory.ShipCategoryToString())} {Localizer.SimpleAppLocalization(context.Item.ShipClass.ShipClassToString())}")</MudText>
<MudText>@($"{Localizer.SimpleAppLocalization(context.Item.ShipClass.ShipClassToString())}, {Localizer.SimpleAppLocalization(context.Item.ShipCategory.ShipCategoryToString())}")</MudText>
</MudPaper>
</TooltipContent>
</MudTooltip>
Expand All @@ -218,7 +216,14 @@
</MudTooltip>
</CellTemplate>
</TemplateColumn>
<TemplateColumn ID="@($"{ShipComparisonDataSections.General.AsString()}_{Localizer.SimpleAppLocalization(nameof(Translation.ChartsWeb_Build))}")" T="GridDataWrapper" Title="@Localizer.SimpleAppLocalization(nameof(Translation.ChartsWeb_Build))" Hidden="@GetColumnDisplayStatus($"{ShipComparisonDataSections.General.AsString()}_{Localizer.SimpleAppLocalization(nameof(Translation.ChartsWeb_Build))}")" CellStyle="@StickyColumnsBackgroundColor" HeaderClass="column-text-center" CellClass="column-text-center">
<TemplateColumn ID="@($"{ShipComparisonDataSections.General.AsString()}_{Localizer.SimpleAppLocalization(nameof(Translation.ShipSelectionWindow_TypeFilter))}")" T="GridDataWrapper" TProperty="string" Title="@Localizer.SimpleAppLocalization(nameof(Translation.ShipSelectionWindow_TypeFilter))" Hidden="@GetColumnDisplayStatus($"{ShipComparisonDataSections.General.AsString()}_{Localizer.SimpleAppLocalization(nameof(Translation.ShipSelectionWindow_TypeFilter))}")" SortBy="@(x => x.Ship.ShipCategory.ShipCategoryToString())" CellStyle="@StickyColumnsBackgroundColor" HeaderClass="column-text-center" CellClass="column-text-center">
<CellTemplate>
<MudText Typo="Typo.body2">
@Localizer.SimpleAppLocalization(context.Item.ShipCategory.ShipCategoryToString())
</MudText>
</CellTemplate>
</TemplateColumn>
<TemplateColumn ID="@($"{ShipComparisonDataSections.General.AsString()}_{Localizer.SimpleAppLocalization(nameof(Translation.ChartsWeb_Build))}1")" T="GridDataWrapper" Title="@Localizer.SimpleAppLocalization(nameof(Translation.ChartsWeb_Build))" Hidden="@GetColumnDisplayStatus($"{ShipComparisonDataSections.General.AsString()}_{Localizer.SimpleAppLocalization(nameof(Translation.ChartsWeb_Build))}")" CellStyle="@StickyColumnsBackgroundColor" HeaderClass="column-text-center" CellClass="column-text-center">
<CellTemplate>
@if (!string.IsNullOrEmpty(context.Item.BuildName))
{
Expand Down Expand Up @@ -415,7 +420,7 @@
ViewModel.ShowPinnedShipsOnly = true;
}

ImmutableList<ShipBuildContainer>? buildContainers = SessionStateCache.GetAndResetBuildTransferContainers();
var buildContainers = SessionStateCache.GetAndResetBuildTransferContainers();
if (buildContainers is not null)
{
await AddShip(buildContainers, false);
Expand All @@ -438,7 +443,7 @@
{
MetricsService.PageAccessCount.WithLabels("comparison").Inc();

hiddenColumns = dataGrid.RenderedColumns.Where(x => x.Hideable is true).ToDictionary(x => x.FieldId, x => hiddenColumns.TryGetValue(x.FieldId, out bool hidden) && hidden);
hiddenColumns = dataGrid.RenderedColumns.Where(x => x.Hideable is not false).ToDictionary(x => x.FieldId, x => hiddenColumns.TryGetValue(x.FieldId, out var hidden) && hidden);

NavManager.TryGetQueryString(HiddenColumnsUrlParameter, out hiddeColumnsUrlString);
if (string.IsNullOrEmpty(hiddeColumnsUrlString))
Expand Down Expand Up @@ -487,7 +492,7 @@
}

MetricsService.BuildConfigurationDialogUsage.WithLabels("comparison").Inc();
IEnumerable<ShipBuildContainer>? results = await buildConfigurationHelper.ShowDialogAsync(shipBuildContainers);
var results = await buildConfigurationHelper.ShowDialogAsync(shipBuildContainers);
isDialogOpen = false;

if (results is not null)
Expand Down Expand Up @@ -674,7 +679,7 @@

private bool GetColumnDisplayStatus(string columnId)
{
return hiddenColumns.TryGetValue(columnId, out bool value) && value;
return hiddenColumns.TryGetValue(columnId, out var value) && value;
}

private async Task OpenHideColumnsDialog()
Expand Down
6 changes: 5 additions & 1 deletion WoWsShipBuilder.Common/wwwroot/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ img.kofiimg {
span.kofitext {
color: #dedede ;
letter-spacing: -0.15px ;
text-wrap: none;
text-wrap: inherit;
vertical-align: middle;
line-height: 33px ;
padding: 0;
Expand Down Expand Up @@ -263,6 +263,10 @@ div.mud-expand-panel {
background-color: color-mix(in srgb, var(--mud-palette-grey-dark), transparent 40%);
}

.data-grid-text-wrap * {
word-break: keep-all
}

.mud-data-grid button.drag-icon-options {
visibility: hidden;
width: 0;
Expand Down

0 comments on commit 704b3e9

Please sign in to comment.