Commit 477c4761 authored by GoshaZotov's avatar GoshaZotov

add to history format table change name

parent 2ea5df30
......@@ -129,6 +129,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)
......
......@@ -4772,6 +4772,11 @@ TablePart.prototype.generateTotalsRowLabel = function()
this.TableColumns[0].generateTotalsRowLabel();
};
TablePart.prototype.changeDisplayName = function(newName)
{
this.DisplayName = newName;
};
/** @constructor */
function AutoFilter() {
this.Ref = null;
......
......@@ -747,6 +747,9 @@ var maxIndividualValues = 10000;
case historyitem_AutoFilter_ChangeTableRef:
this.changeTableRange(data.displayName, data.moveTo);
break;
case historyitem_AutoFilter_ChangeTableName:
this.changeDisplayNameTable(data.displayName, data.val);
break;
}
History.TurnOn();
},
......@@ -817,6 +820,19 @@ var maxIndividualValues = 10000;
}
}
}
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)
......@@ -2256,6 +2272,34 @@ var maxIndividualValues = 10000;
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);
......
......@@ -12784,6 +12784,7 @@
WorksheetView.prototype.af_changeFormatTableInfo = function(tableName, optionType, val)
{
var tablePart = this.model.autoFilters._getFilterByDisplayName(tableName);
var t = this;
if(!tablePart || (tablePart && !tablePart.TableStyleInfo))
{
......@@ -12793,13 +12794,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 );
}
};
......@@ -13012,21 +13017,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