Implement moving through history

[MAILPOET-1976]
This commit is contained in:
Ján Mikláš
2019-05-29 19:03:35 +02:00
committed by M. Shull
parent 1bd4e25694
commit ae664de002

View File

@@ -62,12 +62,18 @@ Module.HistoryView = Marionette.View.extend({
if (!this.canUndo()) { if (!this.canUndo()) {
return; return;
} }
this.model.currentStateIndex += 1;
this.updateArrowsUI();
this.applyState(this.model.currentStateIndex);
}, },
redo: function redo() { redo: function redo() {
if (!this.canRedo()) { if (!this.canRedo()) {
return; return;
} }
this.model.currentStateIndex -= 1;
this.updateArrowsUI();
this.applyState(this.model.currentStateIndex);
}, },
updateArrowsUI: function updateArrowsUI() { updateArrowsUI: function updateArrowsUI() {
@@ -84,6 +90,11 @@ Module.HistoryView = Marionette.View.extend({
this.elements.redo.prop('title', MailPoet.I18n.t('canRedo')); this.elements.redo.prop('title', MailPoet.I18n.t('canRedo'));
} }
}, },
applyState: function applyState(index) {
const stateToApply = JSON.parse(this.model.states[index]);
App.getChannel().trigger('historyUpdate', stateToApply);
},
}); });
App.on('start', function appStart(StartApp) { App.on('start', function appStart(StartApp) {