Commit 3f5b8a26 authored by GoshaZotov's avatar GoshaZotov

change function code style(changeAutoFilter)

parent ec2c4849
......@@ -12012,108 +12012,103 @@
}
};
WorksheetView.prototype.changeAutoFilter = function (tableName, optionType, val) {
// Проверка глобального лока
if (this.collaborativeEditing.getGlobalLock()) {
return;
}
WorksheetView.prototype.changeAutoFilter = function (tableName, optionType, val) {
// Проверка глобального лока
if (this.collaborativeEditing.getGlobalLock()) {
return;
}
if(true === window['AscCommonExcel'].specialFilteringMode){
if (true === window['AscCommonExcel'].specialFilteringMode) {
return;
}
var t = this;
var ar = this.model.selectionRange.getLast().clone();
var t = this;
var ar = this.model.selectionRange.getLast().clone();
var onChangeAutoFilterCallback = function (isSuccess) {
if (false === isSuccess) {
t.handlers.trigger("selectionChanged");
return;
}
var onChangeAutoFilterCallback = function (isSuccess) {
if (false === isSuccess) {
t.handlers.trigger("selectionChanged");
return;
}
switch (optionType) {
case Asc.c_oAscChangeFilterOptions.filter:
{
//DELETE
if (!val) {
var filterRange = null;
var tablePartsContainsRange = t.model.autoFilters._isTablePartsContainsRange(ar);
if (tablePartsContainsRange && tablePartsContainsRange.Ref) {
filterRange = tablePartsContainsRange.Ref.clone();
} else if (t.model.AutoFilter) {
filterRange = t.model.AutoFilter.Ref;
}
switch (optionType) {
case Asc.c_oAscChangeFilterOptions.filter: {
//DELETE
if (!val) {
var filterRange = null;
var tablePartsContainsRange = t.model.autoFilters._isTablePartsContainsRange(ar);
if (tablePartsContainsRange && tablePartsContainsRange.Ref) {
filterRange = tablePartsContainsRange.Ref.clone();
} else if (t.model.AutoFilter) {
filterRange = t.model.AutoFilter.Ref;
}
if (null === filterRange) {
return;
}
if (null === filterRange) {
return;
}
var deleteFilterCallBack = function () {
t.model.autoFilters.deleteAutoFilter(ar, tableName);
var deleteFilterCallBack = function () {
t.model.autoFilters.deleteAutoFilter(ar, tableName);
t.af_drawButtons(filterRange);
t._onUpdateFormatTable(filterRange, false, true);
}
t.af_drawButtons(filterRange);
t._onUpdateFormatTable(filterRange, false, true);
};
t._isLockedCells(filterRange, /*subType*/null, deleteFilterCallBack);
t._isLockedCells(filterRange, /*subType*/null, deleteFilterCallBack);
} else//ADD ONLY FILTER
{
var addFilterCallBack = function () {
History.Create_NewPoint();
History.StartTransaction();
} else//ADD ONLY FILTER
{
var addFilterCallBack = function () {
History.Create_NewPoint();
History.StartTransaction();
t.model.autoFilters.addAutoFilter(null, ar);
t._onUpdateFormatTable(filterRange, false, true);
t.model.autoFilters.addAutoFilter(null, ar);
t._onUpdateFormatTable(filterRange, false, true);
History.EndTransaction();
};
History.EndTransaction();
};
var filterInfo = t.model.autoFilters._getFilterInfoByAddTableProps(ar);
var filterRange = filterInfo.filterRange
var filterInfo = t.model.autoFilters._getFilterInfoByAddTableProps(ar);
t._isLockedCells(filterRange, null, addFilterCallBack)
}
t._isLockedCells(filterInfo.filterRange, null, addFilterCallBack)
}
break;
}
case Asc.c_oAscChangeFilterOptions.style://CHANGE STYLE
{
var changeStyleFilterCallBack = function () {
History.Create_NewPoint();
History.StartTransaction();
break;
}
case Asc.c_oAscChangeFilterOptions.style://CHANGE STYLE
{
var changeStyleFilterCallBack = function () {
History.Create_NewPoint();
History.StartTransaction();
//TODO внутри вызывается _isTablePartsContainsRange
t.model.autoFilters.changeTableStyleInfo(val, ar, tableName);
t._onUpdateFormatTable(filterRange, false, true);
//TODO внутри вызывается _isTablePartsContainsRange
t.model.autoFilters.changeTableStyleInfo(val, ar, tableName);
t._onUpdateFormatTable(filterRange, false, true);
History.EndTransaction();
};
History.EndTransaction();
};
var filterRange;
//calculate lock range and callback parameters
var isTablePartsContainsRange = t.model.autoFilters._isTablePartsContainsRange(ar);
if (isTablePartsContainsRange !== null)//if one of the tableParts contains activeRange
{
filterRange = isTablePartsContainsRange.Ref.clone();
}
var filterRange;
//calculate lock range and callback parameters
var isTablePartsContainsRange = t.model.autoFilters._isTablePartsContainsRange(ar);
if (isTablePartsContainsRange !== null)//if one of the tableParts contains activeRange
{
filterRange = isTablePartsContainsRange.Ref.clone();
}
t._isLockedCells(filterRange, /*subType*/null, changeStyleFilterCallBack);
t._isLockedCells(filterRange, /*subType*/null, changeStyleFilterCallBack);
break;
}
}
};
break;
}
}
};
if(Asc.c_oAscChangeFilterOptions.style === optionType)
{
if (Asc.c_oAscChangeFilterOptions.style === optionType) {
onChangeAutoFilterCallback(true);
} else {
this._isLockedAll(onChangeAutoFilterCallback);
}
else
{
this._isLockedAll(onChangeAutoFilterCallback);
}
};
};
WorksheetView.prototype.applyAutoFilter = function (autoFilterObject) {
var t = this;
......
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