Added some helpful comments to the xml and JS.
This commit is contained in:
parent
f7de7d31af
commit
e17f32dfaf
3 changed files with 6 additions and 2 deletions
|
|
@ -5,16 +5,19 @@ import ListView from 'web.ListView';
|
||||||
const viewRegistry = require('web.view_registry');
|
const viewRegistry = require('web.view_registry');
|
||||||
|
|
||||||
const MailboxesListController = ListController.extend({
|
const MailboxesListController = ListController.extend({
|
||||||
|
// buttons_template must match the t-name on the template for the button (static xml)
|
||||||
buttons_template: 'mail.mailcow_mailbox_list_view_buttons',
|
buttons_template: 'mail.mailcow_mailbox_list_view_buttons',
|
||||||
events: _.extend({}, ListController.prototype.events, {
|
events: _.extend({}, ListController.prototype.events, {
|
||||||
'click .o_button_sync_mailboxes': '_onSyncMailboxes',
|
'click .o_button_sync_mailboxes': '_onSyncMailboxes',
|
||||||
}),
|
}),
|
||||||
|
// This may need to be async function() if there needs to be an await this._rpc({ ... }); call to not reload early
|
||||||
_onSyncMailboxes: function () {
|
_onSyncMailboxes: function () {
|
||||||
this._rpc({
|
this._rpc({
|
||||||
model: 'mail.mailcow.mailbox',
|
model: 'mail.mailcow.mailbox',
|
||||||
method: 'sync_mailboxes',
|
method: 'sync_mailboxes',
|
||||||
args: [],
|
args: [],
|
||||||
});
|
});
|
||||||
|
// Couldn't test this for real, but it runs the action. May need a this.reload()
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -24,4 +27,5 @@ const MailboxesListView = ListView.extend({
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// key must match with the js_class attribute of the tree view you want to modify
|
||||||
viewRegistry.add('mail_mailcow_mailbox_tree', MailboxesListView);
|
viewRegistry.add('mail_mailcow_mailbox_tree', MailboxesListView);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<templates>
|
<templates>
|
||||||
<t t-extend="ListView.buttons" t-name="mail.mailcow_mailbox_list_view_buttons">
|
<t t-extend="ListView.buttons" t-name="mail.mailcow_mailbox_list_view_buttons"> <!-- t-name must match with js controller button template -->
|
||||||
<t t-jquery="button.o_list_button_add" t-operation="after">
|
<t t-jquery="button.o_list_button_add" t-operation="after">
|
||||||
<button type="button"
|
<button type="button"
|
||||||
class="btn btn-primary ml4 o_button_sync_mailboxes"
|
class="btn btn-primary ml4 o_button_sync_mailboxes"
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
<field name="name">mailcow.mailbox.view.tree</field>
|
<field name="name">mailcow.mailbox.view.tree</field>
|
||||||
<field name="model">mail.mailcow.mailbox</field>
|
<field name="model">mail.mailcow.mailbox</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<tree string="Mailbox" decoration-info="active == False" js_class="mail_mailcow_mailbox_tree">
|
<tree string="Mailbox" decoration-info="active == False" js_class="mail_mailcow_mailbox_tree"> <!-- js_class must match the name added to the viewRegistry in js -->
|
||||||
<field name="active"/>
|
<field name="active"/>
|
||||||
<field name="name"/>
|
<field name="name"/>
|
||||||
<field name="local_part"/>
|
<field name="local_part"/>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue