Skip to content
Snippets Groups Projects
Commit d0cdac51 authored by S.Listl's avatar S.Listl
Browse files

Employee load contact title only for single rows

parent 7ad262fe
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,7 @@
<linkedContext>Person</linkedContext>
<mandatory v="true" />
<stateProcess>%aditoprj%/entity/Employee_entity/entityfields/contact_id/stateProcess.js</stateProcess>
<displayValueProcess>%aditoprj%/entity/Employee_entity/entityfields/contact_id/displayValueProcess.js</displayValueProcess>
<onValueChange>%aditoprj%/entity/Employee_entity/entityfields/contact_id/onValueChange.js</onValueChange>
<onValidation>%aditoprj%/entity/Employee_entity/entityfields/contact_id/onValidation.js</onValidation>
</entityField>
......@@ -379,9 +380,6 @@
<jDitoRecordFieldMapping>
<name>CONTACT_ID.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>CONTACT_ID.displayValue</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>DEPARTMENT.value</name>
<isFilterable v="true" />
......
import("system.vars");
import("system.result");
import("system.neon");
import("Contact_lib");
if (vars.get("$sys.viewmode") == neon.FRAME_VIEWMODE_DATASET)
result.string(ContactUtils.getTitleByContactId(vars.get("$field.CONTACT_ID")));
......@@ -22,10 +22,8 @@ else
var fetchRoles = vars.getString("$local.filter").indexOf("ROLE_FILTER") !== -1;
var contactIds = [];
users = users.map(function (user)
{
contactIds.push(user[tools.PARAMS][tools.CONTACTID]);
return [
user[tools.NAME],
user[tools.TITLE],
......@@ -43,24 +41,6 @@ users = users.map(function (user)
];
});
var renderer = new ContactTitleRenderer(Contact.createWithColumnPreset(), ContactTitleRenderer.OPTIONS.NoOption);
var selectExpression = renderer.asSql();
var idsPerPage = 1000;
var names = [];
for (let begin = 0, max = contactIds.length; begin < max; begin += idsPerPage)
{
names = names.concat(newSelect(["CONTACTID", selectExpression])
.from("CONTACT")
.leftJoin("PERSON", "(PERSON.PERSONID = CONTACT.PERSON_ID)")
.whereIfSet("CONTACT.CONTACTID", contactIds.slice(begin, begin + idsPerPage), SqlBuilder.IN())
.table(true));
}
var nameMap = {};
for (let i = 0, l = names.length; i < l; i++)
nameMap[names[i][0]] = names[i][1];
var filter = vars.get("$local.filter");
//TODO: this is a workaround that filters the records manually, it should be possible to filter the users with a tools.* method
......@@ -89,9 +69,8 @@ users = JditoFilterUtils.filterRecords(filterFields, users, filter.filter, filte
for (let i = 0, l = users.length; i < l; i++)
{
users[i][9] = nameMap[users[i][8]] || "";
users[i][12] = "";
users[i][13] = EmployeeUtils.sliceUserId(users[i][0]);
users[i][11] = "";
users[i][12] = EmployeeUtils.sliceUserId(users[i][0]);
}
var order = vars.get("$local.order");
......
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