From ecfb5dcea51f616409613f0539e37347690c82a7 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 27 Jan 2021 20:18:21 +0000 Subject: [PATCH] --- server/AyaNova/DataList/AyaDataList.cs | 9 +++- server/AyaNova/DataList/CustomerDataList.cs | 39 +++++++------- .../AyaNova/DataList/CustomerNoteDataList.cs | 52 +++++++++++++------ server/AyaNova/models/DataListBase.cs | 2 +- 4 files changed, 64 insertions(+), 38 deletions(-) diff --git a/server/AyaNova/DataList/AyaDataList.cs b/server/AyaNova/DataList/AyaDataList.cs index 2fac1227..97995799 100644 --- a/server/AyaNova/DataList/AyaDataList.cs +++ b/server/AyaNova/DataList/AyaDataList.cs @@ -18,8 +18,13 @@ namespace AyaNova.DataList //well, not here exactly but add a new DATALIST class if it will be displayed as a list anywhere in the UI or reported on public AyaDataList() { - // DefaultColumns = new List(); - // DefaultSortBy = new Dictionary(); + /* + + DefaultColumns = new List() { "XXX", "XXXX", "XXXX", "XXXX", "XXXX", "XXX", "XXXX", "XXXX", "XXXX", "XXXX" }; + DefaultSortBy = new Dictionary() { { "XXXX", "+" }, { "XXXX", "-" } }; + + */ + } public string SQLFrom { get; set; } diff --git a/server/AyaNova/DataList/CustomerDataList.cs b/server/AyaNova/DataList/CustomerDataList.cs index 5fc24e24..bb765fcc 100644 --- a/server/AyaNova/DataList/CustomerDataList.cs +++ b/server/AyaNova/DataList/CustomerDataList.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using Newtonsoft.Json.Linq; using AyaNova.Biz; namespace AyaNova.DataList { @@ -14,28 +13,32 @@ namespace AyaNova.DataList //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ - //Default ListView - dynamic dlistView = new JArray(); + // //Default ListView + // dynamic dlistView = new JArray(); - dynamic cm = new JObject(); - cm.fld = "customername"; - cm.sort = "+"; - dlistView.Add(cm); + // dynamic cm = new JObject(); + // cm.fld = "customername"; + // cm.sort = "+"; + // dlistView.Add(cm); - cm = new JObject(); - cm.fld = "customerphone1"; - dlistView.Add(cm); + // cm = new JObject(); + // cm.fld = "customerphone1"; + // dlistView.Add(cm); - cm = new JObject(); - cm.fld = "customeremail"; - dlistView.Add(cm); + // cm = new JObject(); + // cm.fld = "customeremail"; + // dlistView.Add(cm); - cm = new JObject(); - cm.fld = "customerheadoffice"; - dlistView.Add(cm); + // cm = new JObject(); + // cm.fld = "customerheadoffice"; + // dlistView.Add(cm); + + // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); + + DefaultColumns = new List() { "customername", "customerphone1", "customeremail", "customerheadoffice" }; + DefaultSortBy = new Dictionary() { { "customername", "+" } }; - DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); //NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely @@ -310,7 +313,7 @@ namespace AyaNova.DataList FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom16", FieldKey = "customercustom16", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "acustomer.customfields" }); } - + }//eoc }//eons \ No newline at end of file diff --git a/server/AyaNova/DataList/CustomerNoteDataList.cs b/server/AyaNova/DataList/CustomerNoteDataList.cs index 931a1705..71996530 100644 --- a/server/AyaNova/DataList/CustomerNoteDataList.cs +++ b/server/AyaNova/DataList/CustomerNoteDataList.cs @@ -14,24 +14,27 @@ namespace AyaNova.DataList var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType); AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; - //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ - //Default ListView - dynamic dlistView = new JArray(); + // //######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############ + // //Default ListView + // dynamic dlistView = new JArray(); - dynamic cm = new JObject(); - cm.fld = "notedate"; - cm.sort = "-"; - dlistView.Add(cm); + // dynamic cm = new JObject(); + // cm.fld = "notedate"; + // cm.sort = "-"; + // dlistView.Add(cm); - cm = new JObject(); - cm.fld = "notes"; - dlistView.Add(cm); + // cm = new JObject(); + // cm.fld = "notes"; + // dlistView.Add(cm); - cm = new JObject(); - cm.fld = "username"; - dlistView.Add(cm); - DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); + // cm = new JObject(); + // cm.fld = "username"; + // dlistView.Add(cm); + // DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None); + + DefaultColumns = new List() { "notedate", "notes", "username" }; + DefaultSortBy = new Dictionary() { { "notedate", "-" } }; //NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely @@ -78,10 +81,25 @@ namespace AyaNova.DataList }); } - public string DataListServerCriteria(AyaNova.Models.AyContext ct, long currentUserId, DataListOptions dataListOptions) + + public List DataListServerCriteria(long currentUserId, AuthorizationRoles userRoles, DataListBase dataListBase) { - throw new System.NotImplementedException(); + List ret = new List(); + //ClientCriteria MUST be CustomerId + if (string.IsNullOrWhiteSpace(dataListBase.ClientCriteria)) + throw new System.ArgumentNullException("CustomerNoteDataList - ClientCriteria is empty, should be Customer ID"); + + DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metacustomer" }; + + DataListColumnFilter ColumnFilter = new DataListColumnFilter(); + ColumnFilter.value = dataListBase.ClientCriteria; + ColumnFilter.op = "="; + FilterOption.items.Add(ColumnFilter); + + ret.Add(FilterOption); + return ret; } - + + }//eoc }//eons \ No newline at end of file diff --git a/server/AyaNova/models/DataListBase.cs b/server/AyaNova/models/DataListBase.cs index 1b69c675..3b34a28e 100644 --- a/server/AyaNova/models/DataListBase.cs +++ b/server/AyaNova/models/DataListBase.cs @@ -33,7 +33,7 @@ namespace AyaNova.Models public string Column { get; set; } public List items { get; set; } public bool Any { get; set; }//means "or" the filter conditions - DataListFilterOption() + public DataListFilterOption() { items = new List(); }