From fd1b3fc18c9470b7163e39827bc662ed605f57d7 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 8 Feb 2021 15:00:09 +0000 Subject: [PATCH] --- server/AyaNova/DataList/ReviewDataList.cs | 119 +++++++++++------- .../AyaNova/DataList/ServiceBankDataList.cs | 6 +- 2 files changed, 79 insertions(+), 46 deletions(-) diff --git a/server/AyaNova/DataList/ReviewDataList.cs b/server/AyaNova/DataList/ReviewDataList.cs index 1c9a804f..77d802f0 100644 --- a/server/AyaNova/DataList/ReviewDataList.cs +++ b/server/AyaNova/DataList/ReviewDataList.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using AyaNova.Models; using AyaNova.Biz; +using System.Linq; namespace AyaNova.DataList { internal class ReviewDataList : DataListProcessingBase, IDataListInternalCriteria @@ -149,25 +150,7 @@ namespace AyaNova.DataList SqlValueColumnName = "areview.tags" }); - //META userid column - FieldDefinitions.Add(new DataListFieldDefinition - { - FieldKey = "metareviewuser", - UiFieldDataType = (int)UiFieldDataType.InternalId, - SqlIdColumnName = "areview.userid", - SqlValueColumnName = "areview.userid", - IsMeta = true - }); - //META object id column - FieldDefinitions.Add(new DataListFieldDefinition - { - FieldKey = "metareviewobjectid", - UiFieldDataType = (int)UiFieldDataType.InternalId, - SqlIdColumnName = "areview.objectid", - SqlValueColumnName = "areview.objectid", - IsMeta = true - }); FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReviewCustom1", FieldKey = "ReviewCustom1", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areview.customfields" }); FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReviewCustom2", FieldKey = "ReviewCustom2", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areview.customfields" }); @@ -186,6 +169,36 @@ namespace AyaNova.DataList FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReviewCustom15", FieldKey = "ReviewCustom15", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areview.customfields" }); FieldDefinitions.Add(new DataListFieldDefinition { TKey = "ReviewCustom16", FieldKey = "ReviewCustom16", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "areview.customfields" }); + + + //META COLUMNS + FieldDefinitions.Add(new DataListFieldDefinition + { + FieldKey = "metareviewuser", + UiFieldDataType = (int)UiFieldDataType.InternalId, + SqlIdColumnName = "areview.userid", + SqlValueColumnName = "areview.userid", + IsMeta = true + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + FieldKey = "metareviewobjectid", + UiFieldDataType = (int)UiFieldDataType.InternalId, + SqlIdColumnName = "areview.objectid", + SqlValueColumnName = "areview.objectid", + IsMeta = true + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + + FieldKey = "metaobjecttype", + UiFieldDataType = (int)UiFieldDataType.Enum, + EnumType = AyaNova.Util.StringUtil.TrimTypeName(typeof(AyaType).ToString()), + SqlValueColumnName = "areview.objecttype", + IsMeta = true + }); } @@ -210,30 +223,30 @@ namespace AyaNova.DataList public List DataListInternalCriteria(long currentUserId, AuthorizationRoles userRoles, string clientCriteria) { //TODO: support this clientcriteria - // if (vm.objectId && vm.objectId != 0 && vm.objectType) { - // //REMOVE COMMENT BLOCK AFTER TESTING - // // //pre-filter - // // vm.metaView = JSON.stringify([ - // // { - // // fld: "metareviewobjectid", - // // 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}`; - // } + // if (vm.objectId && vm.objectId != 0 && vm.objectType) { + // //REMOVE COMMENT BLOCK AFTER TESTING + // // //pre-filter + // // vm.metaView = JSON.stringify([ + // // { + // // fld: "metareviewobjectid", + // // 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}`; + // } List ret = new List(); bool HasSupervisorRole = userRoles.HasFlag(AuthorizationRoles.BizAdminFull) @@ -250,6 +263,28 @@ namespace AyaNova.DataList ret.Add(FilterOption); } + + //ClientCriteria format for this list is "OBJECTID,AYATYPE" + 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; } diff --git a/server/AyaNova/DataList/ServiceBankDataList.cs b/server/AyaNova/DataList/ServiceBankDataList.cs index b2444966..dec36bb5 100644 --- a/server/AyaNova/DataList/ServiceBankDataList.cs +++ b/server/AyaNova/DataList/ServiceBankDataList.cs @@ -191,10 +191,8 @@ namespace AyaNova.DataList 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 + + //ClientCriteria format for this list is "OBJECTID,AYATYPE" var crit = (clientCriteria ?? "").Split(',').Select(z => z.Trim()).ToArray(); if (crit.Length > 1) {