dev
This commit is contained in:
@@ -51,26 +51,55 @@ Espo.define('Views.Record.ListTreeItem', 'View', function (Dep) {
|
||||
}
|
||||
},
|
||||
|
||||
setup: function () {
|
||||
this.isUnfolded = false;
|
||||
this.scope = this.model.name;
|
||||
setIsSelected: function () {
|
||||
this.isSelected = true;
|
||||
this.selectedData.id = this.model.id;
|
||||
|
||||
var path = this.selectedData.path;
|
||||
var names = this.selectedData.names;
|
||||
path.length = 0;
|
||||
var view = this;
|
||||
while (1) {
|
||||
path.unshift(view.model.id);
|
||||
names[view.model.id] = view.model.get('name');
|
||||
if (view.getParentView().level) {
|
||||
view = view.getParentView().getParentView();
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
setup: function () {
|
||||
if ('level' in this.options) {
|
||||
this.level = this.options.level;
|
||||
}
|
||||
if ('isSelected' in this.options) {
|
||||
this.isSelected = this.options.isSelected;
|
||||
}
|
||||
if ('selectedData' in this.options) {
|
||||
this.selectedData = this.options.selectedData;
|
||||
}
|
||||
|
||||
this.scope = this.model.name;
|
||||
|
||||
this.isUnfolded = false;
|
||||
|
||||
|
||||
var childCollection = this.model.get('childCollection');
|
||||
|
||||
if (this.isUnfolded) {
|
||||
if (childCollection) {
|
||||
this.createChildren();
|
||||
}
|
||||
if (childCollection === false) {
|
||||
this.isEnd = true;
|
||||
} else {
|
||||
if (childCollection === false) {
|
||||
this.isEnd = true;
|
||||
if (childCollection) {
|
||||
childCollection.models.forEach(function (model) {
|
||||
if (~this.selectedData.path.indexOf(model.id)) {
|
||||
this.isUnfolded = true;
|
||||
}
|
||||
}, this);
|
||||
if (this.isUnfolded) {
|
||||
this.createChildren();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +121,7 @@ Espo.define('Views.Record.ListTreeItem', 'View', function (Dep) {
|
||||
el: this.options.el + ' > .children',
|
||||
createDisabled: this.options.createDisabled,
|
||||
level: this.level + 1,
|
||||
selectedId: this.getParentView().selectedId
|
||||
selectedData: this.selectedData
|
||||
}, callback);
|
||||
},
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ Espo.define('Views.Record.ListTree', 'Views.Record.List', function (Dep) {
|
||||
|
||||
createDisabled: true,
|
||||
|
||||
selectedId: null,
|
||||
selectedData: null,
|
||||
|
||||
level: 0,
|
||||
|
||||
@@ -65,12 +65,18 @@ Espo.define('Views.Record.ListTree', 'Views.Record.List', function (Dep) {
|
||||
if ('level' in this.options) {
|
||||
this.level = this.options.level;
|
||||
}
|
||||
if ('selectedId' in this.options) {
|
||||
this.selectedId = this.options.selectedId;
|
||||
if (this.level == 0) {
|
||||
this.selectedData = {
|
||||
id: null,
|
||||
path: [],
|
||||
names: {}
|
||||
};
|
||||
}
|
||||
if ('selectedData' in this.options) {
|
||||
this.selectedData = this.options.selectedData;
|
||||
}
|
||||
Dep.prototype.setup.call(this);
|
||||
|
||||
|
||||
this.on('select', function (o) {
|
||||
if (o.id) {
|
||||
this.$el.find('a.link[data-id="'+o.id+'"]').addClass('text-bold');
|
||||
@@ -87,13 +93,11 @@ Espo.define('Views.Record.ListTree', 'Views.Record.List', function (Dep) {
|
||||
},
|
||||
|
||||
setSelected: function (id) {
|
||||
this.selectedId = id;
|
||||
|
||||
this.rows.forEach(function (key) {
|
||||
var view = this.getView(key);
|
||||
|
||||
if (view.model.id == id) {
|
||||
view.isSelected = true;
|
||||
view.setIsSelected();
|
||||
} else {
|
||||
view.isSelected = false;
|
||||
}
|
||||
@@ -107,7 +111,6 @@ Espo.define('Views.Record.ListTree', 'Views.Record.List', function (Dep) {
|
||||
this.checkedList = [];
|
||||
this.rows = [];
|
||||
|
||||
|
||||
if (this.collection.length > 0) {
|
||||
this.wait(true);
|
||||
|
||||
@@ -121,8 +124,8 @@ Espo.define('Views.Record.ListTree', 'Views.Record.List', function (Dep) {
|
||||
el: this.options.el + ' ' + this.getRowSelector(model.id),
|
||||
createDisabled: this.createDisabled,
|
||||
level: this.level,
|
||||
isSelected: model.id == this.selectedId,
|
||||
selectedId: this.selectedId
|
||||
isSelected: model.id == this.selectedData.id,
|
||||
selectedData: this.selectedData
|
||||
}, function () {
|
||||
this.rows.push('row-' + i);
|
||||
built++;
|
||||
|
||||
Reference in New Issue
Block a user