-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Timeline: More editable control #2305
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea of this PR is good, but there are some logic problems... This will cause some breaking changes.
Please review the different scenarios to make sure the behavior is as expected
lib/timeline/component/ItemSet.js
Outdated
| // override options.editable | ||
| if ((item.editable === false || !item.editable) | ||
| && !this.options.editable.overrideItems) { | ||
| if (!item.editable.updateTime && !item.editable.updateGroup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This predicate is in the ItemSet._onDragStart, my understanding is that remove is only concerned with Item._repaintDeleteButton. Shouldn't this predicate not be affected by the value of remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops you're right. I didn't notice the function it was in. Ignore this comment
lib/timeline/component/ItemSet.js
Outdated
|
|
||
| var updateTimeAllowed = me.options.editable.updateTime || ( | ||
| props.item.editable === true && !me.options.editable.overrideItems); | ||
| var updateTimeAllowed = (me.options.editable.overrideItems && me.options.editable.updateTime) || ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This overrides the previous default... what happens when:
me.options.editable.overrideItems==false and me.options.editable.updateTime==true?
updating time in this case should be allowed even if props.item.editable.updateTime is not defined (or false, as set in default)
lib/timeline/component/ItemSet.js
Outdated
| var updateGroupAllowed = me.options.editable.updateGroup || | ||
| props.item.editable === true; | ||
| var updateGroupAllowed = (me.options.editable.overrideItems && me.options.editable.updateGroup) || | ||
| props.item.editable.updateGroup; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about: !me.options.editable.overrideItems && me.options.editable.updateGroup? You should be able to update groups but in this logic, you can't...
lib/timeline/component/item/Item.js
Outdated
| this.options.editable.overrideItems) | ||
| || (this.data.editable === true && | ||
| || (this.editable.remove && | ||
| !this.options.editable.overrideItems); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about: this.data.editable.remove && !this.options.editable.overrideItems?
7f0b987 to
13a8695
Compare
|
@yotamberk Prior to this PR, there was no default for Thanks for catching the logic flaws. |
lib/timeline/component/ItemSet.js
Outdated
| var updateGroupAllowed = me.options.editable.updateGroup || | ||
| (!this.options.editable.overrideItems && selectedItem.editable === true); | ||
| var updateGroupAllowed = (me.options.editable.overrideItems && this.options.editable.updateGroup) || | ||
| (!this.options.editable.overrideItems && (!selectedItem.editable || selectedItem.editable.updateGroup)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still something weird with the logic. Shouldn't it should be:
(me.options.editable.overrideItems && this.options.editable.updateGroup) || (!this.options.editable.overrideItems && (selectedItem.editable == true || selectedItem.editable.updateGroup))?
lib/timeline/component/ItemSet.js
Outdated
| var updateTimeAllowed = me.options.editable.updateTime || ( | ||
| props.item.editable === true && !me.options.editable.overrideItems); | ||
| var updateTimeAllowed = ((me.options.editable.overrideItems || !props.item.editable ) && me.options.editable.updateTime) || ( | ||
| (props.item.editable && props.item.editable.updateTime) && !me.options.editable.overrideItems); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but here too.
(me.options.editable.overrideItems && me.options.editable.updateTime) || ( (!me.options.editable.overrideItems && (props.item.editable==true || props.item.editable.updateTime));
lib/timeline/component/item/Item.js
Outdated
| || (this.data.editable === true && | ||
| (this.options.editable.overrideItems || !this.editable)) | ||
| || (this.editable && this.editable.remove && | ||
| !this.options.editable.overrideItems); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too:
(this.options.editable.overrideItems && this.options.editable.remove) || (!this.options.editable.overrideItems && (this.editable==true || this.editable.remove)
lib/timeline/component/ItemSet.js
Outdated
|
|
||
| var updateGroupAllowed = me.options.editable.updateGroup || | ||
| props.item.editable === true; | ||
| var updateGroupAllowed = ((me.options.editable.overrideItems || !props.item.editable ) && me.options.editable.updateGroup) || ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too:
(me.options.editable.overrideItems && me.options.editable.updateGroup) || (!me.options.editable.overrideItems && (me.options.editable==true || me.options.editable.updateGroup)
|
I hope I'm not discouraging you. The logic is kind of messy and I think it needs to be cleaned up a bit before being approved |
* Fixed bug introduced in visjs#2284 where overrideItems is set to true when boolean is provided * Added the option of supplying object to item.editable with updateTime, updateGroup, and remove functioning similarly to timeline.editable but only on a single item * Updated Documentation to reflect the new feature * Updated the individualEditableItems example page to show feature usage.
13a8695 to
f2e9a4b
Compare
|
@yotamberk It's not discouraging at all. You are right that it was still messy. While it was "working" to pass all the tests I could come up with, the predicates were not standardized even though they were doing the same basic tests. I decided to formalize this logic:
The abstract predicate that applies in all cases is
I have changed all three predicates you suggested changes on to use this form. The predicate at line 1460 of itemset.js is actually redundant as Your code suggestions included |
|
MUCH BETTER! Did you check the logic matrix?
I'm still wondering about that. seems a little weird that it's different than |
|
@simo9000 Thanks! Thats a nice improvement! |
I resisted the urge to do this but I didn't see a way around it. #2284 provided a clear means of decided when level of options was in control of the editable behavior of items. However it fell short in that when individual items are determined to be editable (and
overrideItemsis false), it enabled all three edit behaviors. This enables further control over individual item behavior but allowingupdateTime,updateGroup, andremoveto be toggled at the item level. I am glad I chose to pursue this as I found a bug which was introduced in #2284 wheretimeline.editable == truewould also setoverrideItemsto true.