Skip to content
Snippets Groups Projects
Commit 18583498 authored by Johannes Hörmann's avatar Johannes Hörmann
Browse files

fix object relation display value

parent 61fb34dc
No related branches found
No related tags found
No related merge requests found
...@@ -108,31 +108,38 @@ ContextUtils._getSelectMap = function() ...@@ -108,31 +108,38 @@ ContextUtils._getSelectMap = function()
{ {
var maskingUtils = new SqlMaskingUtils(); var maskingUtils = new SqlMaskingUtils();
return { return {
// contextId, // contextId: [
// nameField, // nameField, 0
// Tablename (or from-part inc, joins), // Tablename, 1
// IDField, // joins (if needed), 2
// RelationField, // IDField, 3
// CreationDate override Tablename (needed if Tablename is a join clause) // RelationField, 4
// CreationDate, 5
// override Tablename (needed if Tablename is a join clause) 6
// ]
//
// "Appointment": ["SUMMARY", "ASYS_CALENDARBACKEND", "UID"] // "Appointment": ["SUMMARY", "ASYS_CALENDARBACKEND", "UID"]
"Organisation": [ "Organisation": [
"\"NAME\"", "\"NAME\"",
"ORGANISATION", "ORGANISATION",
"",
"ORGANISATIONID", "ORGANISATIONID",
"", "",
"" ""
], ],
"Person": [ "Person": [
(new ContactTitleRenderer(Contact.createWithColumnPreset()).asSql()), (new ContactTitleRenderer(Contact.createWithColumnPreset()).asSql()),
"PERSON join CONTACT on PERSON.PERSONID = CONTACT.PERSON_ID join ORGANISATION on ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID ", "PERSON",
" join CONTACT on PERSON.PERSONID = CONTACT.PERSON_ID join ORGANISATION on ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID ",
"CONTACTID", "CONTACTID",
"CONTACT", "CONTACT",
"" "",
"CONTACT"
], ],
"Activity": [ "Activity": [
"SUBJECT", "SUBJECT",
"ACTIVITY", "ACTIVITY",
"",
"ACTIVITYID", "ACTIVITYID",
"", "",
"" ""
...@@ -146,6 +153,7 @@ ContextUtils._getSelectMap = function() ...@@ -146,6 +153,7 @@ ContextUtils._getSelectMap = function()
"PROJECTTITLE" "PROJECTTITLE"
], "", false), ], "", false),
"SALESPROJECT", "SALESPROJECT",
"",
"SALESPROJECTID", "SALESPROJECTID",
"CONTACT_ID", "CONTACT_ID",
"STARTDATE" "STARTDATE"
...@@ -156,6 +164,7 @@ ContextUtils._getSelectMap = function() ...@@ -156,6 +164,7 @@ ContextUtils._getSelectMap = function()
maskingUtils.cast("CONTRACTCODE", SQLTYPES.VARCHAR, 10) maskingUtils.cast("CONTRACTCODE", SQLTYPES.VARCHAR, 10)
], " "), ], " "),
"CONTRACT", "CONTRACT",
"",
"CONTRACTID", "CONTRACTID",
"CONTACT_ID", "CONTACT_ID",
"CONTRACTSTART" "CONTRACTSTART"
...@@ -169,6 +178,7 @@ ContextUtils._getSelectMap = function() ...@@ -169,6 +178,7 @@ ContextUtils._getSelectMap = function()
maskingUtils.cast("VERSNR", SQLTYPES.VARCHAR, 10) maskingUtils.cast("VERSNR", SQLTYPES.VARCHAR, 10)
], "", false), ], "", false),
"OFFER", "OFFER",
"",
"OFFERID", "OFFERID",
"CONTACT_ID", "CONTACT_ID",
"OFFERDATE" "OFFERDATE"
...@@ -182,6 +192,7 @@ ContextUtils._getSelectMap = function() ...@@ -182,6 +192,7 @@ ContextUtils._getSelectMap = function()
maskingUtils.cast("VERSNR", SQLTYPES.VARCHAR, 10) maskingUtils.cast("VERSNR", SQLTYPES.VARCHAR, 10)
], "", false), ], "", false),
"SALESORDER", "SALESORDER",
"",
"SALESORDERID", "SALESORDERID",
"CONTACT_ID", "CONTACT_ID",
"ORDERDATE" "ORDERDATE"
...@@ -193,6 +204,7 @@ ContextUtils._getSelectMap = function() ...@@ -193,6 +204,7 @@ ContextUtils._getSelectMap = function()
"PRODUCTNAME" "PRODUCTNAME"
], "", false), ], "", false),
"PRODUCT", "PRODUCT",
"",
"PRODUCTID", "PRODUCTID",
"", "",
"" ""
...@@ -200,6 +212,7 @@ ContextUtils._getSelectMap = function() ...@@ -200,6 +212,7 @@ ContextUtils._getSelectMap = function()
"Task": [ "Task": [
"SUBJECT", "SUBJECT",
"TASK", "TASK",
"",
"TASKID", "TASKID",
translate.text("Task"), translate.text("Task"),
"", "",
...@@ -210,8 +223,8 @@ ContextUtils._getSelectMap = function() ...@@ -210,8 +223,8 @@ ContextUtils._getSelectMap = function()
ContextUtils.getFieldTitle = function(pContextId, pDefault) ContextUtils.getFieldTitle = function(pContextId, pDefault)
{ {
if (ContextUtils._getSelectMap()[pContextId] != undefined && ContextUtils._getSelectMap()[pContextId].length >= 3) if (ContextUtils._getSelectMap()[pContextId] != undefined && ContextUtils._getSelectMap()[pContextId].length >= 4)
return ContextUtils._getSelectMap()[pContextId][3]; return ContextUtils._getSelectMap()[pContextId][4];
return pDefault; return pDefault;
} }
...@@ -227,7 +240,7 @@ ContextUtils.getNameSubselectSql = function(pContextIdDbField, pRowIdDbField) ...@@ -227,7 +240,7 @@ ContextUtils.getNameSubselectSql = function(pContextIdDbField, pRowIdDbField)
var selectMap = ContextUtils._getSelectMap() var selectMap = ContextUtils._getSelectMap()
for (let contextId in selectMap) for (let contextId in selectMap)
{ {
select += "when '" + contextId + "' then (select " + selectMap[contextId][0] + " from " + selectMap[contextId][1] + (pRowIdDbField ? " where " + selectMap[contextId][2] + " = " + pRowIdDbField : " ") + ") "; select += "when '" + contextId + "' then (select " + selectMap[contextId][0] + " from " + selectMap[contextId][1] + " " + selectMap[contextId][2] + (pRowIdDbField ? " where " + selectMap[contextId][3] + " = " + pRowIdDbField : " ") + ") ";
} }
select += "else 'Not defined in ContextUtils.getNameSql()!'"; select += "else 'Not defined in ContextUtils.getNameSql()!'";
...@@ -243,7 +256,9 @@ ContextUtils.getNameSql = function(pContextId, pRowId) ...@@ -243,7 +256,9 @@ ContextUtils.getNameSql = function(pContextId, pRowId)
{ {
var selectMap = ContextUtils._getSelectMap() var selectMap = ContextUtils._getSelectMap()
if (selectMap[pContextId] != undefined) if (selectMap[pContextId] != undefined)
return SqlCondition.begin().andPrepare((selectMap[pContextId][4] ? selectMap[pContextId][4] : selectMap[pContextId][1]) + "." + selectMap[pContextId][2], pRowId).buildSql("select " + selectMap[pContextId][0] + " from " + selectMap[pContextId][1], "1=2"); {
return SqlCondition.begin().andPrepare((selectMap[pContextId][6] ? selectMap[pContextId][6] : selectMap[pContextId][1]) + "." + selectMap[pContextId][3], pRowId).buildSql("select " + selectMap[pContextId][0] + " from " + selectMap[pContextId][1] + " " + selectMap[pContextId][2], "1=2");
}
else else
return "select 1 from person where 1=2"; return "select 1 from person where 1=2";
} }
...@@ -257,12 +272,12 @@ ContextUtils.getContextDataSql = function(pContextId, pRowId, pWithDate) ...@@ -257,12 +272,12 @@ ContextUtils.getContextDataSql = function(pContextId, pRowId, pWithDate)
var cond = SqlCondition.begin(); var cond = SqlCondition.begin();
if (pRowId) if (pRowId)
{ {
cond.andPrepare(selectMap[pContextId][1] + "." + selectMap[pContextId][3], pRowId) cond.andPrepare(selectMap[pContextId][1] + "." + selectMap[pContextId][4], pRowId)
} }
var dateColumn = ""; var dateColumn = "";
if (pWithDate === true) if (pWithDate === true)
dateColumn = ", " + selectMap[pContextId][4]; dateColumn = ", " + selectMap[pContextId][6];
return cond.buildSql("select " + selectMap[pContextId][2] + ", " + selectMap[pContextId][0] + dateColumn + " from " + selectMap[pContextId][1], "1=1"); return cond.buildSql("select " + selectMap[pContextId][3] + ", " + selectMap[pContextId][0] + dateColumn + " from " + selectMap[pContextId][1] + " " + selectMap[pContextId][2], "1=1");
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment