-
-
Notifications
You must be signed in to change notification settings - Fork 385
Expand file tree
/
Copy pathAutoGenerateColumnAttribute.cs
More file actions
329 lines (252 loc) · 9.01 KB
/
AutoGenerateColumnAttribute.cs
File metadata and controls
329 lines (252 loc) · 9.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
namespace BootstrapBlazor.Components;
/// <summary>
/// AutoGenerateColumn attribute class, used to mark auto-generated columns in <see cref="Table{TItem}"/>
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
public class AutoGenerateColumnAttribute : AutoGenerateBaseAttribute, ITableColumn
{
/// <summary>
/// Gets or sets the display order. The rules are as follows:
/// <para></para>
/// >0 for the front, 1,2,3...
/// <para></para>
/// =0 for the middle (default)
/// <para></para>
/// <0 for the back, ...-3,-2,-1
/// </summary>
public int Order { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public bool DefaultSort { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public bool SkipValidate { get; set; }
/// <summary>
/// Gets or sets whether the column is read-only when adding a new item. Default is null, using the <see cref="IEditorItem.Readonly"/> value.
/// </summary>
public bool IsReadonlyWhenAdd { get; set; }
bool? ITableColumn.IsReadonlyWhenAdd
{
get => IsReadonlyWhenAdd;
set => IsReadonlyWhenAdd = value ?? false;
}
/// <summary>
/// Gets or sets whether the column is read-only when editing an item. Default is null, using the <see cref="IEditorItem.Readonly"/> value.
/// </summary>
public bool IsReadonlyWhenEdit { get; set; }
bool? ITableColumn.IsReadonlyWhenEdit
{
get => IsReadonlyWhenEdit;
set => IsReadonlyWhenEdit = value ?? false;
}
/// <summary>
/// Gets or sets whether the column is visible when adding a new item. Default is null, using the <see cref="AutoGenerateBaseAttribute.Visible"/> value.
/// </summary>
public bool IsVisibleWhenAdd { get; set; } = true;
bool? ITableColumn.IsVisibleWhenAdd
{
get => IsVisibleWhenAdd;
set => IsVisibleWhenAdd = value ?? true;
}
/// <summary>
/// Gets or sets whether the column is visible when editing an item. Default is null, using the <see cref="AutoGenerateBaseAttribute.Visible"/> value.
/// </summary>
public bool IsVisibleWhenEdit { get; set; } = true;
Func<ITableColumn, string?, SearchFilterAction>? ITableColumn.CustomSearch { get; set; }
bool? ITableColumn.IsVisibleWhenEdit
{
get => IsVisibleWhenEdit;
set => IsVisibleWhenEdit = value ?? true;
}
bool? IEditorItem.Required { get; set; }
bool? ITableColumn.IsRequiredWhenAdd { get; set; }
bool? ITableColumn.IsRequiredWhenEdit { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public string? RequiredErrorMessage { get; set; }
/// <summary>
/// Gets or sets whether to show label tooltip. Mostly used when the label text is too long and gets truncated. Default is false.
/// </summary>
public bool ShowLabelTooltip { get; set; }
bool? IEditorItem.ShowLabelTooltip
{
get => ShowLabelTooltip;
set => ShowLabelTooltip = value ?? false;
}
/// <summary>
/// Gets or sets the default sort order. Default is SortOrder.Unset.
/// </summary>
public SortOrder DefaultSortOrder { get; set; }
IEnumerable<SelectedItem>? IEditorItem.Items { get; set; }
/// <summary>
/// Gets or sets the column width.
/// </summary>
public int Width { get; set; }
int? ITableColumn.Width
{
get => Width <= 0 ? null : Width;
set => Width = value ?? 0;
}
/// <summary>
/// <inheritdoc/>
/// </summary>
public bool Fixed { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public string? CssClass { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public BreakPoint ShownWithBreakPoint { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public string? FormatString { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public string? PlaceHolder { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public Func<object?, Task<string?>>? Formatter { get; set; }
RenderFragment<object>? IEditorItem.EditTemplate { get; set; }
RenderFragment<ITableColumn>? ITableColumn.HeaderTemplate { get; set; }
RenderFragment<ITableColumn>? ITableColumn.ToolboxTemplate { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public Type? ComponentType { get; set; }
IEnumerable<KeyValuePair<string, object>>? IEditorItem.ComponentParameters { get; set; }
RenderFragment<object>? ITableColumn.Template { get; set; }
RenderFragment<object>? ITableColumn.SearchTemplate { get; set; }
RenderFragment? ITableColumn.FilterTemplate { get; set; }
Func<object?, Task<string?>>? ITableColumn.GetTooltipTextCallback { get; set; }
bool? ITableColumn.Searchable { get => Searchable; set => Searchable = value ?? false; }
bool? ITableColumn.Filterable { get => Filterable; set => Filterable = value ?? false; }
bool? ITableColumn.Sortable { get => Sortable; set => Sortable = value ?? false; }
bool? ITableColumn.TextWrap { get => TextWrap; set => TextWrap = value ?? false; }
bool? ITableColumn.TextEllipsis { get => TextEllipsis; set => TextEllipsis = value ?? false; }
bool? IEditorItem.Ignore { get => Ignore; set => Ignore = value ?? false; }
bool? IEditorItem.Readonly { get => Readonly; set => Readonly = value ?? false; }
bool? ITableColumn.Visible { get => Visible; set => Visible = value ?? true; }
bool? ITableColumn.ShowTips { get => ShowTips; set => ShowTips = value ?? false; }
bool? ITableColumn.ShowCopyColumn { get => ShowCopyColumn; set => ShowCopyColumn = value ?? false; }
Alignment? ITableColumn.Align { get => Align; set => Align = value ?? Alignment.None; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public string? Step { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public int Rows { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public int Cols { get; set; }
IFilter? ITableColumn.Filter { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
[NotNull]
public Type? PropertyType { get; internal set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public string? Text { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
[NotNull]
internal string? FieldName { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public bool ShowSearchWhenSelect { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
[Obsolete("已弃用,请删除;Deprecated, please delete")]
[ExcludeFromCodeCoverage]
public bool IsFixedSearchWhenSelect { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public bool IsPopover { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
IEnumerable<SelectedItem>? ILookup.Lookup { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
ILookupService? ILookup.LookupService { get; set; }
/// <summary>
/// <inheritdoc/>>
/// </summary>
public string? LookupServiceKey { get; set; }
/// <summary>
/// <inheritdoc/>>
/// </summary>
public object? LookupServiceData { get; set; }
/// <summary>
/// <inheritdoc/>>
/// </summary>
public StringComparison LookupStringComparison { get; set; } = StringComparison.OrdinalIgnoreCase;
Action<TableCellArgs>? ITableColumn.OnCellRender { get; set; }
List<IValidator>? IEditorItem.ValidateRules { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public virtual string GetDisplayName() => Text ?? "";
/// <summary>
/// <inheritdoc/>
/// </summary>
public string GetFieldName() => FieldName;
/// <summary>
/// <inheritdoc/>
/// </summary>
public string? GroupName { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public int GroupOrder { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public bool HeaderTextWrap { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public bool ShowHeaderTooltip { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public string? HeaderTextTooltip { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public bool HeaderTextEllipsis { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public bool IsMarkupString { get; set; }
/// <summary>
/// <inheritdoc/>
/// </summary>
public bool IgnoreWhenExport { get; set; }
bool? ITableColumn.IgnoreWhenExport
{
get => IgnoreWhenExport;
set => IgnoreWhenExport = value ?? false;
}
}