bptlab / chor-js-demo

A demo showcasing the chor-js BPMN 2.0 choreography diagram modeler.
23 stars 10 forks source link

Add warning on browser reload or window close #58

Closed yT0n1 closed 3 years ago

yT0n1 commented 3 years ago

Fixes #48

jan-ladleif commented 3 years ago

Maybe this should be tied to the event bus, to only fire when the diagram is in a "dirty" state? Otherwise, it might be annoying if I save the diagram and am still forced to confirm that I want to close the window.

yT0n1 commented 3 years ago

I agree that that would probably be the better implementation. In that case, it would also make sense to add similar behavior to the "new diagram button" as well as the "open from disk" button. However, the implementation is quite a bit more work. We will have to write a module and inject it. As far as I remember we do not expose the event-bus to the outside. So I would prefer e merging the currently proposed solution and adding the better behavior at a later point in time.

jan-ladleif commented 3 years ago

The bpmn-js demo https://demo.bpmn.io/ manages to do it without injecting anything, by tapping into modeler.on('commandStack.changed', modelUpdate); and then setting a dirty flag which is cleared on save or load.

Maybe we can do it like that? Seems relatively minimal and elegant. 🙂

yT0n1 commented 3 years ago

I completely overlooked modeler.on() 😅. I made the necessary changes.