1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
Ext.namespace('Zarafa.plugins.files.ui');
Zarafa.plugins.files.ui.FilesTreeContextMenu = Ext.extend(Zarafa.core.ui.menu.ConditionalMenu, {
/**
* @cfg {Zarafa.plugins.files.FilesContext} context The context to which this context menu belongs.
*/
context : undefined,
/**
* The {@link Zarafa.plugins.files.FilesContextModel} which is obtained from the {@link #context}.
* @property
* @type Zarafa.plugins.files.FilesContextModel
*/
model: undefined,
records: undefined,
constructor: function (config) {
config = config || {};
if (!Ext.isDefined(config.model) && Ext.isDefined(config.context)) {
config.model = config.context.getModel();
}
if (Ext.isDefined(config.records)) {
this.records = config.records;
}
Ext.applyIf(config, {
items: [
this.createContextActionItems(),
{xtype: 'menuseparator'},
container.populateInsertionPoint('plugin.files.treecontextmenu.actions', this),
{xtype: 'menuseparator'},
container.populateInsertionPoint('plugin.files.treecontextmenu.options', this)
]
});
Zarafa.plugins.files.ui.FilesTreeContextMenu.superclass.constructor.call(this, config);
},
createContextActionItems: function () {
return [{
xtype : 'zarafa.conditionalitem',
text : dgettext('plugin_files', 'New Folder'),
iconCls : 'files_icon_action files_icon_action_new_folder',
handler : this.onContextItemNewFolder,
scope : this
},{
xtype : 'zarafa.conditionalitem',
text : dgettext('plugin_files', 'Rename'),
iconCls : 'files_icon_action files_icon_action_edit',
handler : this.onContextItemRename,
beforeShow: function (item, records) {
var rec = records[0];
var path = Zarafa.plugins.files.data.Utils.File.stripAccountId(rec.get('id'));
item.setVisible(path != "/");
},
scope : this
}, {
xtype : 'zarafa.conditionalitem',
text : dgettext('plugin_files', 'Delete'),
iconCls : 'files_icon_action files_icon_action_delete',
handler : this.onContextItemDelete,
beforeShow: function (item, records) {
var rec = records[0];
var path = Zarafa.plugins.files.data.Utils.File.stripAccountId(rec.get('id'));
item.setVisible(path != "/");
},
scope : this
}];
},
onContextItemDelete: function (menuitem, event) {
Zarafa.plugins.files.data.Actions.deleteRecords(this.records);
},
onContextItemNewFolder: function (menuitem, event) {
var clickedRecord = this.records[0];
Zarafa.plugins.files.data.Actions.createFolder(this.model, null, clickedRecord.get('id'));
},
onContextItemRename: function (menuitem, event) {
Zarafa.plugins.files.data.Actions.openRenameDialog(this.records[0]);
}
});
Ext.reg('filesplugin.filestreecontextmenu', Zarafa.plugins.files.ui.FilesTreeContextMenu);
|