diff --git a/devdocs/todo.txt b/devdocs/todo.txt
index 9aeb8561..65ed49e2 100644
--- a/devdocs/todo.txt
+++ b/devdocs/todo.txt
@@ -8,7 +8,6 @@
//PICKLISTS:
-todo: all template routes and actual backing code and also validation, needs to validate templates
todo: clean out unneeded leftovers from AyaPickListFieldDefinition
todo: add pickers for all CORE objects (User...?)
todo: write a guide in ayatype for what to do when making a new core object as there are a few things now
diff --git a/server/AyaNova/PickList/AyaPickList.cs b/server/AyaNova/PickList/AyaPickList.cs
index d1bb379d..15ca5336 100644
--- a/server/AyaNova/PickList/AyaPickList.cs
+++ b/server/AyaNova/PickList/AyaPickList.cs
@@ -1,36 +1,24 @@
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
using AyaNova.Biz;
using Newtonsoft.Json.Linq;
-using Microsoft.EntityFrameworkCore;
namespace AyaNova.PickList
{
-
///
/// PickList object base class
///
internal abstract class AyaPickList : IAyaPickList
{
-
public AyaPickList()
- {
-
- }
-
+ {}
public string SQLFrom { get; set; }
public List ColumnDefinitions { get; set; }
public AuthorizationRoles AllowedRoles { get; set; }
public AyaType DefaultListObjectType { get; set; }
-
public string DefaultTemplate { get; set; }
-
-
//return array of field keys in list view
public List GetFieldListFromTemplate(JArray template)
- {
- // [{key:"COLUMN UNIQUE KEY ID",sort:"-" or "+",filter:{any:true/false,items:[{FILTER OBJECT SEE BELOW}]} }, {key:"second column unique key"},{...etc...}]
+ {
List ret = new List();
for (int i = 0; i < template.Count; i++)
{
@@ -39,180 +27,5 @@ namespace AyaNova.PickList
}
return ret;
}
-
-
-
- public Newtonsoft.Json.Linq.JArray GenerateListColumnsJSONFromTemplate(JArray template)
- {
-
- var ListViewFieldKeys = GetFieldListFromTemplate(template);
- var CustomFieldDefinitions = GetCustomFieldDefinitionsForList();
-
- //Generate JSON fragment to return with column definitions
- StringBuilder sb = new StringBuilder();
-
- sb.Append("[");
-
- bool FirstColumnAdded = false;
-
- foreach (string s in ListViewFieldKeys)
- {
- AyaPickListFieldDefinition o = ColumnDefinitions.FirstOrDefault(x => x.FieldKey == s);
-#if (DEBUG)
- //Developers little helper
- if (o == null)
- {
- throw new System.ArgumentNullException($"DEV ERROR in AyaPickList::GenerateListColumnsJSONFromListView - field {s} specified in ListView was NOT found in ObjectFields list");
- }
-#endif
-
- if (o != null)
- {//Here is where we can vet the field name, if it doesn't exist. For production we'll just ignore those ones
-
- if (FirstColumnAdded)
- sb.Append(",");
- sb.Append("{");
- //Build required part of column definition
- if (!o.IsCustomField)
- sb.Append($"\"cm\":\"{o.LtKey}\",\"dt\":{(int)o.ColumnDataType}");
- else
- {
- //insert specific type for this custom field
- if (CustomFieldDefinitions.ContainsKey(o.LtKey))
- {
- var customFieldType = CustomFieldDefinitions[o.LtKey];
- sb.Append($"\"cm\":\"{o.LtKey}\",\"dt\":{customFieldType}");
- }
- else
- {
- //this is normal as there may not be a definition for a Custom field but it's been requested so just treat it like text
- sb.Append($"\"cm\":\"{o.LtKey}\",\"dt\":{(int)UiFieldDataType.Text}");
- }
- }
-
- //Has a AyObjectType? (linkable / openable)
- if (o.AyaObjectType != 0)
- sb.Append($",\"ay\":{(int)o.AyaObjectType}");
-
- //Row ID column?
- if (o.IsRowId)
- {
- sb.Append($",\"rid\":1");
- }
-
- //Has a Enumtype?
- if (!string.IsNullOrEmpty(o.EnumType))
- sb.Append($",\"et\":\"{AyaNova.Util.StringUtil.TrimTypeName(o.EnumType)}\"");
-
- sb.Append("}");
- FirstColumnAdded = true;
-
- }
- }
- sb.Append("]");
-
- return JArray.Parse(sb.ToString());
- }
-
-
- //Find and return a dictionary of all custom fields definitions for all types in list
- //used to build the column array and define specific type defined for custom fields so client datatable
- //knows how to format it
- private Dictionary GetCustomFieldDefinitionsForList()
- {
- //all keys and types can go in the same list since they are unique to each type of list
- //i.e. both users and widget custom fields can be in the same list
- Dictionary ret = new Dictionary();
- List typesProcessed = new List();
- //custom fields handling
- foreach (AyaPickListFieldDefinition d in this.ColumnDefinitions)
- {
- if (d.IsCustomField)
- {
- //this relies on the convention I'm using of AyaType name as the first part of all custom fields lT keys, e.g.
- //WidgetCustom1 -> Widget
- var ayatypename = d.LtKey.Split("Custom")[0];
- if (!typesProcessed.Contains(ayatypename))
- {
- //make sure we do each type only once
- typesProcessed.Add(ayatypename);
- //fetch it and set it
- using (var ct = AyaNova.Util.ServiceProviderProvider.DBContext)
- {
- var fc = ct.FormCustom.AsNoTracking().SingleOrDefault(x => x.FormKey == ayatypename);
-#if (DEBUG)
- if (fc == null)
- {
- throw new System.ArgumentNullException($"AyaPickList:GetCustomFieldDefinitionsForList, Custom field object type {ayatypename} has no FormCustom defined");
- }
-#endif
- //production handling of missing formcustom
- if (fc == null)
- continue;
-
- //iterate the fields and add each custom one with a type to the return dictionary
- var flds = JArray.Parse(fc.Template);
- foreach (JToken t in flds)
- {
- if (t["type"] != null)
- {
- ret.Add(t["fld"].Value(), t["type"].Value());
- }
- }
-
-
- }
-
- }
- }
- }
- /*{[
- {
- "fld": "Notes",
- "required": true
- },
- {
- "fld": "WidgetCustom1",
- "required": false,
- "type": 1
- },
- {
- "fld": "WidgetCustom2",
- "required": true,
- "type": 4
- },
- {
- "fld": "WidgetCustom3",
- "required": false,
- "type": 5
- },
- {
- "fld": "WidgetCustom4",
- "required": false,
- "type": 6
- },
- {
- "fld": "WidgetCustom5",
- "required": false,
- "type": 8
- },
- {
- "fld": "WidgetCustom6",
- "required": false,
- "type": 2
- },
- {
- "fld": "WidgetCustom7",
- "required": false,
- "type": 3
- }
- ]}*/
- return ret;
-
- }
-
-
-
}//eoc
-
}//eons
\ No newline at end of file
diff --git a/server/AyaNova/PickList/AyaPickListFieldDefinition.cs b/server/AyaNova/PickList/AyaPickListFieldDefinition.cs
index 49935e32..0e44cec3 100644
--- a/server/AyaNova/PickList/AyaPickListFieldDefinition.cs
+++ b/server/AyaNova/PickList/AyaPickListFieldDefinition.cs
@@ -8,62 +8,27 @@ 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
+ // 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;
+ //most common defaults
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;
+ IsActiveColumn = false;
+ // AyaObjectType = (int)AyaType.NoType;
}
@@ -80,10 +45,10 @@ namespace AyaNova.PickList
}
}
- public bool HasIdColumn()
- {
- return !string.IsNullOrWhiteSpace(SqlIdColumnName);
- }
+ // public bool HasIdColumn()
+ // {
+ // return !string.IsNullOrWhiteSpace(SqlIdColumnName);
+ // }
}
}
\ No newline at end of file
diff --git a/server/AyaNova/PickList/IAyaPickList.cs b/server/AyaNova/PickList/IAyaPickList.cs
index 906d7c21..ad809826 100644
--- a/server/AyaNova/PickList/IAyaPickList.cs
+++ b/server/AyaNova/PickList/IAyaPickList.cs
@@ -4,29 +4,17 @@ using AyaNova.Biz;
namespace AyaNova.PickList
{
internal interface IAyaPickList
- {
-
- //Item has an active column
-
+ {
//sql query from fragment with table joins et
string SQLFrom { get; set; }
-
//List of fields for this object
List ColumnDefinitions { get; set; }
-
//allowed roles to access this list
AuthorizationRoles AllowedRoles { get; set; }
-
//Default object type to open for rows of this list (use no object if no)
AyaType DefaultListObjectType { get; set; }
-
//Default / STOCK DataListView when none is specified
- string DefaultTemplate { get; set; }
-
- Newtonsoft.Json.Linq.JArray GenerateListColumnsJSONFromTemplate(JArray listViewArray);
+ string DefaultTemplate { get; set; }
List GetFieldListFromTemplate(JArray listViewArray);
-
-
}
-
}
\ No newline at end of file
diff --git a/server/AyaNova/PickList/UserPickList.cs b/server/AyaNova/PickList/UserPickList.cs
index b1b212bd..a04918fb 100644
--- a/server/AyaNova/PickList/UserPickList.cs
+++ b/server/AyaNova/PickList/UserPickList.cs
@@ -46,7 +46,6 @@ namespace AyaNova.PickList
{
LtKey = "UserName",
FieldKey = "username",
- AyaObjectType = AyaType.User,
ColumnDataType = UiFieldDataType.Text,
SqlIdColumnName = "auser.id",
SqlValueColumnName = "auser.name",
diff --git a/server/AyaNova/PickList/WidgetPickList.cs b/server/AyaNova/PickList/WidgetPickList.cs
index 9cc2fb99..e5129ccd 100644
--- a/server/AyaNova/PickList/WidgetPickList.cs
+++ b/server/AyaNova/PickList/WidgetPickList.cs
@@ -46,7 +46,7 @@ namespace AyaNova.PickList
{
LtKey = "WidgetName",
FieldKey = "widgetname",
- AyaObjectType = AyaType.Widget,
+ //AyaObjectType = AyaType.Widget,
ColumnDataType = UiFieldDataType.Text,
SqlIdColumnName = "awidget.id",
SqlValueColumnName = "awidget.name",
@@ -66,7 +66,6 @@ namespace AyaNova.PickList
FieldKey = "username",
LtKey = "User",
ColumnDataType = UiFieldDataType.Text,
- AyaObjectType = AyaType.User,
SqlIdColumnName = "auser.id",
SqlValueColumnName = "auser.name"
});