list buttons
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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}.",
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{#each buttonList}}
|
||||
{{button name scope=../../scope label=label style=style}}
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{#each buttonList}}
|
||||
{{button name scope=../../scope label=label style=style}}
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
|
||||
@@ -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('<button class="btn btn-'+style+'" data-action="'+name+'" type="button">'+self.language.translate(label, 'labels', scope)+'</button>');
|
||||
return new Handlebars.SafeString('<button class="btn btn-'+style+' action" data-action="'+name+'" type="button">'+self.language.translate(label, 'labels', scope)+'</button>');
|
||||
});
|
||||
|
||||
Handlebars.registerHelper('hyphen', function (string) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user