Skip to content

Commit 354419d

Browse files
committed
WiringEditor saved status indicator
1 parent 9ce6c9e commit 354419d

File tree

3 files changed

+46
-16
lines changed

3 files changed

+46
-16
lines changed

VERSION.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ not released yet
77

88
Current:
99

10-
* Layer.onChangeEvt (+implementation in WiringEditor for saved state)
1110
* documentation for ajax controller, especially how to do REST
1211

1312
* BUG: jsBox: form values in input fields are overriden !!
@@ -33,10 +32,13 @@ Changeset:
3332
* Gears (if no backend usable)
3433
* Ajax adapter - configurable XHR calls. Can be configured to do REST or something else...
3534
* propertiesFields default value (becomes optional)
35+
* saved status indicator
3636

37-
* WireIt Guide
38-
* Show only one scissor at a time
37+
* WireIt Guide
3938
* InOutContainer
39+
40+
* Layer.onChangeEvt
41+
* Show only one scissor at a time
4042
* Spring Layout (experimental) (+examples)
4143
* Wire mouse events (experimental) (+examples)
4244
* Added drawing method 'bezierArrows' (experimental)

css/WireItEditor.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ body {
6262
background:transparent url(../images/icons/help.png) no-repeat scroll 10% 50%;
6363
}
6464

65+
/**
66+
* savedStatus
67+
*/
68+
div.savedStatus {
69+
color:orange;
70+
font-size:27pt;
71+
left:650px;
72+
position:absolute;
73+
top:10px;
74+
}
6575

6676
/**
6777
* LEFT

js/WiringEditor.js

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ WireIt.WiringEditor = function(options) {
124124
// Render buttons
125125
this.renderButtons();
126126

127+
// Saved status
128+
this.renderSavedStatus();
129+
127130
// Properties Form
128131
this.renderPropertiesForm();
129132

@@ -209,6 +212,10 @@ WireIt.WiringEditor.prototype = {
209212
parentEl: YAHOO.util.Dom.get('propertiesForm'),
210213
fields: this.options.propertiesFields
211214
});
215+
216+
this.propertiesForm.updatedEvt.subscribe(function() {
217+
this.markUnsaved();
218+
}, this, true);
212219
},
213220

214221
/**
@@ -286,6 +293,15 @@ WireIt.WiringEditor.prototype = {
286293
helpButton.on("click", this.onHelp, this, true);
287294
},
288295

296+
/**
297+
* @method renderSavedStatus
298+
*/
299+
renderSavedStatus: function() {
300+
var top = Dom.get('top');
301+
this.savedStatusEl = WireIt.cn('div', {className: 'savedStatus', title: 'Not saved'}, {display: 'none'}, "*");
302+
top.appendChild(this.savedStatusEl);
303+
},
304+
289305
/**
290306
* save the current module
291307
* @method saveModule
@@ -315,17 +331,17 @@ WireIt.WiringEditor.prototype = {
315331
*/
316332
saveModuleSuccess: function(o) {
317333

318-
this.alert("Saved !");
334+
this.markSaved();
319335

320-
//console.log(this.tempSavedWiring);
321-
var name = this.tempSavedWiring.name;
322-
336+
this.alert("Saved !");
337+
338+
/*var name = this.tempSavedWiring.name;
323339
if(this.modulesByName.hasOwnProperty(name) ) {
324340
//console.log("already exists !");
325341
}
326342
else {
327343
//console.log("new one !");
328-
}
344+
}*/
329345

330346
},
331347

@@ -358,7 +374,10 @@ WireIt.WiringEditor.prototype = {
358374
this.preventLayerChangedEvent = true;
359375

360376
this.layer.clear();
361-
this.propertiesForm.clear();
377+
378+
this.propertiesForm.clear(false); // false to tell inputEx to NOT send the updatedEvt
379+
380+
this.markSaved();
362381

363382
this.preventLayerChangedEvent = false;
364383
},
@@ -547,7 +566,7 @@ WireIt.WiringEditor.prototype = {
547566
// TODO: check if current wiring is saved...
548567
this.layer.clear();
549568

550-
this.propertiesForm.setValue(wiring.properties);
569+
this.propertiesForm.setValue(wiring.properties, false); // the false tells inputEx to NOT fire the updatedEvt
551570

552571
if(lang.isArray(wiring.modules)) {
553572

@@ -576,8 +595,9 @@ WireIt.WiringEditor.prototype = {
576595
}
577596
}
578597

579-
580-
this.preventLayerChangedEvent = true;
598+
this.markSaved();
599+
600+
this.preventLayerChangedEvent = false;
581601

582602
}
583603
catch(ex) {
@@ -606,20 +626,18 @@ WireIt.WiringEditor.prototype = {
606626
}, this, true);
607627
},
608628

609-
610629
onLayerChanged: function() {
611630
if(!this.preventLayerChangedEvent) {
612-
//console.log("layer changed !");
613631
this.markUnsaved();
614632
}
615633
},
616634

617635
markSaved: function() {
618-
636+
this.savedStatusEl.style.display = 'none';
619637
},
620638

621639
markUnsaved: function() {
622-
640+
this.savedStatusEl.style.display = '';
623641
},
624642

625643

0 commit comments

Comments
 (0)