From c9609bf707d32f5752b1fd4ef728e21cf40d8cec Mon Sep 17 00:00:00 2001 From: yuri Date: Fri, 23 Oct 2015 16:28:28 +0300 Subject: [PATCH] stream internal posts 3 --- .../Espo/Resources/i18n/en_US/Global.json | 2 + application/Espo/Services/Stream.php | 2 +- .../client/src/views/stream/notes/post.js | 42 ++++++++++++------- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/application/Espo/Resources/i18n/en_US/Global.json b/application/Espo/Resources/i18n/en_US/Global.json index f74fd07c7b..9cd434d6dd 100644 --- a/application/Espo/Resources/i18n/en_US/Global.json +++ b/application/Espo/Resources/i18n/en_US/Global.json @@ -277,6 +277,8 @@ "postTargetYou": "{user} posted to you", "postTargetYouAndOthers": "{user} posted to {target} and you", "postTargetAll": "{user} posted to all", + "postTargetSelf": "{user} posted to self", + "postTargetSelfAndOthers": "{user} posted to {target} and self", "mentionInPost": "{user} mentioned {mentioned} in {entityType} {entity}", diff --git a/application/Espo/Services/Stream.php b/application/Espo/Services/Stream.php index 5dea9d9c03..bdcf7aa3b5 100644 --- a/application/Espo/Services/Stream.php +++ b/application/Espo/Services/Stream.php @@ -449,7 +449,7 @@ class Stream extends \Espo\Core\Services\Base $e->set('relatedName', $entity->get('name')); } } - if ($e->get('type') == 'Post' && $e->get('parentId') === null) { + if ($e->get('type') == 'Post' && $e->get('parentId') === null && !$e->get('isGlobal')) { $e->loadLinkMultipleField('users'); if (count($e->get('usersIds')) == 0) { $e->loadLinkMultipleField('teams'); diff --git a/frontend/client/src/views/stream/notes/post.js b/frontend/client/src/views/stream/notes/post.js index df8b2f5626..a5ca7eed40 100644 --- a/frontend/client/src/views/stream/notes/post.js +++ b/frontend/client/src/views/stream/notes/post.js @@ -74,22 +74,34 @@ Espo.define('views/stream/notes/post', 'views/stream/note', function (Dep) { this.messageData['targetType'] = this.translateEntityType('User', userIdList.length > 1); - var userHtml = ''; - var userHtmlList = []; - userIdList.forEach(function (userId) { - if (userId === this.getUser().id) { - this.messageName = 'postTargetYou'; - if (userIdList.length > 1) { - this.messageName = 'postTargetYouAndOthers'; + if (userIdList.length === 1 && userIdList[0] === this.model.get('createdById')) { + this.messageName = 'postTargetSelf'; + } else { + var userHtml = ''; + var userHtmlList = []; + userIdList.forEach(function (userId) { + if (userId === this.getUser().id) { + this.messageName = 'postTargetYou'; + if (userIdList.length > 1) { + if (userId === this.model.get('createdById')) { + this.messageName = 'postTargetSelfAndOthers'; + } else { + this.messageName = 'postTargetYouAndOthers'; + } + } + } else { + if (userId === this.model.get('createdById')) { + this.messageName = 'postTargetSelfAndOthers'; + } else { + var userName = userNameHash[userId]; + if (userName) { + userHtmlList.push('' + userName + ''); + } + } } - } else { - var userName = userNameHash[userId]; - if (userName) { - userHtmlList.push('' + userName + ''); - } - } - }, this); - this.messageData['target'] = userHtmlList.join(', '); + }, this); + this.messageData['target'] = userHtmlList.join(', '); + } } } }