Commit c41f33f1 authored by GoshaZotov's avatar GoshaZotov

modify WorksheetView.prototype.addAutoFilter

parent bc659c1c
...@@ -11878,6 +11878,7 @@ ...@@ -11878,6 +11878,7 @@
return res; return res;
}; };
var filterRange, bIsChangeFilterToTable, addNameColumn;
var onChangeAutoFilterCallback = function (isSuccess) { var onChangeAutoFilterCallback = function (isSuccess) {
if (false === isSuccess) { if (false === isSuccess) {
t.model.workbook.handlers.trigger("asc_onError", c_oAscError.ID.LockedAllError, t.model.workbook.handlers.trigger("asc_onError", c_oAscError.ID.LockedAllError,
...@@ -11886,11 +11887,9 @@ ...@@ -11886,11 +11887,9 @@
return; return;
} }
var addFilterCallBack, addNameColumn, filterRange; var addFilterCallBack;
if (addFormatTableOptionsObj && isChangeAutoFilterToTablePart(addFormatTableOptionsObj) === true)//CHANGE FILTER TO TABLEPART if (bIsChangeFilterToTable)//CHANGE FILTER TO TABLEPART
{ {
filterRange = t.model.AutoFilter.Ref.clone();
addFilterCallBack = function () { addFilterCallBack = function () {
History.Create_NewPoint(); History.Create_NewPoint();
History.StartTransaction(); History.StartTransaction();
...@@ -11901,16 +11900,9 @@ ...@@ -11901,16 +11900,9 @@
History.EndTransaction(); History.EndTransaction();
}; };
addNameColumn = false;
if (addFormatTableOptionsObj === false) {
addNameColumn = true;
} else if (typeof addFormatTableOptionsObj == 'object') {
addNameColumn = !addFormatTableOptionsObj.asc_getIsTitle();
}
if (addNameColumn) { if (addNameColumn) {
filterRange.r2 = filterRange.r2 + 1; filterRange.r2 = filterRange.r2 + 1;
} }
t._isLockedCells(filterRange, /*subType*/null, addFilterCallBack); t._isLockedCells(filterRange, /*subType*/null, addFilterCallBack);
} else//ADD } else//ADD
{ {
...@@ -11918,7 +11910,7 @@ ...@@ -11918,7 +11910,7 @@
History.Create_NewPoint(); History.Create_NewPoint();
History.StartTransaction(); History.StartTransaction();
if(null !== styleName) { if (null !== styleName) {
t.handlers.trigger("slowOperation", true); t.handlers.trigger("slowOperation", true);
} }
...@@ -11931,7 +11923,7 @@ ...@@ -11931,7 +11923,7 @@
} }
t._onUpdateFormatTable(filterRange, !!(styleName), true); t._onUpdateFormatTable(filterRange, !!(styleName), true);
if(null !== styleName) { if (null !== styleName) {
t.handlers.trigger("slowOperation", false); t.handlers.trigger("slowOperation", false);
} }
...@@ -11941,16 +11933,35 @@ ...@@ -11941,16 +11933,35 @@
if (styleName === null) { if (styleName === null) {
addFilterCallBack(); addFilterCallBack();
} else { } else {
var filterInfo = t.model.autoFilters._getFilterInfoByAddTableProps(ar, addFormatTableOptionsObj);
filterRange = filterInfo.filterRange;
addNameColumn = filterInfo.addNameColumn;
t._isLockedCells(filterRange, null, addFilterCallBack) t._isLockedCells(filterRange, null, addFilterCallBack)
} }
} }
}; };
if (t._checkAddAutoFilter(ar, styleName, addFormatTableOptionsObj) === true) { //calculate filter range
if (addFormatTableOptionsObj && isChangeAutoFilterToTablePart(addFormatTableOptionsObj) === true) {
filterRange = t.model.AutoFilter.Ref.clone();
addNameColumn = false;
if (addFormatTableOptionsObj === false) {
addNameColumn = true;
} else if (typeof addFormatTableOptionsObj == 'object') {
addNameColumn = !addFormatTableOptionsObj.asc_getIsTitle();
}
bIsChangeFilterToTable = true;
} else {
if (styleName === null) {
filterRange = ar;
} else {
var filterInfo = t.model.autoFilters._getFilterInfoByAddTableProps(ar, addFormatTableOptionsObj, true);
filterRange = filterInfo.filterRange;
addNameColumn = filterInfo.addNameColumn;
}
}
var checkFilterRange = filterInfo ? filterInfo.rangeWithoutDiff : filterRange;
if (t._checkAddAutoFilter(checkFilterRange, styleName, addFormatTableOptionsObj) === true) {
this._isLockedAll(onChangeAutoFilterCallback); this._isLockedAll(onChangeAutoFilterCallback);
this._isLockedDefNames(null, null); this._isLockedDefNames(null, null);
} else//для того, чтобы в случае ошибки кнопка отжималась! } else//для того, чтобы в случае ошибки кнопка отжималась!
......
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