Ext.namespace("Zarafa.widgets.folderwidgets");
Zarafa.widgets.folderwidgets.AbstractFolderWidget=Ext.extend(Zarafa.core.ui.widget.Widget,{folder:void 0,store:void 0,folderType:void 0,reloadTask:void 0,configurationConfig:void 0,constructor:function(a){a=a||{};this.guid=a.guid;Ext.applyIf(a,{hasConfig:!0,height:this.get("widgetheight")||300});Zarafa.widgets.folderwidgets.AbstractFolderWidget.superclass.constructor.call(this,a)},initEvents:function(){Zarafa.widgets.folderwidgets.AbstractFolderWidget.superclass.initEvents.apply(this,arguments);var a=
container.getHierarchyStore();this.mon(a,"load",this.onHierarchyLoad,this);this.onHierarchyLoad(a);this.mon(this.store,"load",this.startReloadTask,this,{single:!0});this.mon(this.store,"load",this.updateFilter,this);this.mon(this.store,"update",this.onStoreUpdate,this)},onHierarchyLoad:function(a){(this.folder=a.getDefaultFolder(this.folderType))&&this.reloadStore()},startReloadTask:function(){this.reloadTask&&Ext.TaskMgr.stop(this.reloadTask);var a=this.get("reloadinterval")||300;this.reloadTask=
Ext.TaskMgr.start({run:this.reloadStore,interval:1E3*a,scope:this})},onStoreUpdate:function(){this.updateFilter()},reloadStore:function(){this.folder&&this.store.load({folder:this.folder})},updateFilter:Ext.emptyFn,viewConfigGetRowClass:function(a,b,c){c.body='<div class="zarafa-grid-body-container">';b=Zarafa.common.categories.Util.getCategories(a);b=Zarafa.common.categories.Util.getCategoriesHtml(b);c.body+='<div class="k-category-container">'+b+"</div>";b=Zarafa.common.ui.grid.Renderers.subject(a.get("subject"),
{});c.body+=String.format('<div class="grid_compact grid_compact_left grid_compact_subject_cell">{0}</div>',b);c.body+="</div>";return"x-grid3-row-expanded "+Zarafa.task.ui.TaskGridView.prototype.viewConfigGetRowClass(a)},createConfigHeight:function(a,b){return{xtype:"zarafa.spinnerfield",fieldLabel:_("Widget height"),name:"widgetheight",boxLabel:_("pixels"),width:60,minValue:a||100,maxValue:b||500,incrementValue:5,defaultValue:this.get("widgetheight")||300,listeners:{change:this.onFieldChange,scope:this},
plugins:["zarafa.numberspinner"]}},config:function(){var a=Ext.apply({},this.configurationConfig||{},{title:_("Configure widget"),layout:"fit",width:320,height:135,modal:!0,items:[{xtype:"form",frame:!0,cls:"k-configure-widget",labelWidth:120,items:[{xtype:"zarafa.spinnerfield",fieldLabel:_("Reload interval"),name:"reloadinterval",boxLabel:_("seconds"),width:60,minValue:30,maxValue:1800,incrementValue:30,defaultValue:this.get("reloadinterval")||300,listeners:{change:this.onFieldChange,scope:this},
plugins:["zarafa.numberspinner"]},this.createConfigHeight()].concat(this.getConfigurationItems()),buttons:[{text:_("Close"),scope:this,handler:function(){this.win.close()}}]}]});this.win=new Ext.Window(a);this.win.show(this)},getConfigurationItems:function(){return[]},onFieldChange:function(a,b,c){a=a.getName();this.set(a,b);"widgetheight"===a&&this.setHeight(b);"reloadinterval"===a&&this.startReloadTask()}});Ext.namespace("Zarafa.widgets.folderwidgets");
Zarafa.widgets.folderwidgets.AppointmentsWidget=Ext.extend(Zarafa.widgets.folderwidgets.AbstractFolderWidget,{constructor:function(a){a=a||{};var b=new Zarafa.calendar.AppointmentStore;Ext.applyIf(a,{autoScroll:!0,layout:"fit",folderType:"calendar",store:b,items:[{xtype:"zarafa.gridpanel",cls:"k-appointmentwidget",store:b,hideHeaders:!0,loadMask:{msg:_("Loading appointments...")},sm:new Zarafa.common.ui.grid.RowSelectionModel({singleSelect:!0}),viewConfig:{deferEmptyText:!1,emptyText:'<div class="emptytext">'+
_("No appointments")+"</div>",forceFit:!0,enableRowBody:!0,rowSelectorDepth:15,getRowClass:this.viewConfigGetRowClass,scope:this},colModel:new Ext.grid.ColumnModel({columns:[{header:_("Time"),dataIndex:"startdate",renderer:this.timeRenderer,scope:this}]}),listeners:{rowcontextmenu:this.onRowContextMenu,rowdblclick:this.onRowDblClick,scope:this}}]});this.configurationConfig={height:180};Zarafa.widgets.folderwidgets.AppointmentsWidget.superclass.constructor.call(this,a)},getConfigurationItems:function(){return[{xtype:"zarafa.spinnerfield",
fieldLabel:_("Number of days"),name:"numdays",boxLabel:_("day(s)"),width:60,minValue:1,maxValue:365,incrementValue:1,defaultValue:this.get("numdays")||5,listeners:{change:this.onNumDaysChange,scope:this},plugins:["zarafa.numberspinner"]}]},onNumDaysChange:function(a,b,c){this.set(a.getName(),b);this.reloadStore()},initEvents:function(){Zarafa.widgets.folderwidgets.AppointmentsWidget.superclass.initEvents.apply(this,arguments);this.mon(this.store,"load",this.startFilterTask,this,{single:!0})},startFilterTask:function(){Ext.TaskMgr.start({run:this.updateFilter,
interval:3E4,scope:this})},reloadStore:function(){if(this.folder){var a=this.get("numdays")||5,b=(new Date).clearTime().getTime()/1E3,a=(new Date).clearTime().add(Date.DAY,a).getTime()/1E3;this.store.load({folder:this.folder,params:{restriction:{startdate:b,duedate:a}}})}},updateFilter:function(){var a=(new Date).getTime()/1E3;this.store.filterBy(function(b){b=b.get("duedate").getTime()/1E3;return!b||b>=a},this)},timeRenderer:function(a,b,c){b="";var d=c.get("recurring_pattern");d&&(b=!0===c.get("exception")?
'&nbsp;<span ext:qwidth="300" ext:qtip="'+d+'"><img src="'+Zarafa.calendar.ui.IconCache.getExceptionIcon().src+'"/></span>':'&nbsp;<span ext:qwidth="300" ext:qtip="'+d+'"><img src="'+Zarafa.calendar.ui.IconCache.getRecurringIcon().src+'"/></span>');d="";!0===c.get("private")&&(d='&nbsp;<img src="'+Zarafa.calendar.ui.IconCache.getPrivateIcon().src+'"/>');var e=(new Date).clearTime(),g=(new Date).add(Date.DAY,1).clearTime(),f=c.get("duedate");c=c.get("alldayevent");return a>=e&&f<=g?c?_("Today (all day)")+
b+d:String.format(_("Today {0} - {1}"),a.format(_("G:i")),f.format(_("G:i")))+b+d:c?String.format(_("{0} - {1} (all day)"),a.format(_("d/m/y")),f.format(_("d/m/y")))+b+d:String.format(_("{0} - {1}"),a.format(_("d/m/y G:i")),f.format(_("d/m/y G:i")))+b+d},onRowContextMenu:function(a,b,c){a=a.getSelectionModel();a.isSelected(b)||a.selectRow(b);this.folder&&(b=container.getContextByFolder(this.folder))&&(b=b.getModel(),Zarafa.core.data.UIFactory.openDefaultContextMenu(a.getSelections(),{position:c.getXY(),
model:b}))},onRowDblClick:function(a,b,c){a=a.getSelectionModel().getSelected();Ext.isEmpty(a)||a.isRecurringOccurence()&&(a=a.convertToOccurenceRecord());Zarafa.core.data.UIFactory.openViewRecord(a)}});Zarafa.onReady(function(){container.registerWidget(new Zarafa.core.ui.widget.WidgetMetaData({name:"appointments",displayName:_("Upcoming Appointments"),widgetConstructor:Zarafa.widgets.folderwidgets.AppointmentsWidget}))});Ext.namespace("Zarafa.widgets.folderwidgets");
Zarafa.widgets.folderwidgets.MailWidget=Ext.extend(Zarafa.widgets.folderwidgets.AbstractFolderWidget,{constructor:function(a){a=a||{};var b=new Zarafa.mail.MailStore;b.setDefaultSort(b.defaultSortInfo.field,b.defaultSortInfo.direction);b.setRestriction({search:Zarafa.core.data.RestrictionFactory.dataResBitmask("0x00E070003",Zarafa.core.mapi.Restrictions.BMR_EQZ,Zarafa.core.mapi.MessageFlags.MSGFLAG_READ)});b.isAdvanceSearchStore=function(){return!0};Ext.applyIf(a,{autoScroll:!0,layout:"fit",folderType:"inbox",
store:b,items:[{xtype:"zarafa.gridpanel",id:"unread-mail-widget",store:b,border:!0,loadMask:{msg:_("Loading mail")+"..."},sm:new Zarafa.common.ui.grid.RowSelectionModel({singleSelect:!0}),viewConfig:{deferEmptyText:!1,emptyText:'<div class="emptytext">'+_("No unread mail.")+"</div>",forceFit:!0,enableRowBody:!0,rowSelectorDepth:15,getRowClass:this.viewConfigGetRowClass},colModel:new Ext.grid.ColumnModel({columns:[{header:_("From"),dataIndex:"sent_representing_name",menuDisabled:!0,renderer:Ext.util.Format.htmlEncode},
{header:_("Received"),dataIndex:"message_delivery_time",editable:!1,menuDisabled:!0,renderer:Zarafa.common.ui.grid.Renderers.datetime}]}),listeners:{rowcontextmenu:this.onRowContextMenu,rowdblclick:this.onRowDblClick,scope:this}}]});Zarafa.widgets.folderwidgets.MailWidget.superclass.constructor.call(this,a)},updateFilter:function(){this.store.filterBy(function(a){return!a.isRead()},this)},viewConfigGetRowClass:function(a,b,c,d){b=a.isRead()?"mail_read":"mail_unread";var e;c.body='<table cellspacing="0" cellpadding="0" border="0" style="width: 100%;">';
c.body+="<tr>";d={};e=Zarafa.common.ui.grid.Renderers.subject(a.get("subject"),d,a);c.body+=String.format('<td style="width: 100%"><div class="grid_compact grid_compact_left grid_compact_subject_cell {0}" style="height: 24px;">{1}</div></td>',d.css,e);d={};e=Zarafa.common.ui.grid.Renderers.attachment(a.get("hasattach"),d,a);c.body+=String.format('<td style="width: 24px"><div class="grid_compact {0}" style="height: 24px; width: 24px;">{1}</div></td>',d.css,e);d={};e=Zarafa.common.ui.grid.Renderers.importance(a.get("importance"),
d,a);c.body+=String.format('<td style="width: 24px"><div class="grid_compact {0}" style="height: 24px; width: 24px;">{1}</div></td>',d.css,e);c.body+="</tr></table>";return"x-grid3-row-expanded "+b},onRowContextMenu:function(a,b,c){a=a.getSelectionModel();a.isSelected(b)||a.selectRow(b);var d;this.folder&&(b=container.getContextByFolder(this.folder))&&(d=b.getModel());Zarafa.core.data.UIFactory.openDefaultContextMenu(a.getSelections(),{position:c.getXY(),model:d})},onRowDblClick:function(a,b,c){Zarafa.core.data.UIFactory.openViewRecord(a.getSelectionModel().getSelected())}});
Zarafa.onReady(function(){container.registerWidget(new Zarafa.core.ui.widget.WidgetMetaData({name:"mail",displayName:_("Unread Mail"),widgetConstructor:Zarafa.widgets.folderwidgets.MailWidget}))});Ext.namespace("Zarafa.widgets.folderwidgets");
Zarafa.widgets.folderwidgets.TasksWidget=Ext.extend(Zarafa.widgets.folderwidgets.AbstractFolderWidget,{constructor:function(a){a=a||{};var b=new Zarafa.task.TaskStore;b.setDefaultSort("duedate","asc");b.setRestriction({task:Zarafa.core.data.RestrictionFactory.createResAnd([Zarafa.core.data.RestrictionFactory.dataResProperty("status",Zarafa.core.mapi.Restrictions.RELOP_NE,Zarafa.core.mapi.TaskStatus.COMPLETE),Zarafa.core.data.RestrictionFactory.dataResProperty("flag_status",Zarafa.core.mapi.Restrictions.RELOP_NE,
Zarafa.core.mapi.FlagStatus.completed)])});Ext.applyIf(a,{autoScroll:!0,layout:"fit",folderType:"todolist",store:b,items:[{xtype:"zarafa.gridpanel",cls:"k-taskwidget",store:b,loadMask:{msg:_("Loading tasks")+"..."},sm:new Zarafa.common.ui.grid.RowSelectionModel({singleSelect:!0}),viewConfig:{deferEmptyText:!1,emptyText:'<div class="emptytext">'+_("No tasks.")+"</div>",forceFit:!0,enableRowBody:!0,rowSelectorDepth:15,getRowClass:this.viewConfigGetRowClass},colModel:new Ext.grid.ColumnModel({columns:[{header:_("Due"),
tooltip:_("Sort by: Due Date"),dataIndex:"duedate",renderer:Zarafa.common.ui.grid.Renderers.utcdate},{header:"<p class='icon_importance'>&nbsp;</p>",tooltip:_("Sort by: Priority"),dataIndex:"importance",width:24,fixed:!0,renderer:Zarafa.common.ui.grid.Renderers.importance},{header:"%",tooltip:_("Sort by: Percentage Completed"),dataIndex:"percent_complete",width:75,renderer:Zarafa.common.ui.grid.Renderers.percentage},{header:_("Owner"),tooltip:_("Sort by: Owner"),dataIndex:"owner",renderer:this.ownerRenderer}],
defaults:{sortable:!0,menuDisabled:!0}}),listeners:{rowcontextmenu:this.onRowContextMenu,rowdblclick:this.onRowDblClick,scope:this}}]});Zarafa.widgets.folderwidgets.TasksWidget.superclass.constructor.call(this,a)},updateFilter:function(){this.store.filterBy(function(a){return a.get("status")!=Zarafa.core.mapi.TaskStatus.COMPLETE},this)},ownerRenderer:function(a,b,c){a=c.get("owner");if(!Ext.isString(a))return"";b=a.split(" ");c="";for(var d=0,e=b.length;d<e;d++)c+=b[d].substring(0,1);return'<span ext:qtip="'+
Ext.util.Format.htmlEncode(a)+'" ext:qwidth="100%">'+Ext.util.Format.htmlEncode(c)+"</span>"},onRowContextMenu:function(a,b,c){a=a.getSelectionModel();a.isSelected(b)||a.selectRow(b);this.folder&&(b=container.getContextByFolder(this.folder))&&(b=b.getModel(),Zarafa.core.data.UIFactory.openDefaultContextMenu(a.getSelections(),{position:c.getXY(),model:b}))},onRowDblClick:function(a,b,c){Zarafa.core.data.UIFactory.openViewRecord(a.getSelectionModel().getSelected())}});
Zarafa.onReady(function(){container.registerWidget(new Zarafa.core.ui.widget.WidgetMetaData({name:"tasks",displayName:_("Tasks / To-Do"),widgetConstructor:Zarafa.widgets.folderwidgets.TasksWidget}))});//# sourceMappingURL=folderwidgets.js.map
