Make diagram editable

How can I make the diagram editable and non-edtiable, depending of a boolean variable. I have a button to enable edition and I want to be able of resize, move parts in the diagram and then save and make it non editable.

I’ve tried this code:

image

That variable inEdition saves the value depending on the buttons of edit and save, but it doesn’t work, I can’t modify the diagram even when changing the value.
I’ve tried algo a RequestUpdate when clicking the buttons, but I still not have any result.

The image is from the definition of NodeTemplate for my diagram

Probably you want to set Diagram.isReadOnly to true or false, appropriately. Read about permissions at User Permissions | GoJS

Thanks, that worked as I expected.