Implement moving through history
[MAILPOET-1976]
This commit is contained in:
@@ -62,12 +62,18 @@ Module.HistoryView = Marionette.View.extend({
|
||||
if (!this.canUndo()) {
|
||||
return;
|
||||
}
|
||||
this.model.currentStateIndex += 1;
|
||||
this.updateArrowsUI();
|
||||
this.applyState(this.model.currentStateIndex);
|
||||
},
|
||||
|
||||
redo: function redo() {
|
||||
if (!this.canRedo()) {
|
||||
return;
|
||||
}
|
||||
this.model.currentStateIndex -= 1;
|
||||
this.updateArrowsUI();
|
||||
this.applyState(this.model.currentStateIndex);
|
||||
},
|
||||
|
||||
updateArrowsUI: function updateArrowsUI() {
|
||||
@@ -84,6 +90,11 @@ Module.HistoryView = Marionette.View.extend({
|
||||
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) {
|
||||
|
Reference in New Issue
Block a user