category fix
This commit is contained in:
@@ -32,6 +32,9 @@ import Collection from 'collection';
|
||||
|
||||
class TreeCollection extends Collection {
|
||||
|
||||
/**
|
||||
* @return {TreeCollection}
|
||||
*/
|
||||
createSeed() {
|
||||
const seed = new this.constructor();
|
||||
|
||||
@@ -61,37 +64,40 @@ class TreeCollection extends Collection {
|
||||
*/
|
||||
this.categoryData = response.data || null;
|
||||
|
||||
const f = (l, depth) => {
|
||||
l.forEach(d => {
|
||||
d.depth = depth;
|
||||
const prepare = (list, depth) => {
|
||||
list.forEach(data => {
|
||||
data.depth = depth;
|
||||
|
||||
const c = this.createSeed();
|
||||
const childCollection = this.createSeed();
|
||||
|
||||
if (d.childList) {
|
||||
if (d.childList.length) {
|
||||
f(d.childList, depth + 1);
|
||||
c.set(d.childList);
|
||||
d.childCollection = c;
|
||||
childCollection.parentId = data.id;
|
||||
|
||||
if (data.childList) {
|
||||
if (data.childList.length) {
|
||||
prepare(data.childList, depth + 1);
|
||||
|
||||
childCollection.set(data.childList);
|
||||
data.childCollection = childCollection;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
d.childCollection = c;
|
||||
data.childCollection = childCollection;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (d.childList === null) {
|
||||
d.childCollection = null;
|
||||
if (data.childList === null) {
|
||||
data.childCollection = null;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
d.childCollection = c;
|
||||
data.childCollection = childCollection;
|
||||
});
|
||||
};
|
||||
|
||||
f(list, 0);
|
||||
prepare(list, 0);
|
||||
|
||||
return list;
|
||||
}
|
||||
@@ -104,8 +110,6 @@ class TreeCollection extends Collection {
|
||||
options.data.parentId = this.parentId;
|
||||
}
|
||||
|
||||
options.data.maxDepth = this.maxDepth;
|
||||
|
||||
return super.fetch(options);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -500,7 +500,6 @@ class ListWithCategories extends ListView {
|
||||
|
||||
collection.setOrder(null, null);
|
||||
collection.url = `${collection.entityType}/action/listTree`;
|
||||
collection.maxDepth = null;
|
||||
collection.data.checkIfEmpty = true;
|
||||
|
||||
if (!this.getAcl().checkScope(this.scope, 'create')) {
|
||||
|
||||
@@ -233,7 +233,6 @@ class ListTreeRecordItemView extends View {
|
||||
this.getCollectionFactory().create(this.scope, collection => {
|
||||
collection.url = this.collection.url;
|
||||
collection.parentId = this.model.id;
|
||||
collection.maxDepth = null;
|
||||
|
||||
Espo.Ui.notify(' ... ');
|
||||
|
||||
|
||||
@@ -285,12 +285,6 @@ class ListTreeRecordView extends ListRecordView {
|
||||
}
|
||||
|
||||
this.collection.fetch();
|
||||
|
||||
/*this.collection.push(model);
|
||||
|
||||
this.buildRows(() => {
|
||||
this.render();
|
||||
});*/
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user