calendarimporter/js/settings/ui/CalSyncGrid.js

169 lines
4.2 KiB
JavaScript
Raw Normal View History

2013-08-25 12:44:25 +02:00
Ext.namespace('Zarafa.plugins.calendarimporter.settings.ui');
2013-08-24 10:27:15 +02:00
/**
2013-08-25 12:44:25 +02:00
* @class Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid
2013-08-24 10:27:15 +02:00
* @extends Ext.grid.GridPanel
2013-08-25 12:44:25 +02:00
* @xtype calendarimporter.calsyncgrid
2013-08-24 10:27:15 +02:00
*
*/
2013-08-25 12:44:25 +02:00
Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid = Ext.extend(Ext.grid.GridPanel, {
2013-08-24 10:27:15 +02:00
/**
* @constructor
* @param {Object} config Configuration structure
*/
constructor : function(config)
{
config = config || {};
Ext.applyIf(config, {
2013-08-25 15:47:49 +02:00
xtype : 'calendarimporter.calsyncgrid',
2013-08-24 10:27:15 +02:00
border : true,
store : config.store,
viewConfig : {
forceFit : true,
2013-08-25 12:44:25 +02:00
emptyText : '<div class=\'emptytext\'>' + _('No ICAL sync entry exists') + '</div>'
2013-08-24 10:27:15 +02:00
},
loadMask : this.initLoadMask(),
columns : this.initColumnModel(),
selModel : this.initSelectionModel(),
listeners : {
viewready : this.onViewReady,
rowdblclick : this.onRowDblClick,
scope : this
}
});
2013-08-25 12:44:25 +02:00
Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid.superclass.constructor.call(this, config);
2013-08-24 10:27:15 +02:00
},
/**
* initialize events for the grid panel.
* @private
*/
initEvents : function()
{
2013-08-25 12:44:25 +02:00
Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid.superclass.initEvents.call(this);
2013-08-24 10:27:15 +02:00
2013-08-25 15:47:49 +02:00
// select first icssync when store has finished loading
2013-08-24 10:27:15 +02:00
this.mon(this.store, 'load', this.onViewReady, this, {single : true});
},
2013-08-25 12:44:25 +02:00
/**
* Render function
* @return {String}
* @private
*/
renderAuthColumn : function(value, p, record)
{
return value ? "true" : "false";
},
2013-08-24 10:27:15 +02:00
/**
* Render function
* @return {String}
* @private
*/
renderCalendarColumn : function(value, p, record)
{
return Zarafa.plugins.calendarimporter.data.Actions.getCalendarFolderByEntryid(value).display_name;
},
2013-08-24 10:27:15 +02:00
/**
* Creates a column model object, used in {@link #colModel} config
* @return {Ext.grid.ColumnModel} column model object
* @private
*/
initColumnModel : function()
{
return [{
2013-08-25 12:44:25 +02:00
dataIndex : 'icsurl',
header : _('ICS File'),
2013-08-24 10:27:15 +02:00
renderer : Zarafa.common.ui.grid.Renderers.text
},
2013-08-26 00:01:21 +02:00
{
dataIndex : 'calendarname',
2013-08-26 00:01:21 +02:00
header : _('Destination Calender'),
renderer : Zarafa.common.ui.grid.Renderers.text
},
2013-08-24 10:27:15 +02:00
{
2013-08-25 12:44:25 +02:00
dataIndex : 'user',
header : _('Authentication'),
renderer : this.renderAuthColumn
},
{
dataIndex : 'intervall',
header : _('Sync Intervall')
},
{
dataIndex : 'lastsync',
header : _('Last Synchronisation'),
2013-08-24 10:27:15 +02:00
renderer : Zarafa.common.ui.grid.Renderers.text
}]
},
/**
* Creates a selection model object, used in {@link #selModel} config
* @return {Ext.grid.RowSelectionModel} selection model object
* @private
*/
initSelectionModel : function()
{
return new Ext.grid.RowSelectionModel({
singleSelect : true
});
},
/**
* Initialize the {@link Ext.grid.GridPanel.loadMask} field
*
* @return {Ext.LoadMask} The configuration object for {@link Ext.LoadMask}
* @private
*/
initLoadMask : function()
{
return {
2013-08-25 12:44:25 +02:00
msg : _('Loading ics sync entries') + '...'
2013-08-24 10:27:15 +02:00
};
},
/**
* Event handler which is fired when the gridPanel is ready. This will automatically
* select the first row in the grid.
* @private
*/
onViewReady : function()
{
this.getSelectionModel().selectFirstRow();
},
/**
2013-08-25 12:44:25 +02:00
* Function will be called to remove a ics sync entry.
2013-08-24 10:27:15 +02:00
*/
2013-08-25 15:47:49 +02:00
removeIcsSyncAs : function()
2013-08-24 10:27:15 +02:00
{
2013-08-25 12:44:25 +02:00
var icsRecord = this.getSelectionModel().getSelected();
if(!icsRecord) {
Ext.Msg.alert(_('Alert'), _('Please select a ics sync entry.'));
2013-08-24 10:27:15 +02:00
return;
}
2013-08-25 12:44:25 +02:00
this.store.remove(icsRecord);
2013-08-24 10:27:15 +02:00
},
/**
2013-08-25 12:44:25 +02:00
* Event handler which is fired when the {@link Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid CalSyncGrid} is double clicked.
2013-08-24 10:27:15 +02:00
* it will call generic function to handle the functionality.
* @private
*/
onRowDblClick : function(grid, rowIndex)
{
2013-08-25 12:44:25 +02:00
Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType['plugins.calendarimporter.settings.dialogs.calsyncedit'], undefined, {
2013-08-24 10:27:15 +02:00
store : grid.getStore(),
item : grid.getStore().getAt(rowIndex),
manager : Ext.WindowMgr
});
}
});
2013-08-25 15:47:49 +02:00
Ext.reg('calendarimporter.calsyncgrid', Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid);