From d622183c6ad664eccea1c90d554790a7ff4e2e80 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 28 Jan 2021 00:57:04 +0300 Subject: [PATCH] [SSE] Fix rules settings --- .../main/app/view/FormatRulesEditDlg.js | 9 +- .../main/app/view/FormatRulesManagerDlg.js | 82 +++++++++++++++---- 2 files changed, 68 insertions(+), 23 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js b/apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js index a29208e7f..4a227d02b 100644 --- a/apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js +++ b/apps/spreadsheeteditor/main/app/view/FormatRulesEditDlg.js @@ -692,9 +692,6 @@ define([ }); this.btnBorders.menu.on('item:click', _.bind(this.onBordersMenu, this)); this.btnBorders.on('click', _.bind(this.onBorders, this)); - var colorVal = $('
'); - $('button:first-child', this.btnBorders.cmpEl).append(colorVal); - colorVal.css('background-color', this.btnBorders.currentColor || 'transparent'); this.mnuBorderColorPicker = new Common.UI.ThemeColorPalette({ el: $('#format-rules-borders-menu-bordercolor') }); @@ -1161,8 +1158,6 @@ define([ } if (props) { - // var val = props.asc_getLocation(); - // this.txtScope.setValue((val) ? val : ''); if (type == Asc.c_oAscCFType.containsText || type == Asc.c_oAscCFType.notContainsText || type == Asc.c_oAscCFType.beginsWith || type == Asc.c_oAscCFType.endsWith || type == Asc.c_oAscCFType.timePeriod || type == Asc.c_oAscCFType.aboveAverage || type == Asc.c_oAscCFType.top10 || type == Asc.c_oAscCFType.cellIs || type == Asc.c_oAscCFType.expression) { @@ -1470,8 +1465,8 @@ define([ onFormatFillColorSelect: function(picker, color, fromBtn) { var clr = (typeof(color) == 'object') ? color.color : color; - this.mnuFillColorPicker.currentColor = color; - $('.btn-color-value-line', this.mnuFillColorPicker.cmpEl).css('background-color', '#' + clr); + this.btnFillColor.currentColor = color; + $('.btn-color-value-line', this.btnFillColor.cmpEl).css('background-color', '#' + clr); picker.currentColor = color; this.xfsFormat.asc_setFillColor(Common.Utils.ThemeColor.getRgbColor(this.mnuFillColorPicker.currentColor)); diff --git a/apps/spreadsheeteditor/main/app/view/FormatRulesManagerDlg.js b/apps/spreadsheeteditor/main/app/view/FormatRulesManagerDlg.js index 28fa617a0..f4fdb61cb 100644 --- a/apps/spreadsheeteditor/main/app/view/FormatRulesManagerDlg.js +++ b/apps/spreadsheeteditor/main/app/view/FormatRulesManagerDlg.js @@ -58,10 +58,23 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa me.template = me.options.template || me.template; - me.listenTo(me.model, 'change:sort', function() { + me.listenTo(me.model, 'change:name', function() { me.render(); me.trigger('change', me, me.model); }); + me.listenTo(me.model, 'change:tip', function() { + var el = me.$el || $(me.el), + tip = el.data('bs.tooltip'); + if (tip) { + var zIndex = tip.options.zIndex; + el.removeData('bs.tooltip'); + el.tooltip({ + title : me.model.get('tip'), + placement : 'cursor', + zIndex : zIndex + }); + } + }); me.listenTo(me.model, 'change:selected', function() { var el = me.$el || $(me.el); el.toggleClass('selected', me.model.get('selected') && me.model.get('allowSelected')); @@ -107,19 +120,13 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa this.cmbScope = new Common.UI.ComboBox({ el : $('#format-manager-combo-scope'), - menuStyle : 'min-width: 100%;', + menuStyle : 'min-width: 100%;max-height: 211px;', editable : false, cls : 'input-group-nr', - data : [ - { value: Asc.c_oAscSelectionForCFType.selection, displayValue: this.textSelection }, - { value: Asc.c_oAscSelectionForCFType.worksheet, displayValue: this.textThisSheet }, - { value: Asc.c_oAscSelectionForCFType.table, displayValue: this.textThisTable }, - { value: Asc.c_oAscSelectionForCFType.pivot, displayValue: this.textThisPivot } - ] + data : [] }).on('selected', function(combo, record) { - me.refreshRuleList(record.value); + me.refreshRuleList(record); }); - this.cmbScope.setValue(Asc.c_oAscSelectionForCFType.selection); this.rulesList = new Common.UI.ListView({ el: $('#format-manager-rules-list', this.$window), @@ -130,7 +137,7 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa '
', '
<%= name %>
', '
', - '
', + '
', '
' ].join('')) }); @@ -184,23 +191,50 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa _setDefaults: function (props) { this.rulesList.on('item:add', _.bind(this.addControls, this)); this.rulesList.on('item:change', _.bind(this.addControls, this)); - this.refreshRuleList(this.cmbScope.getValue()); + this.refreshScopeList(); + this.refreshRuleList(this.cmbScope.getSelectedRecord()); + }, + + refreshScopeList: function() { + var wc = this.api.asc_getWorksheetsCount(), i = -1, + currentSheet = this.api.asc_getActiveWorksheetIndex(); + var items = [ + { value: Asc.c_oAscSelectionForCFType.selection, displayValue: this.textSelection }, + { value: Asc.c_oAscSelectionForCFType.worksheet, displayValue: this.textThisSheet, sheetIndex: currentSheet }, + { value: Asc.c_oAscSelectionForCFType.table, displayValue: this.textThisTable }, + { value: Asc.c_oAscSelectionForCFType.pivot, displayValue: this.textThisPivot } + ]; + if (wc>1) { + while (++i < wc) { + if (!this.api.asc_isWorksheetHidden(i) && i!==currentSheet) { + items.push({ + displayValue:this.api.asc_getWorksheetName(i), + value: Asc.c_oAscSelectionForCFType.worksheet, + sheetIndex: i + }); + } + } + } + this.cmbScope.setData(items); + this.cmbScope.setValue(Asc.c_oAscSelectionForCFType.selection); }, refreshRuleList: function(scope) { - var obj = this.api.asc_getCF(scope, (scope==Asc.c_oAscSelectionForCFType.worksheet) ? this.api.asc_getActiveWorksheetIndex() : undefined); + var obj = this.api.asc_getCF(scope.value, (scope.value==Asc.c_oAscSelectionForCFType.worksheet) ? scope.sheetIndex : undefined); var levels = obj[0]; this.currentRange = obj[1]; var arr = []; if (levels) { for (var i=0; i