temp commit

This commit is contained in:
2013-08-24 08:27:15 +00:00
parent 7b4e1c4569
commit ae48beb111
5 changed files with 581 additions and 0 deletions

View File

@@ -0,0 +1,136 @@
Ext.namespace('Zarafa.common.sendas.ui');
/**
* @class Zarafa.common.sendas.ui.SendAsGrid
* @extends Ext.grid.GridPanel
* @xtype zarafa.sendasgrid
*
* {@link Zarafa.common.sendas.ui.SendAsGrid SendAsGrid} will be used to display
* sendas of the current user.
*/
Zarafa.common.sendas.ui.SendAsGrid = Ext.extend(Ext.grid.GridPanel, {
/**
* @constructor
* @param {Object} config Configuration structure
*/
constructor : function(config)
{
config = config || {};
Ext.applyIf(config, {
xtype : 'zarafa.sendasgrid',
border : true,
store : config.store,
viewConfig : {
forceFit : true,
emptyText : '<div class=\'emptytext\'>' + _('No sendas address exists') + '</div>'
},
loadMask : this.initLoadMask(),
columns : this.initColumnModel(),
selModel : this.initSelectionModel(),
listeners : {
viewready : this.onViewReady,
rowdblclick : this.onRowDblClick,
scope : this
}
});
Zarafa.common.sendas.ui.SendAsGrid.superclass.constructor.call(this, config);
},
/**
* initialize events for the grid panel.
* @private
*/
initEvents : function()
{
Zarafa.common.sendas.ui.SendAsGrid.superclass.initEvents.call(this);
// select first sendas when store has finished loading
this.mon(this.store, 'load', this.onViewReady, this, {single : true});
},
/**
* Creates a column model object, used in {@link #colModel} config
* @return {Ext.grid.ColumnModel} column model object
* @private
*/
initColumnModel : function()
{
return [{
dataIndex : 'display_name',
header : _('Name'),
renderer : Zarafa.common.ui.grid.Renderers.text
},
{
dataIndex : 'email_address',
header : _('Email Address'),
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 {
msg : _('Loading sendas addresses') + '...'
};
},
/**
* 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();
},
/**
* Function will be called to remove a sendas address.
*/
removeSendAs : function()
{
var sendasRecord = this.getSelectionModel().getSelected();
if(!sendasRecord) {
Ext.Msg.alert(_('Alert'), _('Please select a sendas address.'));
return;
}
this.store.remove(sendasRecord);
},
/**
* Event handler which is fired when the {@link Zarafa.common.sendas.ui.SendAsGrid SendAsGrid} is double clicked.
* it will call generic function to handle the functionality.
* @private
*/
onRowDblClick : function(grid, rowIndex)
{
Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType['common.sendas.dialog.sendasedit'], undefined, {
store : grid.getStore(),
item : grid.getStore().getAt(rowIndex),
manager : Ext.WindowMgr
});
}
});
Ext.reg('zarafa.sendasgrid', Zarafa.common.sendas.ui.SendAsGrid);

View File

@@ -0,0 +1,160 @@
Ext.namespace('Zarafa.common.sendas.ui');
/**
* @class Zarafa.common.sendas.ui.SendAsPanel
* @extends Ext.Panel
* @xtype zarafa.sendaspanel
* Will generate UI for the {@link Zarafa.common.settings.SettingsSendAsWidget SettingsSendAsWidget}.
*/
Zarafa.common.sendas.ui.SendAsPanel = Ext.extend(Ext.Panel, {
// 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
xtype : 'zarafa.sendaspanel',
border : false,
layout : {
type : 'vbox',
align : 'stretch',
pack : 'start'
},
items : this.createPanelItems(this.store)
});
Zarafa.common.sendas.ui.SendAsPanel.superclass.constructor.call(this, config);
},
/**
* Function will create panel items for {@link Zarafa.common.sendas.ui.SendAsPanel SendAsPanel}
* @return {Array} array of items that should be added to panel.
* @private
*/
createPanelItems : function(store)
{
return [{
xtype : 'displayfield',
value : _('Here you can setup your alias email addresses.'),
fieldClass : 'x-form-display-field zarafa-delegates-extrainfo'
}, {
xtype : 'container',
flex : 1,
layout : {
type : 'hbox',
align : 'stretch',
pack : 'start'
},
items : [{
xtype : 'zarafa.sendasgrid',
ref : '../sendasGrid',
store : store,
flex : 1
}, {
xtype : 'container',
width : 160,
defaults : {
width : 140
},
layout : {
type : 'vbox',
align : 'center',
pack : 'start'
},
items : [{
xtype : 'button',
text : _('Add') + '...',
handler : this.onSendAsAdd,
ref : '../../addButton',
scope : this
}, {
xtype : 'spacer',
height : 20
}, {
xtype : 'button',
text : _('Remove') + '...',
disabled : true,
ref : '../../removeButton',
handler : this.onSendAsRemove,
scope : this
}]
}]
}];
},
/**
* initialize events for the panel.
* @private
*/
initEvents : function()
{
Zarafa.common.sendas.ui.SendAsPanel.superclass.initEvents.call(this);
// register event to enable/disable buttons
this.mon(this.sendasGrid.getSelectionModel(), 'selectionchange', this.onGridSelectionChange, this);
},
/**
* Handler function will be called when user clicks on 'Add' button,
* this will show addressbook dialog to select sendas user.
* @private
*/
onSendAsAdd : function()
{
Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType['common.sendas.dialog.sendasedit'], undefined, {
store : this.store,
item : undefined,
manager : Ext.WindowMgr
});
},
/**
* Event handler will be called when selection in {@link Zarafa.common.ui.SendAsGrid SendAsGrid}
* 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);
},
/**
* Handler function will be called when user clicks on 'Remove' button,
* this will remove currently selected sendas from sendass list.
* @private
*/
onSendAsRemove : function()
{
this.sendasGrid.removeSendAs();
},
/**
* 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();
}
});
Ext.reg('zarafa.sendaspanel', Zarafa.common.sendas.ui.SendAsPanel);