Commit d504524c authored by GoshaZotov's avatar GoshaZotov

add rename column changes into history

parent b48dbad6
......@@ -142,6 +142,7 @@ function (window, undefined) {
window['AscCH'].historyitem_AutoFilter_ChangeTableRef = 13;
window['AscCH'].historyitem_AutoFilter_ChangeTableName = 14;
window['AscCH'].historyitem_AutoFilter_ClearFilterColumn = 15;
window['AscCH'].historyitem_AutoFilter_ChangeColumnName = 16;
function CHistory()
......
......@@ -1763,8 +1763,10 @@ var g_oUndoRedoData_AutoFilterProperties = {
HeaderRowCount : 15,
TotalsRowCount : 16,
color : 17,
tablePart : 18
};
tablePart : 18,
nCol : 19,
nRow : 20
};
function UndoRedoData_AutoFilter() {
this.Properties = g_oUndoRedoData_AutoFilterProperties;
......@@ -1791,6 +1793,8 @@ function UndoRedoData_AutoFilter() {
this.TotalsRowCount = null;
this.color = null;
this.tablePart = null;
this.nCol = null;
this.nRow = null;
}
UndoRedoData_AutoFilter.prototype = {
getType : function ()
......@@ -1836,6 +1840,8 @@ UndoRedoData_AutoFilter.prototype = {
return tablePart; break;
}
case this.Properties.nCol: return this.nCol; break;
case this.Properties.nRow: return this.nRow; break;
}
return null;
......@@ -1897,6 +1903,8 @@ UndoRedoData_AutoFilter.prototype = {
}
break;
}
case this.Properties.nCol: this.nCol = value;break;
case this.Properties.nRow: this.nRow = value;break;
}
return null;
},
......@@ -3136,8 +3144,6 @@ UndoRedoCell.prototype = {
{
if (bUndo || AscCH.historyitem_Cell_ChangeValueUndo !== Type) {
cell.setValueData(Val);
// ToDo Так делать неправильно, нужно поправить (перенести логику в model, а отрисовку отделить)
ws.autoFilters.renameTableColumn(new Asc.Range(nCol, nRow, nCol, nRow), bUndo);
}
}
else if(AscCH.historyitem_Cell_SetStyle == Type)
......@@ -3872,13 +3878,24 @@ UndoRedoAutoFilters.prototype = {
var ws = wb.getWorksheetById(nSheetId);
if(ws){
var autoFilters = ws.autoFilters;
if (bUndo == true)
if (bUndo === true)
{
autoFilters.Undo(Type, Data);
}
else
{
if(AscCH.historyitem_AutoFilter_ChangeColumnName === Type)
{
if(false != this.wb.bCollaborativeChanges)
{
var collaborativeEditing = this.wb.oApi.collaborativeEditing;
Data.nRow = collaborativeEditing.getLockOtherRow2(nSheetId, Data.nRow);
Data.nCol = collaborativeEditing.getLockOtherColumn2(nSheetId, Data.nCol);
}
}
autoFilters.Redo(Type, Data);
}
}
},
forwardTransformationIsAffect : function(Type) {
return AscCH.historyitem_AutoFilter_Add === Type || AscCH.historyitem_AutoFilter_ChangeTableName === Type ||
......
......@@ -896,6 +896,9 @@
case AscCH.historyitem_AutoFilter_ClearFilterColumn:
this.clearFilterColumn(data.cellId, data.displayName);
break;
case AscCH.historyitem_AutoFilter_ChangeColumnName:
this.renameTableColumn(null, null, data);
break;
}
History.TurnOn();
},
......@@ -923,7 +926,11 @@
delete cloneData.insCells;
//TODO переделать undo, по типам
if(type === AscCH.historyitem_AutoFilter_Move)//перемещение
if(type === AscCH.historyitem_AutoFilter_ChangeColumnName)//перемещение
{
this.renameTableColumn(null, null, undoData);
}
else if(type === AscCH.historyitem_AutoFilter_Move)//перемещение
{
this._moveAutoFilters(null, null, data);
}
......@@ -2829,6 +2836,8 @@
oHistoryObject.val = redoObject.val;
oHistoryObject.color = redoObject.color;
oHistoryObject.tablePart = redoObject.tablePart;
oHistoryObject.nCol = redoObject.nCol;
oHistoryObject.nRow = redoObject.nRow;
}
else
{
......@@ -2850,7 +2859,7 @@
return ws.model;
},
renameTableColumn: function(range, bUndo)
renameTableColumn: function(range, bUndo, props)
{
var worksheet = this.worksheet;
var val;
......@@ -2876,6 +2885,11 @@
return res;
};
if(props)
{
range = new Asc.Range(props.nCol, props.nRow, props.nCol, props.nRow);
}
if(worksheet.TableParts)
{
worksheet.workbook.dependencyFormulas.buildDependency();
......@@ -2898,7 +2912,7 @@
continue;
cell = worksheet.getCell3(ref.r1, j);
val = cell.getValue();
val = props ? props.val : cell.getValue();
//проверка на повторение уже существующих заголовков
if(checkRepeateColumnName(val, filter.TableColumns, j - tableRange.c1))
......@@ -2907,12 +2921,17 @@
}
//если не пустая изменяем TableColumns
var oldVal = filter.TableColumns[j - tableRange.c1].Name;
var newVal = null;
if(val != "" && intersection.c1 <= j && intersection.c2 >= j )
{
filter.TableColumns[j - tableRange.c1].Name = val;
if(!bUndo)
{
cell.setType(CellValueType.String);
}
newVal = val;
}
else if(val == "")//если пустая изменяем генерируем имя и добавляем его в TableColumns
{
filter.TableColumns[j - tableRange.c1].Name = "";
......@@ -2923,6 +2942,12 @@
cell.setType(CellValueType.String);
}
filter.TableColumns[j - tableRange.c1].Name = generateName;
newVal = generateName;
}
if(null !== newVal)
{
this._addHistoryObj({nCol: cell.bbox.c1, nRow: cell.bbox.r1, val: oldVal}, AscCH.historyitem_AutoFilter_ChangeColumnName, {activeCells: range, nCol: cell.bbox.c1, nRow: cell.bbox.r1, val: newVal});
}
}
......
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