Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Fix issue with updating an item's group #2985

Merged
merged 5 commits into from
Apr 28, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions lib/timeline/component/ItemSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1196,14 +1196,6 @@ ItemSet.prototype._addItem = function(item) {
* @private
*/
ItemSet.prototype._updateItem = function(item, itemData) {
var oldGroupId = item.data.group;
var oldSubGroupId = item.data.subgroup;

if (oldGroupId != itemData.group) {
var oldGroup = this.groups[oldGroupId];
if (oldGroup) oldGroup.remove(item);
}

// update the items data (will redraw the item when displayed)
item.setData(itemData);

Expand All @@ -1214,14 +1206,6 @@ ItemSet.prototype._updateItem = function(item, itemData) {
} else if (group && group.data && group.data.showNested) {
item.groupShowing = true;
}
// update group
if (group) {
if (oldGroupId != item.data.group) {
group.add(item);
} else if (oldSubGroupId != item.data.subgroup) {
group.changeSubgroup(item, oldSubGroupId);
}
}
};

/**
Expand Down Expand Up @@ -1587,10 +1571,11 @@ ItemSet.prototype._moveToGroup = function(item, groupId) {
var oldGroup = item.parent;
oldGroup.remove(item);
oldGroup.order();

item.data.group = group.groupId;

group.add(item);
group.order();

item.data.group = group.groupId;
}
};

Expand Down
7 changes: 6 additions & 1 deletion lib/timeline/component/item/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,14 @@ Item.prototype.unselect = function() {
*/
Item.prototype.setData = function(data) {
var groupChanged = data.group != undefined && this.data.group != data.group;
if (groupChanged) {
if (groupChanged && this.parent != null) {
this.parent.itemSet._moveToGroup(this, data.group);
}

var subGroupChanged = data.subgroup != undefined && this.data.subgroup != data.subgroup;
if (subGroupChanged && this.parent != null) {
this.parent.changeSubgroup(this, this.data.subgroup, data.subgroup);
}

this.data = data;
this._updateEditStatus();
Expand Down