diff --git a/process/Context_lib/process.js b/process/Context_lib/process.js index 7eee3571dbc1a681d7989b1a7aac05129c227cee..360093c0332a2c82b27fadf7d8f869c90740af26 100644 --- a/process/Context_lib/process.js +++ b/process/Context_lib/process.js @@ -108,31 +108,38 @@ ContextUtils._getSelectMap = function() { var maskingUtils = new SqlMaskingUtils(); return { - // contextId, - // nameField, - // Tablename (or from-part inc, joins), - // IDField, - // RelationField, - // CreationDate override Tablename (needed if Tablename is a join clause) - + // contextId: [ + // nameField, 0 + // Tablename, 1 + // joins (if needed), 2 + // IDField, 3 + // RelationField, 4 + // CreationDate, 5 + // override Tablename (needed if Tablename is a join clause) 6 + // ] + // // "Appointment": ["SUMMARY", "ASYS_CALENDARBACKEND", "UID"] "Organisation": [ "\"NAME\"", "ORGANISATION", + "", "ORGANISATIONID", "", "" ], "Person": [ (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", "CONTACT", - "" + "", + "CONTACT" ], "Activity": [ "SUBJECT", "ACTIVITY", + "", "ACTIVITYID", "", "" @@ -146,6 +153,7 @@ ContextUtils._getSelectMap = function() "PROJECTTITLE" ], "", false), "SALESPROJECT", + "", "SALESPROJECTID", "CONTACT_ID", "STARTDATE" @@ -156,6 +164,7 @@ ContextUtils._getSelectMap = function() maskingUtils.cast("CONTRACTCODE", SQLTYPES.VARCHAR, 10) ], " "), "CONTRACT", + "", "CONTRACTID", "CONTACT_ID", "CONTRACTSTART" @@ -169,6 +178,7 @@ ContextUtils._getSelectMap = function() maskingUtils.cast("VERSNR", SQLTYPES.VARCHAR, 10) ], "", false), "OFFER", + "", "OFFERID", "CONTACT_ID", "OFFERDATE" @@ -182,6 +192,7 @@ ContextUtils._getSelectMap = function() maskingUtils.cast("VERSNR", SQLTYPES.VARCHAR, 10) ], "", false), "SALESORDER", + "", "SALESORDERID", "CONTACT_ID", "ORDERDATE" @@ -193,6 +204,7 @@ ContextUtils._getSelectMap = function() "PRODUCTNAME" ], "", false), "PRODUCT", + "", "PRODUCTID", "", "" @@ -200,6 +212,7 @@ ContextUtils._getSelectMap = function() "Task": [ "SUBJECT", "TASK", + "", "TASKID", translate.text("Task"), "", @@ -210,8 +223,8 @@ ContextUtils._getSelectMap = function() ContextUtils.getFieldTitle = function(pContextId, pDefault) { - if (ContextUtils._getSelectMap()[pContextId] != undefined && ContextUtils._getSelectMap()[pContextId].length >= 3) - return ContextUtils._getSelectMap()[pContextId][3]; + if (ContextUtils._getSelectMap()[pContextId] != undefined && ContextUtils._getSelectMap()[pContextId].length >= 4) + return ContextUtils._getSelectMap()[pContextId][4]; return pDefault; } @@ -227,7 +240,7 @@ ContextUtils.getNameSubselectSql = function(pContextIdDbField, pRowIdDbField) var selectMap = ContextUtils._getSelectMap() 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()!'"; @@ -243,7 +256,9 @@ ContextUtils.getNameSql = function(pContextId, pRowId) { var selectMap = ContextUtils._getSelectMap() 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 return "select 1 from person where 1=2"; } @@ -257,12 +272,12 @@ ContextUtils.getContextDataSql = function(pContextId, pRowId, pWithDate) var cond = SqlCondition.begin(); if (pRowId) { - cond.andPrepare(selectMap[pContextId][1] + "." + selectMap[pContextId][3], pRowId) + cond.andPrepare(selectMap[pContextId][1] + "." + selectMap[pContextId][4], pRowId) } var dateColumn = ""; 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"); }