|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Ext.namespace('Tine.Felamimail'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Tine.Felamimail.FolderSelectPanel = Ext.extend(Ext.Panel, { |
|
|
|
|
|
|
|
|
|
|
|
frame: true, |
|
border: true, |
|
autoScroll: true, |
|
bodyStyle: 'background-color:white', |
|
selectedNode: null, |
|
|
|
|
|
|
|
|
|
|
|
initComponent: function() { |
|
this.addEvents( |
|
|
|
|
|
|
|
|
|
'folderselect' |
|
); |
|
|
|
this.app = Tine.Tinebase.appMgr.get('Felamimail'); |
|
|
|
if (! this.allAccounts) { |
|
this.account = this.account || this.app.getActiveAccount(); |
|
} |
|
|
|
this.initActions(); |
|
this.initFolderTree(); |
|
|
|
Tine.Felamimail.FolderSelectPanel.superclass.initComponent.call(this); |
|
}, |
|
|
|
|
|
|
|
|
|
initActions: function() { |
|
this.action_cancel = new Ext.Action({ |
|
text: _('Cancel'), |
|
minWidth: 70, |
|
scope: this, |
|
handler: this.onCancel, |
|
iconCls: 'action_cancel' |
|
}); |
|
|
|
this.action_ok = new Ext.Action({ |
|
disabled: true, |
|
text: _('Ok'), |
|
iconCls: 'action_saveAndClose', |
|
minWidth: 70, |
|
handler: this.onOk, |
|
scope: this |
|
}); |
|
|
|
this.fbar = [ |
|
'->', |
|
this.action_cancel, |
|
this.action_ok |
|
]; |
|
}, |
|
|
|
|
|
|
|
|
|
initFolderTree: function() { |
|
|
|
if (this.allAccounts) { |
|
|
|
this.root = new Ext.tree.TreeNode({ |
|
text: 'default', |
|
draggable: false, |
|
allowDrop: false, |
|
expanded: true, |
|
leaf: false, |
|
id: 'root' |
|
}); |
|
|
|
var mainApp = Ext.ux.PopupWindowMgr.getMainWindow().Tine.Tinebase.appMgr.get('Felamimail'); |
|
mainApp.getAccountStore().each(function(record) { |
|
|
|
var node = new Ext.tree.AsyncTreeNode({ |
|
id: record.data.id, |
|
path: '/' + record.data.id, |
|
record: record, |
|
globalname: '', |
|
draggable: false, |
|
allowDrop: false, |
|
expanded: false, |
|
text: Ext.util.Format.htmlEncode(record.get('name')), |
|
|
|
|
|
|
|
qtip: Ext.util.Format.htmlEncode(record.get('host')), |
|
leaf: false, |
|
cls: 'felamimail-node-account', |
|
delimiter: record.get('delimiter'), |
|
ns_personal: record.get('ns_personal'), |
|
account_id: record.data.id |
|
}); |
|
|
|
this.root.appendChild(node); |
|
}, this); |
|
|
|
} else { |
|
this.root = new Ext.tree.AsyncTreeNode({ |
|
text: this.account.get('name'), |
|
draggable: false, |
|
allowDrop: false, |
|
expanded: true, |
|
leaf: false, |
|
cls: 'felamimail-node-account', |
|
id: this.account.id, |
|
path: '/' + this.account.id |
|
}); |
|
} |
|
|
|
|
|
this.folderTree = new Ext.tree.TreePanel({ |
|
id: 'felamimail-foldertree', |
|
rootVisible: ! this.allAccounts, |
|
store: this.store || this.app.getFolderStore(), |
|
|
|
loader: this.loader || new Tine.Felamimail.TreeLoader({ |
|
folderStore: this.store, |
|
app: this.app |
|
}), |
|
root: this.root |
|
}); |
|
this.folderTree.on('dblclick', this.onTreeNodeDblClick, this); |
|
this.folderTree.on('click', this.onTreeNodeClick, this); |
|
|
|
this.items = [this.folderTree]; |
|
}, |
|
|
|
|
|
|
|
|
|
afterRender: function() { |
|
Tine.Felamimail.FolderSelectPanel.superclass.afterRender.call(this); |
|
|
|
var title = (! this.allAccounts) |
|
? String.format(this.app.i18n._('Folders of account {0}'), this.account.get('name')) |
|
: this.app.i18n._('Folders of all accounts'); |
|
|
|
this.window.setTitle(title); |
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onTreeNodeDblClick: function(node) { |
|
this.selectedNode = node; |
|
this.onOk(); |
|
return false; |
|
}, |
|
|
|
|
|
|
|
|
|
onTreeNodeClick: function(node) { |
|
this.selectedNode = node; |
|
this.action_ok.setDisabled(false); |
|
}, |
|
|
|
|
|
|
|
|
|
onCancel: function(){ |
|
this.purgeListeners(); |
|
this.window.close(); |
|
}, |
|
|
|
|
|
|
|
|
|
onOk: function() { |
|
if (this.selectedNode) { |
|
this.fireEvent('folderselect', this.selectedNode); |
|
} |
|
} |
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Tine.Felamimail.FolderSelectPanel.openWindow = function (config) { |
|
var window = Tine.WindowFactory.getWindow({ |
|
width: 200, |
|
height: 300, |
|
modal: true, |
|
name: Tine.Felamimail.FolderSelectPanel.prototype.windowNamePrefix + Ext.id(), |
|
contentPanelConstructor: 'Tine.Felamimail.FolderSelectPanel', |
|
contentPanelConstructorConfig: config |
|
}); |
|
return window; |
|
}; |
|
|