From a4f6ae4356bdf413850dec02a19396c5d8b5781f Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 8 Feb 2021 14:56:07 +0000 Subject: [PATCH] --- .../AyaNova/DataList/ServiceBankDataList.cs | 71 +++++++++++-------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/server/AyaNova/DataList/ServiceBankDataList.cs b/server/AyaNova/DataList/ServiceBankDataList.cs index 3ae16246..b2444966 100644 --- a/server/AyaNova/DataList/ServiceBankDataList.cs +++ b/server/AyaNova/DataList/ServiceBankDataList.cs @@ -1,10 +1,10 @@ using System.Collections.Generic; -using Newtonsoft.Json.Linq; using AyaNova.Models; using AyaNova.Biz; +using System.Linq; namespace AyaNova.DataList { - internal class ServiceBankDataList : DataListProcessingBase + internal class ServiceBankDataList : DataListProcessingBase, IDataListInternalCriteria { public ServiceBankDataList() { @@ -166,44 +166,55 @@ namespace AyaNova.DataList SqlValueColumnName = "aservicebank.hoursbalance" }); - //META object id column + //META FieldDefinitions.Add(new DataListFieldDefinition { - FieldKey = "metaservicebankobjectid", + FieldKey = "metaobjectid", UiFieldDataType = (int)UiFieldDataType.InternalId, SqlIdColumnName = "aservicebank.objectid", SqlValueColumnName = "aservicebank.objectid", IsMeta = true }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + + FieldKey = "metaobjecttype", + UiFieldDataType = (int)UiFieldDataType.Enum, + EnumType = AyaNova.Util.StringUtil.TrimTypeName(typeof(AyaType).ToString()), + SqlValueColumnName = "aservicebank.objecttype", + IsMeta = true + }); } - /* - //TODO: support the clientCriteria - if (vm.objectId && vm.objectId != 0 && vm.objectType) { - // //DYNAMIC FILTER - // vm.metaView = JSON.stringify([ - // { - // fld: "metaservicebankobjectid", - // filter: { - // items: [{ op: "=", value: vm.objectId }] - // } - // }, - // { - // fld: "AyaType", - // filter: { - // items: [{ op: "=", value: vm.objectType }] - // } - // } - // ]); - // vm.name = await window.$gz.api.fetchBizObjectName( - // vm.objectType, - // vm.objectId - // ); - //OBJECTID,AYATYPE - vm.clientCriteria = `${vm.objectId},${vm.objectType}`; - } - */ + public List DataListInternalCriteria(long currentUserId, AuthorizationRoles userRoles, string clientCriteria) + { + List ret = new List(); + //ClientCriteria is optional for this list + //Format for this list is "PARTID,WAREHOUSENAME" where the id is 0 if not filtered or the id to filter + //and bizarrely the warehousename is text or empty if not filtered + var crit = (clientCriteria ?? "").Split(',').Select(z => z.Trim()).ToArray(); + if (crit.Length > 1) + { + //OBJECTID criteria + if (crit[0] != "0") + { + DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metaobjectid" }; + FilterOption.Items.Add(new DataListColumnFilter() { value = crit[0], op = DataListFilterComparisonOperator.Equality }); + ret.Add(FilterOption); + } + + //AYATYPE criteria + if (!string.IsNullOrWhiteSpace(crit[1])) + { + DataListFilterOption FilterOption = new DataListFilterOption() { Column = "metaobjecttype" }; + FilterOption.Items.Add(new DataListColumnFilter() { value = crit[1], op = DataListFilterComparisonOperator.Equality }); + ret.Add(FilterOption); + } + } + return ret; + } }//eoc }//eons \ No newline at end of file