diff --git a/application/Espo/Controllers/Email.php b/application/Espo/Controllers/Email.php
index 1dc8b039a9..9ab1982746 100644
--- a/application/Espo/Controllers/Email.php
+++ b/application/Espo/Controllers/Email.php
@@ -75,5 +75,13 @@ class Email extends \Espo\Core\Controllers\Record
return $this->getRecordService()->markAsReadByIds($ids);
}
+
+ public function actionMarkAllAsRead($params, $data, $request)
+ {
+ if (!$request->isPost()) {
+ throw new BadRequest();
+ }
+ return $this->getRecordService()->markAllAsRead();
+ }
}
diff --git a/application/Espo/Resources/i18n/en_US/Email.json b/application/Espo/Resources/i18n/en_US/Email.json
index b31f8073d4..1793001b05 100644
--- a/application/Espo/Resources/i18n/en_US/Email.json
+++ b/application/Espo/Resources/i18n/en_US/Email.json
@@ -43,7 +43,8 @@
"Email Address": "Email Address",
"Mark Read": "Mark Read",
"Sending...": "Sending...",
- "Save Draft": "Save Draft"
+ "Save Draft": "Save Draft",
+ "Mark all as read": "Mark all as read"
},
"messages": {
"noSmtpSetup": "No SMTP setup. {link}.",
diff --git a/application/Espo/Services/Email.php b/application/Espo/Services/Email.php
index 5e58592d14..6ff8c4bd28 100644
--- a/application/Espo/Services/Email.php
+++ b/application/Espo/Services/Email.php
@@ -234,6 +234,19 @@ class Email extends Record
return true;
}
+ public function markAllAsRead()
+ {
+ $pdo = $this->getEntityManager()->getPDO();
+ $sql = "
+ UPDATE email_user SET is_read = 1
+ WHERE
+ deleted = 0 AND
+ user_id = " . $pdo->quote($this->getUser()->id) . "
+ ";
+ $pdo->query($sql);
+ return true;
+ }
+
public function markAsRead($id)
{
diff --git a/frontend/client/res/templates/record/list-expanded.tpl b/frontend/client/res/templates/record/list-expanded.tpl
index 7b3e52111a..f1f9c3e2ca 100644
--- a/frontend/client/res/templates/record/list-expanded.tpl
+++ b/frontend/client/res/templates/record/list-expanded.tpl
@@ -21,6 +21,10 @@
{{/if}}
{{/if}}
+
+ {{#each buttonList}}
+ {{button name scope=../../scope label=label style=style}}
+ {{/each}}
{{/if}}
diff --git a/frontend/client/res/templates/record/list.tpl b/frontend/client/res/templates/record/list.tpl
index 62c16fd9c1..fd437ff774 100644
--- a/frontend/client/res/templates/record/list.tpl
+++ b/frontend/client/res/templates/record/list.tpl
@@ -23,6 +23,10 @@
{{/if}}
{{/if}}
+
+ {{#each buttonList}}
+ {{button name scope=../../scope label=label style=style}}
+ {{/each}}
{{/if}}
diff --git a/frontend/client/src/view-helper.js b/frontend/client/src/view-helper.js
index 4d66dc9c0b..017efd86d2 100644
--- a/frontend/client/src/view-helper.js
+++ b/frontend/client/src/view-helper.js
@@ -172,7 +172,7 @@
var style = options.hash.style || 'default';
var scope = options.hash.scope || null;
var label = options.hash.label || name;
- return new Handlebars.SafeString('');
+ return new Handlebars.SafeString('');
});
Handlebars.registerHelper('hyphen', function (string) {
diff --git a/frontend/client/src/views/email/record/list.js b/frontend/client/src/views/email/record/list.js
index 0d13ae6e57..72f481f7fc 100644
--- a/frontend/client/src/views/email/record/list.js
+++ b/frontend/client/src/views/email/record/list.js
@@ -25,6 +25,14 @@ Espo.define('Views.Email.Record.List', 'Views.Record.List', function (Dep) {
massActionList: ['remove'],
+ buttonList: [
+ {
+ name: 'markAllAsRead',
+ label: 'Mark all as read',
+ style: 'default'
+ }
+ ],
+
setup: function () {
Dep.prototype.setup.call(this);
@@ -51,6 +59,16 @@ Espo.define('Views.Email.Record.List', 'Views.Record.List', function (Dep) {
}, this);
},
+ actionMarkAllAsRead: function () {
+ $.ajax({
+ url: 'Email/action/markAllAsRead',
+ type: 'POST'
+ });
+ this.collection.forEach(function (model) {
+ model.set('isRead', true);
+ }, this);
+ }
+
});
});
diff --git a/frontend/client/src/views/modals/select-records.js b/frontend/client/src/views/modals/select-records.js
index fc83b45d62..905af5545a 100644
--- a/frontend/client/src/views/modals/select-records.js
+++ b/frontend/client/src/views/modals/select-records.js
@@ -147,7 +147,8 @@ Espo.define('Views.Modals.SelectRecords', 'Views.Modal', function (Dep) {
rowActionsView: false,
type: 'listSmall',
searchManager: searchManager,
- checkAllResultDisabled: !this.massRelateEnabled
+ checkAllResultDisabled: !this.massRelateEnabled,
+ disableButtons: true
}, function (list) {
list.once('select', function (model) {
this.trigger('select', model);
diff --git a/frontend/client/src/views/record/list.js b/frontend/client/src/views/record/list.js
index ebeec54a94..422bee6be1 100644
--- a/frontend/client/src/views/record/list.js
+++ b/frontend/client/src/views/record/list.js
@@ -56,6 +56,8 @@ Espo.define('Views.Record.List', 'View', function (Dep) {
rowActionsColumnWidth: 25,
+ buttonList: [],
+
events: {
'click a.link': function (e) {
if (!this.scope || this.selectable) {
@@ -211,13 +213,13 @@ Espo.define('Views.Record.List', 'View', function (Dep) {
showMoreEnabled: this.showMore,
showCount: this.showCount && this.collection.total > 0,
moreCount: this.collection.total - this.collection.length,
-
checkboxes: this.checkboxes,
massActionList: this.massActionList,
rows: this.rows,
- topBar: paginationTop || this.checkboxes,
+ topBar: paginationTop || this.checkboxes || (this.buttonList.length && !this.disableButtons),
bottomBar: paginationBottom,
- checkAllResultDisabled: this.checkAllResultDisabled
+ checkAllResultDisabled: this.checkAllResultDisabled,
+ buttonList: this.buttonList
};
},
@@ -231,6 +233,8 @@ Espo.define('Views.Record.List', 'View', function (Dep) {
this.rowActionsView = _.isUndefined(this.options.rowActionsView) ? this.rowActionsView : this.options.rowActionsView;
this.showMore = _.isUndefined(this.options.showMore) ? this.showMore : this.options.showMore;
+ this.disableButtons = this.options.disableButtons || false;
+
if ('checkAllResultDisabled' in this.options) {
this.checkAllResultDisabled = this.options.checkAllResultDisabled;
}
@@ -455,6 +459,7 @@ Espo.define('Views.Record.List', 'View', function (Dep) {
this.scope = this.collection.name || null;
this.events = Espo.Utils.clone(this.events);
this.massActionList = Espo.Utils.clone(this.massActionList);
+ this.buttonList = Espo.Utils.clone(this.buttonList);
var checkAllResultMassActionList = [];
this.checkAllResultMassActionList.forEach(function (item) {
@@ -464,8 +469,6 @@ Espo.define('Views.Record.List', 'View', function (Dep) {
}, this);
this.checkAllResultMassActionList = checkAllResultMassActionList;
- Espo.Utils.clone(this.massActionList);
-
if (this.getConfig().get('disableExport') && !this.getUser().get('isAdmin')) {
this.removeMassAction('export');
}
diff --git a/frontend/client/src/views/record/panels/relationship.js b/frontend/client/src/views/record/panels/relationship.js
index 7d4a85c776..5a0570e4e8 100644
--- a/frontend/client/src/views/record/panels/relationship.js
+++ b/frontend/client/src/views/record/panels/relationship.js
@@ -113,6 +113,7 @@ Espo.define('Views.Record.Panels.Relationship', ['Views.Record.Panels.Bottom', '
listLayout: listLayout,
checkboxes: false,
rowActionsView: this.defs.readOnly ? false : (this.defs.rowActionsView || this.rowActionsView),
+ disableButtons: true,
el: this.options.el + ' .list-container',
}, function (view) {
view.render();