Plugin development, attach to send event
-
Hey there,
I’m about to create a plugin to check whether the mail has attachments.
If so, I want to check the names of the attachments for a given customer number.To start with that, I need to attach to the send event of the mail.
I’ve studied the docu here: https://documentation.kopano.io/webapp_developers_javascript_api/
but I couldn’t find the description for the send event. (maybe I am just blind)Is there a way to attach to that event and if so, can you give me an example how the eventhandler could look like?
-
@Bahnstreik said in Plugin development, attach to send event:
ut I couldn’t find the description for the send event. (maybe I am just blin
Hii,
You can attach this event https://documentation.kopano.io/webapp_developers_javascript_api/#!/api/Zarafa.core.ui.MessageContentPanel-event-sendrecord (which will be triggered when message is sent).attached handler will look like below,
onSendRecord : function(msgContentPanel, sentRecord) { } -
Hey,
thanks for responding.
That helped a bit, but I can’t figure out, how to register that event in the initPlugin function.
my code looks something like that:Zarafa.plugins.MyPlugin.PluginKopanoMailChecker = Ext.extend(Zarafa.core.Plugin, { initPlugin: function () { Zarafa.plugins.MyPlugin.PluginMyPlugin.superclass.initPlugin.apply(this, arguments); //I want to register the event here, but I don't know how to get access to MessageContentPanel of the mail. "MessageContentPanel".on("sendrecord", this.onSendRecord) }, onSendRecord: function(panel, record){ //here we go }, ... }
-
Hii,
There is no direct way to get reference of MessageContentPanel class.
New instance of MessageContentPanel will be created on every new mail creation.
But for your plugin, if you want to add a button in MailCreateToolbar then on click handler or on after render of that button you can get reference to MessageContentPanel and attach ‘sendrecord’ or ‘beforesendrecord’ event.And if you intend to implement above approach then you can do following,
-
in initPlugin function :
this.registerInsertionPoint(‘context.mail.mailcreatecontentpanel.toolbar.options’, this.showPluginButton, this); -
in showPluginButton function :
return { xtype : 'button', text : _('Button name', 'plugin_mailchecker'), listeners : { afterrender : function(btn) { var parentToolbar; if (button.ownerCt instanceof Zarafa.core.ui.Toolbar) { parentToolbar = button.ownerCt; } else { // This is the case where button belongs to the "more" menu. // Get the dialog from menu. var moreMenu = button.parentMenu; parentToolbar = moreMenu.ownerCt.ownerCt; } var MessageContentPanel = parentToolbar.dialog; MessageContentPanel.on("sendrecord", this.onSendRecord); }, scope : this }, // do whatever actions needs to be performed on click. handler : this.onClickButton, scope : this };
- in onSendRecord function you will get mailcreatecontentpanel and mail record.
-
-
Hey,
that is exactly what I was looking for, works perfectly for me.
Even though I think it’s kinda weird to create a useless buttons to get access of the MailContentPanel and the send-button…