Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Using ZmTask as DragSource

  1. #1
    skid is offline Member
    Join Date
    Oct 2009
    Posts
    14
    Rep Power
    5

    Question Using ZmTask as DragSource

    Hi all,

    I'm just trying to figure out how to properly use a zmTask object as a dragsource. So far, everything worked fine for contacts and appointments but tasks are giving me a headache.

    This is what I did:
    1. Added <dragSource type="ZmTask"/> to my zimlet xml, just the same way I did with contacts and appointments. This part actually works - after adding this line I'm able to drag a task on my zimlet.
    2. I tried to add another object type check into my prototype.doDrop function of the main JavaScript file. Like this: if(obj.TYPE == "ZmTask") {...} However, this doesn't work while it works perfectly for contacts and appointments. So I checked what the value of obj.TYPE actually is when I drag a task on my zimlet. Unfortunately it says "undefined".
    3. Still I tried to move on and get some information out of the object, e.g. obj.startDate, obj.subject and so on. None of these work.


    Does anyone know what the problem might be? Did anyone already work with tasks or maybe experience the same?

    Any help would be greatly appreciated!

  2. #2
    sposetti is offline Former Zimbran
    Join Date
    Nov 2009
    Posts
    105
    Rep Power
    5

    Default

    Specifying the drag source type to be ZmTask so tasks can be dropped on the panel zimlet is right. But once in doDrop, a ZmTask comes through in an array, not as a single object. So here's a way to check for type == task in doDrop(). We check TYPE == null, which tells us we have something other than an object with a TYPE property, so we dig further to get array element [0], on which we check for "type" property. And if we have that, and it equals "TASK", we have a task. Subject can be retrieved using the arrayObj[0].name property.

    /**
    * This method gets called by the Zimlet framework when an item or items are dropped on the panel.
    *
    * @param obj the dropped object
    */
    com_zimbra_paneldragsourceHandlerObject.prototype. doDrop =
    function(obj) {

    var type = obj.TYPE;
    if (type == null) {
    // might be an array, get the first element

    var arrayObj = obj[0];
    if (arrayObj.type == "TASK") {
    // we have a ZmTask

    var taskName = arrayObj.name;
    // do something
    }

    }
    };
    Last edited by sposetti; 12-10-2009 at 12:07 PM.

  3. #3
    skid is offline Member
    Join Date
    Oct 2009
    Posts
    14
    Rep Power
    5

    Default

    Awesome, this is exactly what I needed. Thanks a lot for your help, it is really appreciated! I almost gave up hope on this one.

  4. #4
    skid is offline Member
    Join Date
    Oct 2009
    Posts
    14
    Rep Power
    5

    Default

    One additional question though. I managed to access all fields of the task through the object, except for the notes.
    Does anyone how to do this? I just checked through ZmTask.js but am unable to find the corresponding field.

  5. #5
    sposetti is offline Former Zimbran
    Join Date
    Nov 2009
    Posts
    105
    Rep Power
    5

    Default

    ZmTask extends ZmCalItem (and so forth) to form the following inheritance chain:

    ZmItem >> ZmCalBaseItem >> ZmCalItem >> ZmTask

    So you should also check in the parent class(es) for the methods/properties you are looking for.

  6. #6
    skid is offline Member
    Join Date
    Oct 2009
    Posts
    14
    Rep Power
    5

    Question

    Sorry for bringing this topic up again. After I (unsuccessfully) tried to find the missing properties I ended up putting this problem on hold to move on to other Zimlet work.

    However, now I'm back at this point and I still don't get it. Both ZmAppt and ZmTask follow the same inheritance chain. Still, the "notes" property only works for ZmAppt (it's "undefined" for ZmTask and I didn't find a corresponding property for it).

    Also, I'm trying to find the ZmAppt properties for [repeat] and [privacy]. For [privacy] there actually is a property defined in ZmAppt (this.privacy) but reading it results in "undefined". For [repeat] I just found the isRecurring property which works but it's just a boolean while I'm looking for a string (telling me the exact reoccurrence like "every day", "every week" ...).

    This forum has been really helpful in the past so I hope someone can point me into the right direction. It's just really tiresome to go through the Zimbra source over and over again just to find some properties. Actually, I just wasted another day on this. I found this to be kinda helpful. Unfortunately it's incomplete.

  7. #7
    sposetti is offline Former Zimbran
    Join Date
    Nov 2009
    Posts
    105
    Rep Power
    5

    Default

    Here is a snippet of code (that can be used in the doDrop method) that shows how to access some of the common ZmTask properties.

    Recurrence "blurb" is the kind-of recurrence string you might be looking for. There is a helper task.getRecurBlurb() or you can access recObj.getBlurb(). The blurb is only available if the task._recurrence object is not null (i.e. the task is recurring).

    As for accessing the "notes" property, I'll check with the engineering team on that.


    Code:
    	var type = obj.TYPE;
    	if (type == null) {
    		var arrayObj = obj[0];
    		if (arrayObj && arrayObj.type == "TASK") {
    			// do something with ZmTask
    
    			var task = arrayObj; // get ZmTask object
    			
    			var taskName = task.getName(); // get name (i.e. "subject") {String}
    
    			var taskLocation = task.getLocation(); // {String}
    			var organizer = task.getOrganizer(); // {String}
    			
    			var percentComplete = task.pComplete; // {int}
    			
    			var priority = task.priority; // {int}
    			var	priorityLabel = ZmCalItem.getLabelForPriority(priority); // {String}
    			
    			var status = task.status; // {int}
    			var statusLabel = ZmCalItem.getLabelForStatus(status); // {String}
    
    			var taskStartDate = task.startDate; // {Date}
    			var taskEndDate = task.endDate; // {Date}
    
    			var isRecurring = task.isRecurring(); // {Boolean}
    			
    			if (isRecurring) {
    				var recObj = task._recurrence; // {ZmRecurrence}
    				var blurb = task.getRecurBlurb(); // {String}
    				var type = task.getRecurType(); // {String}
    			}
    			
    		}
    	}

  8. #8
    skid is offline Member
    Join Date
    Oct 2009
    Posts
    14
    Rep Power
    5

    Default

    Quote Originally Posted by sposetti View Post
    Recurrence "blurb" is the kind-of recurrence string you might be looking for. There is a helper task.getRecurBlurb() or you can access recObj.getBlurb(). The blurb is only available if the task._recurrence object is not null (i.e. the task is recurring).
    This will help me quite a bit. The recurrence code should probably also work for standard appointments.

    Quote Originally Posted by sposetti View Post
    As for accessing the "notes" property, I'll check with the engineering team on that.
    Awesome, thanks.

  9. #9
    skid is offline Member
    Join Date
    Oct 2009
    Posts
    14
    Rep Power
    5

    Default

    Never mind. I finally managed to get the notes property for tasks

  10. #10
    sposetti is offline Former Zimbran
    Join Date
    Nov 2009
    Posts
    105
    Rep Power
    5

    Default

    That's good to hear.

    Can you post your code (the property/method you access) for reference in this thread?

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Cannot get from address into dragSource
    By hookmac123 in forum Zimlets
    Replies: 2
    Last Post: 02-19-2010, 02:45 PM

Posting Permissions

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