calendarimporter/js/settings/ui/CalSyncPanel.js

159 lines
3.9 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.CalSyncPanel
2013-08-24 10:27:15 +02:00
* @extends Ext.Panel
2013-08-25 12:44:25 +02:00
* @xtype calendarimporter.calsyncpanel
2013-08-24 10:27:15 +02:00
* Will generate UI for the {@link Zarafa.common.settings.SettingsSendAsWidget SettingsSendAsWidget}.
*/
2013-08-25 12:44:25 +02:00
Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel = Ext.extend(Ext.Panel, {
2013-08-24 10:27:15 +02:00
// store
store : undefined,
/**
* @constructor
* @param config Configuration structure
*/
constructor : function(config)
{
config = config || {};
if(config.store)
this.store = config.store;
Ext.applyIf(config, {
// Override from Ext.Component
2013-08-25 12:44:25 +02:00
xtype : 'calendarimporter.calsyncpanel',
2013-08-24 10:27:15 +02:00
border : false,
layout : {
type : 'vbox',
align : 'stretch',
pack : 'start'
},
items : this.createPanelItems(this.store)
});
2013-08-25 12:44:25 +02:00
Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel.superclass.constructor.call(this, config);
2013-08-24 10:27:15 +02:00
},
/**
2013-08-25 12:44:25 +02:00
* Function will create panel items for {@link Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel CalSyncPanel}
2013-08-24 10:27:15 +02:00
* @return {Array} array of items that should be added to panel.
* @private
*/
createPanelItems : function(store)
{
return [{
xtype : 'displayfield',
2013-08-25 15:47:49 +02:00
value : _('Here you can enter .ics files that will be synchronised.'),
2013-08-25 12:44:25 +02:00
fieldClass : 'x-form-display-field'
2013-08-24 10:27:15 +02:00
}, {
xtype : 'container',
flex : 1,
layout : {
type : 'hbox',
align : 'stretch',
pack : 'start'
},
items : [{
2013-08-25 12:44:25 +02:00
xtype : 'calendarimporter.calsyncgrid',
ref : '../calsyncGrid',
2013-08-24 10:27:15 +02:00
store : store,
flex : 1
}, {
xtype : 'container',
width : 160,
defaults : {
width : 140
},
layout : {
type : 'vbox',
align : 'center',
pack : 'start'
},
items : [{
xtype : 'button',
text : _('Add') + '...',
2013-08-25 15:47:49 +02:00
handler : this.onCalSyncAdd,
2013-08-24 10:27:15 +02:00
ref : '../../addButton',
scope : this
}, {
xtype : 'spacer',
height : 20
}, {
xtype : 'button',
text : _('Remove') + '...',
disabled : true,
ref : '../../removeButton',
2013-08-25 15:47:49 +02:00
handler : this.onCalSyncRemove,
2013-08-24 10:27:15 +02:00
scope : this
}]
}]
}];
},
/**
* initialize events for the panel.
* @private
*/
initEvents : function()
{
2013-08-25 12:44:25 +02:00
Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel.superclass.initEvents.call(this);
2013-08-24 10:27:15 +02:00
// register event to enable/disable buttons
2013-08-25 12:44:25 +02:00
this.mon(this.calsyncGrid.getSelectionModel(), 'selectionchange', this.onGridSelectionChange, this);
2013-08-24 10:27:15 +02:00
},
/**
2013-08-25 12:44:25 +02:00
* Handler function will be called when user clicks on 'Add' button.
2013-08-24 10:27:15 +02:00
* @private
*/
2013-08-25 15:47:49 +02:00
onCalSyncAdd : function()
2013-08-24 10:27:15 +02:00
{
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 : this.store,
item : undefined,
manager : Ext.WindowMgr
});
},
/**
2013-08-25 12:44:25 +02:00
* Event handler will be called when selection in {@link Zarafa.plugins.calendarimporter.settings.ui.CalSyncGrid CalSyncGrid}
2013-08-24 10:27:15 +02:00
* has been changed
* @param {Ext.grid.RowSelectionModel} selectionModel selection model that fired the event
*/
onGridSelectionChange : function(selectionModel)
{
var noSelection = (selectionModel.hasSelection() === false);
this.removeButton.setDisabled(noSelection);
},
/**
2013-08-25 12:44:25 +02:00
* Handler function will be called when user clicks on 'Remove' button.
2013-08-24 10:27:15 +02:00
* @private
*/
2013-08-25 15:47:49 +02:00
onCalSyncRemove : function()
2013-08-24 10:27:15 +02:00
{
2013-08-25 15:47:49 +02:00
this.calsyncGrid.removeIcsSyncAs();
2013-08-24 10:27:15 +02:00
},
/**
* Function will be used to reload data in the store.
*/
discardChanges : function()
{
this.store.load();
},
/**
* Function will be used to save changes in the store.
*/
saveChanges : function()
{
this.store.save();
}
});
2013-08-25 12:44:25 +02:00
Ext.reg('calendarimporter.calsyncpanel', Zarafa.plugins.calendarimporter.settings.ui.CalSyncPanel);