Commit fa9b68e7 authored by GoshaZotov's avatar GoshaZotov Committed by Alexander.Trofimov

add to history format table change name

parent 4698887a
......@@ -105,6 +105,7 @@ var historyitem_AutoFilter_Change = 10;
var historyitem_AutoFilter_CleanFormat = 11;
var historyitem_AutoFilter_ChangeTableInfo = 12;
var historyitem_AutoFilter_ChangeTableRef = 13;
var historyitem_AutoFilter_ChangeTableName = 14;
function CHistory(workbook)
......
......@@ -4833,6 +4833,11 @@ TablePart.prototype.generateTotalsRowLabel = function()
this.TableColumns[0].generateTotalsRowLabel();
};
TablePart.prototype.changeDisplayName = function(newName)
{
this.DisplayName = newName;
};
/** @constructor */
function AutoFilter() {
this.Ref = null;
......
......@@ -730,6 +730,9 @@
case historyitem_AutoFilter_ChangeTableRef:
this.changeTableRange(data.displayName, data.moveTo);
break;
case historyitem_AutoFilter_ChangeTableName:
this.changeDisplayNameTable(data.displayName, data.val);
break;
}
History.TurnOn();
},
......@@ -800,6 +803,19 @@
}
}
}
else if(type === historyitem_AutoFilter_ChangeTableName)
{
var oldName = cloneData.newDisplayName;
for(var l = 0; l < worksheet.TableParts.length; l++)
{
if(oldName === worksheet.TableParts[l].DisplayName)
{
worksheet.TableParts[l] = cloneData.oldFilter.clone(null);
break;
}
}
}
else if(type === historyitem_AutoFilter_Sort && cloneData.oldFilter)//сортировка
{
if(worksheet.AutoFilter && cloneData.oldFilter.getType() === g_nFiltersType.autoFilter)
......@@ -2238,6 +2254,34 @@
this._setColorStyleTable(tablePart.Ref, tablePart, null, true);
},
changeDisplayNameTable: function(tableName, newName)
{
var tablePart = this._getFilterByDisplayName(tableName);
var worksheet = this.worksheet;
if(!tablePart)
{
return false;
}
var oldFilter = tablePart.clone(null);
History.Create_NewPoint();
History.StartTransaction();
//TODO добавлять в историю смену именного диапазона
var oldNamedrange = worksheet.workbook.dependencyFormulas.getDefNameNodeByName(tablePart.DisplayName);
var newNamedrange = oldNamedrange.clone();
newNamedrange.Name = newName;
oldNamedrange.changeDefName(newNamedrange);
tablePart.changeDisplayName(newName);
this._addHistoryObj({oldFilter: oldFilter, newFilterRef: tablePart.Ref.clone(), newDisplayName: newName}, historyitem_AutoFilter_ChangeTableName,
{activeCells: tablePart.Ref.clone(), val: newName, displayName: tableName});
History.EndTransaction();
},
_clearRange: function(range, isClearText)
{
range.setTableStyle(null);
......
......@@ -12803,6 +12803,7 @@
WorksheetView.prototype.af_changeFormatTableInfo = function(tableName, optionType, val)
{
var tablePart = this.model.autoFilters._getFilterByDisplayName(tableName);
var t = this;
if(!tablePart || (tablePart && !tablePart.TableStyleInfo))
{
......@@ -12812,13 +12813,17 @@
var isChangeTableInfo = this.af_checkChangeTableInfo(tablePart, optionType);
if(isChangeTableInfo !== false)
{
History.Create_NewPoint();
History.StartTransaction();
this.model.autoFilters.changeFormatTableInfo(tableName, optionType, val);
var callback = function()
{
History.Create_NewPoint();
History.StartTransaction();
t.model.autoFilters.changeFormatTableInfo(tableName, optionType, val);
t._onUpdateFormatTable(isChangeTableInfo, false, true);
History.EndTransaction();
};
this._onUpdateFormatTable(isChangeTableInfo, false, true);
//TODO добавить перерисовку таблицы и перерисовку шаблонов
History.EndTransaction();
t._isLockedCells( tablePart.Ref, null, callback );
}
};
......@@ -13031,21 +13036,8 @@
var t = this;
var ws = this.model;
var acitveRange = this.activeRange.clone();
var tablePart = ws.autoFilters._getFilterByDisplayName(tableName);
if(!tablePart)
{
return false;
}
//TODO тестовый вариант. нужно сделать методы и добавлять в историю
var oldNamedrange = this.model.workbook.dependencyFormulas.getDefNameNodeByName(tablePart.DisplayName);
var newNamedrange = oldNamedrange.clone();
newNamedrange.Name = newName;
oldNamedrange.changeDefName(newNamedrange);
tablePart.DisplayName = newName;
this.model.autoFilters.changeDisplayNameTable(tableName, newName);
};
WorksheetView.prototype.af_checkInsDelCells = function(activeRange, val, prop)
......
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