(function (module) {
    module.factory('gridFiles', gridFiles);

    function gridFiles() {
        function compareFileEntry(fentry1, fentry2) {
            if (fentry1.name < fentry2.name) {
                return -1;
            } else if (fentry1.name > fentry2.name) {
                return 1;
            } else {
                return 0;
            }
        }

        function createGridChildren(filesChildren) {
            var children = [];
            filesChildren.forEach(function (entry) {
                var centry;
                if (entry._type == 'directory') {
                    centry = createDirectoryEntry(entry);
                } else {
                    centry = createFileEntry(entry);
                }
                children.push(centry);
            });
            return children;
        }

        function createDirectoryEntry(entry) {
            return {
                group: true,
                expanded: false,
                data: {
                    name: entry.name,
                    _type: 'directory',
                    id: entry.id,
                    size: '',
                    childrenLoaded: false
                },
                children: []
            };
        }

        function createFileEntry(entry) {
            return {
                group: false,
                data: {
                    name: entry.name,
                    _type: 'file',
                    size: entry.size,
                    mediatype: entry.mediatype,
                    id: entry.id
                }
            };
        }

        return {
            toGrid: function (files) {
                var gridData = [
                    {
                        group: true,
                        expanded: true,
                        data: {
                            name: files.name,
                            _type: files._type,
                            id: files.id,
                            childrenLoaded: true
                        },
                        children: []
                    }
                ];
                files.children.sort(compareFileEntry);
                gridData[0].children = createGridChildren(files.children);
                return gridData;
            },

            toGridChildren(fentry) {
                fentry.children.sort(compareFileEntry);
                return createGridChildren(fentry.children);
            },

            findEntry(files, id) {
                var treeModel = new TreeModel(),
                    root = treeModel.parse(files);
                var entry = root.first({strategy: 'pre'}, function (node) {
                    return node.model.data.id === id;
                });
                return entry;
            }
        }
    }
}(angular.module('materialscommons')));

@@ -869,32 +869,64 @@
 yEntry(entry) %7B%0A
+            console.dir(entry);%0A
             retu
@@ -922,32 +922,32 @@
        return %7B%0A
-
                 
@@ -1046,32 +1046,70 @@
 me: entry.name,%0A
+                    path: entry.path,%0A
                 
@@ -1502,16 +1502,54 @@
 'file',%0A
+                    path: entry.path,%0A
         
@@ -1965,24 +1965,70 @@
 files.name,%0A
+                            path: files.path,%0A
             
@@ -2762,19 +2762,14 @@
     
-var entry =
+return
  roo
@@ -2867,16 +2867,16 @@
 === id;%0A
+
         
@@ -2891,38 +2891,8 @@
 %7D);%0A
-                return entry;%0A
     

Set path for top level directory.