Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Undo Not Working (Read 608 times)
alukes
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 47
Joined: Jul 1st, 2011
Undo Not Working
Jun 14th, 2020 at 9:33pm
Print Post  
When I drag and drop a node, delete, then click undo, the node fails to reappear. Also if a drag from one node to another to create a link, delete the link, then click undo, the link fails to reappear.

I have attached a file with the sections of code I think I need to make it work. Let me know what I am missing.

Thanks
  

undo_question.txt ( 4 KB | 22 Downloads )
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 2281
Joined: Oct 19th, 2005
Re: Undo Not Working
Reply #1 - Jun 15th, 2020 at 12:49pm
Print Post  
Try calling only diagram.deleteSelection() from onDelete. This is what the control calls in response to Delete key press, and undo/redo seems to work for it in my test project.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
alukes
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 47
Joined: Jul 1st, 2011
Re: Undo Not Working
Reply #2 - Jun 15th, 2020 at 3:56pm
Print Post  
tried:

function onDelete() {
    diagram.deleteSelection();
}

no help
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 2281
Joined: Oct 19th, 2005
Re: Undo Not Working
Reply #3 - Jun 15th, 2020 at 4:55pm
Print Post  
What's the onDelete function called in response to? Are you sure undo is enabled at that point?
  
Back to top
 
IP Logged
 
alukes
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 47
Joined: Jul 1st, 2011
Re: Undo Not Working
Reply #4 - Jun 16th, 2020 at 3:15am
Print Post  
After I dragged and added a node, I used the delete button with the X in the toolbar.

I using debugger I verified that the onDelete was called and the diagram.deleteSelections() command was executed.

This is the order that I start up mindfusion components.

$(document).ready(function () {
diagram = AbstractionLayer.createControl(Diagram, null, null, null, $("#diagram")[0]);
diagram.setUndoEnabled(true);
nodeList = AbstractionLayer.createControl(NodeListView, null, null, null, $('#nodeList')[0]);
nodeList.setTargetView($("diagram")[0]);
initNodeList(nodeList, diagram);
// overview.setDiagram(diagram);
overview = AbstractionLayer.createControl(Overview, null, null, null, $("#overview")[0]);
overview.setDiagram(diagram);
// create an ZoomControl component that wraps the "zoomer" canvas
var zoomer = MindFusion.Controls.ZoomControl.create($("#zoomer")[0]);
zoomer.setTarget(diagram);
});

InitNodeList(nodeList, diagram) creates the NodeList.

Should I change the order of the above commands? Many diagram set commands and diagram event listeners were omitted.
« Last Edit: Jun 16th, 2020 at 5:19am by alukes »  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 2281
Joined: Oct 19th, 2005
Re: Undo Not Working
Reply #5 - Jun 16th, 2020 at 6:39am
Print Post  
Check if there isn't a startCompositeOperation call somewhere without matching commitCompositeOperation. I imagine undo() could fail if the diagram is still collecting undo records for a composite command.
  
Back to top
 
IP Logged
 
alukes
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 47
Joined: Jul 1st, 2011
Re: Undo Not Working
Reply #6 - Jun 16th, 2020 at 12:38pm
Print Post  
No unmatched startCompositeOperation calls. Undo is still ignored.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 2281
Joined: Oct 19th, 2005
Re: Undo Not Working
Reply #7 - Jun 16th, 2020 at 12:58pm
Print Post  
What does this print in browser's console?

Code
Select All
console.log(diagram.getUndoEnabled());
if (diagram.getUndoEnabled())
{
	console.log(diagram.undoManager.currentComposite);
	console.log(diagram.undoManager.undoHistory.length);
}

diagram.deleteSelection();

if (diagram.getUndoEnabled())
{
	console.log(diagram.undoManager.currentComposite);
	console.log(diagram.undoManager.undoHistory.length);
} 

  
Back to top
 
IP Logged
 
alukes
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 47
Joined: Jul 1st, 2011
Re: Undo Not Working
Reply #8 - Jun 16th, 2020 at 4:17pm
Print Post  
Undo works if I start with a blank diagram.
When I load from JSON, undo doesn't work.

diagram.fromJson(diagramJSON);


This doesn't help.
diagram.startCompositeOperation();
diagram.fromJson(diagramJSON);
diagram.commitCompositeOperation();


This is what is displayed on the console. It is the same no matter if I start with a blank diagram or a diagram loaded from JSON. Also it doesn't change when I delete or undo changes.


true
null
0
null
1



  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 2281
Joined: Oct 19th, 2005
Re: Undo Not Working
Reply #9 - Jun 17th, 2020 at 7:08am
Print Post  
What does this print for undoIndex, both on new diagram and loaded one?

Code
Select All
console.log(diagram.getUndoEnabled());
if (diagram.getUndoEnabled())
{
	console.log(diagram.undoManager.currentComposite);
	console.log(diagram.undoManager.undoHistory.length);
	console.log(diagram.undoManager.undoIndex);}

diagram.deleteSelection();

if (diagram.getUndoEnabled())
{
	console.log(diagram.undoManager.currentComposite);
	console.log(diagram.undoManager.undoHistory.length);
	console.log(diagram.undoManager.undoIndex);
} 



Generally undoEnabled is saved in json too, so if you expect to have older json values where it is false, try resetting like this -

Code
Select All
diagram.setUndoEnabled(false);
diagram.fromJson(json);
diagram.setUndoEnabled(true); 



Otherwise we could not reproduce, and if the console shows undo is enabled and undo history grows, we can't see a reason for undo() to fail. Please attach your diagramJSON string for our developer to test with.
  
Back to top
 
IP Logged
 
alukes
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 47
Joined: Jul 1st, 2011
Re: Undo Not Working
Reply #10 - Jun 18th, 2020 at 1:46am
Print Post  
That worked! 

Thanks for your great support.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint