Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into darc-main-381ecc83-90…
Browse files Browse the repository at this point in the history
…b3-4dc9-a216-48d58896198a
  • Loading branch information
sebastienros committed Jan 17, 2025
2 parents 61b844a + fe21c9a commit 15c4ff9
Show file tree
Hide file tree
Showing 10 changed files with 293 additions and 254 deletions.
3 changes: 1 addition & 2 deletions docs/APIReviewPrinciples.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ The primary goal of this document is to provide a reference for our team and con

We encourage you to refer to this document regularly and contribute to its evolution as we continue to refine our API review process. We also encourage you to follow the [.NET framework design guidelines](https://learn.microsoft.com/dotnet/standard/design-guidelines/) for more general guidance not specific to the dotnet/aspnetcore repository.


## Principles
- Principle 1

## Conventions
- Convention 1
- Convention 1
324 changes: 162 additions & 162 deletions eng/Version.Details.xml

Large diffs are not rendered by default.

162 changes: 81 additions & 81 deletions eng/Versions.props

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
#nullable enable
Microsoft.AspNetCore.Components.QuickGrid.QuickGrid<TGridItem>.RowClass.get -> System.Func<TGridItem, string?>?
Microsoft.AspNetCore.Components.QuickGrid.QuickGrid<TGridItem>.RowClass.set -> void
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@

private void RenderRow(RenderTreeBuilder __builder, int rowIndex, TGridItem item)
{
<tr @key="@(ItemKey(item))" aria-rowindex="@rowIndex">
var rowClass = RowClass?.Invoke(item);
<tr @key="@(ItemKey(item))" aria-rowindex="@rowIndex" class="@rowClass">
@foreach (var col in _columns)
{
<td class="@ColumnClass(col)" @key="@col">@{ col.CellContent(__builder, item); }</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ public partial class QuickGrid<TGridItem> : IAsyncDisposable
/// </summary>
[Parameter(CaptureUnmatchedValues = true)] public IReadOnlyDictionary<string, object>? AdditionalAttributes { get; set; }

/// <summary>
/// Optional. A callback to be invoked for each rendered row to specify a CSS class.
/// </summary>
[Parameter] public Func<TGridItem, string?>? RowClass { get; set; }

[Inject] private IServiceProvider Services { get; set; } = default!;
[Inject] private IJSRuntime JS { get; set; } = default!;

Expand Down
27 changes: 27 additions & 0 deletions src/Components/test/E2ETest/Tests/QuickGridTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,31 @@ public void AdditionalAttributesApplied()
Assert.Equal("somevalue", grid.GetDomAttribute("custom-attrib"));
Assert.Contains("custom-class-attrib", grid.GetDomAttribute("class")?.Split(" "));
}

[Fact]
public void RowClassApplied()
{
var grid = app.FindElement(By.CssSelector("#grid > table"));
var rows = grid.FindElements(By.CssSelector("tbody > tr"));

bool isJulieRowFound = false;
foreach (var row in rows)
{
var firstName = row.FindElement(By.CssSelector("td:nth-child(2)")).Text;
if (firstName == "Julie")
{
isJulieRowFound = true;
Assert.Equal("highlight", row.GetDomAttribute("class"));
}
else
{
Assert.Null(row.GetDomAttribute("class"));
}
}

if (!isJulieRowFound)
{
Assert.Fail("No row found for Julie to highlight.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<h3>Sample QuickGrid Component</h3>

<div id="grid">
<QuickGrid Items="@FilteredPeople" Pagination="@pagination" custom-attrib="somevalue" class="custom-class-attrib">
<QuickGrid Items="@FilteredPeople" Pagination="@pagination" RowClass="HighlightJulie" custom-attrib="somevalue" class="custom-class-attrib">
<PropertyColumn Property="@(p => p.PersonId)" Sortable="true" />
<PropertyColumn Property="@(p => p.firstName)" Sortable="true">
<ColumnOptions>
<div class="search-box">
<input type="search" autofocus @bind="firstNameFilter" @bind:event="oninput" placeholder="First name..." />
</div>
</ColumnOptions>
</PropertyColumn>
<ColumnOptions>
<div class="search-box">
<input type="search" autofocus @bind="firstNameFilter" @bind:event="oninput" placeholder="First name..." />
</div>
</ColumnOptions>
</PropertyColumn>
<PropertyColumn Property="@(p => p.lastName)" Sortable="true" />
<PropertyColumn Property="@(p => p.BirthDate)" Format="yyyy-MM-dd" Sortable="true" />
<PropertyColumn Title="Age in years" Property="@(p => ComputeAge(p.BirthDate))" Sortable="true"/>
Expand All @@ -27,6 +27,8 @@
int ComputeAge(DateOnly birthDate)
=> DateTime.Now.Year - birthDate.Year - (birthDate.DayOfYear < DateTime.Now.DayOfYear ? 0 : 1);

string HighlightJulie(Person person) => person.firstName == "Julie" ? "highlight" : null;

IQueryable<Person> FilteredPeople
{
get
Expand Down
3 changes: 3 additions & 0 deletions src/Installers/Windows/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
Read more here => https://github.com/dotnet/project-system/blob/main/docs/build-acceleration.md#limitations
-->
<AccelerateBuildsInVisualStudio>false</AccelerateBuildsInVisualStudio>

<!-- Suppress validation to avoid Applocker failures when running light.exe on dev machines. -->
<SuppressValidation>true</SuppressValidation>
</PropertyGroup>

</Project>

0 comments on commit 15c4ff9

Please sign in to comment.