Skip to content
Snippets Groups Projects
Commit 0fdc08c2 authored by Sebastian Pongratz's avatar Sebastian Pongratz :ping_pong: Committed by Benjamin Ulrich
Browse files

Beobachtung berechtigung und Bugfix

parent 4d6b1b89
No related branches found
No related tags found
No related merge requests found
......@@ -72,6 +72,144 @@
"description": "There is no index for the column \"DEPLOYMENT_ID\" in the table \"DATABASECHANGELOG\" [59]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationEdit_view/ObservationEdit_view.aod",
"line": -1,
"description": "Dead Reference \"NOTIFICATION_PRIO\" located in: ObserverationEditGeneric/fields/entityField/NOTIFICATION_PRIO [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationEdit_view/ObservationEdit_view.aod",
"line": -1,
"description": "Dead Reference \"OBJECT_FIELD\" located in: ObserverationEditGeneric/fields/entityField/OBJECT_FIELD [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationEdit_view/ObservationEdit_view.aod",
"line": -1,
"description": "Dead Reference \"OBJECT_FILTER\" located in: ObserverationEditGeneric/fields/entityField/OBJECT_FILTER [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationEdit_view/ObservationEdit_view.aod",
"line": -1,
"description": "Dead Reference \"OBJECT_ID\" located in: ObserverationEditGeneric/fields/entityField/OBJECT_ID [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationEdit_view/ObservationEdit_view.aod",
"line": -1,
"description": "Dead Reference \"OBJECT_TYPE\" located in: ObserverationEditGeneric/fields/entityField/OBJECT_TYPE [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationEdit_view/ObservationEdit_view.aod",
"line": -1,
"description": "Dead Reference \"OBSERVER\" located in: ObserverationEditGeneric/fields/entityField/OBSERVER [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationEdit_view/ObservationEdit_view.aod",
"line": -1,
"description": "Dead Reference \"TRIGGEREVENTDELETE\" located in: ObserverationEditGeneric/fields/entityField/TRIGGEREVENTDELETE [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationEdit_view/ObservationEdit_view.aod",
"line": -1,
"description": "Dead Reference \"TRIGGEREVENTINSERT\" located in: ObserverationEditGeneric/fields/entityField/TRIGGEREVENTINSERT [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationEdit_view/ObservationEdit_view.aod",
"line": -1,
"description": "Dead Reference \"TRIGGEREVENTUPDATE\" located in: ObserverationEditGeneric/fields/entityField/TRIGGEREVENTUPDATE [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationFilter_view/ObservationFilter_view.aod",
"line": -1,
"description": "Dead Reference \"FilterActions\" located in: ObservationFilterTreeTable/favoriteActionGroup1/FilterActions [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationFilter_view/ObservationFilter_view.aod",
"line": -1,
"description": "Dead Reference \"NOTIFICATION_PRIO\" located in: ObservationFilterTreeTable/columns/entityField/NOTIFICATION_PRIO [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationFilter_view/ObservationFilter_view.aod",
"line": -1,
"description": "Dead Reference \"OBJECT_TYPE\" located in: ObservationFilterTreeTable/columns/entityField/OBJECT_TYPE [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationFilter_view/ObservationFilter_view.aod",
"line": -1,
"description": "Dead Reference \"OBSERVATION_ID\" located in: ObservationFilterTreeTable/parentField/OBSERVATION_ID [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationFilter_view/ObservationFilter_view.aod",
"line": -1,
"description": "Dead Reference \"OnlyMyObservations_param\" located in: neonDashletConfiguration/parameters/OnlyMyObservations_param [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationFilter_view/ObservationFilter_view.aod",
"line": -1,
"description": "Dead Reference \"observationType\" located in: ObservationFilterTreeTable/columns/entityField/observationType [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationPreview_view/ObservationPreview_view.aod",
"line": -1,
"description": "Dead Reference \"NOTIFICATION_PRIO\" located in: ObservationPreviewCard/subtitleField/NOTIFICATION_PRIO [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationPreview_view/ObservationPreview_view.aod",
"line": -1,
"description": "Dead Reference \"OBJECT_FIELD\" located in: ObservationPreviewGeneric/fields/entityField/OBJECT_FIELD [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationPreview_view/ObservationPreview_view.aod",
"line": -1,
"description": "Dead Reference \"OBJECT_FILTER\" located in: ObservationPreviewGeneric/fields/entityField/OBJECT_FILTER [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationPreview_view/ObservationPreview_view.aod",
"line": -1,
"description": "Dead Reference \"OBJECT_ID\" located in: ObservationPreviewGeneric/fields/entityField/OBJECT_ID [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationPreview_view/ObservationPreview_view.aod",
"line": -1,
"description": "Dead Reference \"OBJECT_TYPE\" located in: ObservationPreviewCard/titleField/OBJECT_TYPE [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationPreview_view/ObservationPreview_view.aod",
"line": -1,
"description": "Dead Reference \"TRIGGEREVENTDELETE\" located in: ObservationPreviewScoreCard/fields/entityField/TRIGGEREVENTDELETE [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationPreview_view/ObservationPreview_view.aod",
"line": -1,
"description": "Dead Reference \"TRIGGEREVENTINSERT\" located in: ObservationPreviewScoreCard/fields/entityField/TRIGGEREVENTINSERT [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/ObservationPreview_view/ObservationPreview_view.aod",
"line": -1,
"description": "Dead Reference \"TRIGGEREVENTUPDATE\" located in: ObservationPreviewScoreCard/fields/entityField/TRIGGEREVENTUPDATE [67]",
"groupName": "nb-tasklist-warning"
},
{
"target": "neonView/SalesprojectAnalysesPhases_view/SalesprojectAnalysesPhases_view.aod",
"line": -1,
......
......@@ -12,10 +12,11 @@ inserted, updated or deleted.
* The entity had to trigger the Workflow in the onInsert, onUpdate and onDelete Processes
* The entity had to have a content Title
* The entity had to be customizing in the Blacklist_param of the Context Consumer if its not an dependency. Otherwise it had to be customizing in the Dependency_lib with the "isObservable" option
* The entity had to be customized in the Observation.OBSERVABLE_ENTITIESfunction of the Observation_lib if its not an dependency. Otherwise it had to be customizing in the Dependency_lib with the "isObservable" option
* The entityfields which should not be displayed must also be customized
=== Enable Observation
* Enable the custom field observation.isEnabled in the _____PREFERENCES_PROJECT
* Create the Observation Context and add the Entity, the Views (ObservationEdit_view, ObservationFilter_view, ObservationPreview_view), the Icon (VAADIN:EYE) and the Tile "Observation" to it
......@@ -3,26 +3,14 @@ import("system.vars");
import("system.result");
import("Sql_lib")
let type;
if (vars.get("$field.OBSERVATION_ID"))
{
result.object(Observation.getAllDependencyValue(newSelect("OBSERVATION.OBJECT_TYPE").from("OBSERVATION").where("OBSERVATION.OBSERVATIONID", vars.get("$field.OBSERVATION_ID")).cell()));
}
else
{
result.object([
"Activity",
"Campaign",
"Contract",
"Employee",
// "Favorite", TODO: Fix errors in favorites dependencies and then remove the comment
"Leadimport",
"Offer",
"Order",
"Organisation",
"Person",
"Product",
"Salesproject",
"SupportTicket",
"Task"
]);
type = newSelect("OBSERVATION.OBJECT_TYPE")
.from("OBSERVATION")
.where("OBSERVATION.OBSERVATIONID", vars.get("$field.OBSERVATION_ID"))
.cell();
}
result.object(Observation.getAllContextValue(type));
import("Context_lib");
import("system.result");
import("system.entities");
import("system.vars");
if (vars.get("$this.value") && vars.get("$this.value") != "FILTER" )
{
var loadConfig = entities.createConfigForLoadingRows()
.entity(vars.get("$field.OBJECT_TYPE") + "_entity")
.fields(["#CONTENTTITLE"])
.uid(vars.get("$this.value"))
result.string(entities.getRow(loadConfig)["#CONTENTTITLE"]);
let contenttitle
try
{
var loadConfig = entities.createConfigForLoadingRows()
.entity(ContextUtils.getEntity(vars.get("$field.OBJECT_TYPE")))
.fields(["#CONTENTTITLE"])
.uid(vars.get("$this.value"))
contenttitle = entities.getRow(loadConfig)["#CONTENTTITLE"];
}
catch (e)
{
// The ID has not been found in the Database
contenttitle = "";
}
result.string(contenttitle);
} else {
result.string("Filter");
}
......@@ -14,6 +14,7 @@
<useFavorites v="true" />
<iconId>VAADIN:BUILDING</iconId>
<imageProcess>%aditoprj%/entity/Organisation_entity/imageProcess.js</imageProcess>
<usePermissions v="true" />
<titlePlural>Companies</titlePlural>
<recordContainer>db</recordContainer>
<entityFields>
......@@ -32,6 +33,7 @@
<title>Name</title>
<contentType>LONG_TEXT</contentType>
<mandatory v="true" />
<usePermissions v="true" />
</entityField>
<entityField>
<name>ORGANISATIONID</name>
......
import("system.vars");
import("system.result");
import("Observation_lib");
import("system.neon");
result.string(Observation.actionState(vars.get("$sys.selection")));
result.string(Observation.actionState(vars.get("$sys.selection")));
\ No newline at end of file
......@@ -73,8 +73,7 @@ Dependency.defaultFunctionForRelation = function (pRelationTable, pRelationField
relationFieldValue = pNewData[pDataTable + "." + pDataField];
}
return newSelect(pRelationTable + "." + pSourceField || "OBJECT_ROWID")
return newSelect(pRelationTable + "." + (pSourceField || "OBJECT_ROWID"))
.from(pRelationTable)
.groupBy(pRelationTable + ".OBJECT_ROWID")
.whereIfSet(pRelationTable + "." + pRelationField, relationFieldValue)
......@@ -142,7 +141,7 @@ Dependency.mapping = function ()
"options" : {
"isObservable" : true
},
"getUIDsfn" : Dependency.defaultFunctionForRelation("TASKLINK", "OBJECT_ROWID", "CONTACTID", "Person", "CONTACT", "ACTIVITY_ID")
"getUIDsfn" : Dependency.defaultFunctionForRelation("TASKLINK", "OBJECT_ROWID", "CONTACTID", "Person", "CONTACT", "TASK_ID")
},
"Favorite_entity" : {
"options" : {
......@@ -162,7 +161,7 @@ Dependency.mapping = function ()
"options" : {
"isObservable" : true
},
"getUIDsfn" : Dependency.defaultFunctionForRelation("TASKLINK", "OBJECT_ROWID", "PERSONID", "PrivatePerson", "PERSON", "ACTIVITY_ID")
"getUIDsfn" : Dependency.defaultFunctionForRelation("TASKLINK", "OBJECT_ROWID", "PERSONID", "PrivatePerson", "PERSON", "TASK_ID")
}
},
"Organisation_entity": {
......@@ -176,7 +175,7 @@ Dependency.mapping = function ()
"options" : {
"isObservable" : true
},
"getUIDsfn" : Dependency.defaultFunctionForRelation("TASKLINK", "OBJECT_ROWID", "CONTACTID", "Organisation", "CONTACT", "ACTIVITY_ID")
"getUIDsfn" : Dependency.defaultFunctionForRelation("TASKLINK", "OBJECT_ROWID", "CONTACTID", "Organisation", "CONTACT", "TASK_ID")
},
"Favorite_entity" : {
"options" : {
......@@ -196,7 +195,7 @@ Dependency.mapping = function ()
"options" : {
"isObservable" : true
},
"getUIDsfn" : Dependency.defaultFunctionForRelation("TASKLINK", "OBJECT_ROWID", "SALESPROJECTID", "Salesproject", "SALESPROJECT", "ACTIVITY_ID")
"getUIDsfn" : Dependency.defaultFunctionForRelation("TASKLINK", "OBJECT_ROWID", "SALESPROJECTID", "Salesproject", "SALESPROJECT", "TASK_ID")
},
"Favorite_entity" : {
"options" : {
......@@ -247,7 +246,7 @@ Dependency.mapping = function ()
"options" : {
"isObservable" : true
},
"getUIDsfn" : Dependency.defaultFunctionForRelation("TASKLINK", "OBJECT_ROWID", "SALESORDERID", "Order", "SALESORDER", "ACTIVITY_ID")
"getUIDsfn" : Dependency.defaultFunctionForRelation("TASKLINK", "OBJECT_ROWID", "SALESORDERID", "Order", "SALESORDER", "TASK_ID")
},
"Favorite_entity" : {
"options" : {
......@@ -267,7 +266,7 @@ Dependency.mapping = function ()
"options" : {
"isObservable" : true
},
"getUIDsfn" : Dependency.defaultFunctionForRelation("TASKLINK", "OBJECT_ROWID", "CONTRACTID", "Contract", "CONTRACT", "ACTIVITY_ID")
"getUIDsfn" : Dependency.defaultFunctionForRelation("TASKLINK", "OBJECT_ROWID", "CONTRACTID", "Contract", "CONTRACT", "TASK_ID")
},
"Favorite_entity" : {
"options" : {
......@@ -287,7 +286,7 @@ Dependency.mapping = function ()
"options" : {
"isObservable" : true
},
"getUIDsfn" : Dependency.defaultFunctionForRelation("TASKLINK", "OBJECT_ROWID", "PRODUCTID", "Product", "PRODUCT", "ACTIVITY_ID")
"getUIDsfn" : Dependency.defaultFunctionForRelation("TASKLINK", "OBJECT_ROWID", "PRODUCTID", "Product", "PRODUCT", "TASK_ID")
},
"Favorite_entity" : {
"options" : {
......@@ -307,7 +306,7 @@ Dependency.mapping = function ()
"options" : {
"isObservable" : true
},
"getUIDsfn" : Dependency.defaultFunctionForRelation("TASKLINK", "OBJECT_ROWID", "CAMPAIGNID", "Campaign", "CAMPAIGN", "ACTIVITY_ID")
"getUIDsfn" : Dependency.defaultFunctionForRelation("TASKLINK", "OBJECT_ROWID", "CAMPAIGNID", "Campaign", "CAMPAIGN", "TASK_ID")
},
"Favorite_entity" : {
"options" : {
......@@ -327,7 +326,7 @@ Dependency.mapping = function ()
"options" : {
"isObservable" : true
},
"getUIDsfn" : Dependency.defaultFunctionForRelation("TASKLINK", "OBJECT_ROWID", "TICKETID", "SupportTicket", "TICKET", "ACTIVITY_ID")
"getUIDsfn" : Dependency.defaultFunctionForRelation("TASKLINK", "OBJECT_ROWID", "TICKETID", "SupportTicket", "TICKET", "TASK_ID")
},
"Favorite_entity" : {
"options" : {
......@@ -615,7 +614,7 @@ Dependency.mapping = function ()
"options" : {
"isObservable" : true
},
"getUIDsfn" : Dependency.defaultFunctionForRelation("TASKLINK", "OBJECT_ROWID", "OFFERID", "Offer", "OFFER", "ACTIVITY_ID")
"getUIDsfn" : Dependency.defaultFunctionForRelation("TASKLINK", "OBJECT_ROWID", "OFFERID", "Offer", "OFFER", "TASK_ID")
},
"Favorite_entity" : {
"options" : {
......@@ -822,27 +821,3 @@ Dependency.getReverseDependency = function (pEntity, pOptionFilter) {
}));
});
}
Dependency.defaultFunctionForRelation = function (pRelationTable, pRelationField, pDataField, pContext, pDataTable)
{
return function (pNewData, pOldData)
{
var relationFieldValue;
if (!pDataTable)
{
relationFieldValue = pNewData["UID.value"] || pNewData[pDataField +".value"];
}
else
{
relationFieldValue = pNewData[pDataTable + "." + pDataField];
}
return newSelect(pRelationTable + ".OBJECT_ROWID")
.from(pRelationTable)
.groupBy(pRelationTable + ".OBJECT_ROWID")
.whereIfSet(pRelationTable + "." + pRelationField, relationFieldValue)
.and(pRelationTable + ".OBJECT_TYPE", pContext)
.arrayColumn();
}
}
......@@ -33,6 +33,29 @@ Observation.PRIO = function () {
Observation.CONTENTTITLE = function () {
return "OBJECT_CONTENTTITLE";
}
Observation.ENTITY_NAME = function () {
return "ENTITY_NAME";
}
/**
* Thees are the Entities which can be selected in the ObservationFilter_view if you have the rights.
*/
Observation.OBSERVABLE_ENTITIES = function () {
return [
"Activity_entity",
"Campaign_entity",
"Contract_entity",
"Employee_entity",
"Leadimport_entity",
"Offer_entity",
"Order_entity",
"Organisation_entity",
"Person_entity",
"Product_entity",
"Salesproject_entity",
"SupportTicket_entity",
"Task_entity"
];
}
/**
* If the variables have not yet been parsed to an Object, they will now.
......@@ -59,12 +82,15 @@ Observation.checkObservation = function(pVariables, pObservationId)
{
if (pVariables[WorkflowVariables.TRIGGER()])
{
// parse all JSON-Objects
Observation.parseVariableIfNeed(pVariables, WorkflowVariables.CHANGED_ROWS());
Observation.parseVariableIfNeed(pVariables, WorkflowVariables.CHANGED_ROWS_TYPES());
Observation.parseVariableIfNeed(pVariables, WorkflowVariables.ROWDATA());
Observation.parseVariableIfNeed(pVariables, WorkflowVariables.INITIAL_ROWDATA());
pVariables[Observation.ENTITY_NAME] = ContextUtils.getEntity(pVariables[WorkflowVariables.TARGET_CONTEXT()]);
var observers = {};
// get all observations with the ovservers
var observations = newSelect(["OBSERVATION.OBJECT_ID", "OBSERVATION.OBJECT_FILTER" ,"OBSERVATION.OBSERVER", "OBSERVATION.OBJECT_FIELD", "O.OBJECT_TYPE", "OBSERVATION.OBSERVATION_ID", "OBSERVATION.NOTIFICATION_PRIO"])
.from("OBSERVATION")
.leftJoin("OBSERVATION", "OBSERVATION.OBSERVATION_ID = O.OBSERVATIONID", "O")
......@@ -74,23 +100,31 @@ Observation.checkObservation = function(pVariables, pObservationId)
.and("OBSERVATION.OBJECT_TYPE", pVariables[WorkflowVariables.TARGET_CONTEXT()]);
if (pObservationId)
{
// if the variable is set the parend observation is search for.
observations.andIfSet("OBSERVATION.OBSERVATIONID", pObservationId)
}
else
{
observations.and("OBSERVATION." + pVariables[WorkflowVariables.TRIGGER()], "1");
}
observations = observations.table();
for (let i = 0; i < observations.length; i++)
{
var tempObserver = {};
var observation = observations[i];
var filterResult = 0;
var user = tools.getUserByAttribute(tools.NAME, observation[2], tools.PROFILE_DEFAULT);
var filterResult;
if (!observation[0] && observation[1] || pObservationId)
// exclude the user who made the changes.
if (user && pVariables[WorkflowVariables.EVENT_USER()] !== observation[2])
{
var config = entities.createConfigForLoadingRows()
.user(user.title)
.uids([pVariables[WorkflowVariables.TARGET_ID()]])
.entity(ContextUtils.getEntity(pVariables[WorkflowVariables.TARGET_CONTEXT()]))
.ignorePermissions(true);
.entity(pVariables[Observation.ENTITY_NAME])
if (observation[1])
config.filter(JSON.stringify(JSON.parse(observation[1]).filter));
......@@ -101,80 +135,103 @@ Observation.checkObservation = function(pVariables, pObservationId)
}
catch (e)
{
// This Catch is needed for the Permission exeptions and the recursion
logging.log(e);
filterResult = null;
}
}
if (pObservationId && ((observation[0] && !observation[1]) || filterResult))
{
return filterResult;
}
if ((observation[0] && !observation[1]) || filterResult)
{
// exclude the user who made the change.
if (pVariables[WorkflowVariables.EVENT_USER()] !== observation[2])
if (filterResult)
{
var observeFileds = {};
if (pObservationId)
{
return filterResult;
}
var observeFields = {};
text.decodeMS(observation[3]).forEach(function (observeFiled) {
let field = text.decodeMS(observeFiled);
let fieldNames = text.decodeMS(field[0]);
let displayValueField = "#COLUMNEXP_____" + fieldNames[1] + ".displayValue";
let observedField = pVariables[WorkflowVariables.ROWDATA()][displayValueField] ? displayValueField : null;
observeFileds[fieldNames[0]] = [field[1], observedField];
if (tools.hasPermission(tools.PERMISSION_VIEW, pVariables[Observation.ENTITY_NAME], fieldNames[1], user.title))
{
observeFields[fieldNames[0]] = [field[1], observedField];
}
});
tempObserver[observation[2]] = {};
pVariables[WorkflowVariables.CHANGED_ROWS()].forEach(function (recordField) {
if (observeFileds[recordField])
if (observeFields[recordField])
{
if (!observers[observation[2]])
observers[observation[2]] = {};
if (observeFileds[recordField][1])
observers[observation[2]][observeFileds[recordField][1]] = observeFileds[recordField][0];
if (observeFields[recordField][1])
{
tempObserver[observation[2]][observeFields[recordField][1]] = observeFields[recordField][0];
}
else
observers[observation[2]][recordField] = observeFileds[recordField][0];
{
tempObserver[observation[2]][recordField] = observeFields[recordField][0];
}
}
});
}
}
else if (pVariables[WorkflowVariables.TRIGGER()] == WorkflowSignalSender.EVENT_DELETE())
{
observers[observation[2]] = {};
}
if (observers[observation[2]])
{
observers[observation[2]][Observation.PRIO()] = observation[6];
if (observation[4] && !pObservationId)
else if (pVariables[WorkflowVariables.TRIGGER()] == WorkflowSignalSender.EVENT_DELETE())
{
observers[observation[2]][Observation.OBJECT_TYPE()] = observation[4];
observers[observation[2]][Observation.OBJECT_IDs()] = {};
tempObserver[observation[2]] = {};
}
if (tempObserver[observation[2]])
{
tempObserver[observation[2]][Observation.PRIO()] = observation[6];
if (observation[4] && !pObservationId)
{
tempObserver[observation[2]][Observation.OBJECT_TYPE()] = observation[4];
tempObserver[observation[2]][Observation.OBJECT_IDs()] = {};
var dependentIds =
Dependency.mapping()[ContextUtils.getEntity(pVariables[WorkflowVariables.TARGET_CONTEXT()])][ContextUtils.getEntity(observation[4])]
.getUIDsfn(pVariables[WorkflowVariables.ROWDATA()], pVariables[WorkflowVariables.INITIAL_ROWDATA()]);
var dependentIds =
Dependency.mapping()[ContextUtils.getEntity(pVariables[WorkflowVariables.TARGET_CONTEXT()])][ContextUtils.getEntity(observation[4])]
.getUIDsfn(pVariables[WorkflowVariables.ROWDATA()], pVariables[WorkflowVariables.INITIAL_ROWDATA()]);
var dependentCheckVars = {}
dependentCheckVars[WorkflowVariables.TRIGGER()] = pVariables[WorkflowVariables.TRIGGER()];
dependentCheckVars[WorkflowVariables.CHANGED_ROWS()] = {};
dependentCheckVars[WorkflowVariables.ROWDATA()] = {};
dependentCheckVars[WorkflowVariables.TARGET_CONTEXT()] = observation[4];
dependentCheckVars[WorkflowVariables.EVENT_USER()] = observation[2];
for (let index = 0; index < dependentIds.length; index++)
var dependentCheckVars = {}
dependentCheckVars[WorkflowVariables.TRIGGER()] = pVariables[WorkflowVariables.TRIGGER()];
dependentCheckVars[WorkflowVariables.TARGET_CONTEXT()] = observation[4];
dependentCheckVars[WorkflowVariables.EVENT_USER()] = observation[2];
for (let index = 0; index < dependentIds.length; index++)
{
dependentCheckVars[WorkflowVariables.TARGET_ID()] = dependentIds[index];
var contentTitle = Observation.checkObservation(dependentCheckVars, observation[5]);
if (contentTitle) // Check Dependent
{
tempObserver[observation[2]][Observation.OBJECT_IDs()][dependentIds[index]] = contentTitle;
}
}
}
}
if (tempObserver[observation[2]] && (!tempObserver[observation[2]][Observation.OBJECT_IDs()] ||Object.keys(tempObserver[observation[2]][Observation.OBJECT_IDs()]).length > 0))
{
if (!observers[observation[2]])
{
dependentCheckVars[WorkflowVariables.TARGET_ID()] = dependentIds[index];
var contentTitle = Observation.checkObservation(dependentCheckVars, observation[5]);
if (contentTitle){ // Check Dependent
observers[observation[2]][Observation.OBJECT_IDs()][dependentIds[index]] = contentTitle;
observers[observation[2]] = tempObserver[observation[2]];
}
else
{
if (!observers[observation[2]][Observation.OBJECT_IDs()] ||
JSON.stringify(observers[observation[2]][Observation.OBJECT_IDs()]) == JSON.stringify(tempObserver[observation[2]][Observation.OBJECT_IDs()]) &&
observers[observation[2]][Observation.OBJECT_TYPE()] == tempObserver[observation[2]][Observation.OBJECT_TYPE()])
{
Object.keys(tempObserver[observation[2]]).forEach(function (pField)
{
if (!observers[observation[2]][pField] && pVariables[WorkflowVariables.CHANGED_ROWS()].indexOf(pField) > -1)
{
observers[observation[2]][pField] = tempObserver[observation[2]][pField];
}
});
}
}
}
tempObserver[observation[2]] = null;
}
}
if (pObservationId)
......@@ -202,13 +259,13 @@ Observation._notifiyUsers = function (pVariables, pObservers)
var user = tools.getUserByAttribute(tools.NAME, pVariables[WorkflowVariables.EVENT_USER()], tools.PROFILE_DEFAULT);
var notificationCaption;
var filteredVariables = {
notificationCaption : translate.text(notificationCaption),
notificationDescription : (user.params.firstname + " " + user.params.lastname).trim() + " " + translate.text("has") + " ",
notificationCaption : translate.text(notificationCaption),
notificationUser : JSON.stringify(observers),
notificationType : "ObservationNotification"
}
observers.forEach(function (pObserver) {
filteredVariables.notificationDescription = (user.params.firstname + " " + user.params.lastname).trim() + " " + translate.text("has") + " ";
// If there is a OBJECT_TYPE, this is a dependency observation
if (pObservers[pObserver][Observation.OBJECT_TYPE()])
{
......@@ -278,7 +335,7 @@ Observation._notification = function (pVariables, pFilteredVariables, pObservers
pNotification.linkinfo == text.encodeMS([pContext, pTargetId]) &&
pNotification.type == pFilteredVariables.notificationType &&
!pNotification.description.endsWith("....there is more data available"))
{
{
isfirstField = false;
pFilteredVariables.notificationContentId = pNotification.contentid;
pFilteredVariables.notificationDescription = pNotification.description;
......@@ -687,8 +744,10 @@ Observation.getAllPosibleFields = function (pType)
if (fields[field].fieldType == project.ENTITYFIELDTYPE_FIELD && recordFieldMappings[fields[field].name])
{
if (!fields[field].usePermissions || (fields[field].usePermissions && tools.hasPermission(tools.PERMISSION_VIEW, entity, field)))
{
let title = fields[field].title ? fields[field].title : fields[field].name;
resultFields.push([text.encodeMS([recordFieldMappings[fields[field].name], title]), title ]);
resultFields.push([text.encodeMS([recordFieldMappings[fields[field].name], title]), title ]);
}
}
}
......@@ -717,24 +776,38 @@ Observation.getAllFieldValue = function (pType)
}
/**
* Get all dependencies of a certain type
* Get all Contexts of a certain type
*
* @param {String} [pType] the Type or the context name
* @return {Array} the possible dependencies
* @return {Array} the possible Contexts
*/
Observation.getAllDependencyValue = function (pType)
Observation.getAllContextValue = function (pType)
{
let contexts = []
let dependencies = Dependency.getReverseDependency(ContextUtils.getEntity(pType), {
"isObservable" : true
});
for (let i = 0; i < dependencies.length; i++)
let entityNames;
if (pType)
{
let context = ContextUtils.getContextId(dependencies[i]);
if (context)
{
contexts.push(context);
entityNames = Dependency.getReverseDependency(ContextUtils.getEntity(pType), {
"isObservable" : true
});
}
else
{
entityNames = Observation.OBSERVABLE_ENTITIES();
}
for (let i = 0; i < entityNames.length; i++)
{
// Check the user's permissions on the entity
if (tools.hasPermission(tools.PERMISSION_VIEW, entityNames[i], null, null))
{
let context = ContextUtils.getContextId(entityNames[i]);
if (context)
{
contexts.push(context);
}
}
}
return contexts;
}
}
\ 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