temp commit
This commit is contained in:
parent
7b4e1c4569
commit
ae48beb111
110
js/settings/SettingsCalSyncWidget.js
Normal file
110
js/settings/SettingsCalSyncWidget.js
Normal file
@ -0,0 +1,110 @@
|
||||
Ext.namespace('Zarafa.plugins.calendarimporter.settings');
|
||||
|
||||
/**
|
||||
* @class Zarafa.plugins.calendarimporter.settings.SettingsCalSyncWidget
|
||||
* @extends Zarafa.settings.ui.SettingsWidget
|
||||
* @xtype calendarimporter.settingscalsyncwidget
|
||||
*
|
||||
* The {@link Zarafa.settings.ui.SettingsWidget widget} for configuring
|
||||
* delegation options in the {@link Zarafa.common.settings.SettingsSendAsCategory sendas category}.
|
||||
*/
|
||||
Zarafa.common.settings.SettingsSendAsWidget = Ext.extend(Zarafa.settings.ui.SettingsWidget, {
|
||||
/**
|
||||
* @cfg {Zarafa.settings.SettingsContext} settingsContext
|
||||
*/
|
||||
settingsContext : undefined,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Object} config Configuration object
|
||||
*/
|
||||
constructor : function(config)
|
||||
{
|
||||
config = config || {};
|
||||
|
||||
var store = new Ext.data.JsonStore({
|
||||
fields : [
|
||||
{ name : 'id', type : 'int' },
|
||||
{ name : 'icsurl' },
|
||||
{ name : 'user' },
|
||||
{ name : 'pass' },
|
||||
{ name : 'intervall', type : 'int' },
|
||||
{ name : 'lastsync' }
|
||||
],
|
||||
sortInfo : {
|
||||
field : 'id',
|
||||
direction : 'ASC'
|
||||
},
|
||||
autoDestroy : true
|
||||
});
|
||||
|
||||
Ext.applyIf(config, {
|
||||
height : 400,
|
||||
title : _('Calendar Sync settings'),
|
||||
xtype : 'calendarimporter.settingscalsyncwidget',
|
||||
layout : {
|
||||
// override from SettingsWidget
|
||||
type : 'fit'
|
||||
},
|
||||
items : [{
|
||||
xtype : 'calendarimporter.calsyncpanel',
|
||||
store : store,
|
||||
ref : 'calsyncPanel'
|
||||
}]
|
||||
});
|
||||
|
||||
Zarafa.plugins.calendarimporter.settings.SettingsCalSyncWidget.superclass.constructor.call(this, config);
|
||||
},
|
||||
|
||||
/**
|
||||
* Called by the {@link Zarafa.settings.ui.SettingsCategory Category} when
|
||||
* it has been called with {@link zarafa.settings.ui.SettingsCategory#update}.
|
||||
* This is used to load the latest version of the settings from the
|
||||
* {@link Zarafa.settings.SettingsModel} into the UI of this category.
|
||||
* @param {Zarafa.settings.SettingsModel} settingsModel The settings to load
|
||||
*/
|
||||
update : function(settingsModel)
|
||||
{
|
||||
this.model = settingsModel;
|
||||
|
||||
// Convert the signatures into Store data
|
||||
var icslinks = settingsModel.get('zarafa/v1/contexts/calendar/icssync', true);
|
||||
var syncArray = [];
|
||||
for (var key in icslinks) {
|
||||
syncArray.push(Ext.apply({}, icslinks[key], { id : key }));
|
||||
}
|
||||
|
||||
// Load all icslinks into the GridPanel
|
||||
var store = this.calsyncPanel.calsyncGrid.getStore();
|
||||
store.loadData(syncArray);
|
||||
},
|
||||
|
||||
/**
|
||||
* Called by the {@link Zarafa.settings.ui.SettingsCategory Category} when
|
||||
* it has been called with {@link zarafa.settings.ui.SettingsCategory#updateSettings}.
|
||||
* This is used to update the settings from the UI into the {@link Zarafa.settings.SettingsModel settings model}.
|
||||
* @param {Zarafa.settings.SettingsModel} settingsModel The settings to update
|
||||
*/
|
||||
updateSettings : function(settingsModel)
|
||||
{
|
||||
settingsModel.beginEdit();
|
||||
|
||||
// Start reading the Grid store and convert the contents back into
|
||||
// an object which can be pushed to the settings.
|
||||
var icslinks = this.sendasPanel.sendasGrid.getStore().getRange();
|
||||
var icslinkData = {};
|
||||
for (var i = 0, len = icslinks.length; i < len; i++) {
|
||||
var icslink = icslinks[i];
|
||||
|
||||
icslinkData[icslink.get('id')] = {
|
||||
'display_name' : icslink.get('display_name'),
|
||||
'email_address' : icslink.get('email_address')
|
||||
};
|
||||
}
|
||||
settingsModel.set('zarafa/v1/contexts/mail/sendas', icslinkData);
|
||||
|
||||
settingsModel.endEdit();
|
||||
}
|
||||
});
|
||||
|
||||
Ext.reg('calendarimporter.settingscalsyncwidget', Zarafa.plugins.calendarimporter.settings.SettingsCalSyncWidget);
|
40
js/settings/dialogs/SendAsEditContentPanel.js
Normal file
40
js/settings/dialogs/SendAsEditContentPanel.js
Normal file
@ -0,0 +1,40 @@
|
||||
Ext.namespace('Zarafa.common.sendas.dialogs');
|
||||
|
||||
/**
|
||||
* @class Zarafa.common.sendas.dialogs.SendAsEditContentPanel
|
||||
* @extends Zarafa.core.ui.ContentPanel
|
||||
* @xtype zarafa.sendaseditcontentpanel
|
||||
*
|
||||
* {@link Zarafa.common.sendas.dialogs.SendAsEditContentPanel SendAsEditContentPanel} will be used to edit sendas addresses.
|
||||
*/
|
||||
Zarafa.common.sendas.dialogs.SendAsEditContentPanel = Ext.extend(Zarafa.core.ui.ContentPanel, {
|
||||
/**
|
||||
* @constructor
|
||||
* @param config Configuration structure
|
||||
*/
|
||||
constructor : function(config)
|
||||
{
|
||||
config = config || {};
|
||||
|
||||
// Add in some standard configuration data.
|
||||
Ext.applyIf(config, {
|
||||
// Override from Ext.Component
|
||||
xtype : 'zarafa.sendaseditcontentpanel',
|
||||
// Override from Ext.Component
|
||||
layout : 'fit',
|
||||
model : true,
|
||||
autoSave : false,
|
||||
width : 400,
|
||||
height : 100,
|
||||
title : _('Send As'),
|
||||
items : [{
|
||||
xtype : 'zarafa.sendaseditpanel',
|
||||
item : config.item
|
||||
}]
|
||||
});
|
||||
|
||||
Zarafa.common.sendas.dialogs.SendAsEditContentPanel.superclass.constructor.call(this, config);
|
||||
}
|
||||
});
|
||||
|
||||
Ext.reg('zarafa.sendaseditcontentpanel', Zarafa.common.sendas.dialogs.SendAsEditContentPanel);
|
135
js/settings/dialogs/SendAsEditPanel.js
Normal file
135
js/settings/dialogs/SendAsEditPanel.js
Normal file
@ -0,0 +1,135 @@
|
||||
Ext.namespace('Zarafa.common.sendas.dialogs');
|
||||
|
||||
/**
|
||||
* @class Zarafa.common.sendas.dialogs.SendAsEditPanel
|
||||
* @extends Ext.form.FormPanel
|
||||
* @xtype zarafa.sendaseditpanel
|
||||
*
|
||||
* Will generate UI for {@link Zarafa.common.sendas.dialogs.SendAsEditContentPanel SendAsEditContentPanel}.
|
||||
*/
|
||||
Zarafa.common.sendas.dialogs.SendAsEditPanel = Ext.extend(Ext.form.FormPanel, {
|
||||
|
||||
/**
|
||||
* the id of the currently edited item
|
||||
*/
|
||||
currentItem : undefined,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param config Configuration structure
|
||||
*/
|
||||
constructor : function(config)
|
||||
{
|
||||
config = config || {};
|
||||
|
||||
if(config.item)
|
||||
this.currentItem = config.item;
|
||||
|
||||
Ext.applyIf(config, {
|
||||
// Override from Ext.Component
|
||||
xtype : 'zarafa.sendaseditpanel',
|
||||
labelAlign : 'left',
|
||||
defaultType: 'textfield',
|
||||
items : this.createPanelItems(config),
|
||||
buttons: [{
|
||||
text: _('Save'),
|
||||
handler: this.doSave,
|
||||
scope: this
|
||||
},
|
||||
{
|
||||
text: _('Cancel'),
|
||||
handler: this.doClose,
|
||||
scope: this
|
||||
}]
|
||||
});
|
||||
|
||||
Zarafa.common.sendas.dialogs.SendAsEditPanel.superclass.constructor.call(this, config);
|
||||
},
|
||||
|
||||
/**
|
||||
* close the dialog
|
||||
*/
|
||||
doClose : function() {
|
||||
this.dialog.close();
|
||||
},
|
||||
|
||||
/**
|
||||
* save the data to the store
|
||||
*/
|
||||
doSave : function() {
|
||||
var store = this.dialog.store;
|
||||
var id = 0;
|
||||
var record = undefined;
|
||||
|
||||
if(!this.currentItem) {
|
||||
record = new store.recordType({
|
||||
id: this.hashCode(this.email_address.getValue()),
|
||||
display_name: this.display_name.getValue(),
|
||||
email_address: this.email_address.getValue()
|
||||
});
|
||||
}
|
||||
|
||||
if(this.email_address.isValid()) {
|
||||
if(record) {
|
||||
store.add(record);
|
||||
} else {
|
||||
this.currentItem.set('display_name', this.display_name.getValue());
|
||||
this.currentItem.set('email_address', this.email_address.getValue());
|
||||
}
|
||||
this.dialog.close();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Function will create panel items for {@link Zarafa.common.sendas.dialogs.SendAsEditPanel SendAsEditPanel}
|
||||
* @return {Array} array of items that should be added to panel.
|
||||
* @private
|
||||
*/
|
||||
createPanelItems : function(config)
|
||||
{
|
||||
var displayName = "";
|
||||
var emailAddress = "";
|
||||
|
||||
if(config.item){
|
||||
displayName = config.item.get('display_name');
|
||||
emailAddress = config.item.get('email_address');
|
||||
}
|
||||
|
||||
return [{
|
||||
fieldLabel: _('Display Name'),
|
||||
name: 'display_name',
|
||||
ref: 'display_name',
|
||||
value: displayName,
|
||||
anchor: '100%'
|
||||
},
|
||||
{
|
||||
fieldLabel: _('Email Address'),
|
||||
name: 'email_address',
|
||||
ref: 'email_address',
|
||||
allowBlank: false,
|
||||
value: emailAddress,
|
||||
vtype:'email',
|
||||
anchor: '100%'
|
||||
}];
|
||||
},
|
||||
|
||||
/**
|
||||
* Java String.hashCode() implementation
|
||||
* @private
|
||||
*/
|
||||
hashCode : function(str){
|
||||
var hash = 0;
|
||||
var chr = 0;
|
||||
var i = 0;
|
||||
|
||||
if (str.length == 0) return hash;
|
||||
for (i = 0; i < str.length; i++) {
|
||||
chr = str.charCodeAt(i);
|
||||
hash = ((hash<<5)-hash)+chr;
|
||||
hash = hash & hash; // Convert to 32bit integer
|
||||
}
|
||||
return Math.abs(hash);
|
||||
}
|
||||
});
|
||||
|
||||
Ext.reg('zarafa.sendaseditpanel', Zarafa.common.sendas.dialogs.SendAsEditPanel);
|
136
js/settings/ui/SendAsGrid.js
Normal file
136
js/settings/ui/SendAsGrid.js
Normal 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);
|
160
js/settings/ui/SendAsPanel.js
Normal file
160
js/settings/ui/SendAsPanel.js
Normal 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);
|
Loading…
Reference in New Issue
Block a user