Files
raven/server/AyaNova/PickList/AyaPickListFieldDefinition.cs
2020-03-13 21:18:59 +00:00

89 lines
2.6 KiB
C#

using AyaNova.Biz;
using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json;
namespace AyaNova.PickList
{
//This class defines a field used for returning data in list format for UI pick lists
public class AyaPickListFieldDefinition
{
//TODO: Many of these options are redundant for a picklist as this object was copied from datalist
//TODO: remove the redundant options once it's working
//CLIENT / SERVER Unique identifier used at BOTH client and server
//also the sql displaycolumnname if identical
public string FieldKey { get; set; }
//CLIENT Use only for display
public string LtKey { 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; }
//PL Used for casting query
public UiFieldDataType ColumnDataType { get; set; }
//CLIENT Use only for display
public string EnumType { get; set; }
//PL Used
public bool IsRowId { get; set; }
//PL Used
public bool IsActiveColumn { get; set; }
public AyaType AyaObjectType { get; set; }
//PL Used
[JsonIgnore]
public string SqlIdColumnName { get; set; }
[JsonIgnore]
public string SqlValueColumnName { get; set; }
public AyaPickListFieldDefinition()
{
//most common defaults
IsCustomField = false;
IsFilterable = true;
IsSortable = true;
IsRowId = false;
IsActiveColumn = false;
//Set openable object type to no type which is the default and means it's not a link to another object
AyaObjectType = (int)AyaType.NoType;
}
//Get column to query for display name or use FieldName if there is no difference
public string GetSqlValueColumnName()
{
if (string.IsNullOrEmpty(SqlValueColumnName))
{
return FieldKey.ToLowerInvariant();
}
else
{
return SqlValueColumnName;
}
}
public bool HasIdColumn()
{
return !string.IsNullOrWhiteSpace(SqlIdColumnName);
}
}
}