This commit is contained in:
2020-11-11 00:35:09 +00:00
parent 119752be02
commit c026e4145b
4 changed files with 164 additions and 5 deletions

View File

@@ -0,0 +1,153 @@
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using AyaNova.Biz;
namespace AyaNova.DataList
{
internal class CustomerDataList : AyaDataList
{
public CustomerDataList()
{
DefaultListObjectType = AyaType.Customer;
SQLFrom = "from acustomer";
var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType);
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
//######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############
//Default ListView
dynamic dlistView = new JArray();
dynamic cm = new JObject();
cm.fld = "customername";
dlistView.Add(cm);
cm = new JObject();
cm.fld = "customeraccountnumber";
dlistView.Add(cm);
cm = new JObject();
cm.fld = "active";
dlistView.Add(cm);
DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None);
// DefaultDataListView = @"
// {
// [{key:""COLUMN UNIQUE KEY ID",sort:"-" or "+",filter:{any:true/false,items:[{FILTER OBJECT SEE BELOW}]} }, {key:"second column unique key"},{...etc...}]
// ""full"":[""widgetname"",""widgetserial"",""widgetdollaramount"",""widgetusertype"",""widgetstartdate"",""widgetactive"",""username""],
// }
// ";
//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
FieldDefinitions = new List<AyaDataListFieldDefinition>();
//DEPRECATED: FieldDefinitions.Add(new AyaDataListFieldDefinition { FieldKey = "df", AyaObjectType = (int)AyaType.Customer, SqlIdColumnName = "awidget.id", IsFilterable = false, IsSortable = false, });
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
TKey = "CustomerName",
FieldKey = "widgetname",
AyaObjectType = (int)AyaType.Customer,
UiFieldDataType = (int)UiFieldDataType.Text,
SqlIdColumnName = "awidget.id",
SqlValueColumnName = "awidget.name",
IsRowId = true
});
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
TKey = "CustomerSerial",
FieldKey = "widgetserial",
UiFieldDataType = (int)UiFieldDataType.Integer,
SqlValueColumnName = "awidget.serial"
});
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
TKey = "CustomerDollarAmount",
FieldKey = "widgetdollaramount",
UiFieldDataType = (int)UiFieldDataType.Currency,
SqlValueColumnName = "awidget.dollaramount"
});
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
TKey = "CustomerCount",
FieldKey = "widgetcount",
UiFieldDataType = (int)UiFieldDataType.Integer,
SqlValueColumnName = "awidget.count"
});
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
TKey = "UserType",
FieldKey = "widgetusertype",
UiFieldDataType = (int)UiFieldDataType.Enum,
EnumType = AyaNova.Util.StringUtil.TrimTypeName(typeof(UserType).ToString()),
SqlValueColumnName = "awidget.usertype"
});
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
TKey = "CustomerStartDate",
FieldKey = "widgetstartdate",
UiFieldDataType = (int)UiFieldDataType.DateTime,
SqlValueColumnName = "awidget.startdate"
});
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
TKey = "CustomerEndDate",
FieldKey = "widgetenddate",
UiFieldDataType = (int)UiFieldDataType.DateTime,
SqlValueColumnName = "awidget.enddate"
});
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
TKey = "CustomerNotes",
FieldKey = "widgetnotes",
UiFieldDataType = (int)UiFieldDataType.Text,
SqlValueColumnName = "awidget.notes"
});
//FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "User", FieldKey = "userid", UiFieldDataType = (int)AyaUiFieldDataType.Text, AyaObjectType = (int)AyaType.User });
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
FieldKey = "username",
TKey = "User",
UiFieldDataType = (int)UiFieldDataType.Text,
AyaObjectType = (int)AyaType.User,
SqlIdColumnName = "auser.id",
SqlValueColumnName = "auser.name"
});
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
TKey = "Active",
FieldKey = "widgetactive",
UiFieldDataType = (int)UiFieldDataType.Bool,
SqlValueColumnName = "awidget.active"
});
FieldDefinitions.Add(new AyaDataListFieldDefinition
{
TKey = "Tags",
FieldKey = "widgettags",
UiFieldDataType = (int)UiFieldDataType.Tags,
SqlValueColumnName = "awidget.tags"
});
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom1", FieldKey = "widgetcustom1", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom2", FieldKey = "widgetcustom2", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom3", FieldKey = "widgetcustom3", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom4", FieldKey = "widgetcustom4", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom5", FieldKey = "widgetcustom5", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom6", FieldKey = "widgetcustom6", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom7", FieldKey = "widgetcustom7", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom8", FieldKey = "widgetcustom8", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom9", FieldKey = "widgetcustom9", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom10", FieldKey = "widgetcustom10", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom11", FieldKey = "widgetcustom11", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom12", FieldKey = "widgetcustom12", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom13", FieldKey = "widgetcustom13", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom14", FieldKey = "widgetcustom14", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom15", FieldKey = "widgetcustom15", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" });
FieldDefinitions.Add(new AyaDataListFieldDefinition { TKey = "CustomerCustom16", FieldKey = "widgetcustom16", IsCustomField = true, IsFilterable = false, IsSortable = false, SqlValueColumnName = "awidget.customfields" });
}
}//eoc
}//eons

View File

@@ -122,7 +122,7 @@ namespace AyaNova.Biz
#region Customer
{
List<AyaFormFieldDefinition> l = new List<AyaFormFieldDefinition>();
l.Add(new AyaFormFieldDefinition { TKey = "Name", FieldKey = "Name", Hideable = false });
l.Add(new AyaFormFieldDefinition { TKey = "CustomerName", FieldKey = "Name", Hideable = false });
l.Add(new AyaFormFieldDefinition { TKey = "CustomerNotes", FieldKey = "Notes" });
l.Add(new AyaFormFieldDefinition { TKey = "Active", FieldKey = "Active", Hideable = false });
l.Add(new AyaFormFieldDefinition { TKey = "Tags", FieldKey = "Tags" });

View File

@@ -35,10 +35,15 @@ namespace AyaNova.Models
public long? ContractID { get; set; }
public DateTime? ContractExpires { get; set; }
public long? DefaultServiceTemplateID { get; set; }
[Phone]
public string Phone1 { get; set; }
[Phone]
public string Phone2 { get; set; }
[Phone]
public string Phone3 { get; set; }
[Phone]
public string Phone4 { get; set; }
[Phone]
public string Phone5 { get; set; }
[EmailAddress]
public string EmailAddress { get; set; }
@@ -55,10 +60,10 @@ namespace AyaNova.Models
public string City { get; set; }
public string Region { get; set; }
public string Country { get; set; }
public decimal Latitude { get; set; }
public decimal Longitude { get; set; }
public decimal? Latitude { get; set; }
public decimal? Longitude { get; set; }
public Customer()
{
Tags = new List<string>();

View File

@@ -485,7 +485,8 @@ $BODY$;
await ExecQueryAsync("CREATE TABLE acustomer (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text not null unique, active bool, " +
"notes text, wiki text, customfields text, tags varchar(255) ARRAY, " +
"webaddress text, popupnotes text, billheadoffice bool, technotes text, accountnumber text, usesbanking bool, contractexpires timestamp null, " +
"phone1 text, phone2 text, phone3 text, phone4 text, phone5 text, emailaddress text)");
"phone1 text, phone2 text, phone3 text, phone4 text, phone5 text, emailaddress text, " +
"postaddress text, postcity text, postregion text, postcountry text, postcode text, address text, city text, region text, country text, latitude decimal(8,6), longitude decimal(9,6))");
await ExecQueryAsync("CREATE UNIQUE INDEX acustomer_name_id_idx ON acustomer (id, name);");
await ExecQueryAsync("CREATE INDEX acustomer_tags ON acustomer using GIN(tags)");