Skip to content

Commit 60adb4a

Browse files
committed
WiringEditor: Adding confirmation before trashing unsaved work
1 parent 354419d commit 60adb4a

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

VERSION.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ Version 0.5.0
66
not released yet
77

88
Current:
9-
10-
* documentation for ajax controller, especially how to do REST
119

1210
* BUG: jsBox: form values in input fields are overriden !!
1311
* BUG: jsBox should be broken (because of autoload)
@@ -32,7 +30,7 @@ Changeset:
3230
* Gears (if no backend usable)
3331
* Ajax adapter - configurable XHR calls. Can be configured to do REST or something else...
3432
* propertiesFields default value (becomes optional)
35-
* saved status indicator
33+
* saved status indicator + confirmation
3634

3735
* WireIt Guide
3836
* InOutContainer

js/WiringEditor.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,13 @@ WireIt.WiringEditor.prototype = {
371371
* @method onNew
372372
*/
373373
onNew: function() {
374+
375+
if(!this.isSaved()) {
376+
if( !confirm("Warning: Your work is not saved yet ! Press ok to continue anyway.") ) {
377+
return;
378+
}
379+
}
380+
374381
this.preventLayerChangedEvent = true;
375382

376383
this.layer.clear();
@@ -550,6 +557,12 @@ WireIt.WiringEditor.prototype = {
550557
*/
551558
loadPipe: function(name) {
552559

560+
if(!this.isSaved()) {
561+
if( !confirm("Warning: Your work is not saved yet ! Press ok to continue anyway.") ) {
562+
return;
563+
}
564+
}
565+
553566
try {
554567

555568
this.preventLayerChangedEvent = true;
@@ -640,6 +653,9 @@ WireIt.WiringEditor.prototype = {
640653
this.savedStatusEl.style.display = '';
641654
},
642655

656+
isSaved: function() {
657+
return (this.savedStatusEl.style.display == 'none');
658+
},
643659

644660
/**
645661
* This method return a wiring within the given vocabulary described by the modules list

0 commit comments

Comments
 (0)