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; ...@@ -105,6 +105,7 @@ var historyitem_AutoFilter_Change = 10;
var historyitem_AutoFilter_CleanFormat = 11; var historyitem_AutoFilter_CleanFormat = 11;
var historyitem_AutoFilter_ChangeTableInfo = 12; var historyitem_AutoFilter_ChangeTableInfo = 12;
var historyitem_AutoFilter_ChangeTableRef = 13; var historyitem_AutoFilter_ChangeTableRef = 13;
var historyitem_AutoFilter_ChangeTableName = 14;
function CHistory(workbook) function CHistory(workbook)
......
...@@ -4833,6 +4833,11 @@ TablePart.prototype.generateTotalsRowLabel = function() ...@@ -4833,6 +4833,11 @@ TablePart.prototype.generateTotalsRowLabel = function()
this.TableColumns[0].generateTotalsRowLabel(); this.TableColumns[0].generateTotalsRowLabel();
}; };
TablePart.prototype.changeDisplayName = function(newName)
{
this.DisplayName = newName;
};
/** @constructor */ /** @constructor */
function AutoFilter() { function AutoFilter() {
this.Ref = null; this.Ref = null;
......
...@@ -730,6 +730,9 @@ ...@@ -730,6 +730,9 @@
case historyitem_AutoFilter_ChangeTableRef: case historyitem_AutoFilter_ChangeTableRef:
this.changeTableRange(data.displayName, data.moveTo); this.changeTableRange(data.displayName, data.moveTo);
break; break;
case historyitem_AutoFilter_ChangeTableName:
this.changeDisplayNameTable(data.displayName, data.val);
break;
} }
History.TurnOn(); History.TurnOn();
}, },
...@@ -800,6 +803,19 @@ ...@@ -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)//сортировка else if(type === historyitem_AutoFilter_Sort && cloneData.oldFilter)//сортировка
{ {
if(worksheet.AutoFilter && cloneData.oldFilter.getType() === g_nFiltersType.autoFilter) if(worksheet.AutoFilter && cloneData.oldFilter.getType() === g_nFiltersType.autoFilter)
...@@ -2238,6 +2254,34 @@ ...@@ -2238,6 +2254,34 @@
this._setColorStyleTable(tablePart.Ref, tablePart, null, true); 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) _clearRange: function(range, isClearText)
{ {
range.setTableStyle(null); range.setTableStyle(null);
......
...@@ -12803,6 +12803,7 @@ ...@@ -12803,6 +12803,7 @@
WorksheetView.prototype.af_changeFormatTableInfo = function(tableName, optionType, val) WorksheetView.prototype.af_changeFormatTableInfo = function(tableName, optionType, val)
{ {
var tablePart = this.model.autoFilters._getFilterByDisplayName(tableName); var tablePart = this.model.autoFilters._getFilterByDisplayName(tableName);
var t = this;
if(!tablePart || (tablePart && !tablePart.TableStyleInfo)) if(!tablePart || (tablePart && !tablePart.TableStyleInfo))
{ {
...@@ -12811,14 +12812,18 @@ ...@@ -12811,14 +12812,18 @@
var isChangeTableInfo = this.af_checkChangeTableInfo(tablePart, optionType); var isChangeTableInfo = this.af_checkChangeTableInfo(tablePart, optionType);
if(isChangeTableInfo !== false) if(isChangeTableInfo !== false)
{
var callback = function()
{ {
History.Create_NewPoint(); History.Create_NewPoint();
History.StartTransaction(); History.StartTransaction();
this.model.autoFilters.changeFormatTableInfo(tableName, optionType, val); t.model.autoFilters.changeFormatTableInfo(tableName, optionType, val);
this._onUpdateFormatTable(isChangeTableInfo, false, true); t._onUpdateFormatTable(isChangeTableInfo, false, true);
//TODO добавить перерисовку таблицы и перерисовку шаблонов
History.EndTransaction(); History.EndTransaction();
};
t._isLockedCells( tablePart.Ref, null, callback );
} }
}; };
...@@ -13032,20 +13037,7 @@ ...@@ -13032,20 +13037,7 @@
var ws = this.model; var ws = this.model;
var acitveRange = this.activeRange.clone(); var acitveRange = this.activeRange.clone();
var tablePart = ws.autoFilters._getFilterByDisplayName(tableName); this.model.autoFilters.changeDisplayNameTable(tableName, newName);
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;
}; };
WorksheetView.prototype.af_checkInsDelCells = function(activeRange, val, prop) 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