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);
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user