This commit is contained in:
58
server/AyaNova/DataList/AyaDataList.cs
Normal file
58
server/AyaNova/DataList/AyaDataList.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using AyaNova.Biz;
|
||||
|
||||
namespace AyaNova.DataList
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// DataList object base class
|
||||
/// </summary>
|
||||
internal abstract class AyaDataList : IAyaDataList
|
||||
{
|
||||
|
||||
internal AyaDataList()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// private string _listKey = string.Empty;
|
||||
// public string ListKey
|
||||
// {
|
||||
// get
|
||||
// {
|
||||
// return _listKey;
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// _listKey = value;
|
||||
// }
|
||||
// }
|
||||
|
||||
//private readonly string _sqlFrom = string.Empty;
|
||||
public string SQLFrom { get; set; }
|
||||
|
||||
// private readonly List<AyaDataListFieldDefinition> _fieldDefinitions = new List<AyaDataListFieldDefinition>();
|
||||
public List<AyaDataListFieldDefinition> FieldDefinitions { get; set; }
|
||||
|
||||
public AuthorizationRoles AllowedRoles { get; set; }
|
||||
|
||||
public AyaType DefaultListObjectType { get; set; }
|
||||
|
||||
public string ListKey { get; set; }
|
||||
|
||||
public string GenerateMINIListColumnsJSON()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public string GenerateListColumnsJSONFromTemplate(string template)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}//eoc
|
||||
|
||||
}//eons
|
||||
@@ -5,19 +5,23 @@ namespace AyaNova.DataList
|
||||
internal interface IAyaDataList
|
||||
{
|
||||
//Unique key to identify this list
|
||||
string ListKey { get; }
|
||||
string ListKey { get; set; }
|
||||
|
||||
//sql query from fragment with table joins et
|
||||
string SQLFrom { get; }
|
||||
string SQLFrom { get; set; }
|
||||
|
||||
//List of fields for this object
|
||||
List<AyaDataListFieldDefinition> FieldDefinitions { get; }
|
||||
List<AyaDataListFieldDefinition> FieldDefinitions { get; set; }
|
||||
|
||||
//allowed roles to access this list
|
||||
AuthorizationRoles AllowedRoles { get; }
|
||||
AuthorizationRoles AllowedRoles { get; set; }
|
||||
|
||||
//Default object type to open for rows of this list (use no object if no)
|
||||
AyaType DefaultListObjectType { get; }
|
||||
AyaType DefaultListObjectType { get; set; }
|
||||
|
||||
|
||||
string GenerateMINIListColumnsJSON();
|
||||
string GenerateListColumnsJSONFromTemplate(string template);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,7 @@ using System.Collections.Generic;
|
||||
using AyaNova.Biz;
|
||||
namespace AyaNova.DataList
|
||||
{
|
||||
internal class TestWidgetUserEmailDataList : IAyaDataList
|
||||
internal class TestWidgetUserEmailDataList : AyaDataList
|
||||
{
|
||||
/*
|
||||
Select awidget.id, awidget.name, auser.name, auser.id, auseroptions.emailaddress
|
||||
@@ -11,55 +11,49 @@ namespace AyaNova.DataList
|
||||
left outer join auseroptions on (auser.id=auseroptions.userid)
|
||||
order by auseroptions.emailaddress desc
|
||||
*/
|
||||
public string ListKey => nameof(TestWidgetUserEmailDataList);
|
||||
|
||||
public string SQLFrom => "from awidget left outer join auser on (awidget.userid=auser.id) left outer join auseroptions on (auser.id=auseroptions.userid)";
|
||||
|
||||
public List<AyaDataListFieldDefinition> FieldDefinitions
|
||||
public TestWidgetUserEmailDataList()
|
||||
{
|
||||
get
|
||||
ListKey = nameof(TestWidgetUserEmailDataList);
|
||||
SQLFrom = "from awidget left outer join auser on (awidget.userid=auser.id) left outer join auseroptions on (auser.id=auseroptions.userid)";
|
||||
AllowedRoles = AuthorizationRoles.AllInternalStaff;//anyone but clients and subcontractors (just for test)
|
||||
DefaultListObjectType = AyaType.Widget;
|
||||
|
||||
FieldDefinitions = new List<AyaDataListFieldDefinition>();
|
||||
FieldDefinitions.Add(new AyaDataListFieldDefinition { FieldKey = "df", AyaObjectType = (int)AyaType.Widget, SqlIdColumnName = "awidget.id" });
|
||||
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||
{
|
||||
List<AyaDataListFieldDefinition> l = new List<AyaDataListFieldDefinition>();
|
||||
l.Add(new AyaDataListFieldDefinition { FieldKey = "df", AyaObjectType = (int)AyaType.Widget, SqlIdColumnName = "awidget.id" });
|
||||
l.Add(new AyaDataListFieldDefinition
|
||||
{
|
||||
FieldKey = "widgetname",
|
||||
LtKey = "WidgetName",
|
||||
UiFieldDataType = (int)AyaUiFieldDataType.Text,
|
||||
AyaObjectType = (int)AyaType.Widget,
|
||||
SqlIdColumnName = "awidget.id",
|
||||
SqlValueColumnName = "awidget.name"
|
||||
});
|
||||
l.Add(new AyaDataListFieldDefinition
|
||||
{
|
||||
FieldKey = "username",
|
||||
LtKey = "User",
|
||||
UiFieldDataType = (int)AyaUiFieldDataType.Text,
|
||||
AyaObjectType = (int)AyaType.User,
|
||||
SqlIdColumnName = "auser.id",
|
||||
SqlValueColumnName = "auser.name"
|
||||
});
|
||||
l.Add(new AyaDataListFieldDefinition
|
||||
{
|
||||
LtKey = "UserEmailAddress",
|
||||
FieldKey = "emailaddress",
|
||||
SqlValueColumnName = "auseroptions.emailaddress",
|
||||
UiFieldDataType = (int)AyaUiFieldDataType.EmailAddress
|
||||
});
|
||||
l.Add(new AyaDataListFieldDefinition
|
||||
{
|
||||
LtKey = "Active",
|
||||
FieldKey = "widgetactive",
|
||||
SqlValueColumnName = "awidget.active",
|
||||
UiFieldDataType = (int)AyaUiFieldDataType.Bool
|
||||
});
|
||||
return l;
|
||||
}
|
||||
FieldKey = "widgetname",
|
||||
LtKey = "WidgetName",
|
||||
UiFieldDataType = (int)AyaUiFieldDataType.Text,
|
||||
AyaObjectType = (int)AyaType.Widget,
|
||||
SqlIdColumnName = "awidget.id",
|
||||
SqlValueColumnName = "awidget.name"
|
||||
});
|
||||
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||
{
|
||||
FieldKey = "username",
|
||||
LtKey = "User",
|
||||
UiFieldDataType = (int)AyaUiFieldDataType.Text,
|
||||
AyaObjectType = (int)AyaType.User,
|
||||
SqlIdColumnName = "auser.id",
|
||||
SqlValueColumnName = "auser.name"
|
||||
});
|
||||
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||
{
|
||||
LtKey = "UserEmailAddress",
|
||||
FieldKey = "emailaddress",
|
||||
SqlValueColumnName = "auseroptions.emailaddress",
|
||||
UiFieldDataType = (int)AyaUiFieldDataType.EmailAddress
|
||||
});
|
||||
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
||||
{
|
||||
LtKey = "Active",
|
||||
FieldKey = "widgetactive",
|
||||
SqlValueColumnName = "awidget.active",
|
||||
UiFieldDataType = (int)AyaUiFieldDataType.Bool
|
||||
});
|
||||
}
|
||||
|
||||
public AuthorizationRoles AllowedRoles => AuthorizationRoles.AllInternalStaff;//anyone but clients and subcontractors (just for test)
|
||||
public AyaType DefaultListObjectType => AyaType.Widget;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}//eoc
|
||||
}//eons
|
||||
@@ -467,7 +467,7 @@ namespace AyaNova.Biz
|
||||
qWhere = DataListSqlFilterCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, DataList.FieldDefinitions, UserId);
|
||||
//ORDER BY CLAUSE - SORT
|
||||
//BUILD ORDER BY AND APPEND IT
|
||||
qOrderBy = SqlFilterOrderByBuilder.DataFilterToSQLOrderBy(TheFilter);
|
||||
qOrderBy = DataListSqlFilterOrderByBuilder.DataFilterToSQLOrderBy(TheFilter);
|
||||
}
|
||||
|
||||
//LIMIT AND OFFSET CLAUSE - PAGING
|
||||
|
||||
Reference in New Issue
Block a user