[SSE] Show rule settings

This commit is contained in:
Julia Radzhabova 2020-04-20 13:49:38 +03:00
parent 753ff60e2d
commit afef3613f3
2 changed files with 63 additions and 41 deletions

View file

@ -122,14 +122,14 @@ define([
name: this.textValue, name: this.textValue,
type: Asc.c_oAscCFType.cellIs, type: Asc.c_oAscCFType.cellIs,
rules: [ rules: [
{ name: this.textGreater, subtype: 0}, { name: this.textGreater, subtype: Asc.c_oAscCFOperator.greaterThan},
{ name: this.textGreaterEq, subtype: 1}, { name: this.textGreaterEq, subtype: Asc.c_oAscCFOperator.greaterThanOrEqual},
{ name: this.textLess, subtype: 2}, { name: this.textLess, subtype: Asc.c_oAscCFOperator.lessThan},
{ name: this.textLessEq, subtype: 3}, { name: this.textLessEq, subtype: Asc.c_oAscCFOperator.lessThanOrEqual},
{ name: this.textEqual, subtype: 4}, { name: this.textEqual, subtype: Asc.c_oAscCFOperator.equal},
{ name: this.textNotEqual, subtype: 5}, { name: this.textNotEqual, subtype: Asc.c_oAscCFOperator.notEqual},
{ name: this.textBetween, subtype: 6}, { name: this.textBetween, subtype: Asc.c_oAscCFOperator.between},
{ name: this.textNotBetween, subtype: 7} { name: this.textNotBetween, subtype: Asc.c_oAscCFOperator.notBetween}
] ]
}, },
{ {
@ -170,16 +170,16 @@ define([
name: 'Date', name: 'Date',
type: Asc.c_oAscCFType.timePeriod, type: Asc.c_oAscCFType.timePeriod,
rules: [ rules: [
{ name: 'Yesterday', subtype: 0}, { name: 'Yesterday', subtype: Asc.c_oAscTimePeriod.yesterday},
{ name: 'Today', subtype: 1}, { name: 'Today', subtype: Asc.c_oAscTimePeriod.today},
{ name: 'Tomorrow', subtype: 2}, { name: 'Tomorrow', subtype: Asc.c_oAscTimePeriod.tomorrow},
{ name: 'In the last 7 days', subtype: 3}, { name: 'In the last 7 days', subtype: Asc.c_oAscTimePeriod.last7Days},
{ name: 'Last week', subtype: 4}, { name: 'Last week', subtype: Asc.c_oAscTimePeriod.lastWeek},
{ name: 'This week', subtype: 5}, { name: 'This week', subtype: Asc.c_oAscTimePeriod.thisWeek},
{ name: 'Next week', subtype: 6}, { name: 'Next week', subtype: Asc.c_oAscTimePeriod.nextWeek},
{ name: 'Last month', subtype: 7}, { name: 'Last month', subtype: Asc.c_oAscTimePeriod.lastMonth},
{ name: 'This month', subtype: 8}, { name: 'This month', subtype: Asc.c_oAscTimePeriod.thisMonth},
{ name: 'Next month', subtype: 9} { name: 'Next month', subtype: Asc.c_oAscTimePeriod.nextMonth}
] ]
}, },
{ {
@ -277,8 +277,9 @@ define([
editable : false, editable : false,
cls : 'input-group-nr', cls : 'input-group-nr',
data : [] data : []
}).on('selected', function(combo, record) {
me.setControls(me.cmbCategory.getValue(), record.value);
}); });
// this.cmbRule.on('selected', _.bind(this.onRuleSelect, this));
this.txtRange1 = new Common.UI.InputFieldBtn({ this.txtRange1 = new Common.UI.InputFieldBtn({
el : $('#format-rules-edit-txt-r1'), el : $('#format-rules-edit-txt-r1'),
@ -444,7 +445,27 @@ define([
_setDefaults: function (props) { _setDefaults: function (props) {
var type = props ? props.asc_getType() : this.type, var type = props ? props.asc_getType() : this.type,
ruleType; ruleType,
subtype = this.subtype;
if (props) {
var value;
switch (type) {
case Asc.c_oAscCFType.containsText:
case Asc.c_oAscCFType.notContainsText:
case Asc.c_oAscCFType.beginsWith:
case Asc.c_oAscCFType.endsWith:
value = props.asc_getContainsText();
this.txtRange1.setValue(value);
break;
case Asc.c_oAscCFType.timePeriod:
subtype = props.asc_getTimePeriod();
break;
case Asc.c_oAscCFType.cellIs:
subtype = props.asc_getOperator();
break;
}
}
var rec = this.ruleStore.findWhere({type: type}); var rec = this.ruleStore.findWhere({type: type});
if (!rec) { if (!rec) {
@ -464,8 +485,6 @@ define([
ruleType = type; ruleType = type;
} else { } else {
// find by subtype // find by subtype
// var subtype = (props) ? props.asc_getSubtype() : this.subtype;
var subtype = this.subtype;
if ((subtype!==undefined) && rules && rules.findWhere({subtype: subtype})) { if ((subtype!==undefined) && rules && rules.findWhere({subtype: subtype})) {
ruleType = subtype; ruleType = subtype;
} }
@ -485,7 +504,7 @@ define([
} }
}, },
refreshRules: function(index, type) { refreshRules: function(index, ruleType) {
var rec = this.ruleStore.findWhere({index: index}); var rec = this.ruleStore.findWhere({index: index});
if (rec) { if (rec) {
var rules = rec.get('rules'), var rules = rec.get('rules'),
@ -494,14 +513,17 @@ define([
cmbData.push({value: (rule.get('type')!==undefined) ? rule.get('type') : rule.get('subtype'), displayValue: rule.get('name')}); cmbData.push({value: (rule.get('type')!==undefined) ? rule.get('type') : rule.get('subtype'), displayValue: rule.get('name')});
}); });
this.cmbRule.setData(cmbData); this.cmbRule.setData(cmbData);
(cmbData.length>0) && this.cmbRule.setValue((type!==undefined) ? type : cmbData[0].value); (cmbData.length>0) && this.cmbRule.setValue((ruleType!==undefined) ? ruleType : cmbData[0].value);
} }
this.setControls(index); this.setControls(index, this.cmbRule.getValue());
}, },
setControls: function(index) { setControls: function(category, rule) {
var hasformat = this.$window.find('.hasformat'); var hasformat = this.$window.find('.hasformat');
hasformat.toggleClass('hidden', index>=7 && index<=10); hasformat.toggleClass('hidden', category>=7 && category<=10);
this.txtRange1.setVisible(category==0 || category==3);
this.txtRange2.setVisible(category==0 && (rule == Asc.c_oAscCFOperator.between || rule == Asc.c_oAscCFOperator.notBetween));
}, },
onSelectData: function(cmp) { onSelectData: function(cmp) {

View file

@ -1879,23 +1879,23 @@ define([
{ {
caption : this.textGreater, caption : this.textGreater,
type : Asc.c_oAscCFType.cellIs, type : Asc.c_oAscCFType.cellIs,
value : 0 value : Asc.c_oAscCFOperator.greaterThan
}, },
{ {
caption : this.textLess, caption : this.textLess,
type : Asc.c_oAscCFType.cellIs, type : Asc.c_oAscCFType.cellIs,
value : 2 value : Asc.c_oAscCFOperator.lessThan
}, },
{ {
caption : this.textEqual, caption : this.textEqual,
type : Asc.c_oAscCFType.cellIs, type : Asc.c_oAscCFType.cellIs,
value : 4 value : Asc.c_oAscCFOperator.equal
}, },
{caption: '--'}, {caption: '--'},
{ {
caption : this.textBetween, caption : this.textBetween,
type : Asc.c_oAscCFType.cellIs, type : Asc.c_oAscCFType.cellIs,
value : 6 value : Asc.c_oAscCFOperator.between
}, },
{ {
caption : this.textTop10, caption : this.textTop10,
@ -1921,16 +1921,16 @@ define([
menu : new Common.UI.Menu({ menu : new Common.UI.Menu({
menuAlign : 'tl-tr', menuAlign : 'tl-tr',
items: [ items: [
{ caption: 'Yesterday', type: Asc.c_oAscCFType.timePeriod, value: 0 }, { caption: 'Yesterday', type: Asc.c_oAscCFType.timePeriod, value: Asc.c_oAscTimePeriod.yesterday },
{ caption: 'Today', type: Asc.c_oAscCFType.timePeriod, value: 1}, { caption: 'Today', type: Asc.c_oAscCFType.timePeriod, value: Asc.c_oAscTimePeriod.today},
{ caption: 'Tomorrow', type: Asc.c_oAscCFType.timePeriod, value: 2}, { caption: 'Tomorrow', type: Asc.c_oAscCFType.timePeriod, value: Asc.c_oAscTimePeriod.tomorrow},
{ caption: 'In the last 7 days', type: Asc.c_oAscCFType.timePeriod, value: 3}, { caption: 'In the last 7 days', type: Asc.c_oAscCFType.timePeriod, value: Asc.c_oAscTimePeriod.last7Days},
{ caption: 'Last week', type: Asc.c_oAscCFType.timePeriod, value: 4}, { caption: 'Last week', type: Asc.c_oAscCFType.timePeriod, value: Asc.c_oAscTimePeriod.lastWeek},
{ caption: 'This week', type: Asc.c_oAscCFType.timePeriod, value: 5}, { caption: 'This week', type: Asc.c_oAscCFType.timePeriod, value: Asc.c_oAscTimePeriod.thisWeek},
{ caption: 'Next week', type: Asc.c_oAscCFType.timePeriod, value: 6}, { caption: 'Next week', type: Asc.c_oAscCFType.timePeriod, value: Asc.c_oAscTimePeriod.nextWeek},
{ caption: 'Last month', type: Asc.c_oAscCFType.timePeriod, value: 7}, { caption: 'Last month', type: Asc.c_oAscCFType.timePeriod, value: Asc.c_oAscTimePeriod.lastMonth},
{ caption: 'This month', type: Asc.c_oAscCFType.timePeriod, value: 8}, { caption: 'This month', type: Asc.c_oAscCFType.timePeriod, value: Asc.c_oAscTimePeriod.thisMonth},
{ caption: 'Next month', type: Asc.c_oAscCFType.timePeriod, value: 9} { caption: 'Next month', type: Asc.c_oAscCFType.timePeriod, value: Asc.c_oAscTimePeriod.nextMonth}
] ]
}) })
}, },