Skip to content
Snippets Groups Projects
Commit ab0c105a authored by Johannes Goderbauer's avatar Johannes Goderbauer
Browse files

Contact: Get view value now supports with or without Organisation-modes

parent 03f682a6
No related branches found
No related tags found
No related merge requests found
......@@ -67,12 +67,18 @@ function ContactUtils() {}
* does not validate if pRelationIdField exists or is a valid or harmful value
*
* @param {String} pContactIdField fieldname for the CONTACTID-condition as TABLEALIAS.COLUMNALIAS; e.g. TASK.EDITOR_CONTACT_ID
* @param {Boolean} [pIncludeOrganisation=true] false if the organisation shall not be included in the result string
* @return {String} a subsql (without bracets) that can be played within an SQL
*/
ContactUtils.getResolvingDisplaySubSql = function(pContactIdField)
ContactUtils.getResolvingDisplaySubSql = function(pContactIdField, pIncludeOrganisation)
{
var contact = Contact.createWithColumnPreset();
var renderer = new ContactTitleRenderer(contact, ContactTitleRenderer.OPTIONS.IncludeOrganisation);
var rendererOptions;
if (pIncludeOrganisation === false)
rendererOptions = ContactTitleRenderer.OPTIONS.NoOption;
else
rendererOptions = ContactTitleRenderer.OPTIONS.IncludeOrganisation;
var renderer = new ContactTitleRenderer(contact, rendererOptions);
var selectExpression = renderer.asSql();
//TODO: verify if there is a better solution for the usage of this as a displayValueExpression --> automatic use of #TITLE | waiting vor implementation
......@@ -342,10 +348,11 @@ ContactUtils.getOrgContactId = function(pOrgId)
* get the name of the person or organisation
*
* @param {String} pContactId the contact id where pers-name or orgname shall be loaded
* @param {Boolean} [pIncludeOrganisation=true] false if the organisation shall not be included in the result string
*
* @return {String} the name or ""
*/
ContactUtils.getFullTitleByContactId = function(pContactId)
ContactUtils.getFullTitleByContactId = function(pContactId, pIncludeOrganisation)
{
var data = newSelect("ORGANISATION.NAME, PERSON.SALUTATION, PERSON.TITLE, PERSON.FIRSTNAME, PERSON.MIDDLENAME, PERSON.LASTNAME")
.from("CONTACT")
......@@ -358,7 +365,12 @@ ContactUtils.getFullTitleByContactId = function(pContactId)
return "";
var contact = new Contact();
[contact.organisationName, contact.salutation, contact.title, contact.firstname, contact.middlename, contact.lastname] = data;
var renderer = new ContactTitleRenderer(contact);
var rendererOptions;
if (pIncludeOrganisation === false)
rendererOptions = ContactTitleRenderer.OPTIONS.NoOption;
else
rendererOptions = ContactTitleRenderer.OPTIONS.IncludeOrganisation;
var renderer = new ContactTitleRenderer(contact, rendererOptions);
return renderer.asString();
}
......@@ -367,10 +379,11 @@ ContactUtils.getFullTitleByContactId = function(pContactId)
* do not use this for a mass of data (e.g. in a loop) since this will be slow due to select-time
*
* @param {String} pPersonId the id of the person where the data shall be loaded
* @param {Boolean} [pIncludeOrganisation=true] false if the organisation shall not be included in the result string
*
* @return {String} the name or ""
*/
ContactUtils.getTitleByPersonId = function(pPersonId)
ContactUtils.getTitleByPersonId = function(pPersonId, pIncludeOrganisation)
{
var data = newSelect("PERSON.SALUTATION, PERSON.TITLE, PERSON.FIRSTNAME, PERSON.MIDDLENAME, PERSON.LASTNAME")
.from("PERSON")
......@@ -381,7 +394,12 @@ ContactUtils.getTitleByPersonId = function(pPersonId)
return "";
var contact = new Contact();
[contact.salutation, contact.title, contact.firstname, contact.middlename, contact.lastname] = data;
var renderer = new ContactTitleRenderer(contact);
var rendererOptions;
if (pIncludeOrganisation === false)
rendererOptions = ContactTitleRenderer.OPTIONS.NoOption;
else
rendererOptions = ContactTitleRenderer.OPTIONS.IncludeOrganisation;
var renderer = new ContactTitleRenderer(contact, rendererOptions);
return renderer.asString();
}
......@@ -644,6 +662,7 @@ function ContactTitleRenderer(pContact, pOptions)
var res = maskingUtil.concat([this.contact.salutation, this.contact.title, this.contact.firstname, this.contact.middlename, this.contact.lastname].filter(function (e){
return e != "";
}), " ");
//binary AND check for possibility to check serveral options
if (this._options & ContactTitleRenderer.OPTIONS.IncludeOrganisation && this.contact.organisationName)
res = maskingUtil.concat([res, this.contact.organisationName], " | ");
return res;
......@@ -652,7 +671,7 @@ function ContactTitleRenderer(pContact, pOptions)
//function that renders the contact into a text (e.g. for a displayValue)
this._asStringFn = function (){
var res = StringUtils.concat(" ", [this.contact.salutation, this.contact.title, this.contact.firstname, this.contact.middlename, this.contact.lastname]);
//binary AND check for possibility to check serveral options
if (this._options & ContactTitleRenderer.OPTIONS.IncludeOrganisation && this.contact.organisationName)
res = StringUtils.concat(" | ", [res, this.contact.organisationName]);
return res;
......
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