|
@@ -83,7 +83,7 @@ namespace InABox.Core
|
|
|
{
|
|
|
public virtual Columns<TLookup> DefineColumns() => Columns.None<TLookup>();
|
|
|
|
|
|
- public virtual string? FormatDisplay(CoreRow row) =>
|
|
|
+ public virtual string FormatDisplay(CoreRow row) =>
|
|
|
LookupFactory.FormatLookup<TLookup>(row.ToDictionary(), new string[] { "Display" });
|
|
|
|
|
|
public virtual Filter<TLookup>? DefineFilter(TEntity[] items) => null;
|
|
@@ -109,7 +109,7 @@ namespace InABox.Core
|
|
|
|
|
|
IColumns ILookupDefinitionGenerator.DefineColumns() => DefineColumns();
|
|
|
|
|
|
- String ILookupDefinitionGenerator.FormatDisplay(CoreRow row) => FormatDisplay(row);
|
|
|
+ string ILookupDefinitionGenerator.FormatDisplay(CoreRow row) => FormatDisplay(row);
|
|
|
|
|
|
IFilter? ILookupDefinitionGenerator.DefineFilter(BaseObject[] items) => DefineFilter(items as TEntity[]);
|
|
|
|
|
@@ -438,6 +438,19 @@ namespace InABox.Core
|
|
|
return DefaultFormatLookup(values, exclude);
|
|
|
}
|
|
|
|
|
|
+ public static string FormatLookup(Type TEntity, CoreRow row, string column)
|
|
|
+ {
|
|
|
+ var generator = GetLookupGenerator(TEntity, column);
|
|
|
+ if(generator != null)
|
|
|
+ {
|
|
|
+ return generator.FormatDisplay(row);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return FormatLookup(TEntity, row.ToDictionary(new[] { "Display" }), Array.Empty<string>());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static ISortOrder? DefineSort(Type T)
|
|
|
{
|
|
|
return GetDefinition(T)?.DefineSortOrder();
|
|
@@ -489,6 +502,10 @@ namespace InABox.Core
|
|
|
|
|
|
public static string FormatLookup<T>(Dictionary<string, object?> values, IEnumerable<string> exclude) => FormatLookup(typeof(T), values, exclude);
|
|
|
|
|
|
+ public static string FormatLookup<TEntity, TLookup, TLookupLink>(CoreRow row, Expression<Func<TEntity, TLookupLink>> column)
|
|
|
+ where TLookupLink : IEntityLink<TLookup>
|
|
|
+ => FormatLookup(typeof(TEntity), row, CoreUtils.GetFullPropertyName(column, "."));
|
|
|
+
|
|
|
public static void OnCreateItem<TEntity, TLookup, TLookupLink>(Expression<Func<TEntity, TLookupLink>> column, TEntity[] items, TLookup item)
|
|
|
where TLookupLink : IEntityLink<TLookup>
|
|
|
where TEntity : BaseObject
|