1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 15:38:15 +00:00

Wiki optimized third (#2406)

This commit is contained in:
shanshuirenjia
2018-09-29 15:47:53 +08:00
committed by Daniel Pan
parent 5cffd4cb69
commit 3ab4cbff4f
22 changed files with 612 additions and 107 deletions

View File

@@ -1,13 +1,15 @@
class Node {
static deserializefromJson(object) {
const {name, type, size, last_update_time, isExpanded = true, children = []} = object;
const {name, type, size, last_update_time, permission, parent_path, isExpanded = true, children = []} = object;
const node = new Node({
name,
type,
size,
last_update_time,
permission,
parent_path,
isExpanded,
children: children.map(item => Node.deserializefromJson(item)),
});
@@ -15,11 +17,13 @@ class Node {
return node;
}
constructor({name, type, size, last_update_time, isExpanded, children}) {
constructor({name, type, size, last_update_time, permission, parent_path, isExpanded, children}) {
this.name = name;
this.type = type;
this.size = size;
this.last_update_time = last_update_time;
this.permission = permission;
this.parent_path = parent_path;
this.isExpanded = isExpanded !== undefined ? isExpanded : true;
this.children = children ? children : [];
this.parent = null;
@@ -31,6 +35,8 @@ class Node {
type: this.type,
size: this.size,
last_update_time: this.last_update_time,
permission: this.permission,
parent_path: this.parent_path,
isExpanded: this.isExpanded
});
n.children = this.children.map(child => {
@@ -101,6 +107,8 @@ class Node {
type: this.type,
size: this.size,
last_update_time: this.last_update_time,
permission: this.permission,
parent_path: this.parent_path,
isExpanded: this.isExpanded,
children: children
}

View File

@@ -186,6 +186,8 @@ class Tree {
type: model.type,
size: bytesToSize(model.size),
last_update_time: moment.unix(model.last_update_time).fromNow(),
permission: model.permission,
parent_path: model.parent_path,
isExpanded: false
});
if (model.children instanceof Array) {
@@ -214,6 +216,8 @@ class Tree {
type: nodeObj.type,
size: bytesToSize(nodeObj.size),
last_update_time: moment.unix(nodeObj.last_update_time).fromNow(),
permission: nodeObj.permission,
parent_path: nodeObj.parent_path,
isExpanded: false
});
node.parent_path = nodeObj.parent_path;
@@ -240,6 +244,8 @@ class Tree {
type: node.type,
size: bytesToSize(node.size),
last_update_time: moment.unix(node.last_update_time).fromNow(),
permission: node.permission,
parent_path: node.parent_path,
isExpanded: false
});
if (node.children instanceof Array) {