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

Employee filter

parent 9f623da9
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.3.2" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.2">
<name>Employee_entity</name>
<title>Employee</title>
<majorModelMode>DISTRIBUTED</majorModelMode>
<title>Employee</title>
<afterUiInit>%aditoprj%/entity/Employee_entity/afterUiInit.js</afterUiInit>
<onValidation>%aditoprj%/entity/Employee_entity/onValidation.js</onValidation>
<afterOperatingState>%aditoprj%/entity/Employee_entity/afterOperatingState.js</afterOperatingState>
<iconId>VAADIN:GROUP</iconId>
<iconId>VAADIN:USER</iconId>
<titleProcess>%aditoprj%/entity/Employee_entity/titleProcess.js</titleProcess>
<recordContainer>jdito</recordContainer>
<entityFields>
......@@ -277,9 +277,11 @@
</entityConsumer>
<entityField>
<name>USERID</name>
<searchable v="false" />
</entityField>
<entityField>
<name>USERID_SMALL</name>
<searchable v="false" />
</entityField>
</entityFields>
<recordContainers>
......
......@@ -40,7 +40,7 @@ users = users.map(function (user)
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);
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
......
......@@ -6,12 +6,13 @@ import("Sql_lib");
* @param {Array} pColumns the column names
* @param {String|Object} pFilter the filter object
*/
function JditoFilter (pColumns, pFilter)
function JditoFilterHelper (pColumns, pFilter)
{
var columnMap = {};
pColumns.forEach(function (row, i)
{
columnMap[row] = i;
if (row)
columnMap[row] = i;
});
this._columnMap = columnMap;
......@@ -29,7 +30,7 @@ function JditoFilter (pColumns, pFilter)
*
* @return {boolean} true, if it matches the condition
*/
JditoFilter.prototype.checkRecord = function (pRow)
JditoFilterHelper.prototype.checkRecord = function (pRow)
{
if (this._filters.length == 0)
return true;
......@@ -49,7 +50,7 @@ JditoFilter.prototype.checkRecord = function (pRow)
/**
* compares two values with the given operator
*/
JditoFilter.prototype._testValue = function (pRowValue, pFilterValue, pOperator)
JditoFilterHelper.prototype._testValue = function (pRowValue, pFilterValue, pOperator)
{
switch (pOperator)
{
......@@ -81,8 +82,7 @@ JditoFilter.prototype._testValue = function (pRowValue, pFilterValue, pOperator)
}
/**
* Provides functions for using the filter with jdito recordcontainers. You should only use this
* if there is no other, faster way to filter the records
* Provides functions for using the filter with jdito recordcontainers
*
* Do not instanciate this!
*
......@@ -91,9 +91,11 @@ JditoFilter.prototype._testValue = function (pRowValue, pFilterValue, pOperator)
function JditoFilterUtils () {}
/**
* Filters the given records
* Filters the given records manually. If you get the records using a sql query, you might consider using
* JditoFilterUtils.getSqlCondition instead for better performance.
*
* @param {Array} pColumns one dimensional array with all column names, the order has to match the columns of pRecords
* @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
*
......@@ -104,7 +106,7 @@ JditoFilterUtils.filterRecords = function (pColumns, pRecords, pFilter)
if (!pFilter)
return pRecords;
var filter = new JditoFilter(pColumns, pFilter);
var filter = new JditoFilterHelper(pColumns, pFilter);
return pRecords.filter(function (row)
{
......
import("Util_lib");
import("system.datetime");
import("system.translate");
import("system.db");
......@@ -173,8 +174,8 @@ OrgUtils.openOrgReport = function(pOrgId)
{
if (pJoinSeparator == undefined)
pJoinSeparator = " ";
pArr.splice(pIndex, pHowMany,
pArr.slice(pIndex, pIndex + pHowMany)
.filter(function (val) {return val;}).join(pJoinSeparator));
pArr.splice(pIndex, pHowMany, ArrayUtils.joinNonEmptyFields(
pArr.slice(pIndex, pIndex + pHowMany), pJoinSeparator)
);
}
}
\ No newline at end of file
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