diff --git a/application/Espo/Core/Utils/Config.php b/application/Espo/Core/Utils/Config.php index 91c96140ad..84f1d83e2c 100644 --- a/application/Espo/Core/Utils/Config.php +++ b/application/Espo/Core/Utils/Config.php @@ -316,6 +316,11 @@ class Config return true; } + + public function getSiteUrl() + { + return rtrim($this->get('siteUrl'), '/'); + } } ?> diff --git a/application/Espo/Core/defaults/config.php b/application/Espo/Core/defaults/config.php index 62deeecadc..dc988b9ebd 100644 --- a/application/Espo/Core/defaults/config.php +++ b/application/Espo/Core/defaults/config.php @@ -100,6 +100,8 @@ return array ( 'assignmentEmailNotifications' => false, 'assignmentEmailNotificationsEntityList' => ['Lead', 'Opportunity', 'Task', 'Case'], 'assignmentNotificationsEntityList' => ['Meeting', 'Call', 'Task', 'Email'], + "portalStreamEmailNotifications" => true, + 'streamEmailNotificationsEntityList' => ['Case'], 'emailMessageMaxSize' => 10, 'notificationsCheckInterval' => 10, 'disabledCountQueryEntityList' => ['Email'], diff --git a/application/Espo/Resources/i18n/en_US/Preferences.json b/application/Espo/Resources/i18n/en_US/Preferences.json index 07f11775d0..1bedbcfa16 100644 --- a/application/Espo/Resources/i18n/en_US/Preferences.json +++ b/application/Espo/Resources/i18n/en_US/Preferences.json @@ -18,8 +18,9 @@ "smtpPassword": "Password", "smtpEmailAddress": "Email Address", "exportDelimiter": "Export Delimiter", - "receiveAssignmentEmailNotifications": "Receive email notifications upon assignment", - "receiveMentionEmailNotifications": "Receive email notifications about mentions in posts", + "receiveAssignmentEmailNotifications": "Email notifications upon assignment", + "receiveMentionEmailNotifications": "Email notifications about mentions in posts", + "receiveStreamEmailNotifications": "Email notifications about posts and status updates", "autoFollowEntityTypeList": "Auto-Follow", "signature": "Email Signature", "dashboardTabList": "Tab List", diff --git a/application/Espo/Resources/i18n/en_US/Settings.json b/application/Espo/Resources/i18n/en_US/Settings.json index f09882df3c..afd84ab888 100644 --- a/application/Espo/Resources/i18n/en_US/Settings.json +++ b/application/Espo/Resources/i18n/en_US/Settings.json @@ -47,8 +47,11 @@ "ldapOptReferrals": "Opt Referrals", "exportDisabled": "Disable Export (only admin is allowed)", "assignmentNotificationsEntityList": "Entities to notify about upon assignment", - "assignmentEmailNotifications": "Send email notifications upon assignment", - "assignmentEmailNotificationsEntityList": "Entities to notify about with email upon assignment", + "assignmentEmailNotifications": "Notifications upon assignment", + "assignmentEmailNotificationsEntityList": "Assignment email notifications scopes", + "streamEmailNotifications": "Notifications about updates in Stream for internal users", + "portalStreamEmailNotifications": "Notifications about updates in Stream for portal users", + "streamEmailNotificationsEntityList": "Stream email notifications scopes", "b2cMode": "B2C Mode", "avatarsDisabled": "Disable Avatars", "followCreatedEntities": "Follow Created Entities", diff --git a/application/Espo/Resources/layouts/Preferences/detail.json b/application/Espo/Resources/layouts/Preferences/detail.json index 416c29b587..c9f1c4573f 100644 --- a/application/Espo/Resources/layouts/Preferences/detail.json +++ b/application/Espo/Resources/layouts/Preferences/detail.json @@ -78,7 +78,8 @@ "label": "Notifications", "name": "notifications", "rows": [ - [{"name": "receiveAssignmentEmailNotifications"}, {"name": "receiveMentionEmailNotifications"}] + [{"name": "receiveAssignmentEmailNotifications"}, {"name": "receiveMentionEmailNotifications"}], + [{"name": "receiveStreamEmailNotifications"}, false] ] } ] diff --git a/application/Espo/Resources/layouts/Settings/notifications.json b/application/Espo/Resources/layouts/Settings/notifications.json index 7e8e7cb515..6df89d7cbf 100644 --- a/application/Espo/Resources/layouts/Settings/notifications.json +++ b/application/Espo/Resources/layouts/Settings/notifications.json @@ -10,7 +10,9 @@ "label": "Email Notifications", "rows": [ [{"name": "assignmentEmailNotifications"}, {"name": "mentionEmailNotifications"}], - [{"name": "assignmentEmailNotificationsEntityList"}] + [{"name": "assignmentEmailNotificationsEntityList"}], + [{"name": "streamEmailNotifications"}, {"name": "portalStreamEmailNotifications"}], + [{"name": "streamEmailNotificationsEntityList"}] ] } ] \ No newline at end of file diff --git a/application/Espo/Resources/metadata/entityDefs/Preferences.json b/application/Espo/Resources/metadata/entityDefs/Preferences.json index ef04d4e131..2b58450fec 100644 --- a/application/Espo/Resources/metadata/entityDefs/Preferences.json +++ b/application/Espo/Resources/metadata/entityDefs/Preferences.json @@ -102,6 +102,10 @@ "type": "bool", "default": true }, + "receiveStreamEmailNotifications": { + "type": "bool", + "default": true + }, "autoFollowEntityTypeList": { "type": "multiEnum", "view": "views/preferences/fields/auto-follow-entity-type-list", diff --git a/application/Espo/Resources/metadata/entityDefs/Settings.json b/application/Espo/Resources/metadata/entityDefs/Settings.json index 23c135a19b..5c1d38dfcf 100644 --- a/application/Espo/Resources/metadata/entityDefs/Settings.json +++ b/application/Espo/Resources/metadata/entityDefs/Settings.json @@ -235,6 +235,19 @@ "type": "bool", "default": false }, + "streamEmailNotifications": { + "type": "bool", + "default": false + }, + "portalStreamEmailNotifications": { + "type": "bool", + "default": true + }, + "streamEmailNotificationsEntityList": { + "type": "multiEnum", + "translation": "Global.scopeNamesPlural", + "view": "views/settings/fields/stream-email-notifications-entity-list" + }, "b2cMode": { "type": "bool", "default": false diff --git a/application/Espo/Resources/templates/assignment/en_US/subject.tpl b/application/Espo/Resources/templates/assignment/en_US/subject.tpl index b6ece9bec5..de2a04b09a 100644 --- a/application/Espo/Resources/templates/assignment/en_US/subject.tpl +++ b/application/Espo/Resources/templates/assignment/en_US/subject.tpl @@ -1 +1 @@ -{{entityType}}: {{name}} \ No newline at end of file +Assigned to you: [{{{entityType}}}] {{{name}}} \ No newline at end of file diff --git a/application/Espo/Resources/templates/notePost/en_US/body.tpl b/application/Espo/Resources/templates/notePost/en_US/body.tpl new file mode 100644 index 0000000000..16b197aec3 --- /dev/null +++ b/application/Espo/Resources/templates/notePost/en_US/body.tpl @@ -0,0 +1,3 @@ +
{{userName}} posted on {{entityTypeLowerFirst}} {{parentName}}.
+{{{post}}}
+ diff --git a/application/Espo/Resources/templates/notePost/en_US/subject.tpl b/application/Espo/Resources/templates/notePost/en_US/subject.tpl new file mode 100644 index 0000000000..511f696b57 --- /dev/null +++ b/application/Espo/Resources/templates/notePost/en_US/subject.tpl @@ -0,0 +1 @@ +Post: [{{{entityType}}}] {{{name}}} \ No newline at end of file diff --git a/application/Espo/Resources/templates/noteStatus/en_US/body.tpl b/application/Espo/Resources/templates/noteStatus/en_US/body.tpl new file mode 100644 index 0000000000..1577656d62 --- /dev/null +++ b/application/Espo/Resources/templates/noteStatus/en_US/body.tpl @@ -0,0 +1,2 @@ +{{userName}} changed {{{fieldTranslatedLowerCase}}} of {{entityTypeLowerFirst}} '{{name}}' to {{valueTranslated}}.
+ diff --git a/application/Espo/Resources/templates/noteStatus/en_US/subject.tpl b/application/Espo/Resources/templates/noteStatus/en_US/subject.tpl new file mode 100644 index 0000000000..3211a8c56d --- /dev/null +++ b/application/Espo/Resources/templates/noteStatus/en_US/subject.tpl @@ -0,0 +1 @@ +{{{valueTranslated}}}: [{{{entityType}}}] {{{name}}} \ No newline at end of file diff --git a/application/Espo/Services/EmailNotification.php b/application/Espo/Services/EmailNotification.php index df7c200053..ecd850fca2 100644 --- a/application/Espo/Services/EmailNotification.php +++ b/application/Espo/Services/EmailNotification.php @@ -46,10 +46,13 @@ class EmailNotification extends \Espo\Core\Services\Base 'language', 'dateTime', 'number', - 'fileManager' + 'fileManager', + 'selectManagerFactory' ]); } + protected $noteNotificationTypeList = ['Post', 'Status']; + protected function getMailSender() { return $this->getInjection('mailSender'); @@ -185,16 +188,19 @@ class EmailNotification extends \Espo\Core\Services\Base return $fileName; } - protected function getMentionTemplate($name) + protected function getTemplate($type, $name, $entityType = null) { - $fileName = $this->getMentionTemplateFileName($name); + if ($entityType) { + $fileName = $this->getEntityTemplateFileName($entityType, $type, $name); + } else { + $fileName = $this->getTemplateFileName($type, $name); + } return file_get_contents($fileName); } - protected function getMentionTemplateFileName($name) + protected function getTemplateFileName($type, $name) { $language = $this->getConfig()->get('language'); - $type = 'mention'; $fileName = "custom/Espo/Custom/Resources/templates/{$type}/{$language}/{$name}.tpl"; if (file_exists($fileName)) return $fileName; @@ -211,6 +217,48 @@ class EmailNotification extends \Espo\Core\Services\Base return $fileName; } + protected function getEntityTemplateFileName($entityType, $type, $name) + { + $language = $this->getConfig()->get('language'); + $moduleName = $this->getMetadata()->getScopeModuleName($entityType); + + $fileName = "custom/Espo/Custom/Resources/templates/{$type}/{$language}/{$entityType}/{$name}.tpl"; + if (file_exists($fileName)) return $fileName; + + if ($moduleName) { + $fileName = "application/Espo/Modules/{$moduleName}/Resources/templates/{$type}/{$language}/{$entityType}/{$name}.tpl"; + if (file_exists($fileName)) return $fileName; + } + + $fileName = "application/Espo/Resources/templates/{$type}/{$language}/{$entityType}/{$name}.tpl"; + if (file_exists($fileName)) return $fileName; + + $fileName = "custom/Espo/Custom/Resources/templates/{$type}/{$language}/{$name}.tpl"; + if (file_exists($fileName)) return $fileName; + + $fileName = "application/Espo/Resources/templates/{$type}/{$language}/{$name}.tpl"; + if (file_exists($fileName)) return $fileName; + + $language = 'en_US'; + + $fileName = "custom/Espo/Custom/Resources/templates/{$type}/{$language}/{$entityType}/{$name}.tpl"; + if (file_exists($fileName)) return $fileName; + + if ($moduleName) { + $fileName = "application/Espo/Modules/{$moduleName}/Resources/templates/{$type}/{$language}/{$entityType}/{$name}.tpl"; + if (file_exists($fileName)) return $fileName; + } + + $fileName = "application/Espo/Resources/templates/{$type}/{$language}/{$entityType}/{$name}.tpl"; + if (file_exists($fileName)) return $fileName; + + $fileName = "custom/Espo/Custom/Resources/templates/{$type}/{$language}/{$name}.tpl"; + if (file_exists($fileName)) return $fileName; + + $fileName = "application/Espo/Resources/templates/{$type}/{$language}/{$name}.tpl"; + return $fileName; + } + public function process() { $dateTime = new \DateTime(); @@ -218,22 +266,38 @@ class EmailNotification extends \Espo\Core\Services\Base $mentionEmailNotifications = $this->getConfig()->get('mentionEmailNotifications'); + $streamEmailNotifications = $this->getConfig()->get('streamEmailNotifications'); + $portalStreamEmailNotifications = $this->getConfig()->get('portalStreamEmailNotifications'); + $typeList = []; if ($mentionEmailNotifications) { $typeList[] = 'MentionInPost'; } - if (!$mentionEmailNotifications) return; + if ($streamEmailNotifications || $portalStreamEmailNotifications) { + $typeList[] = 'Note'; + } + + if (empty($typeList)) return; $where = array( - 'createdAt' > $dateTime, + 'createdAt>' => $dateTime->format('Y-m-d H:i:s'), 'read' => false, 'emailIsProcessed' => false ); - $where['type'] = $typeList; + $sqlArr = []; + foreach ($typeList as $type) { + $methodName = 'getNotificationSelectParams' . $type; + $selectParams = $this->$methodName(); + $selectParams['whereClause'][] = $where; - $notificationList = $this->getEntityManager()->getRepository('Notification')->where($where)->order('createdAt')->find(); + $sqlArr[] = $this->getEntityManager()->getQuery()->createSelectQuery('Notification', $selectParams); + } + + $sql = '' . implode(' UNION ', $sqlArr) . ' ORDER BY number'; + + $notificationList = $this->getEntityManager()->getRepository('Notification')->findByQuery($sql); foreach ($notificationList as $notification) { $notification->set('emailIsProcessed', true); @@ -249,14 +313,57 @@ class EmailNotification extends \Espo\Core\Services\Base } } - public function processNotificationMentionInPost(Entity $notification) + protected function getNotificationSelectParamsMentionInPost() { - $userId = $notification->get('userId'); + $selectManager = $this->getInjection('selectManagerFactory')->create('Notification'); + $selectParams = $selectManager->getEmptySelectParams(); + + $selectParams['whereClause']['type'] = 'MentionInPost'; + + return $selectParams; + } + + protected function getNotificationSelectParamsNote() + { + $selectManager = $this->getInjection('selectManagerFactory')->create('Notification'); + + $selectParams = $selectManager->getEmptySelectParams(); + + $selectParams['whereClause']['type'] = 'Note'; + $selectParams['whereClause']['relatedType'] = 'Note'; + + $selectParams['customJoin'] .= ' JOIN note ON notification.related_id = note.id'; + + $selectParams['whereClause']['note.type'] = $this->noteNotificationTypeList; + + $entityList = $this->getConfig()->get('streamEmailNotificationsEntityList'); + + if (empty($entityList)) { + $selectParams['whereClause']['relatedParentType'] = null; + } else { + $selectParams['whereClause']['relatedParentType'] = $entityList; + } + + $forInternal = $this->getConfig()->get('streamEmailNotifications'); + $forPortal = $this->getConfig()->get('portalStreamEmailNotifications'); + + if ($forInternal && !$forPortal) { + $selectParams['whereClause']['user.isPortalUser'] = false; + } else if (!$forInternal && $forPortal) { + $selectParams['whereClause']['user.isPortalUser'] = true; + } + + return $selectParams; + } + + protected function processNotificationMentionInPost(Entity $notification) + { + if (!$notification->get('userId')) return; + $userId = $notification->get('userId'); $user = $this->getEntityManager()->getEntity('User', $userId); $emailAddress = $user->get('emailAddress'); - if (!$emailAddress) return; $preferences = $this->getEntityManager()->getEntity('Preferences', $userId); @@ -278,20 +385,20 @@ class EmailNotification extends \Espo\Core\Services\Base $parent = $this->getEntityManager()->getEntity($parentType, $parentId); if (!$parent) return; - $data['url'] = rtrim($this->getConfig()->get('siteUrl'), '/') . '/#' . $parentType . '/' . $parentId; + $data['url'] = $this->getConfig()->getSiteUrl() . '/#' . $parentType . '/view/' . $parentId; $data['parentName'] = $parent->get('name'); $data['parentType'] = $parentType; $data['parentId'] = $parentId; } else { - $data['url'] = rtrim($this->getConfig()->get('siteUrl'), '/') . '/#Notification'; + $data['url'] = $this->getConfig()->getSiteUrl() . '/#Notification'; } $data['userName'] = $note->get('createdByName'); $data['post'] = $note->get('post'); - $subjectTpl = $this->getMentionTemplate('subject'); - $bodyTpl = $this->getMentionTemplate('body'); + $subjectTpl = $this->getTemplate('mention', 'subject'); + $bodyTpl = $this->getTemplate('mention', 'body'); $subjectTpl = str_replace(array("\n", "\r"), '', $subjectTpl); $subject = $this->getHtmlizer()->render($note, $subjectTpl, 'mention-email-subject', $data, true); @@ -312,4 +419,145 @@ class EmailNotification extends \Espo\Core\Services\Base $GLOBALS['log']->error('EmailNotification: [' . $e->getCode() . '] ' .$e->getMessage()); } } + + protected function processNotificationNote(Entity $notification) + { + if ($notification->get('relatedType') !== 'Note') return; + if (!$notification->get('relatedId')) return; + + $note = $this->getEntityManager()->getEntity('Note', $notification->get('relatedId')); + if (!$note) return; + if (!in_array($note->get('type'), $this->noteNotificationTypeList)) return; + + if (!$notification->get('userId')) return; + $userId = $notification->get('userId'); + $user = $this->getEntityManager()->getEntity('User', $userId); + + $emailAddress = $user->get('emailAddress'); + if (!$emailAddress) return; + + $preferences = $this->getEntityManager()->getEntity('Preferences', $userId); + if (!$preferences) return; + if (!$preferences->get('receiveStreamEmailNotifications')) return; + + $methodName = 'processNotificationNote' . $note->get('type'); + + if (!method_exists($this, $methodName)) return; + + $this->$methodName($note, $user); + } + + protected function processNotificationNotePost($note, $user) + { + $post = $note->get('post'); + $parentId = $note->get('parentId'); + $parentType = $note->get('parentType'); + + $emailAddress = $user->get('emailAddress'); + if (!$emailAddress) return; + + $data = array(); + + if (!$parentId || !$parentType) return; + + $parent = $this->getEntityManager()->getEntity($parentType, $parentId); + if (!$parent) return; + + $data['url'] = $this->getConfig()->getSiteUrl() . '/#' . $parentType . '/view/' . $parentId; + $data['parentName'] = $parent->get('name'); + $data['parentType'] = $parentType; + $data['parentId'] = $parentId; + + $data['name'] = $data['parentName']; + + $data['entityType'] = $this->getLanguage()->translate($data['parentType'], 'scopeNames'); + $data['entityTypeLowerFirst'] = lcfirst($data['entityType']); + + $data['userName'] = $note->get('createdByName'); + + $data['post'] = $note->get('post'); + + $subjectTpl = $this->getTemplate('notePost', 'subject', $parentType); + $bodyTpl = $this->getTemplate('notePost', 'body', $parentType); + $subjectTpl = str_replace(array("\n", "\r"), '', $subjectTpl); + + $subject = $this->getHtmlizer()->render($note, $subjectTpl, 'note-post-email-subject', $data, true); + $body = $this->getHtmlizer()->render($note, $bodyTpl, 'note-post-email-body', $data, true); + + $email = $this->getEntityManager()->getEntity('Email'); + + $email->set(array( + 'subject' => $subject, + 'body' => $body, + 'isHtml' => true, + 'to' => $emailAddress, + 'isSystem' => true + )); + try { + $this->getMailSender()->send($email); + } catch (\Exception $e) { + $GLOBALS['log']->error('EmailNotification: [' . $e->getCode() . '] ' .$e->getMessage()); + } + } + + protected function processNotificationNoteStatus($note, $user) + { + $post = $note->get('post'); + $parentId = $note->get('parentId'); + $parentType = $note->get('parentType'); + + $emailAddress = $user->get('emailAddress'); + if (!$emailAddress) return; + + $data = array(); + + if (!$parentId || !$parentType) return; + + $parent = $this->getEntityManager()->getEntity($parentType, $parentId); + if (!$parent) return; + + $data['url'] = $this->getConfig()->getSiteUrl() . '/#' . $parentType . '/view/' . $parentId; + $data['parentName'] = $parent->get('name'); + $data['parentType'] = $parentType; + $data['parentId'] = $parentId; + + $data['name'] = $data['parentName']; + + $data['entityType'] = $this->getLanguage()->translate($data['parentType'], 'scopeNames'); + $data['entityTypeLowerFirst'] = lcfirst($data['entityType']); + + $noteData = $note->get('data'); + if (empty($noteData)) return; + + + $data['value'] = $noteData->value; + $data['field'] = $noteData->field; + $data['valueTranslated'] = $this->getLanguage()->translateOption($data['value'], $data['field'], $parentType); + $data['fieldTranslated'] = $this->getLanguage()->translate($data['field'], 'fields', $parentType); + $data['fieldTranslatedLowerCase'] = lcfirst($data['fieldTranslated']); + + $data['userName'] = $note->get('createdByName'); + + $subjectTpl = $this->getTemplate('noteStatus', 'subject', $parentType); + $bodyTpl = $this->getTemplate('noteStatus', 'body', $parentType); + $subjectTpl = str_replace(array("\n", "\r"), '', $subjectTpl); + + $subject = $this->getHtmlizer()->render($note, $subjectTpl, 'note-status-email-subject', $data, true); + $body = $this->getHtmlizer()->render($note, $bodyTpl, 'note-status-email-body', $data, true); + + $email = $this->getEntityManager()->getEntity('Email'); + + $email->set(array( + 'subject' => $subject, + 'body' => $body, + 'isHtml' => true, + 'to' => $emailAddress, + 'isSystem' => true + )); + try { + $this->getMailSender()->send($email); + } catch (\Exception $e) { + $GLOBALS['log']->error('EmailNotification: [' . $e->getCode() . '] ' .$e->getMessage()); + } + } } \ No newline at end of file diff --git a/client/src/views/admin/notifications.js b/client/src/views/admin/notifications.js index db9dfab9f0..ad3b48a09b 100644 --- a/client/src/views/admin/notifications.js +++ b/client/src/views/admin/notifications.js @@ -53,6 +53,21 @@ Espo.define('views/admin/notifications', 'views/settings/record/edit', function setup: function () { Dep.prototype.setup.call(this); + + this.controlStreamEmailNotificationsEntityList(); + this.listenTo(this.model, 'change', function (model) { + if (model.hasChanged('streamEmailNotifications') || model.hasChanged('portalStreamEmailNotifications')) { + this.controlStreamEmailNotificationsEntityList(); + } + }, this); + }, + + controlStreamEmailNotificationsEntityList: function () { + if (this.model.get('streamEmailNotifications') || this.model.get('portalStreamEmailNotifications')) { + this.showField('streamEmailNotificationsEntityList'); + } else { + this.hideField('streamEmailNotificationsEntityList'); + } } }); diff --git a/client/src/views/fields/entity-type-list.js b/client/src/views/fields/entity-type-list.js index ffef67444f..537af0fbcd 100644 --- a/client/src/views/fields/entity-type-list.js +++ b/client/src/views/fields/entity-type-list.js @@ -50,7 +50,9 @@ Espo.define('views/fields/entity-type-list', 'views/fields/multi-enum', function }, setup: function () { - this.params.translation = 'Global.scopeNames'; + if (!this.params.translation) { + this.params.translation = 'Global.scopeNames'; + } this.setupOptions(); Dep.prototype.setup.call(this); } diff --git a/client/src/views/preferences/record/edit.js b/client/src/views/preferences/record/edit.js index 5bb6ec84fb..0f3fbf3a8e 100644 --- a/client/src/views/preferences/record/edit.js +++ b/client/src/views/preferences/record/edit.js @@ -114,6 +114,14 @@ Espo.define('views/preferences/record/edit', 'views/record/edit', function (Dep) hideNotificationPanel = false; } + if (!this.getConfig().get('streamEmailNotifications') && !this.model.get('isPortalUser')) { + this.hideField('receiveStreamEmailNotifications'); + } else if (!this.getConfig().get('portalStreamEmailNotifications') && this.model.get('isPortalUser')) { + this.hideField('receiveStreamEmailNotifications'); + } else { + hideNotificationPanel = false; + } + if (hideNotificationPanel) { this.hidePanel('notifications'); } diff --git a/client/src/views/settings/fields/stream-email-notifications-entity-list.js b/client/src/views/settings/fields/stream-email-notifications-entity-list.js new file mode 100644 index 0000000000..a4fb1d3a68 --- /dev/null +++ b/client/src/views/settings/fields/stream-email-notifications-entity-list.js @@ -0,0 +1,46 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM - Open Source CRM application. + * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko + * Website: http://www.espocrm.com + * + * EspoCRM is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * EspoCRM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with EspoCRM. If not, see http://www.gnu.org/licenses/. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU General Public License version 3. + * + * In accordance with Section 7(b) of the GNU General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. + ************************************************************************/ + +Espo.define('views/settings/fields/stream-email-notifications-entity-list', 'views/fields/entity-type-list', function (Dep) { + + return Dep.extend({ + + setupOptions: function () { + + Dep.prototype.setupOptions.call(this); + + this.params.options = this.params.options.filter(function (scope) { + if (this.getMetadata().get('scopes.' + scope + '.disabled')) return; + if (!this.getMetadata().get('scopes.' + scope + '.object')) return; + if (!this.getMetadata().get('scopes.' + scope + '.stream')) return; + return true; + }, this) + }, + + }); +}); diff --git a/client/src/views/settings/record/edit.js b/client/src/views/settings/record/edit.js index b979f7a94f..5c5d1796c6 100644 --- a/client/src/views/settings/record/edit.js +++ b/client/src/views/settings/record/edit.js @@ -26,12 +26,12 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('Views.Settings.Record.Edit', 'Views.Record.Edit', function (Dep) { +Espo.define('views/settings/record/edit', 'views/record/edit', function (Dep) { return Dep.extend({ sideView: null, - + layoutName: 'settings', buttons: [ @@ -45,10 +45,10 @@ Espo.define('Views.Settings.Record.Edit', 'Views.Record.Edit', function (Dep) { label: 'Cancel', } ], - + setup: function () { Dep.prototype.setup.call(this); - + this.listenTo(this.model, 'after:save', function () { this.getConfig().set(this.model.toJSON()); this.getConfig().storeToCache(); @@ -57,7 +57,7 @@ Espo.define('Views.Settings.Record.Edit', 'Views.Record.Edit', function (Dep) { afterRender: function () { Dep.prototype.afterRender.call(this); - + var currencyListField = this.getFieldView('currencyList'); var defaultCurrencyField = this.getFieldView('defaultCurrency'); if (currencyListField && defaultCurrencyField) {