Skip to content
Snippets Groups Projects
Commit 9b9c81d3 authored by Sebastian Listl's avatar Sebastian Listl :speech_balloon:
Browse files

Person: set person address as standard when a new person is inserted

parent e677b8d4
No related branches found
No related tags found
No related merge requests found
......@@ -478,6 +478,10 @@
<name>ContactIds_param</name>
<expose v="true" />
</entityParameter>
<entityParameter>
<name>ReplaceStandardAddress_param</name>
<expose v="true" />
</entityParameter>
</entityFields>
<recordContainers>
<dbRecordContainer>
......
import("system.logging");
import("KeywordRegistry_basic");
import("DataPrivacy_lib");
import("system.vars");
......@@ -22,6 +23,6 @@ else if (typeParam === "organisation")
scopeType = "Organisation"
new StandardObject("Address", vars.get("$local.uid"), scopeType, rowdata["ADDRESS.CONTACT_ID"])
.onObjectInsert()
.onObjectInsert(vars.exists("$param.ReplaceStandardAddress_param") ? vars.get("$param.ReplaceStandardAddress_param") : undefined)
DataPrivacyUtils.notifyNeedDataPrivacyUpdate(rowdata["ADDRESS.CONTACT_ID"], vars.get("$param.ShowDsgvoMessage_param"));
\ No newline at end of file
DataPrivacyUtils.notifyNeedDataPrivacyUpdate(rowdata["ADDRESS.CONTACT_ID"], vars.get("$param.ShowDsgvoMessage_param"));
......@@ -176,6 +176,10 @@ This field only calculates the Orgid from the ORGANISATION_CONTACTID to save it
<name>ShowDsgvoMessage_param</name>
<valueProcess>%aditoprj%/entity/Person_entity/entityfields/persaddresses/children/showdsgvomessage_param/valueProcess.js</valueProcess>
</entityParameter>
<entityParameter>
<name>ReplaceStandardAddress_param</name>
<valueProcess>%aditoprj%/entity/Person_entity/entityfields/persaddresses/children/replacestandardaddress_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
<entityConsumer>
......
import("system.neon");
import("system.vars");
import("system.result");
//this parameter allows the address entity to set a itself as the standard address
//if the current standard address is the given id
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
result.string(vars.get("$field.ADDRESS_ID"));
\ No newline at end of file
......@@ -72,4 +72,6 @@ notification.addNotificationWith(notificationConfig);
//notification.addNotification(util.getNewUUID(), null, null, null, "_____SYSTEM_NOTIFICATION_MESSAGE", notification.PRIO_NORMAL, 1, notification.STATE_UNSEEN, [EmployeeUtils.getCurrentUserId()], "message", "description");
}
\ No newline at end of file
}
var persAdress
\ No newline at end of file
import("Organisation_lib");
import("Sql_lib");
import("system.db");
import("Keyword_lib");
import("KeywordRegistry_basic");
......@@ -111,12 +112,12 @@ StandardObject.prototype.onPersonValueChange = function (pSelectedOrganisationID
* on a "random" basis: Which object gets first inserted will get the
* place as standard.
*/
StandardObject.prototype.onObjectInsert = function () {
StandardObject.prototype.onObjectInsert = function (pIdToOverwrite) {
this._assertObjectIdNotNull();
this._assertScopeIdNotNull();
if (this.objectType === StandardObject.CONST_OBJECT_ADDRESS()) {
this._onAddressInsert();
this._onAddressInsert(pIdToOverwrite);
} else if (this.objectType === StandardObject.CONST_OBJECT_COMMUNICATION) {
this._onCommunicationInsert();
}
......@@ -127,11 +128,11 @@ StandardObject.prototype.onObjectInsert = function () {
* of the `Address` entity. This will set the standard address on the
* contact if it's currently null.
*/
StandardObject.prototype._onAddressInsert = function () {
StandardObject.prototype._onAddressInsert = function (pIdToOverwrite) {
// Assert
this._assertObjectType(StandardObject.CONST_OBJECT_ADDRESS());
if (!this._hasContactStandardAddress(this.scopeID)) {
if (!this._hasContactStandardAddress(this.scopeID, pIdToOverwrite)) {
this._setContactStandardAddress(this.objectID, this.scopeID);
}
}
......@@ -190,15 +191,16 @@ StandardObject.prototype.onCommunicationUpdate = function (pMediumID) {
* it's currently working on a `Address` object.
*
* @param {String} pContactID Contact ID to check.
* @param {String} [pIdToIgnore] if this address ID is found, act as if it was empty
* @return {Boolean} If the contact ID has standard address.
*/
StandardObject.prototype._hasContactStandardAddress = function (pContactID) {
StandardObject.prototype._hasContactStandardAddress = function (pContactID, pIdToIgnore) {
this._assertObjectType(StandardObject.CONST_OBJECT_ADDRESS());
var databaseResult = db.cell("select ADDRESS_ID from CONTACT"
+ " where CONTACTID = '" + pContactID + "'");
return databaseResult !== "";
return databaseResult !== "" && databaseResult !== pIdToIgnore;
}
/**
......
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