Browse Source

Drag and drop custom fields (#2872)

* Fix redraw order

* Fix error when option is not defined

* Allow template labels

* Add .travis.yml file

* Add experiment travis code

* Fix react example

* Fix drop event item properties

* Fix review comments
gemini
yotamberk 7 years ago
committed by GitHub
parent
commit
bcbce0a2bc
1 changed files with 10 additions and 18 deletions
  1. +10
    -18
      lib/timeline/component/ItemSet.js

+ 10
- 18
lib/timeline/component/ItemSet.js View File

@ -2031,25 +2031,17 @@ ItemSet.prototype._onAddItem = function (event) {
var scale = this.body.util.getScale();
var step = this.body.util.getStep();
var newItemData = {
start: snap ? snap(start, scale, step) : start,
content: 'new item'
};
var newItemData;
if (event.type == 'drop') {
var itemData = JSON.parse(event.dataTransfer.getData("text"))
newItemData.content = itemData.content; // content is required
newItemData.type = itemData.type || 'box';
newItemData[this.itemsData._fieldId] = itemData.id || util.randomUUID();
if (itemData.type == 'range' || (itemData.end && itemData.start)) {
if (!itemData.end) {
var end = this.body.util.toTime(x + this.props.width / 5);
newItemData.end = snap ? snap(end, scale, step) : end;
} else {
newItemData.end = itemData.end;
newItemData.start = itemData.start;
}
newItemData = JSON.parse(event.dataTransfer.getData("text"))
newItemData.content = newItemData.content ? newItemData.content : 'new item'
newItemData.start = newItemData.start ? newItemData.start : (snap ? snap(start, scale, step) : start)
newItemData.type = newItemData.type || 'box';
newItemData[this.itemsData._fieldId] = newItemData.id || util.randomUUID();
if (newItemData.type == 'range' && !newItemData.end) {
var end = this.body.util.toTime(x + this.props.width / 5);
newItemData.end = snap ? snap(end, scale, step) : end;
}
} else {
newItemData[this.itemsData._fieldId] = util.randomUUID();

Loading…
Cancel
Save