diff --git a/application/Espo/Core/Templates/Metadata/Base/entityDefs.json b/application/Espo/Core/Templates/Metadata/Base/entityDefs.json index 3d0f245116..c6a5a99f3c 100644 --- a/application/Espo/Core/Templates/Metadata/Base/entityDefs.json +++ b/application/Espo/Core/Templates/Metadata/Base/entityDefs.json @@ -32,7 +32,8 @@ "view": "views/fields/assigned-user" }, "teams": { - "type": "linkMultiple" + "type": "linkMultiple", + "view": "views/fields/teams" } }, "links": { diff --git a/application/Espo/Core/Templates/Metadata/Person/entityDefs.json b/application/Espo/Core/Templates/Metadata/Person/entityDefs.json index bc8e154bcf..d78ad89afa 100644 --- a/application/Espo/Core/Templates/Metadata/Person/entityDefs.json +++ b/application/Espo/Core/Templates/Metadata/Person/entityDefs.json @@ -73,7 +73,8 @@ "view": "views/fields/assigned-user" }, "teams": { - "type": "linkMultiple" + "type": "linkMultiple", + "view": "views/fields/teams" } }, "links": { diff --git a/application/Espo/Core/Utils/EntityManager.php b/application/Espo/Core/Utils/EntityManager.php index e58deb955c..1935f38905 100644 --- a/application/Espo/Core/Utils/EntityManager.php +++ b/application/Espo/Core/Utils/EntityManager.php @@ -320,9 +320,15 @@ class EntityManager switch ($linkType) { case 'oneToMany': - if ($this->getMetadata()->get('entityDefs.' . $entityForeign . '.field.' . $linkForeign)) { + if ($this->getMetadata()->get('entityDefs.' . $entityForeign . '.fields.' . $linkForeign)) { throw new Conflict('Field ['.$entityForeign.'::'.$linkForeign.'] already exists.'); } + if ($this->getMetadata()->get('entityDefs.' . $entityForeign . '.fields.' . $linkForeign . 'Id')) { + throw new Conflict('Field ['.$entityForeign.'::'.$linkForeign.'Id] already exists.'); + } + if ($this->getMetadata()->get('entityDefs.' . $entityForeign . '.fields.' . $linkForeign . 'Name')) { + throw new Conflict('Field ['.$entityForeign.'::'.$linkForeign.'Name] already exists.'); + } $dataLeft = array( 'fields' => array( $link => array( @@ -361,9 +367,15 @@ class EntityManager ); break; case 'manyToOne': - if ($this->getMetadata()->get('entityDefs.' . $entity . '.field.' . $link)) { + if ($this->getMetadata()->get('entityDefs.' . $entity . '.fields.' . $link)) { throw new Conflict('Field ['.$entity.'::'.$link.'] already exists.'); } + if ($this->getMetadata()->get('entityDefs.' . $entity . '.fields.' . $link . 'Id')) { + throw new Conflict('Field ['.$entity.'::'.$link.'Id] already exists.'); + } + if ($this->getMetadata()->get('entityDefs.' . $entity . '.fields.' . $link . 'Name')) { + throw new Conflict('Field ['.$entity.'::'.$link.'Name] already exists.'); + } $dataLeft = array( 'fields' => array( $link => array( diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json index 92a038dc39..ecd7852583 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Account.json @@ -140,7 +140,8 @@ "view": "views/fields/assigned-user" }, "teams": { - "type": "linkMultiple" + "type": "linkMultiple", + "view": "views/fields/teams" }, "targetLists": { "type": "linkMultiple", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Call.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Call.json index 71bde8a29a..1bf5a7eeaf 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Call.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Call.json @@ -112,7 +112,8 @@ "view": "views/fields/assigned-user" }, "teams": { - "type": "linkMultiple" + "type": "linkMultiple", + "view": "views/fields/teams" } }, "links": { diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json index 3fbe6e015d..abb81583ca 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Campaign.json @@ -47,7 +47,8 @@ "view": "views/fields/assigned-user" }, "teams": { - "type": "linkMultiple" + "type": "linkMultiple", + "view": "views/fields/teams" }, "targetLists": { "type": "linkMultiple", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Case.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Case.json index dcf8507db9..bcbc40e97d 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Case.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Case.json @@ -76,7 +76,8 @@ "view": "views/fields/assigned-user" }, "teams": { - "type": "linkMultiple" + "type": "linkMultiple", + "view": "views/fields/teams" } }, "links": { diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json index acc5f1f6ec..823e233b80 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Contact.json @@ -156,7 +156,8 @@ "view": "views/fields/assigned-user" }, "teams": { - "type": "linkMultiple" + "type": "linkMultiple", + "view": "views/fields/teams" }, "targetLists": { "type": "linkMultiple", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Document.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Document.json index d93b884542..24004f6e8a 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Document.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Document.json @@ -64,7 +64,8 @@ "view": "views/fields/assigned-user" }, "teams": { - "type": "linkMultiple" + "type": "linkMultiple", + "view": "views/fields/teams" }, "accounts": { "type": "linkMultiple", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/DocumentFolder.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/DocumentFolder.json index b8fc16af1f..b158ef1379 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/DocumentFolder.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/DocumentFolder.json @@ -25,7 +25,8 @@ "readOnly": true }, "teams": { - "type": "linkMultiple" + "type": "linkMultiple", + "view": "views/fields/teams" }, "parent": { "type": "link" diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/KnowledgeBaseArticle.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/KnowledgeBaseArticle.json index f01588fc86..319ef38e35 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/KnowledgeBaseArticle.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/KnowledgeBaseArticle.json @@ -55,7 +55,8 @@ "views/fields/assigned-user" }, "teams": { - "type": "linkMultiple" + "type": "linkMultiple", + "view": "views/fields/teams" }, "categories": { "type": "linkMultiple", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/KnowledgeBaseCategory.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/KnowledgeBaseCategory.json index 612cc9f10d..12de952e63 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/KnowledgeBaseCategory.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/KnowledgeBaseCategory.json @@ -29,7 +29,8 @@ "required": true }, "teams": { - "type": "linkMultiple" + "type": "linkMultiple", + "view": "views/fields/teams" }, "parent": { "type": "link" diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json index 3319621ace..64fa3efd57 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Lead.json @@ -115,7 +115,8 @@ "disabled": true }, "teams": { - "type": "linkMultiple" + "type": "linkMultiple", + "view": "views/fields/teams" }, "campaign": { "type": "link", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Meeting.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Meeting.json index 9d8a741268..9e7dc2d4aa 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Meeting.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Meeting.json @@ -107,7 +107,8 @@ "view": "views/fields/assigned-user" }, "teams": { - "type": "linkMultiple" + "type": "linkMultiple", + "view": "views/fields/teams" } }, "links": { diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json index 16722e4a81..015bcc33ff 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Opportunity.json @@ -94,7 +94,8 @@ "view": "views/fields/assigned-user" }, "teams": { - "type": "linkMultiple" + "type": "linkMultiple", + "view": "views/fields/teams" } }, "links": { diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Target.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Target.json index 21d2b6d30f..29376388e5 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Target.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Target.json @@ -86,7 +86,8 @@ "view": "views/fields/assigned-user" }, "teams": { - "type": "linkMultiple" + "type": "linkMultiple", + "view": "views/fields/teams" } }, "links": { diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/TargetList.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/TargetList.json index e759554e7a..c29f6cb148 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/TargetList.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/TargetList.json @@ -36,7 +36,8 @@ "view": "views/fields/assigned-user" }, "teams": { - "type": "linkMultiple" + "type": "linkMultiple", + "view": "views/fields/teams" }, "campaigns": { "type": "link" diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Task.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Task.json index 959b5665b7..4826779c9d 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Task.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/Task.json @@ -85,7 +85,8 @@ "view": "views/fields/assigned-user" }, "teams": { - "type": "linkMultiple" + "type": "linkMultiple", + "view": "views/fields/teams" }, "attachments": { "type": "attachmentMultiple", diff --git a/application/Espo/Repositories/EmailAddress.php b/application/Espo/Repositories/EmailAddress.php index 6724d19880..ca24bf8160 100644 --- a/application/Espo/Repositories/EmailAddress.php +++ b/application/Espo/Repositories/EmailAddress.php @@ -320,6 +320,7 @@ class EmailAddress extends \Espo\Core\ORM\Repositories\RDB ".$pdo->quote($emailAddress->id).", ".$pdo->quote((int)($address === $primary))." ) + ON DUPLICATE KEY UPDATE deleted = 0, `primary` = ".$pdo->quote((int)($address === $primary))." "; $sth = $pdo->prepare($query); $sth->execute(); diff --git a/application/Espo/Repositories/PhoneNumber.php b/application/Espo/Repositories/PhoneNumber.php index d2216d89e4..b0fd95de6e 100644 --- a/application/Espo/Repositories/PhoneNumber.php +++ b/application/Espo/Repositories/PhoneNumber.php @@ -233,6 +233,7 @@ class PhoneNumber extends \Espo\Core\ORM\Repositories\RDB ".$pdo->quote($phoneNumber->id).", ".$pdo->quote((int)($number === $primary))." ) + ON DUPLICATE KEY UPDATE deleted = 0, `primary` = ".$pdo->quote((int)($number === $primary))." "; $sth = $pdo->prepare($query); $sth->execute(); diff --git a/application/Espo/Resources/i18n/en_US/EntityManager.json b/application/Espo/Resources/i18n/en_US/EntityManager.json index 05f9bc527e..13f6138aed 100644 --- a/application/Espo/Resources/i18n/en_US/EntityManager.json +++ b/application/Espo/Resources/i18n/en_US/EntityManager.json @@ -44,6 +44,6 @@ "messages": { "entityCreated": "Entity has been created", "linkAlreadyExists": "Link name conflict.", - "linkConflict": "Link with the same name already exists." + "linkConflict": "Name conflict: link or field with the same name already exists." } } diff --git a/application/Espo/Resources/metadata/entityDefs/Email.json b/application/Espo/Resources/metadata/entityDefs/Email.json index 093704d4d9..65d109f4e3 100644 --- a/application/Espo/Resources/metadata/entityDefs/Email.json +++ b/application/Espo/Resources/metadata/entityDefs/Email.json @@ -206,7 +206,8 @@ "notStorable": true }, "teams": { - "type": "linkMultiple" + "type": "linkMultiple", + "view": "views/fields/teams" }, "users": { "type": "linkMultiple", diff --git a/client/src/views/admin/link-manager/modals/edit.js b/client/src/views/admin/link-manager/modals/edit.js index 2703d605d4..e53cc5e5bf 100644 --- a/client/src/views/admin/link-manager/modals/edit.js +++ b/client/src/views/admin/link-manager/modals/edit.js @@ -338,7 +338,7 @@ Espo.define('views/admin/link-manager/modals/edit', ['views/modal', 'views/admin if (view) { view.disabled = true; } - this.$el.find('.cell-' + name).css('visibility', 'hidden'); + this.$el.find('.cell[data-name=' + name+']').css('visibility', 'hidden'); }, showField: function (name) { @@ -346,7 +346,7 @@ Espo.define('views/admin/link-manager/modals/edit', ['views/modal', 'views/admin if (view) { view.disabled = false; } - this.$el.find('.cell-' + name).css('visibility', 'visible'); + this.$el.find('.cell[data-name=' + name+']').css('visibility', 'visible'); }, handleLinkTypeChange: function () { diff --git a/client/src/views/fields/user-with-avatar.js b/client/src/views/fields/user-with-avatar.js index 0fe178131e..383324736d 100644 --- a/client/src/views/fields/user-with-avatar.js +++ b/client/src/views/fields/user-with-avatar.js @@ -36,7 +36,7 @@ Espo.define('views/fields/user-with-avatar', 'views/fields/user', function (Dep) data: function () { var o = _.extend({}, Dep.prototype.data.call(this)); - if (this.mode == 'detail' || this.mode == 'list') { + if (this.mode == 'detail') { o.avatar = this.getAvatarHtml(); } return o;