Quote:
Originally Posted by marinew Hello,
I am working on calendar app in a zimlet to add specifics actions.
I added some buttons to actionMenu and viewActionMenu => That works well.
Now, I would like to enable / disble these buttons, depending on some conditions.
I got this working, by adding listeners to views and viewManager : Code: MyZimlet.prototype.init = function() {
(...)
this._gcmCalViewCtrl._viewMgr.addViewActionListener(new AjxListener(this._gcmCalViewCtrl, this._activerBoutonsViewActionMenu));
this._gcmCalViewCtrl._listView[this._gcmCalViewCtrl._currentView].addActionListener(new AjxListener(this._gcmCalViewCtrl, this._activerBoutonsActionMenu));
}
MyZimlet.prototype._activerBoutonsViewActionMenu = function(ev) {
// "this" designe le controlleur de l'agenda ZmCalViewController
if (MyZimlet.idRdvCoupe != '') {
this._myZimlet._gcmViewActionMenu.enable(MyZimlet._OP_COLLER_RDV_PATIENT,true);
} else {
this._myZimlet._gcmViewActionMenu.enable(MyZimlet._OP_COLLER_RDV_PATIENT,false);
}
};
MyZimlet.prototype._activerBoutonsActionMenu = function(ev) {
(...)
} Here are the problems :
How can I solve this problem, please ?
I think I could put these instructions directly in Zimbra JS files, but I would like to make "clean" work, and keep all specific code in my Zimlet. Is it possible ?
Thanks for any help ! |
Good stuff. No one has played around with this yet, but you look like a hearty fellow, so this is just my brainstorm. Not garunteed to work.
Quote:
|
1) addListener on viewManager works well when I open directly Calendar (with "app=calendar" parameter in Zimbra URL). But when Zimbra first open on default Mail app, viewManager isn't yet initialized => I've got an error, because I can't add listener on a null viewManager in my zimlet init() function.
|
You either need to wait until it's initialized automatically by Zimbra, or you need to force Zimbra to do that for you.
Strategy number one: Use the Zimlet onShowView method to wait until the particular view you want is being pulled up, and then add the listener:
Strategy number two: Use AjxDispatcher.run("GetWhateverControllerYouAreInte restedIn") to grab the controller and then initilize it by hand.
I like strategy one more, because it doesn't force a calendar load unless the user needs it.
Quote:
|
2) addListener on default calendar view works well when I open directly Calendar at Zimbra startup. But for same reason, it doesn't work for other calendar views, or when Zimbra start on another app.
|
Again, I would argue for stragy one here. onShowView gets called when the view changes to the calendar. I have run into situations where the compose view doesn't trip the method, but it should work.
Quote:
3) I have another similar problem : I redefined some Zimbra standard functions, in order to modify Calendar hours scale like this : Code: ZmCalColView._HOUR_HEIGHT = 84;
ZmCalColView._HALF_HOUR_HEIGHT = ZmCalColView._HOUR_HEIGHT/2;
ZmCalColView._15_MINUTE_HEIGHT = ZmCalColView._HOUR_HEIGHT/4;
ZmCalColView._DAY_HEIGHT = ZmCalColView._HOUR_HEIGHT*24;
ZmCalColView.prototype._getBoundsForDate =
function(d, duration, col) {
(...)
}
ZmCalColView.prototype._getBoundsForCalendar =
function(d, duration, folderId) {
(...)
} This works well, except when I lauch Zimbra on Calendar app. Column where hours are displayed don't take care of my changes on default calendar view. Other views are OK.
I think there is a problem in the order in which things are executed. How may I solve this, without modifying Zimbra sources ?
|
I don't think it's possible for you to force loadyour zimlet before the application starts, which means that the best bet might be for you to force load the component (again. I think you can do this with AjxDispatcher.run) make your changes, and then re-initilize the component.Just a guess really.