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

Jdito entities filter fix

parent a56f0e31
No related branches found
No related tags found
No related merge requests found
......@@ -12,9 +12,9 @@ if (vars.exists("$param.ObjectType_param") && vars.get("$param.ObjectType_param"
var active;
var selectMap = ContextUtils.getSelectMap ()
if(vars.exists("$local.filter") && vars.get("$local.filter") )
if(vars.exists("$local.userfilter") && vars.get("$local.userfilter") )
{
var filter = JSON.parse(vars.getString("$local.filter"));
var filter = JSON.parse(vars.getString("$local.userfilter"));
if(filter.childs != null && filter.childs.length > 0)
{
filter.childs.forEach(function(child)
......
......@@ -320,6 +320,7 @@
<jDitoRecordContainer>
<name>jdito</name>
<jDitoRecordAlias>Data_alias</jDitoRecordAlias>
<isFilterable v="true" />
<isSortable v="true" />
<contentProcess>%aditoprj%/entity/Attribute_entity/recordcontainers/jdito/contentProcess.js</contentProcess>
<onInsert>%aditoprj%/entity/Attribute_entity/recordcontainers/jdito/onInsert.js</onInsert>
......
......@@ -69,9 +69,9 @@ else if (parentType)
}
//when there are filters selected, add them to the conditon
if (vars.exists("$local.filter") && vars.get("$local.filter"))
if (vars.exists("$local.userfilter") && vars.get("$local.userfilter"))
{
var filter = vars.get("$local.filter");
var filter = vars.get("$local.userfilter");
condition.andSqlCondition(JditoFilterUtils.getSqlCondition(filter, "AB_ATTRIBUTE", uidTableAlias));
}
......
......@@ -276,6 +276,7 @@
<jDitoRecordContainer>
<name>jdito</name>
<jDitoRecordAlias>Data_alias</jDitoRecordAlias>
<isFilterable v="true" />
<contentProcess>%aditoprj%/entity/Employee_entity/recordcontainers/jdito/contentProcess.js</contentProcess>
<onInsert>%aditoprj%/entity/Employee_entity/recordcontainers/jdito/onInsert.js</onInsert>
<onUpdate>%aditoprj%/entity/Employee_entity/recordcontainers/jdito/onUpdate.js</onUpdate>
......
import("Attribute_lib");
import("system.vars");
import("system.result");
import("system.tools");
import("Util_lib");
import("Contact_lib");
import("JditoFilter_lib");
import("Employee_lib");
var users;
if (vars.exists("$local.idvalues") && vars.get("$local.idvalues"))
users = [tools.getUserByAttribute(tools.NAME, vars.get("$local.idvalues"), tools.PROFILE_FULL)];
else
{
var values = ["true", "false"];
if (vars.exists("$param.OnlyActives_param") && vars.get("$param.OnlyActives_param") == "true")
values = ["true"];
users = tools.getUsersByAttribute(tools.ISACTIVE, values, tools.PROFILE_FULL);
}
users = users.map(function (user)
{
return [
user[tools.NAME],
user[tools.TITLE],
user[tools.PARAMS][tools.ISACTIVE],
user[tools.PARAMS][tools.FIRSTNAME],
user[tools.PARAMS][tools.LASTNAME],
user[tools.PARAMS][tools.EMAIL],
user[tools.PARAMS][tools.EMAIL],
user[tools.DESCRIPTION],
user[tools.PARAMS][tools.CONTACTID],
ContactUtils.getTitleByContactId(user[tools.PARAMS][tools.CONTACTID]), //TODO: get the names more efficiently
user[tools.PARAMS].department
];
});
var filter = vars.exists("$local.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
users = JditoFilterUtils.filterRecords(["UID", "TITLE", "ISACTIVE", "FIRSTNAME", "LASTNAME", "EMAIL_ADDRESS", "", "DESCRIPTION", "CONTACT_ID", "", "DEPARTMENT"], users, filter);
ArrayUtils.sort2d(users, 0, true, false); //sort by username
result.object(users);
import("Attribute_lib");
import("system.vars");
import("system.result");
import("system.tools");
import("Util_lib");
import("Contact_lib");
import("JditoFilter_lib");
import("Employee_lib");
var users;
if (vars.exists("$local.idvalues") && vars.get("$local.idvalues"))
users = [tools.getUserByAttribute(tools.NAME, vars.get("$local.idvalues"), tools.PROFILE_FULL)];
else
{
var values = ["true", "false"];
if (vars.exists("$param.OnlyActives_param") && vars.get("$param.OnlyActives_param") == "true")
values = ["true"];
users = tools.getUsersByAttribute(tools.ISACTIVE, values, tools.PROFILE_FULL);
}
users = users.map(function (user)
{
return [
user[tools.NAME],
user[tools.TITLE],
user[tools.PARAMS][tools.ISACTIVE],
user[tools.PARAMS][tools.FIRSTNAME],
user[tools.PARAMS][tools.LASTNAME],
user[tools.PARAMS][tools.EMAIL],
user[tools.PARAMS][tools.EMAIL],
user[tools.DESCRIPTION],
user[tools.PARAMS][tools.CONTACTID],
ContactUtils.getTitleByContactId(user[tools.PARAMS][tools.CONTACTID]), //TODO: get the names more efficiently
user[tools.PARAMS].department
];
});
var filter = vars.exists("$local.userfilter") && vars.get("$local.userfilter");
//TODO: this is a workaround that filters the records manually, it should be possible to filter the users with a tools.* method
users = JditoFilterUtils.filterRecords(["UID", "TITLE", "ISACTIVE", "FIRSTNAME", "LASTNAME", "EMAIL_ADDRESS", "", "DESCRIPTION", "CONTACT_ID", "", "DEPARTMENT"], users, filter);
ArrayUtils.sort2d(users, 0, true, false); //sort by username
result.object(users);
......@@ -31,9 +31,9 @@ var tableNameCond = _getTableNameCondition();
recordCond.andSqlCondition(tableNameCond);
//user defined filter
if (vars.exists("$local.filter") && vars.get("$local.filter"))
if (vars.exists("$local.userfilter") && vars.get("$local.userfilter"))
{
var filter = vars.get("$local.filter");
var filter = vars.get("$local.userfilter");
recordCond.andSqlCondition((JditoFilterUtils.getSqlCondition(filter, "AB_LOGHISTORY")));
}
......
......@@ -33,7 +33,7 @@ if (uidParam)
}
else
{
var filter = vars.get("$local.filter")
var filter = vars.get("$local.userfilter")
var selectedRelationType = null;
if (filter)
......
......@@ -97,7 +97,7 @@ function JditoFilterUtils () {}
* @param {Array} pColumns one dimensional array with all column names (only the columns with the idValue, displayValue columns should be null or ""),
* the order has to match the columns of the recordFields property in the recordcontainer
* @param {Array} pRecords two dimensional array with all records
* @param {String|Object} pFilter the value of $local.filter
* @param {String|Object} pFilter the value of $local.userfilter
*
* @return {Array} the filtered records
*/
......@@ -117,19 +117,25 @@ JditoFilterUtils.filterRecords = function (pColumns, pRecords, pFilter)
/**
* builds an sql condition from the given filter
*
* @param {String|Object} pFilter the filter as JSON
* @param {Object} pFilter the filter object
* @param {String} pTable the database table
* @param {String} [pTableAlias=null] the database table alias
* @param {Object} [pColumnMap=null] custom mapping for the fields to the DB columns, this is necessary
* if the fields are from different tables
* @param {Object} [pColumnMap=null] Custom mapping for the fields to the DB columns, this is necessary
* if the fields are from different tables. Structure has to be like this:
* {
* FIELD1 : "TABLE1.COLUMN1",
* FIELD2 : ["TABLE2", "COLUMN2", "TABLE2ALIAS"] //do it like this if the table has an alias
* }
*
* @example
* if (vars.exists("$local.filter") && vars.get("$local.filter"))
* var condition = SqlCondition.begin();
* if (vars.exists("$local.userfilter") && vars.get("$local.userfilter"))
* {
* var filter = vars.get("$local.filter");
* var filter = vars.get("$local.userfilter");
* condition.andSqlCondition((JditoFilterUtils.getSqlCondition(filter, "AB_ATTRIBUTE")));
* }
*
* var attributeSql = condition.buildSql("select AB_ATTRIBUTEID from AB_ATTRIBUTE");
*
* @return {SqlCondition} the SqlCondition object
*/
JditoFilterUtils.getSqlCondition = function (pFilter, pTable, pTableAlias, pColumnMap)
......@@ -138,8 +144,6 @@ JditoFilterUtils.getSqlCondition = function (pFilter, pTable, pTableAlias, pColu
if (!pFilter)
return condition;
if (pFilter.length) //check if pFilter is a string
pFilter = pFilter;
if (!pColumnMap)
pColumnMap = {};
......
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