Commit 89a7fe42 authored by Frank Bergmann's avatar Frank Bergmann

- Removed redundand local files

parent d6baa866
/*
* Data related to a local file.
*
* This data is provided by the electron-tree module.
*/
Ext.define('POSync.model.LocalFile', {
extend: 'Ext.data.TreeModel',
idProperty: 'path',
fields: [
'path', // The full path of the file or directory
'name', // The name (with extension) of the file or directory
'extension', // The extension of the file or directory
'size', // The size in bytes
'type', // Either 'directory' or 'file'
'children', // List of files and subdirectories (for directories only)
// Added for internal sencha management
'expandable', // true if directory contents are shown
'expanded', // true if directory contents are shown
'leaf', // true if node has no children
'sha1',
'date',
'mime_type',
'iconCls'
],
proxy: {
type: 'memory',
reader: {
type: 'json',
root: 'children'
}
}
});
/*
* DataStore for local files.
*
* Proxy URL depends on application's configuration settings.
*/
Ext.define('POSync.store.LocalFiles', {
extend: 'Ext.data.TreeStore',
requires: 'POSync.model.LocalFile',
model: 'POSync.model.LocalFile',
isLoaded: null, // ID of project loaded
root: {
expanded: true,
children: []
},
/* Load the store with the specified tree */
loadTree: function (tree) {
var proxy = this.getProxy();
proxy.data = tree;
this.load();
},
/**
* Check if a file with the given path exists
*/
searchUsingPathArray: function(pathArray) {
var me = this;
var root = me.getRootNode();
// console.log(root);
// Iterate through the pathArray elements from
// the top to find the file in the local folder
var node = root;
for (var i = 0; i < pathArray.length; i++) {
var path = pathArray[i];
// Check all children
var child = null;
var children = node.children;
if (!children) return null;
for (var j = 0; j < children.length; j++) {
var childName = children[j].get('name');
if (path == childName) {
child = children[j];
}
}
if (!child) return null;
node = child;
}
}
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment