Browse Source

Nested groups order logic (#3206)

* Fix sorting of nestedgroups when groups added after initial groups setting

* Fix nesteded groups logic when adding and removing

* Remove empty lines

* Fix comments from PR

* Remove spaces from empty line

* Fix PR review comments
revert-3409-performance
Yotam Berkowitz 7 years ago
committed by GitHub
parent
commit
8c8f21d369
1 changed files with 30 additions and 9 deletions
  1. +30
    -9
      lib/timeline/component/ItemSet.js

+ 30
- 9
lib/timeline/component/ItemSet.js View File

@ -146,6 +146,28 @@ function ItemSet(body, options) {
this.groupListeners = {
'add': function (event, params, senderId) { // eslint-disable-line no-unused-vars
me._onAddGroups(params.items);
if (me.groupsData && me.groupsData.length > 0) {
var groupsData = me.groupsData.getDataSet();
groupsData.get().forEach(function (groupData) {
if (groupData.nestedGroups) {
if (groupData.showNested != false) {
groupData.showNested = true;
}
var updatedGroups = [];
groupData.nestedGroups.forEach(function(nestedGroupId) {
var updatedNestedGroup = groupsData.get(nestedGroupId);
if (!updatedNestedGroup) { return; }
updatedNestedGroup.nestedInGroup = groupData.id;
if (groupData.showNested == false) {
updatedNestedGroup.visible = false;
}
updatedGroups = updatedGroups.concat(updatedNestedGroup);
});
groupsData.update(updatedGroups, senderId);
}
});
}
},
'update': function (event, params, senderId) { // eslint-disable-line no-unused-vars
me._onUpdateGroups(params.items);
@ -1662,21 +1684,20 @@ ItemSet.prototype._onGroupClick = function (event) {
if (!group || !group.nestedGroups) return;
var groupsData = this.groupsData;
if (this.groupsData instanceof DataView) {
groupsData = this.groupsData.getDataSet()
}
var groupsData = this.groupsData.getDataSet();
group.showNested = !group.showNested;
var nestingGroup = groupsData.get(group.groupId)
if (nestingGroup.showNested == undefined) { nestingGroup.showNested = true; }
nestingGroup.showNested = !nestingGroup.showNested;
var nestedGroups = groupsData.get(group.nestedGroups).map(function(nestedGroup) {
if (nestedGroup.visible == undefined) { nestedGroup.visible = true; }
nestedGroup.visible = !!group.showNested;
nestedGroup.visible = nestingGroup.showNested;
return nestedGroup;
});
groupsData.update(nestedGroups);
if (group.showNested) {
groupsData.update(nestedGroups.concat(nestingGroup));
if (nestingGroup.showNested) {
util.removeClassName(group.dom.label, 'collapsed');
util.addClassName(group.dom.label, 'expanded');
} else {

Loading…
Cancel
Save