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

Fix regression introduced in #2743. #2796

Merged
merged 1 commit into from
Feb 27, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions lib/timeline/component/item/Item.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,11 @@ Item.prototype._updateEditStatus = function() {
updateGroup: this.data.editable,
remove: this.data.editable
}
} else if (typeof this.data.editable === 'object') {
// TODO: in vis.js 5.0, we should change this to not reset options from the timeline configuration.
// Basically just remove the next line...
this.editable = {};
util.selectiveExtend(['updateTime', 'updateGroup', 'remove'], this.editable, this.data.editable);
}
}
}
Expand Down
100 changes: 100 additions & 0 deletions test/PointItem.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,104 @@ describe('Timeline PointItem', function () {
assert.equal(pointItem.dom.dot.className, "vis-item vis-dot vis-editable");
assert.equal(pointItem.dom.point.className, "vis-item vis-point vis-editable");
});

it('should redraw() and then have the correct property for an editable: {updateTime} override item (with boolean option)', function() {
var pointItem = new PointItem({start: now.toDate(), editable: {updateTime: true}}, null, {editable: true});
var parent = TestSupport.buildMockItemSet();
pointItem.setParent(parent);
pointItem.redraw();
assert.equal(pointItem.editable.updateTime, true);
assert.equal(pointItem.editable.updateGroup, undefined);
assert.equal(pointItem.editable.remove, undefined);
});

it('should redraw() and then have the correct property for an editable: {updateTime} override item (with boolean option false)', function() {
var pointItem = new PointItem({start: now.toDate(), editable: {updateTime: true}}, null, {editable: false});
var parent = TestSupport.buildMockItemSet();
pointItem.setParent(parent);
pointItem.redraw();
assert.equal(pointItem.editable.updateTime, true);
assert.equal(pointItem.editable.updateGroup, undefined);
assert.equal(pointItem.editable.remove, undefined);
});

it('should redraw() and then have the correct property for an editable: {updateGroup} override item (with boolean option)', function() {
var pointItem = new PointItem({start: now.toDate(), editable: {updateGroup: true}}, null, {editable: true});
var parent = TestSupport.buildMockItemSet();
pointItem.setParent(parent);
pointItem.redraw();
assert.equal(pointItem.editable.updateTime, undefined);
assert.equal(pointItem.editable.updateGroup, true);
assert.equal(pointItem.editable.remove, undefined);
});

it('should redraw() and then have the correct property for an editable: {updateGroup} override item (with boolean option false)', function() {
var pointItem = new PointItem({start: now.toDate(), editable: {updateGroup: true}}, null, {editable: false});
var parent = TestSupport.buildMockItemSet();
pointItem.setParent(parent);
pointItem.redraw();
assert.equal(pointItem.editable.updateTime, undefined);
assert.equal(pointItem.editable.updateGroup, true);
assert.equal(pointItem.editable.remove, undefined);
});

it('should redraw() and then have the correct property for an editable: {remove} override item (with boolean option)', function() {
var pointItem = new PointItem({start: now.toDate(), editable: {remove: true}}, null, {editable: true});
var parent = TestSupport.buildMockItemSet();
pointItem.setParent(parent);
pointItem.redraw();
assert.equal(pointItem.editable.updateTime, undefined);
assert.equal(pointItem.editable.updateGroup, undefined);
assert.equal(pointItem.editable.remove, true);
});

it('should redraw() and then have the correct property for an editable: {remove} override item (with boolean option false)', function() {
var pointItem = new PointItem({start: now.toDate(), editable: {remove: true}}, null, {editable: false});
var parent = TestSupport.buildMockItemSet();
pointItem.setParent(parent);
pointItem.redraw();
assert.equal(pointItem.editable.updateTime, undefined);
assert.equal(pointItem.editable.updateGroup, undefined);
assert.equal(pointItem.editable.remove, true);
});

it('should redraw() and then have the correct property for an editable: {updateTime, remove} override item (with boolean option)', function() {
var pointItem = new PointItem({start: now.toDate(), editable: {updateTime: true, remove: true}}, null, {editable: true});
var parent = TestSupport.buildMockItemSet();
pointItem.setParent(parent);
pointItem.redraw();
assert.equal(pointItem.editable.updateTime, true);
assert.equal(pointItem.editable.updateGroup, undefined);
assert.equal(pointItem.editable.remove, true);
});

it('should redraw() and then have the correct property for an editable: {updateTime, remove} override item (with boolean option false)', function() {
var pointItem = new PointItem({start: now.toDate(), editable: {updateTime: true, remove: true}}, null, {editable: false});
var parent = TestSupport.buildMockItemSet();
pointItem.setParent(parent);
pointItem.redraw();
assert.equal(pointItem.editable.updateTime, true);
assert.equal(pointItem.editable.updateGroup, undefined);
assert.equal(pointItem.editable.remove, true);
});

it('should redraw() and then have the correct property for an editable: {updateTime, updateGroup, remove} override item (with boolean option)', function() {
var pointItem = new PointItem({start: now.toDate(), editable: {updateTime: true, updateGroup: true, remove: true}}, null, {editable: true});
var parent = TestSupport.buildMockItemSet();
pointItem.setParent(parent);
pointItem.redraw();
assert.equal(pointItem.editable.updateTime, true);
assert.equal(pointItem.editable.updateGroup, true);
assert.equal(pointItem.editable.remove, true);
});

it('should redraw() and then have the correct property for an editable: {updateTime, updateGroup, remove} override item (with boolean option false)', function() {
var pointItem = new PointItem({start: now.toDate(), editable: {updateTime: true, updateGroup: true, remove: true}}, null, {editable: false});
var parent = TestSupport.buildMockItemSet();
pointItem.setParent(parent);
pointItem.redraw();
assert.equal(pointItem.editable.updateTime, true);
assert.equal(pointItem.editable.updateGroup, true);
assert.equal(pointItem.editable.remove, true);
});
});