From e290cea279e5afe3504fdeaf6327cf849681c1d4 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 4 May 2016 14:40:08 +0300 Subject: [PATCH] =?UTF-8?q?[SSE]=20=D0=92=D1=8B=D1=81=D1=82=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=86=D0=B2=D0=B5=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D1=8B=D1=85=20=D1=84=D0=B8=D0=BB=D1=8C=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/lib/component/ColorPaletteExt.js | 18 +-- .../main/app/view/AutoFilterDialog.js | 106 ++++++++++++------ 2 files changed, 81 insertions(+), 43 deletions(-) diff --git a/apps/common/main/lib/component/ColorPaletteExt.js b/apps/common/main/lib/component/ColorPaletteExt.js index f1c1f7fae..4bed5af59 100644 --- a/apps/common/main/lib/component/ColorPaletteExt.js +++ b/apps/common/main/lib/component/ColorPaletteExt.js @@ -106,13 +106,13 @@ define([ handleClick: function(e) { var me = this; - var target = $(e.target).closest('a'); + var target = $(e.target).closest('div.palette-color-item'); var color, cmp; if (target.length==0) return; if (target.hasClass('color-transparent') ) { - $(me.el).find('a.' + me.selectedCls).removeClass(me.selectedCls); + $(me.el).find('div.' + me.selectedCls).removeClass(me.selectedCls); target.addClass(me.selectedCls); me.value = 'transparent'; me.trigger('select', me, 'transparent'); @@ -120,7 +120,7 @@ define([ if (!/^[a-fA-F0-9]{6}$/.test(me.value) || _.indexOf(me.colors, me.value)<0 ) me.value = false; - $(me.el).find('a.' + me.selectedCls).removeClass(me.selectedCls); + $(me.el).find('div.' + me.selectedCls).removeClass(me.selectedCls); target.addClass(me.selectedCls); color = target[0].className.match(me.colorRe)[1]; @@ -142,21 +142,21 @@ define([ select: function(color, suppressEvent) { var el = $(this.el); - el.find('a.' + this.selectedCls).removeClass(this.selectedCls); + el.find('div.' + this.selectedCls).removeClass(this.selectedCls); if (!color) return; if (typeof(color) == 'object' ) { var effectEl; if (color.effectId !== undefined) { - effectEl = el.find('a[effectid="'+color.effectId+'"]').first(); + effectEl = el.find('div[effectid="'+color.effectId+'"]').first(); if (effectEl.length>0) { effectEl.addClass(this.selectedCls); this.value = effectEl[0].className.match(this.colorRe)[1].toUpperCase(); } else this.value = false; } else if (color.effectValue !== undefined) { - effectEl = el.find('a[effectvalue="'+color.effectValue+'"].color-' + color.color.toUpperCase()).first(); + effectEl = el.find('div[effectvalue="'+color.effectValue+'"].color-' + color.color.toUpperCase()).first(); if (effectEl.length>0) { effectEl.addClass(this.selectedCls); this.value = effectEl[0].className.match(this.colorRe)[1].toUpperCase(); @@ -173,7 +173,7 @@ define([ if (_.indexOf(this.colors, this.value)<0) this.value = false; if (color != this.value || this.options.allowReselect) { - (color == 'transparent') ? el.find('a.color-transparent').addClass(this.selectedCls) : el.find('a.palette-color.color-' + color).first().addClass(this.selectedCls); + (color == 'transparent') ? el.find('div.color-transparent').addClass(this.selectedCls) : el.find('div.palette-color.color-' + color).first().addClass(this.selectedCls); this.value = color; if (suppressEvent !== true) { this.fireEvent('select', this, color); @@ -182,7 +182,7 @@ define([ } else { var co = el.find('#'+color).first(); if (co.length==0) - co = el.find('a[color="'+color+'"]').first(); + co = el.find('div[color="'+color+'"]').first(); if (co.length>0) { co.addClass(this.selectedCls); this.value = color.toUpperCase(); @@ -206,7 +206,7 @@ define([ }, clearSelection: function(suppressEvent) { - $(this.el).find('a.' + this.selectedCls).removeClass(this.selectedCls); + $(this.el).find('div.' + this.selectedCls).removeClass(this.selectedCls); this.value = undefined; } }); diff --git a/apps/spreadsheeteditor/main/app/view/AutoFilterDialog.js b/apps/spreadsheeteditor/main/app/view/AutoFilterDialog.js index 1a9f63584..3d6d1f7f1 100644 --- a/apps/spreadsheeteditor/main/app/view/AutoFilterDialog.js +++ b/apps/spreadsheeteditor/main/app/view/AutoFilterDialog.js @@ -519,6 +519,7 @@ define([ '006400', '800080', '8B0000', '808000', 'FFFFFF', 'D3D3D3' ] }); + this.mnuSortColorCellsPicker.on('select', _.bind(this.onSortColorCellsSelect, this)); this.mnuSortColorFontPicker = new Common.UI.ColorPaletteExt({ el: $('#filter-dlg-sort-font-color'), @@ -529,6 +530,7 @@ define([ '006400', '800080', '8B0000', '808000', 'FFFFFF', 'D3D3D3' ] }); + this.mnuSortColorFontPicker.on('select', _.bind(this.onSortColorFontSelect, this)); this.mnuFilterColorCellsPicker = new Common.UI.ColorPaletteExt({ el: $('#filter-dlg-filter-cells-color'), @@ -539,6 +541,7 @@ define([ '006400', '800080', '8B0000', '808000', 'FFFFFF', 'D3D3D3' ] }); + this.mnuFilterColorCellsPicker.on('select', _.bind(this.onFilterColorSelect, this, null)); this.mnuFilterColorFontPicker = new Common.UI.ColorPaletteExt({ el: $('#filter-dlg-filter-font-color'), @@ -549,6 +552,7 @@ define([ '006400', '800080', '8B0000', '808000', 'FFFFFF', 'D3D3D3' ] }); + this.mnuFilterColorFontPicker.on('select', _.bind(this.onFilterColorSelect, this, false)); this.input = new Common.UI.InputField({ el : $('#id-sd-cell-search', this.$window), @@ -742,6 +746,30 @@ define([ dlgDigitalFilter.show(); }, + onFilterColorSelect: function(isCellColor, picker, color) { + var filterObj = this.configTo.asc_getFilterObj(); + if (filterObj.asc_getType() !== Asc.c_oAscAutoFilterTypes.ColorFilter) { + filterObj.asc_setFilter(new Asc.ColorFilter()); + filterObj.asc_setType(Asc.c_oAscAutoFilterTypes.ColorFilter); + } + + var colorFilter = filterObj.asc_getFilter(); + colorFilter.asc_setCellColor(isCellColor); + colorFilter.asc_setCColor(Common.Utils.ThemeColor.getRgbColor(color)); + + this.api.asc_applyAutoFilter('colorFilter', this.configTo); + + this.close(); + }, + + onSortColorCellsSelect: function(picker, color) { + + }, + + onSortColorFontSelect: function(picker, color) { + + }, + onCellCheck: function (listView, itemView, record) { if (this.checkCellTrigerBlock) return; @@ -834,40 +862,6 @@ define([ this.miTextFilter.setChecked(isCustomFilter && isTextFilter, true); this.miNumFilter.setChecked(isCustomFilter && !isTextFilter, true); - if (isCustomFilter) { - var customFilter = filterObj.asc_getFilter(), - customFilters = customFilter.asc_getCustomFilters(), - isAnd = (customFilter.asc_getAnd()), - cond1 = customFilters[0].asc_getOperator(), - cond2 = ((customFilters.length>1) ? (customFilters[1].asc_getOperator() || 0) : 0), - items = (isTextFilter) ? this.miTextFilter.menu.items : this.miNumFilter.menu.items, - isCustomConditions = true; - - if (customFilters.length==1) - items.forEach(function(item){ - item.setChecked(item.value == cond1, true); - if (item.value == cond1) isCustomConditions = false; - }); - else if (!isTextFilter && (cond1 == Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo && cond2 == Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo || - cond1 == Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo && cond2 == Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo)){ - items[7].setChecked(true, true); // between filter - isCustomConditions = false; - } - if (isCustomConditions) - items[items.length-1].setChecked(true, true); - } - - this.miSortLow2High.setChecked(false, true); - this.miSortHigh2Low.setChecked(false, true); - var sort = this.configTo.asc_getSortState(); - if (sort) { - if ('ascending' === sort) { - this.miSortLow2High.setChecked(true, true); - } else { - this.miSortHigh2Low.setChecked(true, true); - } - } - if (colorsFont && colorsFont.length>0) { var colors = []; colorsFont.forEach(function(item, index) { @@ -896,6 +890,50 @@ define([ this.miFilterCellColor.setVisible(false); } + if (isCustomFilter) { + var customFilter = filterObj.asc_getFilter(), + customFilters = customFilter.asc_getCustomFilters(), + isAnd = (customFilter.asc_getAnd()), + cond1 = customFilters[0].asc_getOperator(), + cond2 = ((customFilters.length>1) ? (customFilters[1].asc_getOperator() || 0) : 0), + items = (isTextFilter) ? this.miTextFilter.menu.items : this.miNumFilter.menu.items, + isCustomConditions = true; + + if (customFilters.length==1) + items.forEach(function(item){ + item.setChecked(item.value == cond1, true); + if (item.value == cond1) isCustomConditions = false; + }); + else if (!isTextFilter && (cond1 == Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo && cond2 == Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo || + cond1 == Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo && cond2 == Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo)){ + items[7].setChecked(true, true); // between filter + isCustomConditions = false; + } + if (isCustomConditions) + items[items.length-1].setChecked(true, true); + } else if (this.initialFilterType === Asc.c_oAscAutoFilterTypes.ColorFilter) { + var colorFilter = filterObj.asc_getFilter(), + filterColor = colorFilter.asc_getCColor(); + if (filterColor) + filterColor = Common.Utils.ThemeColor.getHexColor(filterColor.get_r(), filterColor.get_g(), filterColor.get_b()).toLocaleUpperCase(); + if ( colorFilter.asc_getCellColor()===null ) // cell color + this.mnuFilterColorCellsPicker.select(filterColor, true); + else if (colorFilter.asc_getCellColor()===false) // font color + this.mnuFilterColorFontPicker.select(filterColor, true); + } + + this.miSortLow2High.setChecked(false, true); + this.miSortHigh2Low.setChecked(false, true); + var sort = this.configTo.asc_getSortState(); + if (sort) { + if ('ascending' === sort) { + this.miSortLow2High.setChecked(true, true); + } else { + this.miSortHigh2Low.setChecked(true, true); + } + } + + this.btnOk.setDisabled(isCustomFilter); },