Only send save operation of changes has been perfomed.

Change default SMTP port.
This commit is contained in:
Paulo Gustavo Veiga 2012-07-15 22:20:21 -03:00
parent d304909a86
commit 8d4b336908
9 changed files with 39 additions and 45 deletions

View File

@ -527,13 +527,6 @@ mindplot.Designer = new Class({
this._relPivot.start(nodes[0], pos); this._relPivot.start(nodes[0], pos);
}, },
needsSave:function () {
//@Todo: Review all this ...
return this._actionDispatcher._actionRunner.hasBeenChanged();
},
getMindmapProperties:function () { getMindmapProperties:function () {
return {zoom:this.getModel().getZoom()}; return {zoom:this.getModel().getZoom()};
}, },

View File

@ -50,13 +50,5 @@ mindplot.DesignerActionRunner = new Class({
fireChangeEvent:function () { fireChangeEvent:function () {
var event = this._undoManager.buildEvent(); var event = this._undoManager.buildEvent();
this._notifier.fireEvent("modelUpdate", event); this._notifier.fireEvent("modelUpdate", event);
},
markAsChangeBase: function() {
return this._undoManager.markAsChangeBase();
},
hasBeenChanged: function() {
return this._undoManager.hasBeenChanged();
} }
}); });

View File

@ -21,8 +21,6 @@ mindplot.DesignerUndoManager = new Class({
this._undoQueue = []; this._undoQueue = [];
this._redoQueue = []; this._redoQueue = [];
this._baseId = 0; this._baseId = 0;
this._fireChange = fireChange;
}, },
enqueue:function(command) { enqueue:function(command) {
@ -62,9 +60,9 @@ mindplot.DesignerUndoManager = new Class({
}, },
markAsChangeBase: function() { markAsChangeBase: function() {
var undoLenght = this._undoQueue.length; var undoLength = this._undoQueue.length;
if (undoLenght > 0) { if (undoLength > 0) {
var command = this._undoQueue[undoLenght - 1]; var command = this._undoQueue[undoLength - 1];
this._baseId = command.getId(); this._baseId = command.getId();
} else { } else {
this._baseId = 0; this._baseId = 0;
@ -73,11 +71,11 @@ mindplot.DesignerUndoManager = new Class({
hasBeenChanged: function() { hasBeenChanged: function() {
var result = true; var result = true;
var undoLenght = this._undoQueue.length; var undoLength= this._undoQueue.length;
if (undoLenght == 0 && this._baseId == 0) { if (undoLength == 0 && this._baseId == 0) {
result = false; result = false;
} else if (undoLenght > 0) { } else if (undoLength > 0) {
var command = this._undoQueue[undoLenght - 1]; var command = this._undoQueue[undoLength - 1];
result = (this._baseId != command.getId()); result = (this._baseId != command.getId());
} }
return result; return result;

View File

@ -23,12 +23,6 @@ mindplot.StandaloneActionDispatcher = new Class({
this._actionRunner = new mindplot.DesignerActionRunner(commandContext, this); this._actionRunner = new mindplot.DesignerActionRunner(commandContext, this);
}, },
hasBeenChanged:function () {
// @todo: This don't seems to belong here.
this._actionRunner.hasBeenChanged();
},
addTopics:function (models, parentTopicsId) { addTopics:function (models, parentTopicsId) {
var command = new mindplot.commands.AddTopicCommand(models, parentTopicsId); var command = new mindplot.commands.AddTopicCommand(models, parentTopicsId);
this.execute(command); this.execute(command);

View File

@ -26,6 +26,12 @@ mindplot.widget.IMenu = new Class({
this._toolbarElems = []; this._toolbarElems = [];
this._containerId = containerId; this._containerId = containerId;
this._mapId = mapId; this._mapId = mapId;
this._mindmapUpdated = false;
// Register update events ...
this._designer.addEvent('modelUpdate', function () {
this.setRequireChange(true);
}.bind(this));
}, },
clear:function () { clear:function () {
@ -35,9 +41,17 @@ mindplot.widget.IMenu = new Class({
}, },
discardChanges:function () { discardChanges:function () {
// Avoid autosave before leaving the page ....
this.setRequireChange(false);
// Finally call discard function ...
var persistenceManager = mindplot.PersistenceManager.getInstance(); var persistenceManager = mindplot.PersistenceManager.getInstance();
var mindmap = designer.getMindmap(); var mindmap = designer.getMindmap();
persistenceManager.discardChanges(mindmap.getId()); persistenceManager.discardChanges(mindmap.getId());
// Reload the page ...
window.location.reload();
}, },
save:function (saveElem, designer, saveHistory) { save:function (saveElem, designer, saveHistory) {
@ -54,6 +68,7 @@ mindplot.widget.IMenu = new Class({
} }
// Call persistence manager for saving ... // Call persistence manager for saving ...
var menu = this;
var persistenceManager = mindplot.PersistenceManager.getInstance(); var persistenceManager = mindplot.PersistenceManager.getInstance();
persistenceManager.save(mindmap, mindmapProp, saveHistory, { persistenceManager.save(mindmap, mindmapProp, saveHistory, {
onSuccess:function () { onSuccess:function () {
@ -61,6 +76,7 @@ mindplot.widget.IMenu = new Class({
saveElem.setStyle('cursor', 'pointer'); saveElem.setStyle('cursor', 'pointer');
$notify($msg('SAVE_COMPLETE')); $notify($msg('SAVE_COMPLETE'));
} }
menu.setRequireChange(false);
}, },
onError:function () { onError:function () {
if (saveHistory) { if (saveHistory) {
@ -69,5 +85,13 @@ mindplot.widget.IMenu = new Class({
} }
} }
}); });
},
isSaveRequired:function () {
return this._mindmapUpdated;
},
setRequireChange:function (value) {
this._mindmapUpdated = value;
} }
}); });

View File

@ -304,14 +304,14 @@ mindplot.widget.Menu = new Class({
if (!readOnly) { if (!readOnly) {
// To prevent the user from leaving the page with changes ... // To prevent the user from leaving the page with changes ...
$(window).addEvent('beforeunload', function () { $(window).addEvent('beforeunload', function () {
if (designer.needsSave()) { if (this.isSaveRequired()) {
this.save(saveElem, designer, false); this.save(saveElem, designer, false);
} }
}.bind(this)); }.bind(this));
// Autosave on a fixed period of time ... // Autosave on a fixed period of time ...
(function () { (function () {
if (designer.needsSave()) { if (this.isSaveRequired()) {
this.save(saveElem, designer, false); this.save(saveElem, designer, false);
} }
}.bind(this)).periodical(30000); }.bind(this)).periodical(30000);
@ -321,14 +321,7 @@ mindplot.widget.Menu = new Class({
var discardElem = $('discard'); var discardElem = $('discard');
if (discardElem) { if (discardElem) {
this._addButton('discard', false, false, function () { this._addButton('discard', false, false, function () {
// Avoid autosave before leaving the page ....
$(window).removeEvents(['beforeunload']);
// Discard changes ...
this.discardChanges(); this.discardChanges();
// Reload the page ...
window.location.reload();
}.bind(this)); }.bind(this));
this._registerTooltip('discard', $msg('DISCARD_CHANGES')); this._registerTooltip('discard', $msg('DISCARD_CHANGES'));
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 590 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 629 B

View File

@ -24,7 +24,7 @@ database.password=
#------------------------ #------------------------
# Plain SMTP Server Configuration # Plain SMTP Server Configuration
#------------------------ #------------------------
mail.smtp.port=465 mail.smtp.port=25
mail.smtp.host=localhost mail.smtp.host=localhost
mail.username=root mail.username=root
mail.password= mail.password=