add ban management page
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Html;
|
||||
|
||||
namespace WebfrontCore.ViewModels;
|
||||
|
||||
@ -19,7 +20,7 @@ public class TableInfo
|
||||
|
||||
public class RowDefinition
|
||||
{
|
||||
public List<string> Datum { get; } = new();
|
||||
public List<ColumnTypeDefinition> Datum { get; } = new();
|
||||
}
|
||||
|
||||
public class ColumnDefinition
|
||||
@ -28,6 +29,23 @@ public class ColumnDefinition
|
||||
public string ColumnSpan { get; set; }
|
||||
}
|
||||
|
||||
public enum ColumnType
|
||||
{
|
||||
Text,
|
||||
Link,
|
||||
Icon,
|
||||
Button
|
||||
}
|
||||
|
||||
public class ColumnTypeDefinition
|
||||
{
|
||||
public ColumnType Type { get; set; }
|
||||
public string Value { get; set; }
|
||||
public string Data { get; set; }
|
||||
public IHtmlContent Template { get; set; }
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
public static class TableInfoExtensions
|
||||
{
|
||||
public static TableInfo WithColumns(this TableInfo info, IEnumerable<string> columns)
|
||||
@ -42,6 +60,16 @@ public static class TableInfoExtensions
|
||||
|
||||
public static TableInfo WithRows<T>(this TableInfo info, IEnumerable<T> source,
|
||||
Func<T, IEnumerable<string>> selector)
|
||||
{
|
||||
return WithRows(info, source, (outer) => selector(outer).Select(item => new ColumnTypeDefinition
|
||||
{
|
||||
Value = item,
|
||||
Type = ColumnType.Text
|
||||
}));
|
||||
}
|
||||
|
||||
public static TableInfo WithRows<T>(this TableInfo info, IEnumerable<T> source,
|
||||
Func<T, IEnumerable<ColumnTypeDefinition>> selector)
|
||||
{
|
||||
info.Rows.AddRange(source.Select(row =>
|
||||
{
|
||||
|
Reference in New Issue
Block a user