This commit is contained in:
2020-01-17 20:12:59 +00:00
parent 629058ce4e
commit ac8f1846a8
5 changed files with 75 additions and 139 deletions

View File

@@ -282,7 +282,7 @@ namespace AyaNova.Biz
if (FieldList != null)
{
var TheField = FieldList.SingleOrDefault(x => x.FieldName.ToLowerInvariant() == fld);
var TheField = FieldList.SingleOrDefault(x => x.FieldKey.ToLowerInvariant() == fld);
if (TheField == null)
{
@@ -351,7 +351,7 @@ namespace AyaNova.Biz
if (FieldList != null)
{
if (!FieldList.Exists(x => x.FieldName.ToLowerInvariant() == fld && x.IsFilterable))
if (!FieldList.Exists(x => x.FieldKey.ToLowerInvariant() == fld && x.IsFilterable))
{
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "Sort", $"Sort array item {i}, fld property value \"{fld}\" is not a valid value for ListKey specified");
}

View File

@@ -158,152 +158,83 @@ namespace AyaNova.Biz
//first column is the non visible Default Id column so that the client knows what to open when there is no field with ID selected that matches underlying record type
//in this case the default of id is sufficient for this list
l.Add(new AyaField { LtKey = "df", AyaObjectType = (int)AyaType.Widget });
l.Add(new AyaField { LtKey = "WidgetName", FieldName = "Name", UiFieldDataType = (int)AyaUiFieldDataType.Text, Hideable = false });
l.Add(new AyaField { LtKey = "WidgetSerial", FieldName = "Serial", UiFieldDataType = (int)AyaUiFieldDataType.Integer });
l.Add(new AyaField { LtKey = "WidgetDollarAmount", FieldName = "DollarAmount", UiFieldDataType = (int)AyaUiFieldDataType.Currency });
l.Add(new AyaField { LtKey = "WidgetCount", FieldName = "Count", UiFieldDataType = (int)AyaUiFieldDataType.Integer });
l.Add(new AyaField { LtKey = "WidgetRoles", FieldName = "Roles", UiFieldDataType = (int)AyaUiFieldDataType.Enum, EnumType = typeof(AuthorizationRoles).ToString() });
l.Add(new AyaField { LtKey = "WidgetStartDate", FieldName = "StartDate", UiFieldDataType = (int)AyaUiFieldDataType.DateTime });
l.Add(new AyaField { LtKey = "WidgetEndDate", FieldName = "EndDate", UiFieldDataType = (int)AyaUiFieldDataType.DateTime });
l.Add(new AyaField { LtKey = "WidgetNotes", FieldName = "Notes", UiFieldDataType = (int)AyaUiFieldDataType.Text });
l.Add(new AyaField { LtKey = "WidgetName", FieldKey = "Name", UiFieldDataType = (int)AyaUiFieldDataType.Text, Hideable = false });
l.Add(new AyaField { LtKey = "WidgetSerial", FieldKey = "Serial", UiFieldDataType = (int)AyaUiFieldDataType.Integer });
l.Add(new AyaField { LtKey = "WidgetDollarAmount", FieldKey = "DollarAmount", UiFieldDataType = (int)AyaUiFieldDataType.Currency });
l.Add(new AyaField { LtKey = "WidgetCount", FieldKey = "Count", UiFieldDataType = (int)AyaUiFieldDataType.Integer });
l.Add(new AyaField { LtKey = "WidgetRoles", FieldKey = "Roles", UiFieldDataType = (int)AyaUiFieldDataType.Enum, EnumType = typeof(AuthorizationRoles).ToString() });
l.Add(new AyaField { LtKey = "WidgetStartDate", FieldKey = "StartDate", UiFieldDataType = (int)AyaUiFieldDataType.DateTime });
l.Add(new AyaField { LtKey = "WidgetEndDate", FieldKey = "EndDate", UiFieldDataType = (int)AyaUiFieldDataType.DateTime });
l.Add(new AyaField { LtKey = "WidgetNotes", FieldKey = "Notes", UiFieldDataType = (int)AyaUiFieldDataType.Text });
//More to do on this, maybe the datatype should be a LINK or something for UI purposes
//circle back on this when there is enough infrastructure to test
l.Add(new AyaField { LtKey = "User", FieldName = "userid", UiFieldDataType = (int)AyaUiFieldDataType.Text, AyaObjectType = (int)AyaType.User });
l.Add(new AyaField { LtKey = "Active", FieldName = "Active", UiFieldDataType = (int)AyaUiFieldDataType.Bool, Hideable = false });
l.Add(new AyaField { LtKey = "Tags", FieldName = "Tags", UiFieldDataType = (int)AyaUiFieldDataType.Tags });
l.Add(new AyaField { LtKey = "User", FieldKey = "userid", UiFieldDataType = (int)AyaUiFieldDataType.Text, AyaObjectType = (int)AyaType.User });
l.Add(new AyaField { LtKey = "Active", FieldKey = "Active", UiFieldDataType = (int)AyaUiFieldDataType.Bool, Hideable = false });
l.Add(new AyaField { LtKey = "Tags", FieldKey = "Tags", UiFieldDataType = (int)AyaUiFieldDataType.Tags });
l.Add(new AyaField { LtKey = "WidgetCustom1", FieldName = "WidgetCustom1", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom2", FieldName = "WidgetCustom2", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom3", FieldName = "WidgetCustom3", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom4", FieldName = "WidgetCustom4", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom5", FieldName = "WidgetCustom5", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom6", FieldName = "WidgetCustom6", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom7", FieldName = "WidgetCustom7", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom8", FieldName = "WidgetCustom8", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom9", FieldName = "WidgetCustom9", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom10", FieldName = "WidgetCustom10", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom11", FieldName = "WidgetCustom11", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom12", FieldName = "WidgetCustom12", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom13", FieldName = "WidgetCustom13", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom14", FieldName = "WidgetCustom14", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom15", FieldName = "WidgetCustom15", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom16", FieldName = "WidgetCustom16", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom1", FieldKey = "WidgetCustom1", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom2", FieldKey = "WidgetCustom2", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom3", FieldKey = "WidgetCustom3", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom4", FieldKey = "WidgetCustom4", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom5", FieldKey = "WidgetCustom5", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom6", FieldKey = "WidgetCustom6", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom7", FieldKey = "WidgetCustom7", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom8", FieldKey = "WidgetCustom8", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom9", FieldKey = "WidgetCustom9", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom10", FieldKey = "WidgetCustom10", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom11", FieldKey = "WidgetCustom11", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom12", FieldKey = "WidgetCustom12", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom13", FieldKey = "WidgetCustom13", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom14", FieldKey = "WidgetCustom14", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom15", FieldKey = "WidgetCustom15", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom16", FieldKey = "WidgetCustom16", IsCustomField = true });
break;
#endregion
case USER_KEY:
#region USER_KEY
l.Add(new AyaField { LtKey = "df", AyaObjectType = (int)AyaType.User });
l.Add(new AyaField { LtKey = "Name", FieldName = "Name", UiFieldDataType = (int)AyaUiFieldDataType.Text, Hideable = false });
l.Add(new AyaField { LtKey = "UserEmployeeNumber", FieldName = "EmployeeNumber", UiFieldDataType = (int)AyaUiFieldDataType.Text });
l.Add(new AyaField { LtKey = "AuthorizationRoles", FieldName = "Roles", Hideable = false, UiFieldDataType = (int)AyaUiFieldDataType.Enum, EnumType = typeof(AuthorizationRoles).ToString() });
l.Add(new AyaField { LtKey = "UserNotes", FieldName = "Notes", UiFieldDataType = (int)AyaUiFieldDataType.Text });
l.Add(new AyaField { LtKey = "UserUserType", FieldName = "UserType", Hideable = false, UiFieldDataType = (int)AyaUiFieldDataType.Enum, EnumType = typeof(UserType).ToString() });
l.Add(new AyaField { LtKey = "Active", FieldName = "Active", UiFieldDataType = (int)AyaUiFieldDataType.Bool, Hideable = false });
l.Add(new AyaField { LtKey = "Tags", FieldName = "Tags", UiFieldDataType = (int)AyaUiFieldDataType.Tags });
l.Add(new AyaField { LtKey = "Name", FieldKey = "Name", UiFieldDataType = (int)AyaUiFieldDataType.Text, Hideable = false });
l.Add(new AyaField { LtKey = "UserEmployeeNumber", FieldKey = "EmployeeNumber", UiFieldDataType = (int)AyaUiFieldDataType.Text });
l.Add(new AyaField { LtKey = "AuthorizationRoles", FieldKey = "Roles", Hideable = false, UiFieldDataType = (int)AyaUiFieldDataType.Enum, EnumType = typeof(AuthorizationRoles).ToString() });
l.Add(new AyaField { LtKey = "UserNotes", FieldKey = "Notes", UiFieldDataType = (int)AyaUiFieldDataType.Text });
l.Add(new AyaField { LtKey = "UserUserType", FieldKey = "UserType", Hideable = false, UiFieldDataType = (int)AyaUiFieldDataType.Enum, EnumType = typeof(UserType).ToString() });
l.Add(new AyaField { LtKey = "Active", FieldKey = "Active", UiFieldDataType = (int)AyaUiFieldDataType.Bool, Hideable = false });
l.Add(new AyaField { LtKey = "Tags", FieldKey = "Tags", UiFieldDataType = (int)AyaUiFieldDataType.Tags });
l.Add(new AyaField { LtKey = "UserCustom1", FieldName = "UserCustom1", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom2", FieldName = "UserCustom2", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom3", FieldName = "UserCustom3", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom4", FieldName = "UserCustom4", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom5", FieldName = "UserCustom5", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom6", FieldName = "UserCustom6", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom7", FieldName = "UserCustom7", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom8", FieldName = "UserCustom8", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom9", FieldName = "UserCustom9", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom10", FieldName = "UserCustom10", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom11", FieldName = "UserCustom11", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom12", FieldName = "UserCustom12", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom13", FieldName = "UserCustom13", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom14", FieldName = "UserCustom14", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom15", FieldName = "UserCustom15", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom16", FieldName = "UserCustom16", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom1", FieldKey = "UserCustom1", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom2", FieldKey = "UserCustom2", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom3", FieldKey = "UserCustom3", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom4", FieldKey = "UserCustom4", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom5", FieldKey = "UserCustom5", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom6", FieldKey = "UserCustom6", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom7", FieldKey = "UserCustom7", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom8", FieldKey = "UserCustom8", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom9", FieldKey = "UserCustom9", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom10", FieldKey = "UserCustom10", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom11", FieldKey = "UserCustom11", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom12", FieldKey = "UserCustom12", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom13", FieldKey = "UserCustom13", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom14", FieldKey = "UserCustom14", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom15", FieldKey = "UserCustom15", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom16", FieldKey = "UserCustom16", IsCustomField = true });
break;
#endregion
case TEST_WIDGET_USER_EMAIL_ADDRESS_LIST_KEY:
#region WIDGET_USER_EMAIL_ADDRESS_LIST_KEY
/*
Select awidget.id as df, awidget.id as widgetid, awidget.name as widgetname, auser.name as username, auser.id as userid, auseroptions.emailaddress
from awidget
left outer join auser on (awidget.userid=auser.id)
left outer join auseroptions on (auser.id=auseroptions.userid)
public string Key { get; set; }
public string PropertyName { get; set; }
public bool Hideable { get; set; }
public bool SharedLTKey { get; set; }
public bool Custom { get; set; }
public bool Filterable { get; set; }
public bool Sortable { get; set; }
public int UiFieldDataType { get; set; }
public string EnumType { get; set; }
public int AyObjectType { get; set; }
//For query building
//This is the equivalent of the v7 SqlColumnNameAttribute
public string SqlIdColumn { get; set; }
public string SqlDisplayColumn { get; set; }
*/
//THIS is strictly a list object, not for forms so it doesn't need hideable set to any as that's a customization thing
//Property name is what the client looks for in the object to display
// and also what the return list generator uses to read in the column to deal with
//so property name is really displayasname and is always unique so actually it's really the unique key identifier, not KEY which is the ltkey
//sqlidcolumn and sqldisplaycolumn are actually sqlselectid and sqlselectdisplay
// - they could be a fragment with an alias i.e. sqlselectid="awidget.id as widgetid"
//need a separate property for the id column name to fetch
// for example:
/* WORKING OUT WHAT OBJECTFIELD REALLY SHOULD BE
Select awidget.id, awidget.name, auser.name, auser.id, auseroptions.emailaddress
from awidget
left outer join auser on (awidget.userid=auser.id)
left outer join auseroptions on (auser.id=auseroptions.userid)
order by auseroptions.emailaddress desc
There's actually no need for aliases. I'm fetching the values positionally and already know the columns that will be involved and the user will never see the aliases anyway so it's just fluff
Havev confirmed even without a join can still use the full tablename.columnname method for select statement so stick with that always
It's alright to have all the info in one place here because whatever the client needs can be parsed out and send separately without the server needed stuff
Nothing at the client yet is using any of this other than the custom fields formatter
Here at the server some validators maybe are using it and the sql builders
So rename things and see what breaks I guess
Named AYFIELD?
CLIENT ONLY USED
LtKey="WidgetName" (this is not necessarily unique per list, for example it could be "active" or "notes" in the UI (in a report for example) more than once in cases )
AyaObjectType=ayatype.widget
UiFieldDataType=AyaUiFieldDataType.Text
Hideable=false (this is required for the edit form customizations, not the list template because it will warn if no fields are visible and doesn't require any particular field to be visible, just one of them)
enumtype (required for client display)
SERVER ONLY USED
sqlidcolumnName="awidget.id"
sqldisplaycolumnName="awidget.name"
BOTH
PropertyName (RENAME TO FieldName)="widgetname" (this is the unique key for this object and what the template and builders and client should be using)
Custom (RENAME it IsCustomField TODO: WHO NEEDS THIS? this is used by the form customization at the client end and for validation I think NEED TO CHECK)
filterable (RENAME to IsFilterable required for CLIENT UI datafilter builder and validation)
sortable (RENAME to IsSortable required for CLIENT UI datafilter builder and validation)
SharedLTKEY= (DEPRECATE, NO IDEA, NOT REALLY required, probably thought I needed it for localized text editing maybe?)
*/
l.Add(new AyaField { LtKey = "df", AyaObjectType = (int)AyaType.Widget, SqlIdColumnName = "awidget.id as df" });
l.Add(new AyaField { LtKey = "df", AyaObjectType = (int)AyaType.Widget, SqlIdColumnName = "awidget.id" });
l.Add(new AyaField
{
FieldKey = "widgetname",
LtKey = "WidgetName",
FieldName = "widgetname",
UiFieldDataType = (int)AyaUiFieldDataType.Text,
AyaObjectType = (int)AyaType.Widget,
SqlIdColumnName = "awidget.id",
@@ -311,14 +242,20 @@ So rename things and see what breaks I guess
});
l.Add(new AyaField
{
FieldKey = "username",
LtKey = "User",
FieldName = "username",
UiFieldDataType = (int)AyaUiFieldDataType.Text,
AyaObjectType = (int)AyaType.User,
SqlIdColumnName = "userid",
SqlDisplayColumnName = "auser.name as username"
SqlIdColumnName = "auser.id",
SqlDisplayColumnName = "auser.name"
});
l.Add(new AyaField
{
LtKey = "UserEmailAddress",
FieldKey = "emailaddress",
SqlDisplayColumnName = "auseroptions.emailaddress",
UiFieldDataType = (int)AyaUiFieldDataType.EmailAddress
});
l.Add(new AyaField { LtKey = "UserEmailAddress", FieldName = "emailaddress", UiFieldDataType = (int)AyaUiFieldDataType.EmailAddress });
break;
#endregion
@@ -408,27 +345,26 @@ So rename things and see what breaks I guess
public class AyaField
{
//CLIENT / SERVER Unique identifier used at BOTH client and server
//also the sql displaycolumnname if identical
public string FieldName { get; set; }
public string FieldKey { get; set; }
//CLIENT Use only for display
public string LtKey { get; set; }
//CLIENT form customization
public bool Hideable { get; set; }
//CLIENT / SERVER - client display server validation purposes
public bool IsCustomField { get; set; }
//CLIENT / SERVER - client display server validation purposes
public bool IsFilterable { get; set; }
//CLIENT / SERVER - client display server validation purposes
public bool IsSortable { get; set; }
//CLIENT Use only for display
//CLIENT Use only for display
public int UiFieldDataType { get; set; }
//CLIENT Use only for display
@@ -459,7 +395,7 @@ So rename things and see what breaks I guess
{
if (string.IsNullOrEmpty(SqlDisplayColumnName))
{
return FieldName.ToLowerInvariant();
return FieldKey.ToLowerInvariant();
}
else
{

View File

@@ -37,7 +37,7 @@ namespace AyaNova.Biz
if (!FF.IsCustomField)
{
//Now get the actual property name from the available fields using the lt key
string RequiredPropertyName = FF.FieldName;
string RequiredPropertyName = FF.FieldKey;
//use reflection to get the underlying value from the proposed object to be saved
object propertyValue = proposedObject.GetType().GetProperty(RequiredPropertyName).GetValue(proposedObject, null);

View File

@@ -38,7 +38,7 @@ namespace AyaNova.Biz
tagList = filterItem["value"].ToObject<List<String>>();
}
var dataType = objectFields.Find(x => x.FieldName.ToLowerInvariant() == fld).UiFieldDataType;
var dataType = objectFields.Find(x => x.FieldKey.ToLowerInvariant() == fld).UiFieldDataType;
sb.Append("(");
sb.Append(DataFilterToColumnCriteria(fld, (AyaUiFieldDataType)dataType, opType, val, tagList, userId));
if (i < FilterArray.Count - 1)

View File

@@ -411,8 +411,8 @@ namespace AyaNova.Biz
//TODO: Get template (MOCKED FOR NOW UNTIL PROOF OF CONCEPT)
var MOCK_WIDGET_USER_EMAIL_DISPLAY_TEMPLATE_JSON = @"
{
""full"":[""WidgetName"",""User"",""UserEmailAddress""],
""mini"":[""WidgetName"",""User"",""UserEmailAddress""]
""full"":[""widgetname"",""username"",""emailaddress""],
""mini"":[""widgetname"",""username"",""emailaddress""]
}
";