preferences: auto-follow improvements

This commit is contained in:
yuri
2017-11-13 14:43:09 +02:00
parent 495f8bf968
commit 0c993c069d
10 changed files with 86 additions and 14 deletions
+10
View File
@@ -36,11 +36,21 @@ class User extends \Espo\Core\Entities\Person
return $this->get('isAdmin');
}
public function isSystem()
{
return $this->id === 'system';
}
public function isActive()
{
return $this->get('isActive');
}
public function isPortal()
{
return $this->isPortalUser();
}
public function isPortalUser()
{
return $this->get('isPortalUser');
+21 -2
View File
@@ -56,6 +56,11 @@ class Stream extends \Espo\Core\Hooks\Base
return $this->getInjection('serviceFactory');
}
protected function getPreferences()
{
return $this->getInjection('container')->get('preferences');
}
protected function checkHasStream(Entity $entity)
{
$entityType = $entity->getEntityType();
@@ -185,9 +190,23 @@ class Stream extends \Espo\Core\Hooks\Base
$createdById = $entity->get('createdById');
if (
($this->getConfig()->get('followCreatedEntities') || $this->getUser()->get('isPortalUser'))
!$this->getUser()->isSystem()
&&
!empty($createdById)
$createdById
&&
$createdById === $this->getUser()->id
&&
(
$this->getUser()->isPortalUser()
||
$this->getPreferences()->get('followCreatedEntities')
||
(
is_array($this->getPreferences()->get('followCreatedEntityTypeList'))
&&
in_array($entityType, $this->getPreferences()->get('followCreatedEntityTypeList'))
)
)
) {
$userIdList[] = $createdById;
}
@@ -34,11 +34,12 @@ use Espo\Core\Utils\Json;
class Preferences extends \Espo\Core\ORM\Repository
{
protected $defaultAttributeListFromSettings = array(
protected $defaultAttributeListFromSettings = [
'decimalMark',
'thousandSeparator',
'exportDelimiter'
);
'exportDelimiter',
'followCreatedEntities'
];
protected $data = array();
@@ -31,7 +31,8 @@
"emailReplyToAllByDefault": "Standardmäßig Allen antworten",
"dashboardLayout": "Dashboard Layout",
"emailReplyForceHtml": "E-Mail Antwort als HTML",
"doNotFillAssignedUserIfNotRequired": "Zugwiesenen Benutzer nicht ausfüllen wenn optional"
"doNotFillAssignedUserIfNotRequired": "Zugwiesenen Benutzer nicht ausfüllen wenn optional",
"followCreatedEntities": "Eigene Einträge abonnieren"
},
"options": {
"weekStart": {
@@ -21,18 +21,20 @@
"receiveAssignmentEmailNotifications": "Email notifications upon assignment",
"receiveMentionEmailNotifications": "Email notifications about mentions in posts",
"receiveStreamEmailNotifications": "Email notifications about posts and status updates",
"autoFollowEntityTypeList": "Auto-Follow",
"autoFollowEntityTypeList": "Global Auto-Follow",
"signature": "Email Signature",
"dashboardTabList": "Tab List",
"defaultReminders": "Default Reminders",
"theme": "Theme",
"useCustomTabList": "Custom Tab List",
"tabList": "Tab List",
"emailReplyToAllByDefault": "Email Reply to All by Default",
"emailReplyToAllByDefault": "Email Reply to all by default",
"dashboardLayout": "Dashboard Layout",
"emailReplyForceHtml": "Email Reply in HTML",
"doNotFillAssignedUserIfNotRequired": "Do not fill Assigned User if not required",
"followEntityOnStreamPost": "Auto-follow entity after posting in Stream"
"doNotFillAssignedUserIfNotRequired": "Do not pre-fill assigned user on record creation",
"followEntityOnStreamPost": "Auto-follow record after posting in Stream",
"followCreatedEntities": "Auto-follow created records",
"followCreatedEntityTypeList": "Auto-follow created records of specific entity types"
},
"links": {
},
@@ -50,6 +52,9 @@
"Locale": "Locale"
},
"tooltips": {
"autoFollowEntityTypeList": "User will automatically follow all new records of the selected entity types, will see information in the stream and receive notifications."
"autoFollowEntityTypeList": "Automatically follow ALL new records (created by any user) of the selected entity types. To be able to see information in the stream and receive notifications about all records in the system.",
"doNotFillAssignedUserIfNotRequired": "When create record assigned user won't be filled with own user unless the field is required.",
"followCreatedEntities": "When create new records they will be automatically followed even if assigned to another user.",
"followCreatedEntityTypeList": "When create new records of selected entity types they will be followed automatically even if assigned to another user."
}
}
@@ -63,7 +63,7 @@
"streamEmailNotificationsEntityList": "Stream email notifications scopes",
"b2cMode": "B2C Mode",
"avatarsDisabled": "Disable Avatars",
"followCreatedEntities": "Follow Created Entities",
"followCreatedEntities": "Follow created records",
"displayListViewRecordCount": "Display Total Count (on List View)",
"theme": "Theme",
"userThemesDisabled": "Disable User Themes",
@@ -59,6 +59,18 @@
{
"name": "followEntityOnStreamPost"
}
],
[
false,
{
"name": "followCreatedEntities"
}
],
[
false,
{
"name": "followCreatedEntityTypeList"
}
]
]
},
@@ -60,7 +60,10 @@
"autoFollowEntityTypeList": false,
"emailReplyForceHtml": false,
"emailReplyToAllByDefault": false,
"signature": false
"signature": false,
"followCreatedEntities": false,
"followEntityOnStreamPost": false,
"doNotFillAssignedUserIfNotRequired": false
},
"Call": {
"reminders": false
@@ -150,11 +150,22 @@
"notStorable": true
},
"doNotFillAssignedUserIfNotRequired": {
"type": "bool"
"type": "bool",
"tooltip": true
},
"followEntityOnStreamPost": {
"type": "bool",
"default": true
},
"followCreatedEntities": {
"type": "bool",
"tooltip": true
},
"followCreatedEntityTypeList": {
"type": "multiEnum",
"view": "views/preferences/fields/auto-follow-entity-type-list",
"translation": "Global.scopeNamesPlural",
"tooltip": true
}
}
}
@@ -100,6 +100,8 @@ Espo.define('views/preferences/record/edit', 'views/record/edit', function (Dep)
this.hideField('dashboardLayout');
}
this.controlFollowCreatedEntityListVisibility();
this.listenTo(this.model, 'change:followCreatedEntities', this.controlFollowCreatedEntityListVisibility);
var hideNotificationPanel = true;
if (!this.getConfig().get('assignmentEmailNotifications') || this.model.get('isPortalUser')) {
@@ -153,6 +155,14 @@ Espo.define('views/preferences/record/edit', 'views/record/edit', function (Dep)
}, this);
},
controlFollowCreatedEntityListVisibility: function () {
if (!this.model.get('followCreatedEntities')) {
this.showField('followCreatedEntityTypeList');
} else {
this.hideField('followCreatedEntityTypeList');
}
},
actionReset: function () {
this.confirm(this.translate('resetPreferencesConfirmation', 'messages'), function () {
$.ajax({