Commit 5a0f3f84 authored by GoshaZotov's avatar GoshaZotov Committed by Alexander.Trofimov

add color sort

parent 25832f7f
...@@ -553,9 +553,9 @@ var editor; ...@@ -553,9 +553,9 @@ var editor;
ws.applyAutoFilter(autoFilterObject); ws.applyAutoFilter(autoFilterObject);
}; };
spreadsheet_api.prototype.asc_sortColFilter = function(type, cellId, displayName) { spreadsheet_api.prototype.asc_sortColFilter = function(type, cellId, displayName, color) {
var ws = this.wb.getWorksheet(); var ws = this.wb.getWorksheet();
ws.sortColFilter(type, cellId, displayName); ws.sortColFilter(type, cellId, displayName, color);
}; };
spreadsheet_api.prototype.asc_getAddFormatTableOptions = function(range) { spreadsheet_api.prototype.asc_getAddFormatTableOptions = function(range) {
......
...@@ -37,7 +37,9 @@ var c_oAscMergeOptions = { ...@@ -37,7 +37,9 @@ var c_oAscMergeOptions = {
var c_oAscSortOptions = { var c_oAscSortOptions = {
Ascending: 1, Ascending: 1,
Descending: 2 Descending: 2,
ByColorFill: 3,
ByColorFont: 4
}; };
var c_oAscBorderOptions = { var c_oAscBorderOptions = {
......
...@@ -8563,7 +8563,7 @@ Range.prototype.cleanHyperlinks=function(){ ...@@ -8563,7 +8563,7 @@ Range.prototype.cleanHyperlinks=function(){
this.removeHyperlink(aHyperlinks.inner[i].data); this.removeHyperlink(aHyperlinks.inner[i].data);
History.EndTransaction(); History.EndTransaction();
}; };
Range.prototype.sort=function(nOption, nStartCol, colorText, colorFill){ Range.prototype.sort=function(nOption, nStartCol, color){
//todo горизонтальная сортировка //todo горизонтальная сортировка
var aMerged = this.worksheet.mergeManager.get(this.bbox); var aMerged = this.worksheet.mergeManager.get(this.bbox);
if(aMerged.outer.length > 0 || (aMerged.inner.length > 0 && null == _isSameSizeMerged(this.bbox, aMerged.inner))) if(aMerged.outer.length > 0 || (aMerged.inner.length > 0 && null == _isSameSizeMerged(this.bbox, aMerged.inner)))
...@@ -8577,7 +8577,10 @@ Range.prototype.sort=function(nOption, nStartCol, colorText, colorFill){ ...@@ -8577,7 +8577,10 @@ Range.prototype.sort=function(nOption, nStartCol, colorText, colorFill){
nStartCol = merged.bbox.c1; nStartCol = merged.bbox.c1;
} }
this.worksheet.workbook.lockDraw(); this.worksheet.workbook.lockDraw();
var isSortColor = !!(colorText || colorFill); var colorFill = nOption === AscCommonExcel.c_oAscSortOptions.ByColorFill ? color : null;
var colorText = nOption === AscCommonExcel.c_oAscSortOptions.ByColorFont ? color : null;
var isSortColor = !!(colorFill || colorText);
var oRes = null; var oRes = null;
var oThis = this; var oThis = this;
var bAscent = false; var bAscent = false;
......
...@@ -1499,7 +1499,7 @@ ...@@ -1499,7 +1499,7 @@
var t = this; var t = this;
if(!sortProps) if(!sortProps)
sortProps = this.getPropForSort(type, cellId, activeRange, displayName); sortProps = this.getPropForSort(cellId, activeRange, displayName);
curFilter = sortProps.curFilter, sortRange = sortProps.sortRange, filterRef = sortProps.filterRef, startCol = sortProps.startCol, maxFilterRow = sortProps.maxFilterRow; curFilter = sortProps.curFilter, sortRange = sortProps.sortRange, filterRef = sortProps.filterRef, startCol = sortProps.startCol, maxFilterRow = sortProps.maxFilterRow;
...@@ -1538,13 +1538,12 @@ ...@@ -1538,13 +1538,12 @@
onSortAutoFilterCallback(); onSortAutoFilterCallback();
}, },
getPropForSort: function(type, cellId, activeRange, displayName) getPropForSort: function(cellId, activeRange, displayName)
{ {
var worksheet = this.worksheet; var worksheet = this.worksheet;
var t = this; var t = this;
var curFilter, sortRange, filterRef, startCol, maxFilterRow; var curFilter, sortRange, filterRef, startCol, maxFilterRow;
var resType = type == 'ascending';
var isCellIdString = false; var isCellIdString = false;
if(cellId !== undefined && cellId != "" && typeof cellId == 'string') if(cellId !== undefined && cellId != "" && typeof cellId == 'string')
{ {
......
...@@ -12009,21 +12009,22 @@ ...@@ -12009,21 +12009,22 @@
this._isLockedAll( onChangeAutoFilterCallback ); this._isLockedAll( onChangeAutoFilterCallback );
}; };
WorksheetView.prototype.sortColFilter = function ( type, cellId, displayName ) { WorksheetView.prototype.sortColFilter = function ( type, cellId, displayName, color ) {
var t = this; var t = this;
var ar = this.activeRange.clone( true ); var ar = this.activeRange.clone( true );
var onChangeAutoFilterCallback = function ( isSuccess ) { var onChangeAutoFilterCallback = function ( isSuccess ) {
if ( false === isSuccess ) { if ( false === isSuccess ) {
return; return;
} }
var sortProps = t.model.autoFilters.getPropForSort(type, cellId, ar, displayName); var sortProps = t.model.autoFilters.getPropForSort(cellId, ar, displayName);
var onSortAutoFilterCallBack = function() var onSortAutoFilterCallBack = function()
{ {
History.Create_NewPoint(); History.Create_NewPoint();
History.StartTransaction(); History.StartTransaction();
t.cellCommentator.sortComments(sortProps.sortRange.sort(type == 'ascending', sortProps.startCol)); var sort = sortProps.sortRange.sort(type, sortProps.startCol, color);
t.cellCommentator.sortComments(sort);
t.model.autoFilters.sortColFilter( type, cellId, ar, sortProps, displayName ); t.model.autoFilters.sortColFilter( type, cellId, ar, sortProps, displayName );
t._onUpdateFormatTable(sortProps.sortRange.bbox, false); t._onUpdateFormatTable(sortProps.sortRange.bbox, false);
...@@ -12032,7 +12033,7 @@ ...@@ -12032,7 +12033,7 @@
if(null === sortProps) if(null === sortProps)
{ {
t.setSelectionInfo("sort", type == 'ascending'); t.setSelectionInfo("sort", type);
} }
else if(false !== sortProps) else if(false !== sortProps)
{ {
......
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