diff --git a/entity/AttributeRelation_entity/recordcontainers/db/conditionProcess.js b/entity/AttributeRelation_entity/recordcontainers/db/conditionProcess.js index 623fac4157f0adf965683447e178916aedffc2a6..d2b666631967c44d632fcdd249414629786e0219 100644 --- a/entity/AttributeRelation_entity/recordcontainers/db/conditionProcess.js +++ b/entity/AttributeRelation_entity/recordcontainers/db/conditionProcess.js @@ -1,4 +1,3 @@ -import("system.logging"); import("system.vars"); import("system.db"); import("system.result"); @@ -7,9 +6,6 @@ import("Sql_lib"); var cond = SqlCondition.begin() .andPrepareVars("AB_ATTRIBUTERELATION.OBJECT_ROWID", "$param.ObjectRowId_param"); -if (vars.exists("$param.ObjectRowId_param")) - logging.log(vars.get("$param.ObjectRowId_param")) - if (vars.exists("$param.ObjectRowId_param") && vars.get("$param.ObjectRowId_param") && vars.exists("$param.FilteredAttributeIds_param") && vars.get("$param.FilteredAttributeIds_param")) { diff --git a/entity/EmployeeRole_entity/EmployeeRole_entity.aod b/entity/EmployeeRole_entity/EmployeeRole_entity.aod index f1844865091ec2e23e838f2fdf2d9d6bbcdc1fb3..4fd240c55b0c3e2f349e1b5a7fcfe12d58b5b74e 100644 --- a/entity/EmployeeRole_entity/EmployeeRole_entity.aod +++ b/entity/EmployeeRole_entity/EmployeeRole_entity.aod @@ -9,8 +9,6 @@ </entityProvider> <entityField> <name>UID</name> - <title>Role</title> - <possibleItemsProcess>%aditoprj%/entity/EmployeeRole_entity/entityfields/uid/possibleItemsProcess.js</possibleItemsProcess> </entityField> <entityParameter> <name>UserTitle_param</name> @@ -35,6 +33,11 @@ </entityParameter> </children> </entityProvider> + <entityField> + <name>ROLE</name> + <title>Role</title> + <possibleItemsProcess>%aditoprj%/entity/EmployeeRole_entity/entityfields/role/possibleItemsProcess.js</possibleItemsProcess> + </entityField> </entityFields> <recordContainers> <jDitoRecordContainer> @@ -46,6 +49,7 @@ <onDelete>%aditoprj%/entity/EmployeeRole_entity/recordcontainers/jdito/onDelete.js</onDelete> <recordFields> <element>UID.value</element> + <element>ROLE.value</element> </recordFields> </jDitoRecordContainer> </recordContainers> diff --git a/entity/EmployeeRole_entity/entityfields/uid/possibleItemsProcess.js b/entity/EmployeeRole_entity/entityfields/role/possibleItemsProcess.js similarity index 100% rename from entity/EmployeeRole_entity/entityfields/uid/possibleItemsProcess.js rename to entity/EmployeeRole_entity/entityfields/role/possibleItemsProcess.js diff --git a/entity/EmployeeRole_entity/recordcontainers/jdito/contentProcess.js b/entity/EmployeeRole_entity/recordcontainers/jdito/contentProcess.js index 9f314aac5dbc8d4ee75add77ed01fdf2b0b7f7fb..5e4ff916b039af3ae7779f072503a419b2c4c960 100644 --- a/entity/EmployeeRole_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/EmployeeRole_entity/recordcontainers/jdito/contentProcess.js @@ -5,7 +5,7 @@ import("system.tools"); var roles = []; var userTitle = vars.exists("$param.UserTitle_param") && vars.get("$param.UserTitle_param"); -if (userTitle) - roles = tools.getRoles(userTitle).map(function (role) {return [role]}); +if (userTitle && tools.existUsers(userTitle)) + roles = tools.getRoles(userTitle).map(function (role) {return [role, role]}); result.object(roles); \ No newline at end of file diff --git a/entity/EmployeeRole_entity/recordcontainers/jdito/onInsert.js b/entity/EmployeeRole_entity/recordcontainers/jdito/onInsert.js index 23ca713599d221b3315480fa38f37fd9eea7b173..cd847798b8185ce26d821b1637726d6ff6e3284c 100644 --- a/entity/EmployeeRole_entity/recordcontainers/jdito/onInsert.js +++ b/entity/EmployeeRole_entity/recordcontainers/jdito/onInsert.js @@ -3,7 +3,7 @@ import("system.vars"); import("system.tools"); var userTitle = vars.exists("$param.UserTitle_param") && vars.get("$param.UserTitle_param"); -var role = vars.get("$field.UID"); +var role = vars.get("$field.ROLE"); if (userTitle) { diff --git a/entity/EmployeeRole_entity/recordcontainers/jdito/onUpdate.js b/entity/EmployeeRole_entity/recordcontainers/jdito/onUpdate.js index 23ca713599d221b3315480fa38f37fd9eea7b173..ae08df85d869504a918c2b71140f22bdc5df8459 100644 --- a/entity/EmployeeRole_entity/recordcontainers/jdito/onUpdate.js +++ b/entity/EmployeeRole_entity/recordcontainers/jdito/onUpdate.js @@ -3,14 +3,16 @@ import("system.vars"); import("system.tools"); var userTitle = vars.exists("$param.UserTitle_param") && vars.get("$param.UserTitle_param"); -var role = vars.get("$field.UID"); +var oldRole = vars.get("$field.UID"); +var newRole = vars.get("$field.ROLE"); -if (userTitle) +if (userTitle && oldRole != newRole) { var user = tools.getUser(userTitle); var roles = tools.getRoles(userTitle); var roleObj = {}; - roles = [role].concat(roles) + roleObj[oldRole] = true; + roles = [newRole].concat(roles) .filter(function (role) { var exists = role in roleObj; diff --git a/entity/Employee_entity/Employee_entity.aod b/entity/Employee_entity/Employee_entity.aod index fae8cd5d3095141a0e24163fcfccfbea72f851c9..ca823d2c5423a9d44d919718bd6f372b63566ca8 100644 --- a/entity/Employee_entity/Employee_entity.aod +++ b/entity/Employee_entity/Employee_entity.aod @@ -12,14 +12,6 @@ <entityProvider> <name>#PROVIDER</name> <lookupIdfield>CONTACT_ID</lookupIdfield> - <dependencies> - <entityDependency> - <name>823f9c90-c834-4e37-a47b-b3756fd28182</name> - <entityName>Timetracking_entity</entityName> - <fieldName>Employees</fieldName> - <isConsumer v="false" /> - </entityDependency> - </dependencies> </entityProvider> <entityField> <name>UID</name> @@ -37,7 +29,7 @@ <title>Person</title> <consumer>Contacts</consumer> <linkedContext>Person</linkedContext> - <mandatory v="false" /> + <mandatory v="true" /> <onValidation>%aditoprj%/entity/Employee_entity/entityfields/contact_id/onValidation.js</onValidation> </entityField> <entityField> @@ -139,8 +131,8 @@ <name>IMAGE</name> <contentType>IMAGE</contentType> <searchable v="false" /> - <state>READONLY</state> <valueProcess>%aditoprj%/entity/Employee_entity/entityfields/image/valueProcess.js</valueProcess> + <onValueChange>%aditoprj%/entity/Employee_entity/entityfields/image/onValueChange.js</onValueChange> <onValueChangeTypes> <element>MASK</element> </onValueChangeTypes> @@ -148,6 +140,7 @@ <entityField> <name>DEPARTMENT</name> <title>Department</title> + <state>INVISIBLE</state> </entityField> <entityField> <name>DESCRIPTION</name> @@ -247,6 +240,12 @@ <fieldName>Employees</fieldName> <isConsumer v="false" /> </entityDependency> + <entityDependency> + <name>73f93f34-bfe9-48fd-b9ce-7f8ba46014c9</name> + <entityName>Timetracking_entity</entityName> + <fieldName>Employees</fieldName> + <isConsumer v="false" /> + </entityDependency> </dependencies> <children> <entityParameter> diff --git a/entity/Employee_entity/afterOperatingState.js b/entity/Employee_entity/afterOperatingState.js index 96b470c432e7f422b7731d6ef74948d3d377a61c..bfb14f69c3df5a7c4b78ac91f3781e56736762f3 100644 --- a/entity/Employee_entity/afterOperatingState.js +++ b/entity/Employee_entity/afterOperatingState.js @@ -3,4 +3,4 @@ import("system.neon"); import("system.vars"); if (vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW) - neon.setFieldValue("$field.UID", ""); \ No newline at end of file + neon.setFieldValue("$field.UID", ""); //UID = user-title, should be initially empty \ No newline at end of file diff --git a/entity/Employee_entity/entityfields/image/onValueChange.js b/entity/Employee_entity/entityfields/image/onValueChange.js new file mode 100644 index 0000000000000000000000000000000000000000..8698d90353b719f652eec1427f0d8b881a8a8660 --- /dev/null +++ b/entity/Employee_entity/entityfields/image/onValueChange.js @@ -0,0 +1,4 @@ +import("Entity_lib"); + +// TODO: also there is currently no good way to do updates with fields not connected to the record container. Workaround: imagevariable and update in onDBUpdate Process #1030023 +FieldChanges.setChange("$field.IMAGE"); \ No newline at end of file diff --git a/entity/Employee_entity/recordcontainers/jdito/contentProcess.js b/entity/Employee_entity/recordcontainers/jdito/contentProcess.js index f09c6c4a6666aad38676b3cfb56ff1d4da1939c4..917242b94f7722685a31a4c77b11822cc46865a9 100644 --- a/entity/Employee_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/Employee_entity/recordcontainers/jdito/contentProcess.js @@ -4,14 +4,21 @@ import("system.tools"); import("Util_lib"); import("Contact_lib"); +var filter = vars.exists("$local.filter") && vars.get("$local.filter"); + var users; if (vars.exists("$local.idvalues") && vars.get("$local.idvalues")) - users = vars.get("$local.idvalues"); + users = [tools.getUser(vars.get("$local.idvalues"), tools.PROFILE_FULL)]; else - users = tools.getStoredUsers().map(function (row) {return row[1];}); +{ + var values = ["true", "false"]; + if (vars.exists("$param.OnlyActives_param") && vars.get("$param.OnlyActives_param") == "true") + values = ["true"]; + users = tools.getUsersByAttribute(tools.ISACTIVE, values, tools.PROFILE_FULL); +} + users = users.map(function (user) { - user = tools.getUser(user, tools.PROFILE_FULL); return [ user[tools.TITLE], user[tools.TITLE], @@ -25,8 +32,6 @@ users = users.map(function (user) user[tools.PARAMS][tools.FRAME_STOREDSEARCHES] ]; }); -ArrayUtils.sort2d(users, 0, true, false); - -var filter = vars.exists("$local.filter") && vars.get("$local.filter"); +ArrayUtils.sort2d(users, 0, true, false); //sort by username result.object(users); \ No newline at end of file diff --git a/entity/Employee_entity/recordcontainers/jdito/onDelete.js b/entity/Employee_entity/recordcontainers/jdito/onDelete.js index c6dddbee3da753e52e0820e2b758101f89220eee..b3064b9528d3c514953b7e2441c5d71490bcb865 100644 --- a/entity/Employee_entity/recordcontainers/jdito/onDelete.js +++ b/entity/Employee_entity/recordcontainers/jdito/onDelete.js @@ -1,4 +1,8 @@ +import("system.neon"); import("system.vars"); import("system.tools"); +import("Employee_lib"); -tools.deleteUser(vars.get("$field.UID")); \ No newline at end of file +//TODO: the current user should not delete himself, put this condition in grantDelete when available +if (EmployeeUtils.getCurrentUserName() != vars.get("$field.UID")) + tools.deleteUser(vars.get("$field.UID")); \ No newline at end of file diff --git a/entity/Employee_entity/recordcontainers/jdito/onInsert.js b/entity/Employee_entity/recordcontainers/jdito/onInsert.js index 1ab06f0014d202c4c882b5f160e64e530a808d0d..3693a103f69a82d454fdbad9cf027ef76635ecc4 100644 --- a/entity/Employee_entity/recordcontainers/jdito/onInsert.js +++ b/entity/Employee_entity/recordcontainers/jdito/onInsert.js @@ -10,6 +10,7 @@ params[tools.EMAIL] = vars.get("$field.EMAIL_ADDRESS"); params[tools.CALENDARID] = vars.get("$field.EMAIL_ADDRESS"); params[tools.CONTACTID] = vars.get("$field.CONTACT_ID"); params[tools.DESCRIPTION] = vars.get("$field.DESCRIPTION"); +params[tools.ISACTIVE] = vars.get("$field.ISACTIVE"); user[tools.TITLE] = vars.get("$field.UID"); user[tools.PARAMS] = params; diff --git a/entity/Employee_entity/recordcontainers/jdito/onUpdate.js b/entity/Employee_entity/recordcontainers/jdito/onUpdate.js index d3fd1e6b72a45c0dffe646c5326211a0e6a64719..5cc71867cd697b16bbfc17ef56a0678b144e2545 100644 --- a/entity/Employee_entity/recordcontainers/jdito/onUpdate.js +++ b/entity/Employee_entity/recordcontainers/jdito/onUpdate.js @@ -1,10 +1,28 @@ +import("system.db"); import("system.logging"); import("system.vars"); import("system.tools"); +import("Person_lib"); +import("Entity_lib"); -var user = tools.getUser(vars.get("$field.TITLE_ORIGINAL")); +// TODO: this is a workaround for missing possibility to react on changes of fields not connected to record Contqainer #1030023 +FieldChanges.assimilateChangeAndDispose("$field.IMAGE", function (state, value) +{ + var personId = db.cell(SqlCondition.begin() + .andPrepareVars("CONTACT.CONTACTID", "$field.CONTACT_ID") + .buildSql("select PERSON_ID from CONTACT") + ); + if (state == FieldChanges.STATE_CHANGED()) + PersUtils.setImage(personId, value); + else + PersUtils.removeImage(personId); +}); + +var user = {}; +user[tools.PARAMS] = []; user[tools.TITLE] = vars.get("$field.UID"); +user[tools.PARAMS][tools.ISACTIVE] = vars.get("$field.ISACTIVE"); user[tools.PARAMS][tools.FIRSTNAME] = vars.get("$field.FIRSTNAME"); user[tools.PARAMS][tools.LASTNAME] = vars.get("$field.LASTNAME"); user[tools.PARAMS][tools.EMAIL] = vars.get("$field.EMAIL_ADDRESS"); diff --git a/entity/Timetracking_entity/Timetracking_entity.aod b/entity/Timetracking_entity/Timetracking_entity.aod index 443bfc6a974afe29ca34117c96bb3041305482c8..ec6bf91c594cfddb9dbc20928f70eb0f77ee6023 100644 --- a/entity/Timetracking_entity/Timetracking_entity.aod +++ b/entity/Timetracking_entity/Timetracking_entity.aod @@ -94,7 +94,7 @@ <dependency> <name>dependency</name> <entityName>Employee_entity</entityName> - <fieldName>#PROVIDER</fieldName> + <fieldName>Employees</fieldName> </dependency> </entityConsumer> </entityFields> diff --git a/neonView/EmployeePreview_view/EmployeePreview_view.aod b/neonView/EmployeePreview_view/EmployeePreview_view.aod index 02a259276ef72e87836eea0072d78dc32a910679..41c53f7a3b87f4e45ee9769f101be68a7112f324 100644 --- a/neonView/EmployeePreview_view/EmployeePreview_view.aod +++ b/neonView/EmployeePreview_view/EmployeePreview_view.aod @@ -20,6 +20,10 @@ <showDrawer v="true" /> <entityField>#ENTITY</entityField> <fields> + <entityFieldLink> + <name>68755289-a351-4915-8626-52f023e237f8</name> + <entityField>ISACTIVE</entityField> + </entityFieldLink> <entityFieldLink> <name>a5f8b519-26d8-4824-b9cf-9119c03b1bd8</name> <entityField>CONTACT_ID</entityField> diff --git a/neonView/EmployeeRoleEdit_view/EmployeeRoleEdit_view.aod b/neonView/EmployeeRoleEdit_view/EmployeeRoleEdit_view.aod index 3013b36d8eea22b1db66714a1dc21ec1dc6f7725..adf9bda6f454cf54c1463a721f68993868e59299 100644 --- a/neonView/EmployeeRoleEdit_view/EmployeeRoleEdit_view.aod +++ b/neonView/EmployeeRoleEdit_view/EmployeeRoleEdit_view.aod @@ -14,7 +14,7 @@ <columns> <neonTableColumn> <name>ecaa1457-eb60-4116-a46c-9c91e2d3fd63</name> - <entityField>UID</entityField> + <entityField>ROLE</entityField> </neonTableColumn> </columns> </genericMultipleViewTemplate> diff --git a/neonView/EmployeeRoleFilter_view/EmployeeRoleFilter_view.aod b/neonView/EmployeeRoleFilter_view/EmployeeRoleFilter_view.aod index 1938871992dbc405ad159fca8148d432706feb53..92602b21460d327d2bdb2e51fe9b1018bd3d8cba 100644 --- a/neonView/EmployeeRoleFilter_view/EmployeeRoleFilter_view.aod +++ b/neonView/EmployeeRoleFilter_view/EmployeeRoleFilter_view.aod @@ -15,7 +15,7 @@ <columns> <neonTableColumn> <name>ab1c8d39-fc29-42e8-8b8e-3557d544b272</name> - <entityField>UID</entityField> + <entityField>ROLE</entityField> </neonTableColumn> </columns> </tableViewTemplate> diff --git a/process/Employee_lib/process.js b/process/Employee_lib/process.js index 9a781c2556f3f9065557f487f8a76cdacad45a4b..ef3273b495502a48ea29ed752400895251dd08a8 100644 --- a/process/Employee_lib/process.js +++ b/process/Employee_lib/process.js @@ -16,5 +16,17 @@ function EmployeeUtils () {} */ EmployeeUtils.getCurrentContactId = function () { - return tools.getCurrentUser()[tools.PARAMS][tools.CONTACTID]; + var user = tools.getCurrentUser(); + return user ? user[tools.PARAMS][tools.CONTACTID] : null; +} + +/** + * Returns the username id of the current user + * + * @return the username + */ +EmployeeUtils.getCurrentUserName = function () +{ + var user = tools.getCurrentUser(); + return user ? user[tools.TITLE] : null; } \ No newline at end of file