diff --git a/server/DataList/ProductDataList.cs b/server/DataList/ProductDataList.cs new file mode 100644 index 0000000..98cf311 --- /dev/null +++ b/server/DataList/ProductDataList.cs @@ -0,0 +1,89 @@ +using System.Collections.Generic; +using System.Linq; +using Sockeye.Biz; +using Sockeye.Models; + +namespace Sockeye.DataList +{ + internal class ProductDataList : DataListProcessingBase + { + public ProductDataList(long translationId) + { + DefaultListAType = SockType.Product; + SQLFrom = @"FROM aproduct LEFT JOIN avendor ON (aproduct.vendorid = avendor.id)"; + + var RoleSet = BizRoles.GetRoleSet(DefaultListAType); + AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; + DefaultColumns = new List() { "ProductName", "ProductVendorCode", "ProductOurCode" }; + DefaultSortBy = new Dictionary() { { "ProductName", "+" } }; + FieldDefinitions = new List(); + /* +await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'Product', 'Product' FROM atranslation t where t.baselanguage = 'en'"); +await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'ProductList', 'Products' FROM atranslation t where t.baselanguage = 'en'"); +await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'ProductName', 'Name' FROM atranslation t where t.baselanguage = 'en'"); +await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'ProductLicenseInterval', 'License period' FROM atranslation t where t.baselanguage = 'en'"); +await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'ProductMaintInterval', 'Maintenance period' FROM atranslation t where t.baselanguage = 'en'"); +await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'ProductVendorCode', 'Vendor code' FROM atranslation t where t.baselanguage = 'en'"); +await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'ProductOurCode', 'Our code' FROM atranslation t where t.baselanguage = 'en'"); +id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name TEXT NOT NULL, active BOOL NOT NULL DEFAULT true, " ++ "vendorid BIGINT NOT NULL REFERENCES avendor(id), licenseinterval INTERVAL, maintinterval INTERVAL, vendorcode TEXT NOT NULL, ourcode TEXT NOT NULL, " ++ "wiki TEXT, tags VARCHAR(255) ARRAY + */ + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "ProductName", + FieldKey = "ProductName", + SockType = (int)SockType.Product, + UiFieldDataType = (int)UiFieldDataType.Text, + SqlIdColumnName = "aproduct.id", + SqlValueColumnName = "aproduct.name", + IsRowId = true + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "Active", + FieldKey = "Active", + UiFieldDataType = (int)UiFieldDataType.Bool, + SqlValueColumnName = "aproduct.active" + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "ProductVendorCode", + FieldKey = "ProductVendorCode", + UiFieldDataType = (int)UiFieldDataType.Text, + SqlValueColumnName = "aproduct.vendorcode" + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "ProductOurCode", + FieldKey = "ProductOurCode", + UiFieldDataType = (int)UiFieldDataType.Text, + SqlValueColumnName = "aproduct.ourcode" + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "Vendor", + FieldKey = "Vendor", + SockType = (int)SockType.Vendor, + UiFieldDataType = (int)UiFieldDataType.Text, + SqlIdColumnName = "aproduct.vendorid", + SqlValueColumnName = "avendor.name" + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "Tags", + FieldKey = "producttags", + UiFieldDataType = (int)UiFieldDataType.Tags, + SqlValueColumnName = "aproduct.tags" + }); + + } + + }//eoc +}//eons \ No newline at end of file