Skip to content

Commit

Permalink
datasets: more doccomments
Browse files Browse the repository at this point in the history
  • Loading branch information
exyi committed Apr 27, 2024
1 parent 1295be1 commit 882b6e7
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/Framework/Core/Controls/Options/GridViewDataSetOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace DotVVM.Framework.Controls
{
/// <summary> Contains filtering, sorting, and paging options of a <see cref="GridViewDataSet{T}" />. </summary>
public class GridViewDataSetOptions<TFilteringOptions, TSortingOptions, TPagingOptions>
where TFilteringOptions : IFilteringOptions
where TSortingOptions : ISortingOptions
Expand All @@ -12,6 +13,7 @@ public class GridViewDataSetOptions<TFilteringOptions, TSortingOptions, TPagingO
public TPagingOptions PagingOptions { get; set; } = default!;
}

/// <summary> Contains filtering, sorting, and paging options of a <see cref="GridViewDataSet{T}" /> </summary>
public class GridViewDataSetOptions : GridViewDataSetOptions<NoFilteringOptions, SortingOptions, PagingOptions>
{
}
Expand Down
3 changes: 3 additions & 0 deletions src/Framework/Core/Controls/Options/IPagingOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ namespace DotVVM.Framework.Controls
/// <summary>
/// Represents a marker interface for GridViewDataSet paging options.
/// </summary>
/// <seealso cref="PagingOptions"/>
/// <seealso cref="NextTokenHistoryPagingOptions"/>
/// <seealso cref="NextTokenPagingOptions"/>
public interface IPagingOptions
{
}
Expand Down
4 changes: 3 additions & 1 deletion src/Framework/Core/Controls/Options/ISortingOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ namespace DotVVM.Framework.Controls
/// <summary>
/// Represents a marker interface for sorting options.
/// </summary>
/// <seealso cref="SortingOptions" />
/// <seealso cref="MultiCriteriaSortingOptions" />
/// <seealso cref="NoSortingOptions" />
public interface ISortingOptions
{
}
Expand Down Expand Up @@ -37,7 +40,6 @@ public interface ISortingStateCapability : ISortingOptions
/// Determines whether the column with specified sort expression is sorted in descending order.
/// </summary>
bool IsColumnSortedDescending(string? sortExpression);

}

/// <summary>
Expand Down
10 changes: 10 additions & 0 deletions src/Framework/Core/Controls/Options/MultiCriteriaSortingOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@

namespace DotVVM.Framework.Controls;

/// <summary>
/// Sorting options which supports sorting by multiple columns.
/// In the default implementation, the sorting is applied in the reverse order of clicks on the columns - i.e. the last clicked column is the primary sort criterion, the previous one is the secondary criterion, etc.
/// It behaves similarly to the standard <see cref="SortingOptions"/>, except that sorting is "stable".
/// Maximum number of sort criteria can be set by <see cref="MaxSortCriteriaCount"/>, and is 3 by default.
/// </summary>
public class MultiCriteriaSortingOptions : ISortingOptions, ISortingStateCapability, ISortingSetSortExpressionCapability, IApplyToQueryable
{
public IList<SortCriterion> Criteria { get; set; } = new List<SortCriterion>();

/// <summary> Maximum length of the <see cref="Criteria" /> list. When exceeded, the overhanging tail is discarded. </summary>
public int MaxSortCriteriaCount { get; set; } = 3;

public virtual IQueryable<T> ApplyToQueryable<T>(IQueryable<T> queryable)
Expand All @@ -20,6 +27,7 @@ public virtual IQueryable<T> ApplyToQueryable<T>(IQueryable<T> queryable)
return queryable;
}

/// <summary> When overridden in derived class, it can disallow sorting by certain columns. </summary>
public virtual bool IsSortingAllowed(string sortExpression) => true;

public virtual void SetSortExpression(string? sortExpression)
Expand Down Expand Up @@ -57,7 +65,9 @@ public virtual void SetSortExpression(string? sortExpression)
}
}

/// <summary> Returns if the specified column is sorted in ascending order in any of the <see cref="Criteria"/> </summary>
public bool IsColumnSortedAscending(string? sortExpression) => Criteria.Any(c => c.SortExpression == sortExpression && !c.SortDescending);

/// <summary> Returns if the specified column is sorted in descending order in any of the <see cref="Criteria"/> </summary>
public bool IsColumnSortedDescending(string? sortExpression) => Criteria.Any(c => c.SortExpression == sortExpression && c.SortDescending);
}
8 changes: 6 additions & 2 deletions src/Framework/Core/Controls/Options/PagingOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace DotVVM.Framework.Controls
{
/// <summary>
/// Represents settings for paging.
/// Represents settings for offset-based paging using <see cref="PageIndex" /> and <see cref="PageSize" />.
/// </summary>
public class PagingOptions : IPagingOptions, IPagingFirstPageCapability, IPagingLastPageCapability, IPagingPreviousPageCapability, IPagingNextPageCapability, IPagingPageIndexCapability, IPagingPageSizeCapability, IPagingTotalItemsCountCapability, IApplyToQueryable, IPagingOptionsLoadingPostProcessor
{
Expand Down Expand Up @@ -57,25 +57,29 @@ public int PagesCount
/// </summary>
public int TotalItemsCount { get; set; }

/// <summary> Sets PageIndex to zero. </summary>
public void GoToFirstPage() => PageIndex = 0;

/// <summary> Sets PageIndex to the last page (PagesCount - 1). </summary>
public void GoToLastPage() => PageIndex = PagesCount - 1;

/// <summary> Increments the page counter, if the next page exists. </summary>
public void GoToNextPage()
{
if (PageIndex < PagesCount - 1)
{
PageIndex++;
}
}
/// <summary> Decrements the page counter, unless PageIndex is already zero. </summary>
public void GoToPreviousPage()
{
if (PageIndex > 0)
{
PageIndex--;
}
}

/// <summary> Sets page index to the <paramref name="pageIndex"/>. If the index overflows, PageIndex is set to the first/last page. </summary>
public void GoToPage(int pageIndex)
{
if (PageIndex >= 0 && PageIndex < PagesCount)
Expand Down
10 changes: 5 additions & 5 deletions src/Framework/Framework/Controls/GridViewCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@

namespace DotVVM.Framework.Controls
{
/// <summary> Contains pre-created data bindings for the <see cref="GridView" /> components. Instance can obtained from <see cref="GridViewDataSetBindingProvider" /> </summary>
public class GridViewCommands
{

private readonly ConcurrentDictionary<string?, IValueBinding<bool>> isSortColumnAscending = new();
private readonly ConcurrentDictionary<string?, IValueBinding<bool>> isSortColumnDescending = new();
private readonly ConcurrentDictionary<string, IValueBinding<bool>> isSortColumnAscending = new();
private readonly ConcurrentDictionary<string, IValueBinding<bool>> isSortColumnDescending = new();

public ICommandBinding? SetSortExpression { get; init; }

internal IValueBinding<Func<string, bool>>? IsColumnSortedAscending { get; init; }
internal IValueBinding<Func<string, bool>>? IsColumnSortedDescending { get; init; }

public IValueBinding<bool>? GetIsColumnSortedAscendingBinding(string? sortExpression)
public IValueBinding<bool>? GetIsColumnSortedAscendingBinding(string sortExpression)
{
if (IsColumnSortedAscending == null)
{
Expand All @@ -24,7 +24,7 @@ public class GridViewCommands
return isSortColumnAscending.GetOrAdd(sortExpression, _ => IsColumnSortedAscending.Select(a => a(sortExpression)));
}

public IValueBinding<bool>? GetIsColumnSortedDescendingBinding(string? sortExpression)
public IValueBinding<bool>? GetIsColumnSortedDescendingBinding(string sortExpression)
{
if (IsColumnSortedDescending == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

namespace DotVVM.Framework.Controls;

/// <summary> Creates data bindings for GridView, DataPager and related components. </summary>
public class GridViewDataSetBindingProvider
{
private readonly BindingCompilationService service;
Expand Down

0 comments on commit 882b6e7

Please sign in to comment.