|
|
@ -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(); |
|
|
|