|
@@ -14,7 +14,7 @@ public interface IDynamicDashboardTable
|
|
|
{
|
|
|
string Key { get; set; }
|
|
|
|
|
|
- IEnumerable<CoreColumn> CoreColumns { get; }
|
|
|
+ IEnumerable<CoreColumn> GetColumns(DynamicDashboardDataComponent data);
|
|
|
}
|
|
|
|
|
|
public interface IDynamicDashboardDataQuery : IDynamicDashboardTable
|
|
@@ -27,11 +27,12 @@ public interface IDynamicDashboardDataQuery : IDynamicDashboardTable
|
|
|
|
|
|
ISortOrder? SortOrder { get; set; }
|
|
|
|
|
|
- IEnumerable<CoreColumn> IDynamicDashboardTable.CoreColumns => Columns.Columns().Select(x => new CoreColumn
|
|
|
- {
|
|
|
- ColumnName = x.Name,
|
|
|
- DataType = x.Type
|
|
|
- });
|
|
|
+ IEnumerable<CoreColumn> IDynamicDashboardTable.GetColumns(DynamicDashboardDataComponent data) =>
|
|
|
+ Columns.Columns().Select(x => new CoreColumn
|
|
|
+ {
|
|
|
+ ColumnName = x.Name,
|
|
|
+ DataType = x.Type
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
public class DynamicDashboardDataQuery<T> : IDynamicDashboardDataQuery
|
|
@@ -74,8 +75,6 @@ public class DynamicDashboardAdditionalTable : IDynamicDashboardTable
|
|
|
{
|
|
|
public string Key { get; set; } = "";
|
|
|
|
|
|
- public List<CoreColumn> Columns { get; set; } = new();
|
|
|
-
|
|
|
private string? _script;
|
|
|
public string? Script
|
|
|
{
|
|
@@ -90,7 +89,7 @@ public class DynamicDashboardAdditionalTable : IDynamicDashboardTable
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- IEnumerable<CoreColumn> IDynamicDashboardTable.CoreColumns => Columns;
|
|
|
+ public IEnumerable<CoreColumn> GetColumns(DynamicDashboardDataComponent data) => SetupColumns(data);
|
|
|
|
|
|
private ScriptDocument? _scriptDocument;
|
|
|
private ScriptDocument? ScriptDocument
|
|
@@ -112,13 +111,43 @@ public class DynamicDashboardAdditionalTable : IDynamicDashboardTable
|
|
|
|
|
|
public class Module
|
|
|
{
|
|
|
+ public IEnumerable<CoreColumn> SetupColumns(DynamicDashboardDataComponent data)
|
|
|
+ {
|
|
|
+ // Return the list of columns for this table.
|
|
|
+ return [
|
|
|
+ new CoreColumn(typeof(string), ""Column1""),
|
|
|
+ new CoreColumn(typeof(int), ""Column2"")];
|
|
|
+ }
|
|
|
+
|
|
|
public void PopulateTable(CoreTable table, DynamicDashboardData data)
|
|
|
{
|
|
|
// Populate 'table' using the data from 'data'.
|
|
|
+
|
|
|
+ // For example, to add rows to the table:
|
|
|
+ var newRow = table.NewRow();
|
|
|
+ newRow[""Column1""] = ""First Column Data"";
|
|
|
+ newRow[""Column2""] = 1;
|
|
|
+ table.Rows.Add(newRow);
|
|
|
}
|
|
|
}";
|
|
|
}
|
|
|
|
|
|
+ private IEnumerable<CoreColumn> SetupColumns(DynamicDashboardDataComponent data)
|
|
|
+ {
|
|
|
+ if (ScriptDocument is null) return [];
|
|
|
+
|
|
|
+ var method = ScriptDocument.GetMethod(methodName: "SetupColumns");
|
|
|
+ if(method is not null)
|
|
|
+ {
|
|
|
+ return method.Invoke(ScriptDocument!.GetObject(), [data]) as IEnumerable<CoreColumn>
|
|
|
+ ?? [];
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public void PopulateTable(CoreTable table, DynamicDashboardData data)
|
|
|
{
|
|
|
if (ScriptDocument is null) return;
|
|
@@ -152,7 +181,7 @@ public class DynamicDashboardDataComponent
|
|
|
foreach(var tableDef in AdditionalTables)
|
|
|
{
|
|
|
var table = new CoreTable();
|
|
|
- table.Columns.AddRange(tableDef.Columns);
|
|
|
+ table.Columns.AddRange(tableDef.GetColumns(this));
|
|
|
tableDef.PopulateTable(table, data);
|
|
|
data.Data.Add(tableDef.Key, table);
|
|
|
}
|