Added some helpful comments to the xml and JS.

This commit is contained in:
Marc Durepos 2023-06-29 22:24:28 -04:00
parent f7de7d31af
commit e17f32dfaf
3 changed files with 6 additions and 2 deletions

View file

@ -5,16 +5,19 @@ import ListView from 'web.ListView';
const viewRegistry = require('web.view_registry');
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',
events: _.extend({}, ListController.prototype.events, {
'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 () {
this._rpc({
model: 'mail.mailcow.mailbox',
method: 'sync_mailboxes',
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);

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<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">
<button type="button"
class="btn btn-primary ml4 o_button_sync_mailboxes"

View file

@ -4,7 +4,7 @@
<field name="name">mailcow.mailbox.view.tree</field>
<field name="model">mail.mailcow.mailbox</field>
<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="name"/>
<field name="local_part"/>