diff --git a/entity/ObjectTree_entity/entityfields/target_id/linkedContextProcess.js b/entity/ObjectTree_entity/entityfields/target_id/linkedContextProcess.js index 1309ba4e92dedd6284a0482f87b00c1c46a0f7c8..215d53285d594413acd924470d6bfd2d8e735ee8 100644 --- a/entity/ObjectTree_entity/entityfields/target_id/linkedContextProcess.js +++ b/entity/ObjectTree_entity/entityfields/target_id/linkedContextProcess.js @@ -5,4 +5,4 @@ import("Context_lib"); if (vars.get("$field.TARGET_CONTEXT")) { result.string(ContextUtils.getContextName(vars.get("$field.TARGET_CONTEXT"))); -} +} \ No newline at end of file diff --git a/entity/Object_entity/Object_entity.aod b/entity/Object_entity/Object_entity.aod index 99ed95858065c06f5a57e982a8701195b1d412c1..a1759bc528bc35bd0bc3af5e0e6086611d43b612 100644 --- a/entity/Object_entity/Object_entity.aod +++ b/entity/Object_entity/Object_entity.aod @@ -133,6 +133,7 @@ <entityProvider> <name>FilteredObjects</name> <fieldType>DEPENDENCY_IN</fieldType> + <targetConsumerProcess>%aditoprj%/entity/Object_entity/entityfields/filteredobjects/targetConsumerProcess.js</targetConsumerProcess> <dependencies> <entityDependency> <name>e644a709-cc8f-425e-bef2-9c51eea9bbe9</name> diff --git a/entity/Object_entity/entityfields/allobjects/targetConsumerProcess.js b/entity/Object_entity/entityfields/allobjects/targetConsumerProcess.js index 1a9d1e2e9d5ce31c14e07d1f1eee3f01b05eba78..8ba22ed45d1674ebb7da780fa596b38df518d035 100644 --- a/entity/Object_entity/entityfields/allobjects/targetConsumerProcess.js +++ b/entity/Object_entity/entityfields/allobjects/targetConsumerProcess.js @@ -4,28 +4,7 @@ import("Context_lib"); if (vars.exists("$param.ObjectType_param") && vars.get("$param.ObjectType_param")) { - switch(vars.get("$param.ObjectType_param")) - { - case ContextUtils.getContextName("Organisation"): - result.string("Organisations"); - break; - case ContextUtils.getContextName("Person"): - result.string("Persons"); - break; - case ContextUtils.getContextName("Offer"): - result.string("Offers"); - break; - case ContextUtils.getContextName("Order"): - result.string("Orders"); - break; - case ContextUtils.getContextName("Product"): - result.string("Products"); - break; - case ContextUtils.getContextName("Contract"): - result.string("Contracts"); - break; - case ContextUtils.getContextName("Salesproject"): - result.string("Salesprojects"); - break; - } + var consumer = ContextUtils.getContextConsumer(vars.get("$param.ObjectType_param")); + if (consumer) + result.string(consumer); } \ No newline at end of file diff --git a/entity/Object_entity/entityfields/filteredobjects/targetConsumerProcess.js b/entity/Object_entity/entityfields/filteredobjects/targetConsumerProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..8ba22ed45d1674ebb7da780fa596b38df518d035 --- /dev/null +++ b/entity/Object_entity/entityfields/filteredobjects/targetConsumerProcess.js @@ -0,0 +1,10 @@ +import("system.vars"); +import("system.result"); +import("Context_lib"); + +if (vars.exists("$param.ObjectType_param") && vars.get("$param.ObjectType_param")) +{ + var consumer = ContextUtils.getContextConsumer(vars.get("$param.ObjectType_param")); + if (consumer) + result.string(consumer); +} \ No newline at end of file diff --git a/process/Context_lib/process.js b/process/Context_lib/process.js index 0890b12f0f1561015d6a9076f40f53cfd90e780d..238aa4b1ac561df18d93ace719f7216624672b3d 100644 --- a/process/Context_lib/process.js +++ b/process/Context_lib/process.js @@ -54,6 +54,34 @@ ContextUtils.getContextName = function(pContextId) return pContextId; } +/** + * Returns the Name of the correct Consumer or null + * + * @param {String} pContextId the id of a context + * @return {String|null} Name of the correct Consumer + */ +ContextUtils.getContextConsumer = function(pContextId) +{ + // TODO: is there a better solution without a swiutch case? maybe metadata of context / entity + switch(pContextId) + { + case ContextUtils.getContextName("Organisation"): + return "Organisations"; + case ContextUtils.getContextName("Person"): + return "Persons"; + case ContextUtils.getContextName("Offer"): + return "Offers"; + case ContextUtils.getContextName("Order"): + return "Orders"; + case ContextUtils.getContextName("Product"): + return "Products"; + case ContextUtils.getContextName("Contract"): + return "Contracts"; + case ContextUtils.getContextName("Salesproject"): + return "Salesprojects"; + } +} + /** * * @param {Boolean} [pFilter=false] filter only for contexts which have a mapping in ContextUtils.getSelectMap