Results 1 to 6 of 6

Thread: Action Menu button: get message IDs with "zero" selection?

  1. #1
    Join Date
    Apr 2008
    Location
    Vancouver, BC
    Posts
    54
    Rep Power
    7

    Default Action Menu button: get message IDs with "zero" selection?

    I'm adding a button to the action/context menu in the Mail list view. I have no problems getting the message ID in the button handler when the message is either visible in the viewing pane (e.g. has been clicked on), or is checked. When I right-click on a message that isn't visible, I can't get the ID. However, when I select one of the built-in actions, like Mark as Unread, that action is able to get the message IDs.

    That was probably a bit complicated to follow, so here's a video of what I'm talking about: https://www.youtube.com/watch?v=ozxw...ature=youtu.be

    My code to add the button:
    Code:
    ca_sfu_archiveMessage.prototype.onActionMenuInitialized = function(controller, actionMenu) {
    
        // enable the button for multi-selections and zero-selections(?)
        controller.operationsToEnableOnMultiSelection.push('ARCHIVE_MESSAGE');
        controller.operationsToEnableOnZeroSelection.push('ARCHIVE_MESSAGE');
    
        this.addArchiveButton('actionMenu', actionMenu, controller);
    };
    
    ca_sfu_archiveMessage.prototype.addArchiveButton = function(where, target, controller) {
        var offsets = {
            toolbar: 1,
            actionMenu: 1
        }
        , index = -1
        , buttonArgs, button;
        for (var i=0; i < target.opList.length; i++) {
            if (target.opList[i] === ZmOperation.SPAM) {
                index = i + offsets[where];
                break;
            }
        };
    
        buttonArgs = {
            text: 'Archive',
            tooltip: 'Archive Message',
            index: index,
            image: 'Warning',
            enabled: false
        };
    
        button = target.createOp('ARCHIVE_MESSAGE', buttonArgs);
        var listener = new AjxListener(this, this.buttonHandler, controller);
        button.addSelectionListener(listener);
    };
    
    ca_sfu_archiveMessage.prototype.buttonHandler = function(controller, ev) {
        var dlg = appCtxt.getMsgDialog();
        dlg.setTitle('Get Message Test');
        var msg = controller.getMsg();
        var content = msg ? "Selected Message ID: " + msg.id : "No Message Selected";
        dlg.setContent(content);
        dlg.popup();
    };
    I've tried using the same methods that ZmMailListController.prototype._redirectListener and ZmMailListController.prototype._markUnreadListener use to get the IDs, since they work with in a "zero-selection" scenario, but haven't had any luck.

    Anyone have an idea as to how I can get the ID in this situation? It's not a big deal for this particular zimlet, but I would like to figure it out since the built-in actions seem to support it.
    Graham Ballantyne
    Simon Fraser University

  2. #2
    Join Date
    Jul 2013
    Posts
    105
    Rep Power
    2

    Default

    I saw your tweet, Graham. I'll see if I can draw some more attention to your post.

  3. #3
    Join Date
    Sep 2012
    Location
    jhoncarter2030@gmail.com
    Posts
    61
    Rep Power
    3

    Default

    Hey,
    While no email is selected, you would need to use "appCtxt.getCurrentController().getDnDSelectio n()" method in your handler. It will get an Object of ZmMailMsg OR ZmConv.
    jhoncarter2030@gmail.com

    Zimbra Customization, Administration, Developments.

  4. #4
    Join Date
    Apr 2008
    Location
    Vancouver, BC
    Posts
    54
    Rep Power
    7

    Default

    Quote Originally Posted by jhon View Post
    Hey,
    While no email is selected, you would need to use "appCtxt.getCurrentController().getDnDSelectio n()" method in your handler. It will get an Object of ZmMailMsg OR ZmConv.
    Thanks for the reply. I'm just getting back to this project.

    The action menu button handler receives the current controller, which is either ZmTradController nor ZmConvListController, depending on what the view the user is using. Neither of those controllers have a getDnDSelection method on them. The only place I can see it being defined is on DwtListView, line 702 , and the only relevant place it is being used is in ZmListController, line 588.
    Graham Ballantyne
    Simon Fraser University

  5. #5
    Join Date
    Apr 2008
    Location
    Vancouver, BC
    Posts
    54
    Rep Power
    7

    Default

    Ah, got it! Inside the button handler: controller._listView[controller._currentViewId].getDnDSelection() returns the selected messages, even without a "real" selection. It's very similar to how ZmMailListController.prototype._markUnreadListener gets the selection (which works even if a message isn't really selected). In that case, it calls .getSelected(), which works, but getSelected() doesn't work when called by the zimlet (it returns an empty array).

    Thanks for the pointer.
    Graham Ballantyne
    Simon Fraser University

  6. #6
    Join Date
    Sep 2012
    Location
    jhoncarter2030@gmail.com
    Posts
    61
    Rep Power
    3

    Default

    You're welcome my friend
    jhoncarter2030@gmail.com

    Zimbra Customization, Administration, Developments.

Similar Threads

  1. How to add "Register" or "Sign Up" button on Login page
    By watashi in forum Administrators
    Replies: 2
    Last Post: 03-24-2013, 08:40 AM
  2. How to add "Register" or "Sign Up" button on Login page
    By watashi in forum General Questions
    Replies: 1
    Last Post: 03-24-2013, 08:19 AM
  3. Replies: 11
    Last Post: 03-21-2011, 09:36 PM
  4. Replies: 2
    Last Post: 12-19-2009, 09:34 AM
  5. Replies: 8
    Last Post: 08-08-2007, 12:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •