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; ...@@ -129,6 +129,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)
......
...@@ -4772,6 +4772,11 @@ TablePart.prototype.generateTotalsRowLabel = function() ...@@ -4772,6 +4772,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;
......
...@@ -747,6 +747,9 @@ var maxIndividualValues = 10000; ...@@ -747,6 +747,9 @@ var maxIndividualValues = 10000;
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();
}, },
...@@ -817,6 +820,19 @@ var maxIndividualValues = 10000; ...@@ -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)//сортировка 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)
...@@ -2256,6 +2272,34 @@ var maxIndividualValues = 10000; ...@@ -2256,6 +2272,34 @@ var maxIndividualValues = 10000;
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);
......
...@@ -12784,6 +12784,7 @@ ...@@ -12784,6 +12784,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))
{ {
...@@ -12792,14 +12793,18 @@ ...@@ -12792,14 +12793,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 );
} }
}; };
...@@ -13013,20 +13018,7 @@ ...@@ -13013,20 +13018,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