Skip to content
Snippets Groups Projects
Commit e7a33223 authored by Daniel Tran's avatar Daniel Tran Committed by Johannes Goderbauer
Browse files

#1058757: district management impl

parent 7b23cd0f
No related branches found
No related tags found
No related merge requests found
Showing
with 436 additions and 6 deletions
import("system.vars");
import("system.result");
import("system.neon");
if (!vars.get("$field.parentFilter") || !vars.get("$field.PARENTDISTRICT_DISTRICTID"))
result.string(neon.COMPONENTSTATE_DISABLED);
else
result.string(neon.COMPONENTSTATE_READONLY);
\ No newline at end of file
import("system.result");
import("system.vars");
import("system.neon");
import("Sql_lib");
var res = "";
var parentDistrictId = vars.get("$field.PARENTDISTRICT_DISTRICTID");
if (parentDistrictId)
{
var completeParentFilter = _getParentFilter(parentDistrictId, null);
completeParentFilter.entity = "Organisation_entity";
res = completeParentFilter;
}
else
{
var entity = "Organisation_entity";
var emptyFilter = {
entity: entity,
filter: {
type: "group",
operator: "AND",
childs: []
}
};
res = emptyFilter;
}
result.string(JSON.stringify(res));
function _getParentFilter(pParentDistrictId, pPreviousFilter)
{
var resFilter;
if (pPreviousFilter != null)
{
resFilter = pPreviousFilter;
}
if (pParentDistrictId)
{
var parentDistrictFilter, grandParentDistrict;
[parentDistrictFilter, grandParentDistrict] = newSelect(["DISTRICT.DISTRICT_FILTER", "DISTRICT.PARENTDISTRICT_DISTRICTID"])
.from("DISTRICT")
.where("DISTRICT.DISTRICTID", pParentDistrictId)
.arrayRow();
parentDistrictFilter = JSON.parse(parentDistrictFilter);
if (pPreviousFilter)
parentDistrictFilter.filter.childs.push(resFilter.filter);//todo: kommentar ergänzen was wir heir eigentlcih machen
resFilter = parentDistrictFilter;
if (grandParentDistrict.length > 0)
{
resFilter = _getParentFilter(grandParentDistrict, resFilter);
}
}
return resFilter;
}
\ No newline at end of file
import("system.logging");
import("system.vars");
import("system.result");
import("system.entities");
import("system.neon");
var appliedFilter = vars.get("$field.DISTRICT_FILTER");
var conf, rows, districtTurnover = 0;
if (appliedFilter)
{
appliedFilter = JSON.parse(appliedFilter).filter;
appliedFilter = JSON.stringify(appliedFilter);
conf = entities.createConfigForLoadingRows()
.entity("Organisation_entity")
.fields(["TurnoverCurrentYear"])
.filter(appliedFilter);
rows = entities.getRows(conf);
for (i = 0; i < rows.length; i++) {
appliedFilter += Number(rows[i].TurnoverCurrentYear);
}
}
result.string(districtTurnover);
\ No newline at end of file
import("system.vars");
import("system.neon");
import("system.result");
var currentUser = null;
if (vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_EDIT)
{
currentUser = vars.get("$sys.user");
}
result.string(currentUser);
\ No newline at end of file
import("system.vars");
import("system.neon");
import("system.result");
var currentUser = null;
if (vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW)
{
currentUser = vars.get("$sys.user");
}
result.string(currentUser);
\ No newline at end of file
import("CachedRecordContainer_lib");
import("system.result");
var cacheKey;
cacheKey = CachedRecordContainerUtils.getCommonKey("$param.OnlyResponsibleDistricts");
result.string(cacheKey);
\ No newline at end of file
import("system.result");
import("system.vars");
import("Sql_lib");
var onlyResponsibleParam = vars.get("$param.OnlyResponsibleDistricts");
if (onlyResponsibleParam)
{
var responsibleDistricts = newSelect("DISTRICTRESPONSIBLE.DISTRICT_ID")
.from("DISTRICTRESPONSIBLE")
.where("DISTRICTRESPONSIBLE.EMPLOYEE_CONTACT_ID", onlyResponsibleParam)
.arrayColumn();
var cond = newWhere("DISTRICT.DISTRICTID", responsibleDistricts, SqlBuilder.IN());
result.string(cond.toString());
}
\ No newline at end of file
import("system.db");
import("system.result");
result.object({"DISTRICT_NUMBER" : db.ASCENDING});
\ No newline at end of file
import("system.result");
import("Sql_lib");
result.string(newSelect("DISTRICT.DISTRICT_NAME")
.from("DISTRICT")
.where("DISTRICT.PARENTDISTRICT_DISTRICTID = DISTRICT.DISTRICTID")
.toString());
\ No newline at end of file
......@@ -227,6 +227,18 @@
<fieldName>Documents</fieldName>
<isConsumer v="false" />
</entityDependency>
<entityDependency>
<name>b7b14281-6e78-4005-ad5b-14dffc4091f5</name>
<entityName>District_entity</entityName>
<fieldName>Documents</fieldName>
<isConsumer v="false" />
</entityDependency>
<entityDependency>
<name>e6553781-e306-4335-a929-2c2a8ad8270f</name>
<entityName>DistrictResponsible_entity</entityName>
<fieldName>Documents</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
<children>
<entityParameter>
......
......@@ -262,6 +262,12 @@
<fieldName>Leadimport_Empl</fieldName>
<isConsumer v="false" />
</entityDependency>
<entityDependency>
<name>e9a775ab-e63d-493d-94dc-6b27dfb77173</name>
<entityName>DistrictResponsible_entity</entityName>
<fieldName>Employees</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
<children>
<entityParameter>
......@@ -384,6 +390,10 @@
<name>#PROVIDER_AGGREGATES</name>
<useAggregates v="true" />
</entityProvider>
<entityParameter>
<name>DepartmentAttrIdByEmployeeContactId_param</name>
<expose v="true" />
</entityParameter>
</entityFields>
<recordContainers>
<jDitoRecordContainer>
......
......@@ -87,6 +87,12 @@
<fieldName>Languages</fieldName>
<isConsumer v="false" />
</entityDependency>
<entityDependency>
<name>9ee48241-5d40-46e9-83ec-a1dc55fdb7d5</name>
<entityName>District_entity</entityName>
<fieldName>Languages</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
<children>
<entityParameter>
......
......@@ -111,6 +111,18 @@
<fieldName>LogHistories</fieldName>
<isConsumer v="false" />
</entityDependency>
<entityDependency>
<name>fd46379e-f1be-4a9e-9914-4f3f81d96ad5</name>
<entityName>District_entity</entityName>
<fieldName>LogHistories</fieldName>
<isConsumer v="false" />
</entityDependency>
<entityDependency>
<name>e97b5f2d-d2e0-4539-96e9-e3f96107ffaa</name>
<entityName>DistrictResponsible_entity</entityName>
<fieldName>LogHistories</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
</entityProvider>
<entityParameter>
......
......@@ -174,12 +174,6 @@
<targetIdField>CONTACT_ID</targetIdField>
<recordContainer>db</recordContainer>
<dependencies>
<entityDependency>
<name>df6a9a25-f787-41f6-877b-c8e3cbbdc6be</name>
<entityName>Salesproject_entity</entityName>
<fieldName>Members</fieldName>
<isConsumer v="false" />
</entityDependency>
<entityDependency>
<name>efeb191c-dd03-46e1-b176-c4e0c2f75fc5</name>
<entityName>Campaign_entity</entityName>
......@@ -203,6 +197,28 @@
<name>#PROVIDER_AGGREGATES</name>
<useAggregates v="true" />
</entityProvider>
<entityConsumer>
<name>DistrictResponsibles</name>
<dependency>
<name>dependency</name>
</dependency>
</entityConsumer>
<entityProvider>
<name>WithDistrictResponsibles</name>
<recordContainer>jdito</recordContainer>
<dependencies>
<entityDependency>
<name>6f90b6c6-118c-485e-9a41-365bdc325f9b</name>
<entityName>Salesproject_entity</entityName>
<fieldName>Members</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
</entityProvider>
<entityField>
<name>UID</name>
<documentation>%aditoprj%/entity/Member_entity/entityfields/uid/documentation.adoc</documentation>
</entityField>
</entityFields>
<recordContainers>
<dbRecordContainer>
......@@ -325,5 +341,72 @@
</dbRecordFieldMapping>
</recordFieldMappings>
</dbRecordContainer>
<jDitoRecordContainer>
<name>jdito</name>
<jDitoRecordAlias>Data_alias</jDitoRecordAlias>
<contentProcess>%aditoprj%/entity/Member_entity/recordcontainers/jdito/contentProcess.js</contentProcess>
<recordFieldMappings>
<jDitoRecordFieldMapping>
<name>UID.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>OBJECTMEMBERID.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>CONTACT_ID.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>CONTACTROLE.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>DEPARTMENT.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>ICON.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>IMAGE.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>MEMBERROLE.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>OBJECT_ROWID.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>OBJECT_TYPE.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>ORG_ORGID.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>ORGANISATION_NAME.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>PERSON_FIRSTNAME.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>PERSON_FULL_NAME.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>PERSON_LASTNAME.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>PERSON_PERSID.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>PERSON_SALUTATION.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>PERSON_TITLE.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>POSITION.value</name>
</jDitoRecordFieldMapping>
<jDitoRecordFieldMapping>
<name>TARGETCONTEXT.value</name>
</jDitoRecordFieldMapping>
</recordFieldMappings>
</jDitoRecordContainer>
</recordContainers>
</entity>
Is only used by the jdito record container.
\ No newline at end of file
import("system.result");
import("system.vars");
import("system.entities");
import("KeywordRegistry_basic");
import("Sql_lib");
var idValues = vars.get("$local.idvalues");
var filter = vars.get("$local.filter");
var memberLoadingConfig = entities.createConfigForLoadingRows()
.entity("Member_entity")
.provider("Links")
.addParameter("ObjectRowId_param", vars.get("$param.ObjectRowId_param"))
.addParameter("ObjectType_param", vars.get("$param.ObjectType_param"))
.fields(["#UID", "CONTACT_ID", "CONTACTROLE", "DEPARTMENT", "ICON", "IMAGE", "MEMBERROLE", "OBJECT_ROWID", "OBJECT_TYPE",
"OBJECTMEMBERID", "ORG_ORGID", "ORGANISATION_NAME", "PERSON_FIRSTNAME", "PERSON_FULL_NAME",
"PERSON_LASTNAME", "PERSON_PERSID", "PERSON_SALUTATION", "PERSON_TITLE", "POSITION", "TARGETCONTEXT"]);
if (idValues)
{
memberLoadingConfig.uids(idValues);
}
if (filter && filter.filter != null)
{
memberLoadingConfig.filter(JSON.stringify(filter.filter));
}
var memberRows = entities.getRows(memberLoadingConfig);
if (vars.get("$param.ObjectType_param") == "Salesproject" && vars.get("$param.ObjectRowId_param") != null)
{
var orgContactId = newSelect("SALESPROJECT.CONTACT_ID")
.from("SALESPROJECT")
.where("SALESPROJECT.SALESPROJECTID", "$param.ObjectRowId_param")
.cell();
var districtLoadingConfig = entities.createConfigForLoadingRows()
.entity("DistrictResponsible_entity")
.provider("OrganisationResponsibles")
.addParameter("OrgUid_param", orgContactId)
.fields(["#UID","DISTRICTRESPONSIBLEID", "DISTRICT_ID", "EMPLOYEE_CONTACT_ID",
"EMPLOYEE_CONTACT_ID.displayValue", "USER_EDIT", "USER_NEW",
"departmentAttributeName", "DATE_EDIT", "DATE_NEW"]);
var districtRows = entities.getRows(districtLoadingConfig);
districtRows = districtRows.map(function(row)
{
return [row["#UID"], row["DISTRICTRESPONSIBLEID"], row["DISTRICT_ID"], row["EMPLOYEE_CONTACT_ID"], row["EMPLOYEE_CONTACT_ID.displayValue"],
row["USER_EDIT"], row["USER_NEW"], row["departmentAttributeName"], row["DATE_EDIT"], row["DATE_NEW"]];
});
}
memberRows = memberRows.map(function(row)
{
return [row["#UID"], row["OBJECTMEMBERID"], row["CONTACT_ID"], row["CONTACTROLE"], row["DEPARTMENT"], row["ICON"], row["IMAGE"], row["MEMBERROLE"], row["OBJECT_ROWID"],
row["OBJECT_TYPE"], row["ORG_ORGID"], row["ORGANISATION_NAME"], row["PERSON_FIRSTNAME"],
row["PERSON_FULL_NAME"], row["PERSON_LASTNAME"], row["PERSON_PERSID"], row["PERSON_SALUTATION"], row["PERSON_TITLE"],
row["POSITION"], row["TARGETCONTEXT"]];
});
var responsibleUids = [];
districtRows.forEach(function(row){
responsibleUids.push(row[3]);
});
var loadingConfPers = entities.createConfigForLoadingRows()
.entity("Person_entity")
.uids(responsibleUids)
.fields(["ORGANISATION_ID", "ORGANISATION_NAME", "CONTACTROLE", "POSITION",
"FIRSTNAME", "LASTNAME", "SALUTATION", "TITLE"]);
var persRows = entities.getRows(loadingConfPers);
var counter = 0;
persRows = persRows.map(function(row){
return [row["SALUTATION"], row["TITLE"], row["FIRSTNAME"], row["LASTNAME"],
row["ORGANISATION_NAME"], row["ORGANISATION_ID"], row["CONTACTROLE"],
row["POSITION"], row["PERSONID"]];
});
districtRows.forEach(function(row){
memberRows.push(
[row[0],
null,
row[3],
persRows[counter][6],
row[7],
"VAADIN:GLOBE",
"TEXT:" + row[4].substring(row[4].indexOf(" ", 0)+1, row[4].length),
"MEMBERROLEDISTRICTRESPONSIBLE",
vars.get("$param.ObjectRowId_param"),
vars.get("$param.ObjectType_param"),
persRows[counter][5],
persRows[counter][4],
persRows[counter][2],
row[4],
persRows[counter][3],
persRows[counter][8],
persRows[counter][0],
persRows[counter][1],
persRows[counter][7],
null
]);
counter++;
});
result.object(memberRows);
\ No newline at end of file
......@@ -144,6 +144,12 @@
<fieldName>OrganisationConsumer</fieldName>
<isConsumer v="false" />
</entityDependency>
<entityDependency>
<name>36d6824f-8f2f-4207-9dde-60f0b8f08815</name>
<entityName>District_entity</entityName>
<fieldName>Organisations</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
<children>
<entityParameter>
......@@ -1231,6 +1237,24 @@
<documentation>%aditoprj%/entity/Organisation_entity/entityfields/indexp/documentation.adoc</documentation>
<recordContainer>index</recordContainer>
</entityProvider>
<entityConsumer>
<name>DistrictResponsibles</name>
<dependency>
<name>dependency</name>
<entityName>DistrictResponsible_entity</entityName>
<fieldName>OrganisationResponsibles</fieldName>
</dependency>
<children>
<entityParameter>
<name>OrgUid_param</name>
<valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/districtresponsibles/children/orguid_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
<entityParameter>
<name>FilterPreSet_param</name>
<expose v="true" />
</entityParameter>
</entityFields>
<recordContainers>
<dbRecordContainer>
......
import("system.result");
import("system.vars");
result.string(vars.get("$field.CONTACTID"));
\ 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