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

[Projekt: Entwicklung - Neon][TicketNr.: 1041584][Filter - Attribute]

parent 76e50707
No related branches found
No related tags found
No related merge requests found
import("system.db");
import("Context_lib");
import("Sql_lib");
import("Attribute_lib");
import("system.vars");
import("system.result");
import("AttributeFilter_lib");
var name = vars.get("$local.name");
name = name.substr(name.lastIndexOf(".")+1);
name = JSON.parse(name);
var attributeId = name.id;
var dbField = AttributeTypeUtil.getDatabaseField(name.type);
var condition = vars.get("$local.condition");
condition = condition.replace("{'table.column'}", dbField, "g");
var preparedValues = [
[ContextUtils.getCurrentContextId(), SqlUtils.getSingleColumnType("AB_ATTRIBUTERELATION.OBJECT_TYPE")],
[attributeId, SqlUtils.getSingleColumnType("AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID")]
];
var resSql = "CONTACTID in (select CONTACT.CONTACTID \n\
from CONTACT \n\
left join AB_ATTRIBUTERELATION on (AB_ATTRIBUTERELATION.OBJECT_ROWID = CONTACT.CONTACTID \n\
and AB_ATTRIBUTERELATION.OBJECT_TYPE = ? \n\
and AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID = ?) \n\
where " + condition + " )";
resSql = db.translateCondition([resSql, preparedValues]);
result.string(resSql);
\ No newline at end of file
var sqlCond = AttributeFilterExtensionMaker.makeFilterConditionSql();
result.string(sqlCond);
\ No newline at end of file
import("Context_lib");
import("Attribute_lib");
import("system.entities");
import("system.result");
import("AttributeFilter_lib");
var res = [];
var loadingConfig = entities.createConfigForLoadingRows().entity("Attribute_entity")
.provider("SpecificAttribute")
.fields(["UID", "FULL_ATTRIBUTE_NAME", "ATTRIBUTE_TYPE"])
.addParameter("ObjectType_param", ContextUtils.getCurrentContextId());
var attributeRows = entities.getRows(loadingConfig);
attributeRows.forEach(function(row){
var attributeType = row["ATTRIBUTE_TYPE"];
var contentType = AttributeTypeUtil.getContentType(attributeType);
if (contentType)
{
var id = {id: row["UID"], type: attributeType};
id = JSON.stringify(id);
res.push({
name: id,
title: row["FULL_ATTRIBUTE_NAME"],
contentType: contentType == "UNKNOWN" ? "TEXT" : contentType, //TODO: temporary test
hasDropDownValues: contentType == "UNKNOWN" || contentType == "BOOLEAN" ? true : false//TODO: temporary test
});
}
});
res = JSON.stringify(res);
result.string(res);
\ No newline at end of file
var fields = AttributeFilterExtensionMaker.makeFilterFields();
result.string(fields);
\ No newline at end of file
import("Context_lib");
import("system.translate");
import("system.db");
import("system.result");
import("system.vars");
import("Attribute_lib");
import("Sql_lib");
import("AttributeFilter_lib");
var filter = JSON.parse(vars.getString("$local.filter"));
var name = JSON.parse(filter.name);
var attributeId = name.id;
var attrType = name.type.trim();
if (attrType == $AttributeTypes.COMBO.toString())
{
var valueSql = SqlCondition.begin()
.andPrepare("AB_ATTRIBUTE.ATTRIBUTE_ACTIVE", "1")
.andPrepare("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID", attributeId)
.andPrepare("AB_ATTRIBUTE.ATTRIBUTE_TYPE", $AttributeTypes.COMBOVALUE)
.buildSql("select AB_ATTRIBUTEID, ATTRIBUTE_NAME from AB_ATTRIBUTE", "1=2", "order by SORTING asc");
var valueList = db.table(valueSql);
for (let i = 0; i < valueList.length; i++)
{
valueList[i][1] = translate.text(valueList[i][1]);
}
result.object(valueList);
}
else if (attrType == $AttributeTypes.BOOLEAN.toString())
{
result.object([
["1", translate.text("Yes")],
["0", translate.text("No")]
]);
}
//TODO this is a workaround for keywords, when it's possible to use the consumer remove this
else if (attrType == $AttributeTypes.KEYWORD.toString())
{
var attrKeywordSelect = "select DROPDOWNDEFINITION from AB_ATTRIBUTE";
attrKeywordSelect = SqlCondition.begin()
.andPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", attributeId)
.buildSql(attrKeywordSelect);
var sql = SqlCondition.begin()
.andPrepare("AB_KEYWORD_ENTRY.CONTAINER", db.cell(attrKeywordSelect))
.buildSql("select AB_KEYWORD_ENTRY.KEYID, AB_KEYWORD_ENTRY.TITLE from AB_KEYWORD_ENTRY", "1=2", "order by SORTING asc");
var keywords = db.table(sql).map(function (row)
{
return [row[0], translate.text(row[1])];
});
result.object(keywords);
}
else if (attrType == $AttributeTypes.OBJECTSELECTION.toString())
{
var module = db.cell(SqlCondition.begin()
.andPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", attributeId)
.buildSql("select DROPDOWNDEFINITION from AB_ATTRIBUTE")
);
var objects = [];
objects = db.table(ContextUtils.getContextDataSql(module));
result.object(objects);
}
else
result.object(null)
\ No newline at end of file
var values = AttributeFilterExtensionMaker.makeFilterValues();
result.object(values);
\ 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