Commit 26e085bf authored by Mikolaï Krol's avatar Mikolaï Krol

erp5_jexcel_editor: resize table in undo/redo history

parent f8adcd76
/*jslint nomen: true, indent: 2, maxlen: 80 */
/*global window, rJS, RSVP, jexcel, domsugar, document, alert, prompt, confirm,
navigator*/
/*global window, rJS, RSVP, jexcel, domsugar, document, alert,
prompt, confirm, navigator*/
(function (window, rJS, jexcel, domsugar, document, alert,
prompt, confirm, navigator) {
"use strict";
......@@ -854,6 +854,7 @@ navigator*/
var r = prompt("Number of rows :", instance.options.data.length);
var c = prompt("Number of columns :", instance.options.columns.length);
if (c > 0 && r > 0) {
instance.setHistory({action: "beginResizeTable"});
if (c > instance.options.columns.length) {
while (instance.options.columns.length < c) {
instance.insertColumn();
......@@ -874,6 +875,7 @@ navigator*/
instance.deleteRow(instance.options.data.length - 1, 1);
}
}
instance.setHistory({action: "endResizeTable"});
}
})
......
......@@ -6305,7 +6305,12 @@ console.log(ret);
// History
var historyRecord = obj.history[obj.historyIndex--];
if (historyRecord.action == 'endChangeType') {
if (historyRecord.action === 'endResizeTable') {
while (obj.history[obj.historyIndex].action !== "beginResizeTable") {
obj.undo();
}
obj.undo();
} else if (historyRecord.action == 'endChangeType') {
obj.options.columns[historyRecord.column].type = historyRecord.oldType;
while (obj.history[obj.historyIndex].action !== "beginChangeType") {
obj.undo();
......@@ -6389,12 +6394,17 @@ console.log(ret);
if (obj.historyIndex < obj.history.length - 1) {
// History
var historyRecord = obj.history[++obj.historyIndex];
if (historyRecord.action == 'beginChangeType') {
if (historyRecord.action == 'beginResizeTable') {
while (obj.history[obj.historyIndex].action !== "endResizeTable") {
obj.redo();
}
obj.redo();
} else if (historyRecord.action == 'beginChangeType') {
obj.options.columns[historyRecord.column].type = historyRecord.newType;
while (obj.history[obj.historyIndex].action !== "endChangeType") {
obj.redo();
}
//obj.undo();
obj.redo();
} else if (historyRecord.action == 'insertRow') {
obj.historyProcessRow(0, historyRecord);
} else if (historyRecord.action == 'deleteRow') {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment