From df9633503b9215e5fb3eda32401f2eac123c6283 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Sat, 30 Mar 2024 10:07:38 +0200 Subject: [PATCH] email account filters --- .../layouts/EmailAccount/filters.json | 3 + .../metadata/clientDefs/EmailAccount.json | 1 - client/src/views/email-account/list.js | 66 ++++++++++++------- 3 files changed, 44 insertions(+), 26 deletions(-) create mode 100644 application/Espo/Resources/layouts/EmailAccount/filters.json diff --git a/application/Espo/Resources/layouts/EmailAccount/filters.json b/application/Espo/Resources/layouts/EmailAccount/filters.json new file mode 100644 index 0000000000..4c3e12df8c --- /dev/null +++ b/application/Espo/Resources/layouts/EmailAccount/filters.json @@ -0,0 +1,3 @@ +[ + "assignedUser" +] diff --git a/application/Espo/Resources/metadata/clientDefs/EmailAccount.json b/application/Espo/Resources/metadata/clientDefs/EmailAccount.json index 677f99fb49..91f6b477f2 100644 --- a/application/Espo/Resources/metadata/clientDefs/EmailAccount.json +++ b/application/Espo/Resources/metadata/clientDefs/EmailAccount.json @@ -9,7 +9,6 @@ "list": "views/email-account/list" }, "inlineEditDisabled": true, - "searchPanelDisabled": true, "formDependency": { "storeSentEmails": { "map": { diff --git a/client/src/views/email-account/list.js b/client/src/views/email-account/list.js index b9f2af20b4..057b22930b 100644 --- a/client/src/views/email-account/list.js +++ b/client/src/views/email-account/list.js @@ -26,35 +26,51 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -define('views/email-account/list', ['views/list'], function (Dep) { +import ListView from 'views/list'; - return Dep.extend({ +class EmailAccountListView extends ListView { - keepCurrentRootUrl: true, + keepCurrentRootUrl = true - setup: function () { - Dep.prototype.setup.call(this); + setup() { + this.options.params = this.options.params || {}; + const params = this.options.params || {}; - this.options.params = this.options.params || {}; + this.userId = params.userId; - var params = this.options.params || {}; - if (params.userId) { - this.collection.where = [{ - type: 'equals', - field: 'assignedUserId', - value: params.userId - }]; - } - }, + super.setup(); - getCreateAttributes: function () { - var attributes = {}; - if (this.options.params.userId) { - attributes.assignedUserId = this.options.params.userId; - attributes.assignedUserName = this.options.params.userName || this.options.params.userId; - } - return attributes; - }, + if (this.userId) { + this.collection.where = [{ + type: 'equals', + field: 'assignedUserId', + value: params.userId, + }]; + } + } - }); -}); + setupSearchPanel() { + if (this.userId || !this.getUser().isAdmin()) { + this.searchPanel = false; + + this.searchManager.reset(); + + return; + } + + super.setupSearchPanel(); + } + + getCreateAttributes() { + const attributes = {}; + + if (this.options.params.userId) { + attributes.assignedUserId = this.options.params.userId; + attributes.assignedUserName = this.options.params.userName || this.options.params.userId; + } + + return attributes; + } +} + +export default EmailAccountListView;