Navigation

    Kopano
    • Register
    • Login
    • Search
    • Categories
    • Get Official Kopano Support
    • Recent
    Statement regarding the closure of the Kopano community forum and the end of the community edition

    Plugin development, attach to send event

    Plugins for Kopano WebApp
    2
    5
    781
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Bahnstreik
      Bahnstreik last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • mvasava
        mvasava last edited by

        @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) { }

        1 Reply Last reply Reply Quote 0
        • Bahnstreik
          Bahnstreik last edited by

          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
          },
          ...
          }
          
          1 Reply Last reply Reply Quote 0
          • mvasava
            mvasava last edited by mvasava

            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.
            1 Reply Last reply Reply Quote 1
            • Bahnstreik
              Bahnstreik last edited by

              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…

              1 Reply Last reply Reply Quote 0
              • First post
                Last post