This commit is contained in:
2020-03-17 18:13:46 +00:00
parent 54efbd9df8
commit 05bd6db5c6
11 changed files with 26 additions and 44 deletions

View File

@@ -1,7 +1,6 @@
using System.Collections.Generic;
using AyaNova.Biz;
using Newtonsoft.Json.Linq;
namespace AyaNova.PickList
{
/// <summary>
@@ -10,7 +9,7 @@ namespace AyaNova.PickList
internal abstract class AyaPickList : IAyaPickList
{
public AyaPickList()
{}
{ }
public string SQLFrom { get; set; }
public List<AyaPickListFieldDefinition> ColumnDefinitions { get; set; }
public AuthorizationRoles AllowedRoles { get; set; }
@@ -18,7 +17,7 @@ namespace AyaNova.PickList
public string DefaultTemplate { get; set; }
//return array of field keys in list view
public List<string> GetFieldListFromTemplate(JArray template)
{
{
List<string> ret = new List<string>();
for (int i = 0; i < template.Count; i++)
{

View File

@@ -1,11 +1,8 @@
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
//This class defines a field used for pick list templating querying processing editing and returning
public class AyaPickListFieldDefinition
{
//CLIENT / SERVER Unique identifier used at BOTH client and server
@@ -27,9 +24,7 @@ namespace AyaNova.PickList
{
//most common defaults
IsRowId = false;
IsActiveColumn = false;
// AyaObjectType = (int)AyaType.NoType;
IsActiveColumn = false;
}
//Get column to query for display name or use FieldName if there is no difference
@@ -44,11 +39,5 @@ namespace AyaNova.PickList
return SqlValueColumnName;
}
}
// public bool HasIdColumn()
// {
// return !string.IsNullOrWhiteSpace(SqlIdColumnName);
// }
}
}

View File

@@ -13,8 +13,11 @@ namespace AyaNova.PickList
{
switch (ayaType)
{
//CoreBizObject add here
case AyaType.Widget:
return new WidgetPickList() as IAyaPickList;
case AyaType.User:
return new UserPickList() as IAyaPickList;
}
return null;
}
@@ -33,9 +36,7 @@ namespace AyaNova.PickList
TranslationKeysToFetch.Add(name);
ret.Add(new NameIdItem() { Name = name, Id = (long)t });
}
}
var LT = TranslationBiz.GetSubsetStaticAsync(TranslationKeysToFetch, TranslationId).Result;
foreach (NameIdItem i in ret)
{
@@ -43,7 +44,5 @@ namespace AyaNova.PickList
}
return ret;
}
}//eoc
}//eons

View File

@@ -11,11 +11,8 @@ namespace AyaNova.PickList
DefaultListObjectType = AyaType.User;
SQLFrom = "from auser";
AllowedRoles = BizRoles.GetRoleSet(DefaultListObjectType).Select;
//Default template
dynamic dTemplate = new JArray();
dynamic cm = new JObject();
cm.fld = "username";
dTemplate.Add(cm);
@@ -30,9 +27,8 @@ namespace AyaNova.PickList
base.DefaultTemplate = dTemplate.ToString(Newtonsoft.Json.Formatting.None);
//NOTE: Due to the join, all the sql id and name fields that can conflict with the joined (in this case User) table need to be specified completely
//NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely
ColumnDefinitions = new List<AyaPickListFieldDefinition>();
ColumnDefinitions.Add(new AyaPickListFieldDefinition
{
LtKey = "Active",
@@ -41,7 +37,6 @@ namespace AyaNova.PickList
SqlValueColumnName = "auser.active",
IsActiveColumn = true
});
ColumnDefinitions.Add(new AyaPickListFieldDefinition
{
LtKey = "UserName",
@@ -51,7 +46,6 @@ namespace AyaNova.PickList
SqlValueColumnName = "auser.name",
IsRowId = true
});
ColumnDefinitions.Add(new AyaPickListFieldDefinition
{
LtKey = "UserEmployeeNumber",
@@ -60,7 +54,6 @@ namespace AyaNova.PickList
SqlValueColumnName = "auser.employeenumber"
});
ColumnDefinitions.Add(new AyaPickListFieldDefinition
{
LtKey = "Tags",
@@ -68,8 +61,6 @@ namespace AyaNova.PickList
ColumnDataType = UiFieldDataType.Tags,
SqlValueColumnName = "auser.tags"
});
}
}//eoc
}//eons

View File

@@ -7,7 +7,6 @@ namespace AyaNova.PickList
{
public WidgetPickList()
{
DefaultListObjectType = AyaType.Widget;
SQLFrom = "from awidget left outer join auser on (awidget.userid=auser.id)";
AllowedRoles = BizRoles.GetRoleSet(DefaultListObjectType).Select;
@@ -31,8 +30,6 @@ namespace AyaNova.PickList
//NOTE: Due to the join, all the sql id and name fields that can conflict with the joined (in this case User) table need to be specified completely
ColumnDefinitions = new List<AyaPickListFieldDefinition>();
//DEPRECATED: FieldDefinitions.Add(new AyaPickListFieldDefinition { FieldKey = "df", AyaObjectType = (int)AyaType.Widget, SqlIdColumnName = "awidget.id", IsFilterable = false, IsSortable = false, });
ColumnDefinitions.Add(new AyaPickListFieldDefinition
{
LtKey = "Active",
@@ -77,8 +74,6 @@ namespace AyaNova.PickList
ColumnDataType = UiFieldDataType.Tags,
SqlValueColumnName = "awidget.tags"
});
}
}//eoc
}//eons

View File

@@ -20,6 +20,7 @@ namespace AyaNova.Biz
{
get
{
//CoreBizObject add here
List<string> l = new List<string>{
AyaType.Widget.ToString(),AyaType.User.ToString()
};
@@ -40,7 +41,7 @@ namespace AyaNova.Biz
***************************** Otherwise the hidden field can't be set and the object can't be saved EVER
*/
List<AyaFormFieldDefinition> l = new List<AyaFormFieldDefinition>();
//CoreBizObject add here
if (key == AyaType.Widget.ToString())
{

View File

@@ -6,13 +6,17 @@ namespace AyaNova.Biz
/// </summary>
public enum AyaType : int
{
//COREBIZOBJECT attribute must be set on objects that are:
//Attachable objects can have attachments,
//wikiable objects can have a wiki
//reviewable objects can have a review which is basically the same as a Reminder but with an object attached (was follow up schedmarker in v7)
//PIckList-able (has picklist template)
//Pretty much everything that represents some kind of real world object is wikiable or attachable as long as it has an ID and a type
//exceptions would be utility type objects like datalistview, formcustom etc that are not
//COREBIZOBJECT attribute must be set on objects that are:
//Attachable objects can have attachments,
//wikiable objects can have a wiki
//reviewable objects can have a review which is basically the same as a Reminder but with an object attached (was follow up schedmarker in v7)
//PIckList-able (has picklist template)
//Pretty much everything that represents some kind of real world object is wikiable or attachable as long as it has an ID and a type
//exceptions would be utility type objects like datalistview, formcustom etc that are not
//NOTE: NEW CORE OBJECTS - All areas of server code that require adding any new core objects have been tagged with the following comment:
//CoreBizObject add here
//Search for that and you will see all areas that need coding for the new object
NoType = 0,
Global = 1,

View File

@@ -30,6 +30,7 @@ namespace AyaNova.Biz
}
switch (aytype)
{
//CoreBizObject add here
case AyaType.User:
return await ct.User.AnyAsync(m => m.Id == id);
case AyaType.Widget:

View File

@@ -23,6 +23,7 @@ namespace AyaNova.Biz
{
switch (aytype)
{
//CoreBizObject add here
case AyaType.User:
return new UserBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
case AyaType.Widget:

View File

@@ -17,6 +17,7 @@ namespace AyaNova.Biz
{
string TABLE = string.Empty;
string COLUMN = "name";
//CoreBizObject add here
switch (aytype)
{
case AyaType.User:

View File

@@ -29,6 +29,7 @@ namespace AyaNova.Biz
//DELETE = There is no specific delete right for now though it's checked for by routes in Authorized.cs in case we want to add it in future as a separate right from create.
#region All roles initialization
//CoreBizObject add here
////////////////////////////////////////////////////////////
//USER
@@ -189,7 +190,7 @@ namespace AyaNova.Biz
//ONGOING VALIDATION TO CATCH MISMATCH WHEN NEW ROLES ADDED (wont' catch changes to existing unfortunately)
//var lastRoles = "{\"User\":{\"Change\":2,\"ReadFullRecord\":1},\"UserOptions\":{\"Change\":2,\"ReadFullRecord\":1},\"Widget\":{\"Change\":34,\"ReadFullRecord\":17},\"ServerState\":{\"Change\":16384,\"ReadFullRecord\":131071},\"License\":{\"Change\":16386,\"ReadFullRecord\":8193},\"LogFile\":{\"Change\":0,\"ReadFullRecord\":24576},\"JobOperations\":{\"Change\":16384,\"ReadFullRecord\":8195},\"AyaNova7Import\":{\"Change\":16384,\"ReadFullRecord\":0},\"Metrics\":{\"Change\":0,\"ReadFullRecord\":24576},\"Translation\":{\"Change\":16386,\"ReadFullRecord\":131071},\"DataListView\":{\"Change\":2,\"ReadFullRecord\":131071},\"FormCustom\":{\"Change\":2,\"ReadFullRecord\":131071}}";
var lastRoles = "{\"User\":{\"Change\":2,\"ReadFullRecord\":1,\"Select\":131071},\"UserOptions\":{\"Change\":2,\"ReadFullRecord\":1,\"Select\":0},\"Widget\":{\"Change\":34,\"ReadFullRecord\":17,\"Select\":131071},\"ServerState\":{\"Change\":16384,\"ReadFullRecord\":131071,\"Select\":0},\"License\":{\"Change\":16386,\"ReadFullRecord\":8193,\"Select\":0},\"LogFile\":{\"Change\":0,\"ReadFullRecord\":24576,\"Select\":0},\"JobOperations\":{\"Change\":16384,\"ReadFullRecord\":8195,\"Select\":0},\"AyaNova7Import\":{\"Change\":16384,\"ReadFullRecord\":0,\"Select\":0},\"Metrics\":{\"Change\":0,\"ReadFullRecord\":24576,\"Select\":0},\"Translation\":{\"Change\":16386,\"ReadFullRecord\":131071,\"Select\":0},\"DataListView\":{\"Change\":2,\"ReadFullRecord\":131071,\"Select\":0},\"FormCustom\":{\"Change\":2,\"ReadFullRecord\":131071,\"Select\":0},\"PickListTemplate\":{\"Change\":2,\"ReadFullRecord\":131071,\"Select\":131071}}";
Dictionary<AyaType, BizRoleSet> lastRolesDeserialized = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<AyaType, BizRoleSet>>(lastRoles);
if (lastRolesDeserialized.Count != roles.Count)
{