[SSE] Change settings for conditional formatting

This commit is contained in:
Julia Radzhabova 2021-02-02 11:03:27 +03:00
parent 46d7ed84f1
commit a9f022503d
2 changed files with 129 additions and 27 deletions

View file

@ -130,6 +130,14 @@ define([
'</div>',
'</td>',
'</tr>',
'<tr class="scale">',
'<td colspan="3" class="padding-small">',
'<label class="header">', me.textPreview,'</label>',
'<div style="border: 1px solid #cbcbcb;width: 100%; height: 40px; padding: 3px;">',
'<div id="format-rules-edit-preview-scale" style="width: 100%; height: 100%; position: relative; margin: 0 auto;"></div>',
'</div>',
'</td>',
'</tr>',
'<tr class="databar">',
'<td class="padding-large" style="padding-top: 8px;">',
'<div style="width:150px; display: inline-block; margin-right: 10px;vertical-align: top;">',
@ -1121,6 +1129,11 @@ define([
value = props.asc_getColorScaleOrDataBarOrIconSetRule();
break;
}
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) {
this.xfsFormat = props.asc_getDxf();
}
}
var rec = this.ruleStore.where({type: type});
@ -1158,13 +1171,6 @@ define([
this.refreshRules(rec.get('index'), ruleType);
}
if (props) {
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) {
this.xfsFormat = props.asc_getDxf();
}
}
var xfs = this.xfsFormat ? this.xfsFormat : (new AscCommonExcel.CellXfs());
if (xfs) {
this.btnBold.toggle(xfs.asc_getFontBold() === true, true);
@ -1240,7 +1246,7 @@ define([
case Asc.c_oAscCFType.colorScale:
var scaleProps = new AscCommonExcel.CColorScale();
var scalesCount = rec.get('num');
var arr = (scalesCount) ? [this.scaleControls[0], this.scaleControls[2]] : this.scaleControls;
var arr = (scalesCount==2) ? [this.scaleControls[0], this.scaleControls[2]] : this.scaleControls;
var colors = [], scales = [];
for (var i=0; i<scalesCount; i++) {
var scale = new AscCommonExcel.CConditionalFormatValueObject();
@ -1248,10 +1254,10 @@ define([
scale.asc_setType(controls.combo.getValue());
scale.asc_setVal(controls.range.getValue());
scales.push(scale);
colors.push(Common.Utils.ThemeColor.getRgbColor(Common.Utils.ThemeColor.getRgbColor(controls.color.currentColor)));
colors.push(Common.Utils.ThemeColor.getRgbColor(controls.colorPicker.currentColor));
}
scaleProps.asc_setColors();
scaleProps.asc_setCFVOs();
scaleProps.asc_setColors(colors);
scaleProps.asc_setCFVOs(scales);
props.asc_setColorScaleOrDataBarOrIconSetRule(scaleProps);
break;
case Asc.c_oAscCFType.dataBar:
@ -1309,6 +1315,34 @@ define([
(cmbData.length>0) && this.cmbRule.setValue((ruleType!==undefined) ? ruleType : cmbData[0].value);
}
this.setControls(index, this.cmbRule.getValue());
if (rec) {
var type = rec.get('type');
this._changedProps = new AscCommonExcel.CConditionalFormattingRule();
this._changedProps.asc_setType(type);
if (type == Asc.c_oAscCFType.containsText || type == Asc.c_oAscCFType.containsBlanks || type == Asc.c_oAscCFType.duplicateValues ||
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) {
this.xfsFormat && this._changedProps.asc_setDxf(this.xfsFormat);
} else if (type == Asc.c_oAscCFType.colorScale) {
var scalesCount = rec.get('num');
var arr = (scalesCount==2) ? [this.scaleControls[0], this.scaleControls[2]] : this.scaleControls;
var colors = [], scales = [];
for (var i=0; i<arr.length; i++) {
var scale = new AscCommonExcel.CConditionalFormatValueObject();
var controls = arr[i];
scale.asc_setType(controls.combo.getValue());
scale.asc_setVal(controls.range.getValue());
scales.push(scale);
colors.push(Common.Utils.ThemeColor.getRgbColor(controls.colorPicker.currentColor));
}
this.scaleProps = new AscCommonExcel.CColorScale();
this.scaleProps.asc_setColors(colors);
this.scaleProps.asc_setCFVOs(scales);
this._changedProps.asc_setColorScaleOrDataBarOrIconSetRule(this.scaleProps);
}
this.previewFormat();
}
},
setControls: function(category, rule) {
@ -1489,7 +1523,19 @@ define([
},
previewFormat: function() {
this.api.asc_getPreviewCF('format-rules-edit-preview-format', this.xfsFormat, this.xfsFormat ? Common.define.conditionalData.exampleText : Common.define.conditionalData.noFormatText);
if (this._changedProps) {
var type = this._changedProps.asc_getType();
if (type == Asc.c_oAscCFType.containsText || type == Asc.c_oAscCFType.containsBlanks || type == Asc.c_oAscCFType.duplicateValues ||
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) {
this.xfsFormat && !this._changedProps.asc_getDxf() && this._changedProps.asc_setDxf(this.xfsFormat);
this._changedProps.asc_getPreview('format-rules-edit-preview-format', this.xfsFormat ? Common.define.conditionalData.exampleText : Common.define.conditionalData.noFormatText);
} else if (type == Asc.c_oAscCFType.colorScale) {
this._changedProps.asc_getPreview('format-rules-edit-preview-scale', '');
} else if (type == Asc.c_oAscCFType.dataBar) {
this._changedProps.asc_getPreview('format-rules-edit-preview-databar', '');
}
}
},
updateThemeColors: function() {
@ -1499,8 +1545,11 @@ define([
var colorPicker = btn.getPicker();
colorPicker.options.type = i;
colorPicker.updateColors(Common.Utils.ThemeColor.getEffectColors(), Common.Utils.ThemeColor.getStandartColors());
colorPicker.currentColor = (i==0) ? 'FFC000' : (i==1 ? 'FFFF00' : '92D050');
colorPicker.select(colorPicker.currentColor, true);
btn.setColor(colorPicker.currentColor);
this.scaleControls[i].colorPicker = colorPicker;
// btn.on('color:select', _.bind(this.onColorsSelect, this));
btn.on('color:select', _.bind(this.onScaleColorsSelect, this));
}
var me = this;
@ -1526,6 +1575,17 @@ define([
this.mnuBorderColorPicker.updateColors(Common.Utils.ThemeColor.getEffectColors(), Common.Utils.ThemeColor.getStandartColors());
},
onScaleColorsSelect: function(picker, color) {
picker.currentColor = color;
if (this.scaleProps ) {
var colors = this.scaleProps.asc_getColors();
colors[picker.options.type] = Common.Utils.ThemeColor.getRgbColor(picker.currentColor);
this.scaleProps.asc_setColors(colors);
this.previewFormat();
}
},
onPrimary: function() {
this.onDlgBtnClick('ok');
return false;

View file

@ -469,13 +469,14 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa
drawRulePreview: function(rule) {
var props = rule.get('props'),
type = props.asc_getType();
type = props.asc_getType(),
text = '';
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) {
var dxf = props.asc_getDxf();
this.api.asc_getPreviewCF(this.rules[rule.get('ruleIndex')].previewDiv, dxf, dxf ? Common.define.conditionalData.exampleText : Common.define.conditionalData.noFormatText);
text = props.asc_getDxf() ? Common.define.conditionalData.exampleText : Common.define.conditionalData.noFormatText;
}
props.asc_getPreview(this.rules[rule.get('ruleIndex')].previewDiv, text);
},
onSelectData: function(item, cmp) {
@ -527,28 +528,30 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa
rec.set('props', settings);
previewRec = rec;
} else {
var store = me.rulesList.store,
index = rec ? store.indexOf(rec)+1 : store.length;
settings.asc_setLocation(me.currentRange);
previewRec = store.add({
ruleIndex: index,
var ruleStore = me.rulesStores[me.currentSheet];
previewRec = ruleStore.add({
ruleIndex: me.rules.length,
name: name,
tip: name,
range: me.currentRange,
activeSheet: true,
ruleChanged: true,
priority: 1,
props: settings
}, {at: index});
me.updateRulesCount();
me.rulesList.selectRecord(previewRec);
me.updateButtons();
// need to update priorities
}, {at: 0});
me.updateRulesPriority(ruleStore);
}
}
}
}).on('close', function() {
me.show();
previewRec && me.drawRulePreview(previewRec);
if (isEdit) {
previewRec && me.drawRulePreview(previewRec);
} else if (previewRec) {
me.cmbScope.setValue(Asc.c_oAscSelectionForCFType.selection);
me.refreshRuleList(me.cmbScope.getSelectedRecord());
}
});
me.hide();
@ -578,8 +581,11 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa
rec = this.rulesList.getSelectedRec();
if (rec) {
var index = store.indexOf(rec);
var newrec = store.at(up ? this.getPrevRuleIndex(index) : this.getNextRuleIndex(index)),
prioritynew = newrec.get('priority');
newrec.set('priority', rec.get('priority'));
rec.set('priority', prioritynew);
store.add(store.remove(rec), {at: up ? Math.max(0, index-1) : Math.min(length-1, index+1)});
// need to update priorities
this.rulesList.selectRecord(rec);
this.rulesList.scrollToRecord(rec);
}
@ -605,6 +611,34 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa
this.btnDown.setDisabled(index<0 || index==this.listSettings.max);
},
getPrevRuleIndex: function(index) {
var store = this.rulesList.store;
if (this.cmbScope.getValue() == Asc.c_oAscSelectionForCFType.worksheet) {
return Math.max(0, index-1);
} else {
for (var i=index-1; i>=this.listSettings.min; i--) {
if (store.at(i).get('cls')!=='hidden') {
return i;
}
}
return this.listSettings.min;
}
},
getNextRuleIndex: function(index) {
var store = this.rulesList.store;
if (this.cmbScope.getValue() == Asc.c_oAscSelectionForCFType.worksheet) {
return Math.min(store.length-1, index+1);
} else {
for (var i=index+1; i<=this.listSettings.max; i++) {
if (store.at(i).get('cls')!=='hidden') {
return i;
}
}
return this.listSettings.max;
}
},
updateRulesCount: function() {
var store = this.rulesList.store;
if (this.cmbScope.getValue() == Asc.c_oAscSelectionForCFType.worksheet) {
@ -621,6 +655,14 @@ define([ 'text!spreadsheeteditor/main/app/template/FormatRulesManagerDlg.templa
}
},
updateRulesPriority: function(store) {
for (var i=1; i<store.length; i++) {
var item = store.at(i);
item.set('priority', item.get('priority')+1);
}
},
getSettings: function() {
var sheets = [];
for (var sheet in this.rulesStores) {