Final (?) de-widgetification
This commit is contained in:
@@ -9,14 +9,7 @@ namespace AyaNova.PickList
|
||||
|
||||
internal static class PickListSqlBuilder
|
||||
{
|
||||
/*Example
|
||||
select awidget.id as plId, awidget.active as plActive, awidget.name || ' ' || awidget.serial || ' ' || auser.name as plname, awidget.tags
|
||||
from awidget left join auser on (awidget.userid=auser.id)
|
||||
where array_to_string(awidget.tags,',') like '%zone-8%'
|
||||
and awidget.active = true
|
||||
and ((awidget.name like '%we%') or (cast (awidget.serial as text) like '%we%') or (auser.name like '%we%'))
|
||||
order by awidget.name,awidget.serial,auser.name limit 100
|
||||
*/
|
||||
|
||||
|
||||
//Maximum number of results to return at any given time
|
||||
//did a little research and may adjust this but it can be fairly girthy in this day and age
|
||||
@@ -149,7 +142,7 @@ namespace AyaNova.PickList
|
||||
lOrderBy.Add(valueColumnName);
|
||||
|
||||
//THIS is the best filter method for a like comparison to each individual tag:
|
||||
//(array_to_string(awidget.tags,',') like '%zo%')
|
||||
//(array_to_string(acustomer.tags,',') like '%zo%')
|
||||
//Note that a tag specific query takes precendence over this which exists
|
||||
//in cases where there are tags in the template and the user has not specified a tag specific query
|
||||
//so this will handle it as a like query against all tags as a composite string of text just like
|
||||
@@ -191,7 +184,7 @@ namespace AyaNova.PickList
|
||||
lOrderBy.Add(valueColumnName);
|
||||
|
||||
//Where fragment is different for non text fields: it needs to be cast to text to like query on it
|
||||
//(cast (awidget.serial as text) like '%some%')
|
||||
//(cast (aworkorder.serial as text) like '%some%')
|
||||
if (HasAutoCompleteQuery)
|
||||
if (ServerGlobalBizSettings.Cache.SearchCaseSensitiveOnly)
|
||||
sWhere = $"(cast ({valueColumnName} as text) like '%{autoCompleteQuery}%')";
|
||||
@@ -221,9 +214,9 @@ namespace AyaNova.PickList
|
||||
sb.Append(", ");
|
||||
|
||||
//nope, this will return null if any of the values are null, very bad for this use, instead
|
||||
//select name || ' ' || serial || ' ' || array_to_string(tags,',') as display from awidget
|
||||
//select name || ' ' || serial || ' ' || array_to_string(tags,',') as display from acustomer
|
||||
//this, on the other hand will work even if all of them are null
|
||||
//concat_ws(' ', awidget.name, awidget.serial, auser.name)
|
||||
//concat_ws(' ', acustomer.name, acustomer.serial, auser.name)
|
||||
|
||||
sb.Append("concat_ws(' ', ");
|
||||
foreach (string s in lSelect)
|
||||
@@ -315,8 +308,8 @@ namespace AyaNova.PickList
|
||||
return sb.ToString();
|
||||
|
||||
}
|
||||
//"select awidget.id as plId || ' 'awidget.active as plActive || ' 'awidget.name || ' 'awidget.serial || ' 'auser.name as plname from awidget left join auser on (awidget.userid=auser.id)
|
||||
//where awidget.active = true and ((awidget.name like '%on%') or (cast (awidget.serial as text) like '%on%') or (auser.name like '%on%')) order by awidget.name,awidget.serial,auser.name limit 100"
|
||||
//"select acustomer.id as plId || ' 'acustomer.active as plActive || ' 'acustomer.name || ' 'acustomer.serial || ' 'auser.name as plname from acustomer left join auser on (acustomer.userid=auser.id)
|
||||
//where acustomer.active = true and ((acustomer.name like '%on%') or (cast (acustomer.serial as text) like '%on%') or (auser.name like '%on%')) order by acustomer.name,acustomer.serial,auser.name limit 100"
|
||||
|
||||
|
||||
}//eoc
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using AyaNova.Biz;
|
||||
namespace AyaNova.PickList
|
||||
{
|
||||
internal class WidgetPickList : AyaPickList
|
||||
{
|
||||
public WidgetPickList()
|
||||
{
|
||||
DefaultListAType = AyaType.Widget;
|
||||
SQLFrom = "from awidget left join auser on (awidget.userid=auser.id)";
|
||||
AllowedRoles = BizRoles.GetRoleSet(DefaultListAType).Select;
|
||||
|
||||
//Default template
|
||||
dynamic dTemplate = new JArray();
|
||||
|
||||
dynamic cm = new JObject();
|
||||
cm.fld = "widgetname";
|
||||
dTemplate.Add(cm);
|
||||
|
||||
cm = new JObject();
|
||||
cm.fld = "widgetserial";
|
||||
dTemplate.Add(cm);
|
||||
|
||||
cm = new JObject();
|
||||
cm.fld = "username";
|
||||
dTemplate.Add(cm);
|
||||
|
||||
cm = new JObject();
|
||||
cm.fld = "widgettags";
|
||||
dTemplate.Add(cm);
|
||||
|
||||
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
|
||||
ColumnDefinitions = new List<AyaPickListFieldDefinition>();
|
||||
ColumnDefinitions.Add(new AyaPickListFieldDefinition
|
||||
{
|
||||
TKey = "Active",
|
||||
FieldKey = "widgetactive",
|
||||
ColumnDataType = UiFieldDataType.Bool,
|
||||
SqlValueColumnName = "awidget.active",
|
||||
IsActiveColumn = true
|
||||
});
|
||||
|
||||
ColumnDefinitions.Add(new AyaPickListFieldDefinition
|
||||
{
|
||||
TKey = "WidgetName",
|
||||
FieldKey = "widgetname",
|
||||
//AType = AyaType.Widget,
|
||||
ColumnDataType = UiFieldDataType.Text,
|
||||
SqlIdColumnName = "awidget.id",
|
||||
SqlValueColumnName = "awidget.name",
|
||||
IsRowId = true
|
||||
});
|
||||
|
||||
ColumnDefinitions.Add(new AyaPickListFieldDefinition
|
||||
{
|
||||
TKey = "WidgetSerial",
|
||||
FieldKey = "widgetserial",
|
||||
ColumnDataType = UiFieldDataType.Integer,
|
||||
SqlValueColumnName = "awidget.serial"
|
||||
});
|
||||
|
||||
ColumnDefinitions.Add(new AyaPickListFieldDefinition
|
||||
{
|
||||
FieldKey = "username",
|
||||
TKey = "User",
|
||||
ColumnDataType = UiFieldDataType.Text,
|
||||
SqlIdColumnName = "auser.id",
|
||||
SqlValueColumnName = "auser.name"
|
||||
});
|
||||
|
||||
ColumnDefinitions.Add(new AyaPickListFieldDefinition
|
||||
{
|
||||
TKey = "Tags",
|
||||
FieldKey = "widgettags",
|
||||
ColumnDataType = UiFieldDataType.Tags,
|
||||
SqlValueColumnName = "awidget.tags"
|
||||
});
|
||||
}
|
||||
}//eoc
|
||||
}//eons
|
||||
Reference in New Issue
Block a user