email filter mark as read

This commit is contained in:
Yuri Kuznetsov
2022-10-24 11:34:26 +03:00
parent 5a29830202
commit acfcc65aee
12 changed files with 67 additions and 14 deletions

View File

@@ -213,6 +213,10 @@ class Email implements AssignmentNotificator
continue;
}
if ($entity->getLinkMultipleColumn('users', EmailEntity::USERS_COLUMN_IS_READ, $userId)) {
continue;
}
if (!$this->userChecker->checkAssignment(EmailEntity::ENTITY_TYPE, $userId)) {
continue;
}

View File

@@ -69,6 +69,7 @@ class EmailFilterManager
[
EmailFilter::ACTION_SKIP,
EmailFilter::ACTION_MOVE_TO_FOLDER,
EmailFilter::ACTION_NONE,
]
)
)

View File

@@ -29,13 +29,16 @@
namespace Espo\Entities;
class EmailFilter extends \Espo\Core\ORM\Entity
use Espo\Core\ORM\Entity;
class EmailFilter extends Entity
{
public const ENTITY_TYPE = 'EmailFilter';
public const ACTION_SKIP = 'Skip';
public const ACTION_MOVE_TO_FOLDER = 'Move to Folder';
public const ACTION_MOVE_TO_GROUP_FOLDER = 'Move to Group Folder';
public const ACTION_NONE = 'None';
/**
* @return self::ACTION_*|null
@@ -55,6 +58,11 @@ class EmailFilter extends \Espo\Core\ORM\Entity
return $this->get('groupEmailFolderId');
}
public function markAsRead(): bool
{
return (bool) $this->get('markAsRead');
}
public function isGlobal(): bool
{
return (bool) $this->get('isGlobal');

View File

@@ -45,7 +45,7 @@ use Espo\Repositories\EmailAddress as EmailAddressRepository;
use Espo\Entities\EmailAddress;
/**
* @extends Database<\Espo\Entities\Email>
* @extends Database<EmailEntity>
*/
class Email extends Database implements
@@ -444,15 +444,20 @@ class Email extends Database implements
$action = $filter->getAction();
if ($action === EmailFilter::ACTION_SKIP) {
$entity->setLinkMultipleColumn('users', 'inTrash', $userId, true);
$entity->setLinkMultipleColumn('users', EmailEntity::USERS_COLUMN_IN_TRASH, $userId, true);
}
else if ($action === EmailFilter::ACTION_MOVE_TO_FOLDER) {
$folderId = $filter->getEmailFolderId();
if ($folderId) {
$entity->setLinkMultipleColumn('users', 'folderId', $userId, $folderId);
$entity
->setLinkMultipleColumn('users', EmailEntity::USERS_COLUMN_FOLDER_ID, $userId, $folderId);
}
}
if ($filter->markAsRead()) {
$entity->setLinkMultipleColumn('users', EmailEntity::USERS_COLUMN_IS_READ, $userId, true);
}
}
}
}

View File

@@ -7,7 +7,8 @@
"action": "Action",
"isGlobal": "Is Global",
"emailFolder": "Folder",
"groupEmailFolder": "Group Email Folder"
"groupEmailFolder": "Group Email Folder",
"markAsRead": "Mark as Read"
},
"links": {
"emailFolder": "Folder",
@@ -19,6 +20,7 @@
},
"options": {
"action": {
"None": "None",
"Skip": "Ignore",
"Move to Folder": "Put in Folder",
"Move to Group Folder": "Put in Group Folder"

View File

@@ -16,6 +16,9 @@
[
false, {"name": "groupEmailFolder"}
],
[
false, {"name": "markAsRead"}
],
[
{"name": "subject", "fullWidth": true}
],

View File

@@ -16,6 +16,9 @@
[
{"name": "groupEmailFolder"}
],
[
{"name": "markAsRead"}
],
[
{"name": "from"}
],

View File

@@ -1,6 +1,7 @@
[
"parent",
"action",
"markAsRead",
"createdBy",
"createdAt"
]

View File

@@ -7,6 +7,7 @@
"recordViews": {
"list": "views/email-filter/record/list"
},
"inlineEditDisabled": true,
"searchPanelDisabled": false,
"menu": {
"list": {
@@ -82,6 +83,17 @@
}
]
}
},
"markAsRead": {
"visible": {
"conditionGroup": [
{
"attribute": "parentType",
"type": "equals",
"value": "User"
}
]
}
}
},
"options": {
@@ -107,7 +119,8 @@
],
"optionList": [
"Skip",
"Move to Folder"
"Move to Folder",
"None"
]
},
{

View File

@@ -44,7 +44,8 @@
"options": [
"Skip",
"Move to Folder",
"Move to Group Folder"
"Move to Group Folder",
"None"
],
"view": "views/email-filter/fields/action"
},
@@ -55,6 +56,9 @@
"groupEmailFolder": {
"type": "link"
},
"markAsRead": {
"type": "bool"
},
"createdAt": {
"type": "datetime",
"readOnly": true

View File

@@ -93,6 +93,7 @@ class EmailFilter extends Record
!in_array(
$entity->getAction(),
[
EmailFilterEntity::ACTION_NONE,
EmailFilterEntity::ACTION_SKIP,
EmailFilterEntity::ACTION_MOVE_TO_FOLDER,
]

View File

@@ -56,8 +56,7 @@ define('handlers/email-filter', ['dynamic-handler'], (Dep) => {
}
else if (
this.model.get('parentType') &&
!this.recordView.options.duplicateSourceId &&
this.model.get('parentType') !== 'User'
!this.recordView.options.duplicateSourceId
) {
this.recordView.setFieldReadOnly('parent');
this.recordView.setFieldReadOnly('isGlobal');
@@ -69,11 +68,15 @@ define('handlers/email-filter', ['dynamic-handler'], (Dep) => {
}
if (value) {
this.model.set('action', 'Skip');
this.model.set('parentType', null);
this.model.set('parentId', null);
this.model.set('emailFolderId', null);
this.model.set('groupEmailFolderId', null);
this.model.set({
action: 'Skip',
parentName: null,
parentType: null,
parentId: null,
emailFolderId: null,
groupEmailFolderId: null,
markAsRead: false,
});
}
});
@@ -84,10 +87,15 @@ define('handlers/email-filter', ['dynamic-handler'], (Dep) => {
// Avoiding side effects.
setTimeout(() => {
if (value !== 'User') {
this.model.set('markAsRead', false);
}
if (value === 'EmailAccount') {
this.model.set('action', 'Skip');
this.model.set('emailFolderId', null);
this.model.set('groupEmailFolderId', null);
this.model.set('markAsRead', false);
return;
}