Add and delete new folders to the list to be synchronised
Write a php code for adding and removing device folder from device. Write a js code for adding and removing folder into store while user select / deselect folder
This commit is contained in:
@ -1,33 +1,62 @@
|
||||
Ext.namespace('Zarafa.plugins.mdm.data');
|
||||
|
||||
/**
|
||||
* @class Zarafa.plugins.mdm.data.MDMDeviceFolderStore
|
||||
* @extends Zarafa.core.data.MAPISubStore
|
||||
* @xtype mdm.devicefolderstore
|
||||
* Store specific for MDM Plugin which creates {@link Zarafa.plugins.mdm.MDMDeviceFolderStore record}.
|
||||
*/
|
||||
Zarafa.plugins.mdm.data.MDMDeviceFolderStore = Ext.extend(Zarafa.core.data.MAPISubStore, {
|
||||
/**
|
||||
* @constructor
|
||||
* @param config Configuration object
|
||||
*/
|
||||
constructor: function (config)
|
||||
{
|
||||
config = config || {};
|
||||
|
||||
Ext.applyIf(config, {
|
||||
autoLoad: true,
|
||||
remoteSort: false,
|
||||
reader: new Zarafa.plugins.mdm.data.JsonDeviceFolderReader(),
|
||||
writer: new Zarafa.core.data.JsonWriter(),
|
||||
proxy: new Zarafa.core.data.IPMProxy({
|
||||
listModuleName: 'pluginmdmmodule',
|
||||
itemModuleName: 'pluginmdmmodule'
|
||||
})
|
||||
});
|
||||
|
||||
Zarafa.plugins.mdm.data.MDMDeviceFolderStore.superclass.constructor.call(this, config);
|
||||
}
|
||||
});
|
||||
|
||||
Ext.namespace('Zarafa.plugins.mdm.data');
|
||||
|
||||
/**
|
||||
* @class Zarafa.plugins.mdm.data.MDMDeviceFolderStore
|
||||
* @extends Zarafa.core.data.MAPISubStore
|
||||
* @xtype mdm.devicefolderstore
|
||||
* Store specific for MDM Plugin which creates {@link Zarafa.plugins.mdm.MDMDeviceFolderStore record}.
|
||||
*/
|
||||
Zarafa.plugins.mdm.data.MDMDeviceFolderStore = Ext.extend(Zarafa.core.data.MAPISubStore, {
|
||||
/**
|
||||
* @constructor
|
||||
* @param config Configuration object
|
||||
*/
|
||||
constructor: function (config)
|
||||
{
|
||||
config = config || {};
|
||||
|
||||
Ext.applyIf(config, {
|
||||
autoLoad: true,
|
||||
remoteSort: false,
|
||||
reader: new Zarafa.plugins.mdm.data.JsonDeviceFolderReader(),
|
||||
writer: new Zarafa.plugins.mdm.data.MDMDeviceFolderWriter(),
|
||||
proxy: new Zarafa.core.data.IPMProxy({
|
||||
listModuleName: 'pluginmdmmodule',
|
||||
itemModuleName: 'pluginmdmmodule'
|
||||
})
|
||||
});
|
||||
|
||||
Zarafa.plugins.mdm.data.MDMDeviceFolderStore.superclass.constructor.call(this, config);
|
||||
},
|
||||
|
||||
/**
|
||||
* Function which is use to add {@link Zarafa.plugins.mdm.data.MDMDeviceFolderRecord folder} into
|
||||
* {@link Zarafa.plugins.mdm.MDMDeviceFolderStore store} which will share with respective device.
|
||||
* @param {Zarafa.hierarchy.data.IPFRecord} folder folder which is will add into {@link Zarafa.plugins.mdm.MDMDeviceFolderStore store}
|
||||
*/
|
||||
addFolder : function (folder)
|
||||
{
|
||||
var record = Zarafa.core.data.RecordFactory.createRecordObjectByCustomType(Zarafa.core.data.RecordCustomObjectType.MDM_Device_Folder, {
|
||||
"entryid": folder.get("entryid")
|
||||
});
|
||||
this.add(record);
|
||||
},
|
||||
|
||||
/**
|
||||
* Function which is use to remove {@link Zarafa.plugins.mdm.data.MDMDeviceFolderRecord folder} from
|
||||
* {@link Zarafa.plugins.mdm.MDMDeviceFolderStore store}.
|
||||
* @param {Zarafa.hierarchy.data.IPFRecord} folder folder which is will remove from {@link Zarafa.plugins.mdm.MDMDeviceFolderStore store}
|
||||
*/
|
||||
removeFolder : function (folder)
|
||||
{
|
||||
var found = this.findBy(function (record) {
|
||||
return Zarafa.core.EntryId.compareEntryIds(record.get("entryid"), folder.get("entryid"));
|
||||
});
|
||||
|
||||
if (found >= 0) {
|
||||
this.removeAt(found);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Ext.reg('mdm.devicefolderstore', Zarafa.plugins.mdm.data.MDMDeviceFolderStore);
|
52
js/data/MDMDeviceFolderWriter.js
Normal file
52
js/data/MDMDeviceFolderWriter.js
Normal file
@ -0,0 +1,52 @@
|
||||
Ext.namespace('Zarafa.plugins.mdm.data');
|
||||
|
||||
/**
|
||||
* @class Zarafa.plugins.mdm.data.MDMDeviceFolderWriter
|
||||
* @extends Zarafa.core.data.JsonWriter
|
||||
*
|
||||
* This extension of the {@link Zarafa.core.data.JsonWriter} for writing
|
||||
* {@link Zarafa.plugins.mdm.data.MDMDeviceFolderRecord records} in preparation for executing CRUD action on
|
||||
* {@link Zarafa.plugins.mdm.data.MDMDeviceFolderStore stores}
|
||||
*/
|
||||
Zarafa.plugins.mdm.data.MDMDeviceFolderWriter = Ext.extend(Zarafa.core.data.JsonWriter, {
|
||||
/**
|
||||
* Similar to {@link Ext.data.JsonWriter#toHash}
|
||||
*
|
||||
* Convert sharedFolder into a hash. {@link Zarafa.plugins.mdm.data.MDMDeviceFolderRecord folder} exists
|
||||
* within a {@link Zarafa.plugins.mdm.data.MDMDeviceRecord IPMRecord} and thus must be serialized
|
||||
* seperately into the hash object.
|
||||
*
|
||||
* @param {Ext.data.Record} record The record to hash
|
||||
* @return {Object} The hashed object
|
||||
* @override
|
||||
* @private
|
||||
*/
|
||||
toPropHash : function(record)
|
||||
{
|
||||
var sharedFolderStore = record.getSubStore('sharedfolders');
|
||||
var hash = {};
|
||||
|
||||
if (!Ext.isDefined(sharedFolderStore)) {
|
||||
return hash;
|
||||
}
|
||||
|
||||
// Get list of modified (modified and newly added) records
|
||||
var modifiedRecords = sharedFolderStore.getModifiedRecords();
|
||||
// Get list of removed records
|
||||
var deletedRecords = sharedFolderStore.getRemovedRecords();
|
||||
|
||||
// Adding the modified folder to the add or modified part of the sharedFolder bit
|
||||
if (modifiedRecords.length) {
|
||||
hash.sharedfolders = {};
|
||||
hash.sharedfolders.add = modifiedRecords.map(function(r){return r.data;});
|
||||
}
|
||||
|
||||
// Adding the removed folders to the remove part of the sharedFolder bit
|
||||
if (deletedRecords.length) {
|
||||
hash.sharedfolders = hash.sharedfolders || {};
|
||||
hash.sharedfolders.remove = deletedRecords.map(function(r){return r.data;});
|
||||
}
|
||||
|
||||
return hash;
|
||||
}
|
||||
});
|
@ -1,57 +1,49 @@
|
||||
Ext.namespace('Zarafa.hierarchy.data');
|
||||
|
||||
/**
|
||||
* @class Zarafa.plugins.mdm.data.MDMHierarchyTreeLoader
|
||||
* @extends Zarafa.hierarchy.data.HierarchyTreeLoader
|
||||
*
|
||||
* A Special treeloader to be used by the {@link Zarafa.plugins.mdm.data.MDMHierarchyTreeLoader MDMHierarchyTree}.
|
||||
* This wil dynamically load the child nodes for a given node by obtaining the subfolders of
|
||||
* the folder related to the given node.
|
||||
*/
|
||||
Zarafa.plugins.mdm.data.MDMHierarchyTreeLoader = Ext.extend(Zarafa.hierarchy.data.HierarchyTreeLoader, {
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Object} config Configuration object
|
||||
*/
|
||||
constructor : function(config)
|
||||
{
|
||||
Zarafa.plugins.mdm.data.MDMHierarchyTreeLoader.superclass.constructor.call(this, config);
|
||||
},
|
||||
|
||||
/**
|
||||
* Add extra attributes for a new {@link Zarafa.hierarchy.ui.FolderNode folderNode} which is about
|
||||
* to be created. This will check the {@link Zarafa.hierarchy.ui.FolderNode#folder folder} to
|
||||
* see what properties must be set.
|
||||
*
|
||||
* Override to provide (@link Zarafa.plugins.mdm.ui.MDMFolderNodeUI MDMFolderNodeUI} to ui provider
|
||||
* @param {Object} attr The attributes which will be used to create the node
|
||||
* @return {Zarafa.hierarchy.ui.FolderNode} The created node
|
||||
*/
|
||||
createNode : function(attr)
|
||||
{
|
||||
var folder = attr.folder;
|
||||
|
||||
if (folder) {
|
||||
if (attr.nodeType === 'rootfolder') {
|
||||
attr.extendedDisplayName = this.tree.hasFilter();
|
||||
}
|
||||
|
||||
// To uniquely identify the favorites tree nodes we append the "favorites-" key word with node id
|
||||
// when the node is created.
|
||||
attr.id = folder.isFavoritesFolder() ? "favorites-" + folder.get('entryid') : folder.get('entryid');
|
||||
if (folder.isFavoritesRootFolder()) {
|
||||
attr.leaf = folder.get('assoc_content_count') === 0;
|
||||
} else {
|
||||
attr.leaf = !folder.get('has_subfolder');
|
||||
}
|
||||
|
||||
attr.uiProvider = Zarafa.plugins.mdm.ui.MDMFolderNodeUI;
|
||||
attr.expanded = this.tree.isFolderOpened(folder);
|
||||
attr.allowDrag = !folder.isDefaultFolder();
|
||||
}
|
||||
|
||||
// call parent of parent because of parent class will change ui provider
|
||||
return Zarafa.hierarchy.data.HierarchyTreeLoader.superclass.createNode.apply(this, arguments);
|
||||
}
|
||||
});
|
||||
Ext.namespace('Zarafa.hierarchy.data');
|
||||
|
||||
/**
|
||||
* @class Zarafa.plugins.mdm.data.MDMHierarchyTreeLoader
|
||||
* @extends Zarafa.hierarchy.data.HierarchyTreeLoader
|
||||
*
|
||||
* A Special treeloader to be used by the {@link Zarafa.plugins.mdm.data.MDMHierarchyTreeLoader MDMHierarchyTree}.
|
||||
* This wil dynamically load the child nodes for a given node by obtaining the subfolders of
|
||||
* the folder related to the given node.
|
||||
*/
|
||||
Zarafa.plugins.mdm.data.MDMHierarchyTreeLoader = Ext.extend(Zarafa.hierarchy.data.HierarchyTreeLoader, {
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Object} config Configuration object
|
||||
*/
|
||||
constructor : function(config)
|
||||
{
|
||||
Zarafa.plugins.mdm.data.MDMHierarchyTreeLoader.superclass.constructor.call(this, config);
|
||||
},
|
||||
|
||||
/**
|
||||
* Add extra attributes for a new {@link Zarafa.hierarchy.ui.FolderNode folderNode} which is about
|
||||
* to be created. This will check the {@link Zarafa.hierarchy.ui.FolderNode#folder folder} to
|
||||
* see what properties must be set.
|
||||
*
|
||||
* Override to provide (@link Zarafa.plugins.mdm.ui.MDMFolderNodeUI MDMFolderNodeUI} to ui provider
|
||||
* @param {Object} attr The attributes which will be used to create the node
|
||||
* @return {Zarafa.hierarchy.ui.FolderNode} The created node
|
||||
*/
|
||||
createNode : function(attr)
|
||||
{
|
||||
var folder = attr.folder;
|
||||
|
||||
if (folder) {
|
||||
if (attr.nodeType === 'rootfolder') {
|
||||
attr.extendedDisplayName = this.tree.hasFilter();
|
||||
}
|
||||
|
||||
attr.leaf = !folder.get('has_subfolder');
|
||||
attr.uiProvider = Zarafa.plugins.mdm.ui.MDMFolderNodeUI;
|
||||
attr.expanded = this.tree.isFolderOpened(folder);
|
||||
attr.allowDrag = !folder.isDefaultFolder();
|
||||
}
|
||||
|
||||
// call parent of parent because of parent class will change ui provider
|
||||
return Zarafa.hierarchy.data.HierarchyTreeLoader.superclass.createNode.apply(this, arguments);
|
||||
}
|
||||
});
|
||||
|
@ -27,6 +27,7 @@ Zarafa.plugins.mdm.dialogs.MDMDeviceContentPanel = Ext.extend(Zarafa.core.ui.Rec
|
||||
}),
|
||||
layout: 'fit',
|
||||
stateful: false,
|
||||
showInfoMask : false,
|
||||
showLoadMask: false,
|
||||
width: isKOE ? 440 : 405,
|
||||
height: isKOE ? 450 : 420,
|
||||
|
@ -32,15 +32,11 @@ Zarafa.plugins.mdm.dialogs.MDMDeviceDetailsTab = Ext.extend(Ext.form.FormPanel,
|
||||
layout: 'form',
|
||||
labelWidth: 150
|
||||
},
|
||||
|
||||
plugins : ['zarafa.recordcomponentupdaterplugin'],
|
||||
items: [
|
||||
this.createDeviceInfoPanel(config.isKoe),
|
||||
this.createVersionInfoPanel(config.isKoe)
|
||||
],
|
||||
listeners: {
|
||||
afterlayout: this.onAfterLayout,
|
||||
scope: this
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
// KOE information
|
||||
@ -156,12 +152,14 @@ Zarafa.plugins.mdm.dialogs.MDMDeviceDetailsTab = Ext.extend(Ext.form.FormPanel,
|
||||
},
|
||||
|
||||
/**
|
||||
* Function which handles the afterlayout event
|
||||
* Which is use to set record values into form fields.
|
||||
* Updates the panel by loading data from the record.
|
||||
*
|
||||
* @param {Zarafa.core.data.IPMRecord} record The record update the panel with.
|
||||
* @param {Boolean} contentReset force the component to perform a full update of the data.
|
||||
*/
|
||||
onAfterLayout: function ()
|
||||
update : function(record, contentReset)
|
||||
{
|
||||
this.getForm().loadRecord(this.record);
|
||||
this.getForm().loadRecord(record);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -33,14 +33,11 @@ Zarafa.plugins.mdm.dialogs.MDMDeviceGeneralTab = Ext.extend(Ext.form.FormPanel,
|
||||
labelWidth: 150,
|
||||
cls: 'mdm-device-panel'
|
||||
},
|
||||
plugins : ['zarafa.recordcomponentupdaterplugin'],
|
||||
items: [
|
||||
this.createDeviceInfoPanel(config),
|
||||
this.createFolderInfoPanel()
|
||||
],
|
||||
listeners: {
|
||||
afterlayout: this.onAfterLayout,
|
||||
scope: this
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
Zarafa.plugins.mdm.dialogs.MDMDeviceGeneralTab.superclass.constructor.call(this, config);
|
||||
@ -173,12 +170,15 @@ Zarafa.plugins.mdm.dialogs.MDMDeviceGeneralTab = Ext.extend(Ext.form.FormPanel,
|
||||
},
|
||||
|
||||
/**
|
||||
* Function which handles the after layoutevent.
|
||||
* Which is use to set record values into form fields.
|
||||
* Updates the panel by loading data from the record into the header template, and
|
||||
* loading the body html into the embedded iframe.
|
||||
*
|
||||
* @param {Zarafa.core.data.IPMRecord} record The record update the panel with.
|
||||
* @param {Boolean} contentReset force the component to perform a full update of the data.
|
||||
*/
|
||||
onAfterLayout: function ()
|
||||
update : function(record, contentReset)
|
||||
{
|
||||
this.getForm().loadRecord(this.record);
|
||||
this.getForm().loadRecord(record);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -198,6 +198,7 @@ Zarafa.plugins.mdm.dialogs.MDMDeviceGeneralTab = Ext.extend(Ext.form.FormPanel,
|
||||
*/
|
||||
onClickManageSharedFolder: function ()
|
||||
{
|
||||
this.dialog.record.opened = false;
|
||||
Zarafa.core.data.UIFactory.openLayerComponent(Zarafa.core.data.SharedComponentType['mdm.dialog.mdmmanagesharedfoldercontentpanel'], undefined, {
|
||||
manager: Ext.WindowMgr,
|
||||
record: this.dialog.record
|
||||
|
@ -2,13 +2,13 @@ Ext.namespace('Zarafa.plugins.mdm.dialogs');
|
||||
|
||||
/**
|
||||
* @class Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderContentPanel
|
||||
* @extends Zarafa.core.ui.ContentPanel
|
||||
* @extends Zarafa.core.ui.RecordContentPanel
|
||||
* @xtype zarafa.managesharedfoldercontentpanel
|
||||
*
|
||||
* This will display a {@link Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderPanel contentpanel}
|
||||
* to show {@link Zarafa.core.data.IPFRecord folders} which are shared with device.
|
||||
*/
|
||||
Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderContentPanel = Ext.extend(Zarafa.core.ui.ContentPanel, {
|
||||
Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderContentPanel = Ext.extend(Zarafa.core.ui.RecordContentPanel, {
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@ -22,6 +22,11 @@ Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderContentPanel = Ext.extend(Zarafa
|
||||
xtype: 'mdm.managesharedfoldercontentpanel',
|
||||
layout: 'fit',
|
||||
title: dgettext('plugin_mdm','Manage Shared Folder'),
|
||||
modal: true,
|
||||
stateful: false,
|
||||
showInfoMask : false,
|
||||
showLoadMask: false,
|
||||
closeOnSave: true,
|
||||
width: 300,
|
||||
height: 350,
|
||||
items: [{
|
||||
|
@ -1,132 +1,217 @@
|
||||
Ext.namespace('Zarafa.plugins.mdm.dialogs');
|
||||
|
||||
/**
|
||||
* @class Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderPanel
|
||||
* @extends Ext.Panel
|
||||
* @xtype mdm.managesharedfolderpanel
|
||||
*
|
||||
* Panel for users to show the {@link Zarafa.core.data.IPFRecord folders} which are shared with device
|
||||
*/
|
||||
Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderPanel = Ext.extend(Ext.Panel, {
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Object} config Configuration structure
|
||||
*/
|
||||
constructor: function (config)
|
||||
{
|
||||
config = config || {};
|
||||
|
||||
Ext.applyIf(config, {
|
||||
xtype: 'mdm.managesharedfolderpanel',
|
||||
layout: {
|
||||
type: 'fit',
|
||||
align: 'stretch'
|
||||
},
|
||||
border: false,
|
||||
header: false,
|
||||
items: [
|
||||
this.createTreePanel()
|
||||
],
|
||||
buttonAlign: 'right',
|
||||
buttons: [{
|
||||
text: _('Apply'),
|
||||
ref: '../okButton',
|
||||
cls: 'zarafa-action',
|
||||
scope: this
|
||||
}, {
|
||||
text: _('Cancel'),
|
||||
ref: '../cancelButton',
|
||||
handler: this.onCancel,
|
||||
scope: this
|
||||
}]
|
||||
});
|
||||
|
||||
Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderPanel.superclass.constructor.call(this, config);
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a {@link Zarafa.hierarchy.ui.Tree treepanel}
|
||||
* which contains all the {@link Zarafa.hierarchy.data.MAPIFolderRecord folders}
|
||||
* on which search get perform.
|
||||
* @return {Object} Configuration object for the tree panel.
|
||||
* @private
|
||||
*/
|
||||
createTreePanel: function ()
|
||||
{
|
||||
return {
|
||||
xtype: 'panel',
|
||||
layout : 'form',
|
||||
defaults: {
|
||||
cls : 'mdm-create-tree-panel-item'
|
||||
},
|
||||
border: false,
|
||||
flex: 1,
|
||||
items: [{
|
||||
xtype: 'displayfield',
|
||||
hideLabel : true,
|
||||
value: dgettext('plugin_mdm','Select folders to sync on your device')
|
||||
}, {
|
||||
xtype: 'mdm.hierarchytree',
|
||||
autoScroll : true,
|
||||
nodeConfig : {
|
||||
checked : false
|
||||
},
|
||||
multiSelect: true,
|
||||
hideShowAllFolders: true,
|
||||
border: true,
|
||||
treeSorter: true,
|
||||
bbarConfig: {
|
||||
hidden: true
|
||||
},
|
||||
enableDD: false,
|
||||
anchor: '100% 90%',
|
||||
ref: '../hierarchyTree'
|
||||
}]
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Initialize the events
|
||||
* @private
|
||||
*/
|
||||
initEvents: function ()
|
||||
{
|
||||
Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderPanel.superclass.initEvents.apply(this, arguments);
|
||||
this.mon(this.hierarchyTree, 'load', this.onTreeNodeLoad, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Fired when the {@link Zarafa.hierarchy.ui.Tree Tree} fires the {@link Zarafa.hierarchy.ui.Tree#load load}
|
||||
* event. This function will try to select those {@link Ext.tree.TreeNode TreeNode} in
|
||||
* {@link Zarafa.hierarchy.ui.Tree Tree} which was shared with respective device. When the given node is not loaded yet, it will try again
|
||||
* later when the event is fired again.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
onTreeNodeLoad: function ()
|
||||
{
|
||||
var subStore = this.dialog.record.getSubStore('sharedfolders');
|
||||
var folders = subStore.getRange();
|
||||
folders.forEach(function (folder) {
|
||||
var node = this.hierarchyTree.getNodeById(folder.get('entryid'));
|
||||
if (Ext.isDefined(node)) {
|
||||
if(node.hasChildNodes()){
|
||||
node.expand();
|
||||
}
|
||||
node.getUI().toggleCheck(true)
|
||||
}
|
||||
}, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Action handler when the user presses the "Cancel" button.
|
||||
* This will close the panel.
|
||||
*/
|
||||
onCancel: function ()
|
||||
{
|
||||
this.dialog.close();
|
||||
}
|
||||
});
|
||||
|
||||
Ext.namespace('Zarafa.plugins.mdm.dialogs');
|
||||
|
||||
/**
|
||||
* @class Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderPanel
|
||||
* @extends Ext.Panel
|
||||
* @xtype mdm.managesharedfolderpanel
|
||||
*
|
||||
* Panel for users to show the {@link Zarafa.core.data.IPFRecord folders} which are shared with device
|
||||
*/
|
||||
Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderPanel = Ext.extend(Ext.Panel, {
|
||||
|
||||
/**
|
||||
* @cfg {Zarafa.plugins.mdm.data.MDMDeviceFolderStore} store contains {@link Zarafa.plugins.mdm.data.MDMDeviceFolderRecord folders} which
|
||||
* is going to shared with device.
|
||||
*/
|
||||
sharedFoldersStore : undefined,
|
||||
|
||||
/**
|
||||
* @cfg {Zarafa.core.data.IPMRecord} record The mail which
|
||||
* is being update by this panel.
|
||||
*/
|
||||
record: null,
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @param {Object} config Configuration structure
|
||||
*/
|
||||
constructor: function (config)
|
||||
{
|
||||
config = config || {};
|
||||
|
||||
Ext.applyIf(config, {
|
||||
xtype: 'mdm.managesharedfolderpanel',
|
||||
layout: {
|
||||
type: 'fit',
|
||||
align: 'stretch'
|
||||
},
|
||||
border: false,
|
||||
header: false,
|
||||
items: [
|
||||
this.createTreePanel()
|
||||
],
|
||||
buttonAlign: 'right',
|
||||
plugins : ['zarafa.recordcomponentupdaterplugin'],
|
||||
buttons: [{
|
||||
text: _('Apply'),
|
||||
handler: this.onApply,
|
||||
cls: 'zarafa-action',
|
||||
scope: this
|
||||
}, {
|
||||
text: _('Cancel'),
|
||||
handler: this.onCancel,
|
||||
scope: this
|
||||
}]
|
||||
});
|
||||
|
||||
Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderPanel.superclass.constructor.call(this, config);
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a {@link Zarafa.hierarchy.ui.Tree treepanel}
|
||||
* which contains all the {@link Zarafa.hierarchy.data.MAPIFolderRecord folders}
|
||||
* on which search get perform.
|
||||
* @return {Object} Configuration object for the tree panel.
|
||||
* @private
|
||||
*/
|
||||
createTreePanel: function ()
|
||||
{
|
||||
return {
|
||||
xtype: 'panel',
|
||||
layout : 'form',
|
||||
defaults: {
|
||||
cls : 'mdm-create-tree-panel-item'
|
||||
},
|
||||
border: false,
|
||||
flex: 1,
|
||||
items: [{
|
||||
xtype: 'displayfield',
|
||||
hideLabel : true,
|
||||
value: dgettext('plugin_mdm','Select folders to sync on your device')
|
||||
}, {
|
||||
xtype: 'mdm.hierarchytree',
|
||||
autoScroll : true,
|
||||
hideOwnTree : true,
|
||||
nodeConfig : {
|
||||
checked : false
|
||||
},
|
||||
multiSelect: true,
|
||||
hideShowAllFolders: true,
|
||||
border: true,
|
||||
treeSorter: true,
|
||||
bbarConfig: {
|
||||
hidden: true
|
||||
},
|
||||
enableDD: false,
|
||||
anchor: '100% 90%',
|
||||
ref: '../hierarchyTree'
|
||||
}]
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Initialize the events
|
||||
* @private
|
||||
*/
|
||||
initEvents: function ()
|
||||
{
|
||||
Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderPanel.superclass.initEvents.apply(this, arguments);
|
||||
this.mon(this.hierarchyTree, {
|
||||
expandnode: this.onTreeNodeExpand,
|
||||
checkchange: this.onTreeNodeCheckChange,
|
||||
click: this.onTreeNodeClick,
|
||||
scope: this
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Fired when the {@link Zarafa.hierarchy.ui.Tree Tree} fires the {@link Zarafa.hierarchy.ui.Tree#nodeexpand nodeexpand}
|
||||
* event.
|
||||
* It will update the hierarchy by selecting child node if it will shared with device.
|
||||
* @private
|
||||
*/
|
||||
onTreeNodeExpand: function ()
|
||||
{
|
||||
if (!this.record.isOpened()) {
|
||||
return false;
|
||||
}
|
||||
this.updateHierarchy();
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the panel by loading data from the record.
|
||||
*
|
||||
* @param {Zarafa.core.data.IPMRecord} record The record update the panel with.
|
||||
* @param {Boolean} contentReset force the component to perform a full update of the data.
|
||||
*/
|
||||
update : function(record, contentReset)
|
||||
{
|
||||
this.record = record;
|
||||
this.sharedFoldersStore = record.getSubStore('sharedfolders');
|
||||
this.updateHierarchy();
|
||||
},
|
||||
|
||||
/**
|
||||
* Function will try to select those {@link Ext.tree.TreeNode TreeNode} in
|
||||
* {@link Zarafa.hierarchy.ui.Tree Tree} which was shared with respective device.
|
||||
*/
|
||||
updateHierarchy : function ()
|
||||
{
|
||||
var folders = this.sharedFoldersStore.getRange();
|
||||
folders.forEach(function (folder) {
|
||||
var node = this.hierarchyTree.getNodeById(folder.get('entryid'));
|
||||
if (Ext.isDefined(node)) {
|
||||
if (node.hasChildNodes()) {
|
||||
node.expand();
|
||||
}
|
||||
node.isNodeSelected = true;
|
||||
node.getUI().toggleCheck(true);
|
||||
}
|
||||
}, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Called when a treeNode is click in tree. The corresponding folder is added to,
|
||||
* or removed from the active folder list depending on the state of the check box.
|
||||
* @param {Ext.tree.TreeNode} treeNode tree node.
|
||||
* @private
|
||||
*/
|
||||
onTreeNodeClick : function(treeNode)
|
||||
{
|
||||
var treeNodeui = treeNode.getUI();
|
||||
if (treeNodeui.checkbox.checked && treeNode.isNodeSelected) {
|
||||
treeNodeui.toggleCheck(false);
|
||||
return false;
|
||||
}
|
||||
treeNode.isNodeSelected = true;
|
||||
this.sharedFoldersStore.addFolder(treeNode.getFolder());
|
||||
treeNodeui.toggleCheck(true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Called when a check box in the calendar tree is toggled. The corresponding folder is added to,
|
||||
* or removed from the active folder list depending on the state of the check box.
|
||||
* @param {Ext.tree.TreeNode} node tree node.
|
||||
* @param {Boolean} checked indicates whether the box is checked.
|
||||
* @private
|
||||
*/
|
||||
onTreeNodeCheckChange : function(node, checked)
|
||||
{
|
||||
if (!checked) {
|
||||
node.isNodeSelected = false;
|
||||
this.sharedFoldersStore.removeFolder(node.getFolder());
|
||||
} else if (checked && !node.isNodeSelected) {
|
||||
this.onTreeNodeClick(node);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Action handler when the user presses the "Apply" button.
|
||||
* This save the record and close the panel.
|
||||
*/
|
||||
onApply : function ()
|
||||
{
|
||||
this.record.save();
|
||||
},
|
||||
|
||||
/**
|
||||
* Action handler when the user presses the "Cancel" button.
|
||||
* This will close the panel.
|
||||
*/
|
||||
onCancel: function ()
|
||||
{
|
||||
this.dialog.close();
|
||||
}
|
||||
});
|
||||
|
||||
Ext.reg('mdm.managesharedfolderpanel', Zarafa.plugins.mdm.dialogs.MDMManageSharedFolderPanel);
|
@ -38,6 +38,25 @@ Zarafa.plugins.mdm.ui.MDMHierarchyTreePanel = Ext.extend(Zarafa.hierarchy.ui.Tre
|
||||
|
||||
// call parent
|
||||
Zarafa.plugins.mdm.ui.MDMHierarchyTreePanel.superclass.initComponent.apply(this, arguments);
|
||||
},
|
||||
|
||||
/**
|
||||
* The filter which is applied for filtering nodes from the
|
||||
* {@link Zarafa.hierarchy.ui.Tree HierarchyTree}.
|
||||
* It will hide own user store.
|
||||
*
|
||||
* @param {Object} folder the folder to filter
|
||||
* @return {Boolean} true to accept the folder
|
||||
*/
|
||||
nodeFilter: function (folder)
|
||||
{
|
||||
var hide = Zarafa.plugins.mdm.ui.MDMHierarchyTreePanel.superclass.nodeFilter.apply(this, arguments);
|
||||
|
||||
if(hide && this.hideOwnTree) {
|
||||
hide = !folder.getMAPIStore().isDefaultStore();
|
||||
}
|
||||
|
||||
return hide;
|
||||
}
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user