[SSE] Refactoring conditional formatting
This commit is contained in:
parent
77491f30cc
commit
753ff60e2d
|
@ -385,6 +385,9 @@ define([
|
|||
toolbar.btnPrintTitles.on('click', _.bind(this.onPrintTitlesClick, this));
|
||||
if (toolbar.btnCondFormat.rendered) {
|
||||
toolbar.btnCondFormat.menu.on('item:click', _.bind(this.onCondFormatMenu, this));
|
||||
toolbar.btnCondFormat.menu.items[7].menu.on('item:click', _.bind(this.onCondFormatMenu, this));
|
||||
toolbar.btnCondFormat.menu.items[9].menu.on('item:click', _.bind(this.onCondFormatMenu, this));
|
||||
toolbar.btnCondFormat.menu.items[21].menu.on('item:click', _.bind(this.onCondFormatMenu, this));
|
||||
}
|
||||
Common.Gateway.on('insertimage', _.bind(this.insertImage, this));
|
||||
|
||||
|
@ -1454,8 +1457,8 @@ define([
|
|||
},
|
||||
|
||||
onCondFormatMenu: function(menu, item) {
|
||||
var me = this;
|
||||
if (item.value == 'manage') {
|
||||
var me = this;
|
||||
(new SSE.Views.FormatRulesManagerDlg({
|
||||
api: me.api,
|
||||
handler: function (result, settings) {
|
||||
|
@ -1463,6 +1466,19 @@ define([
|
|||
}
|
||||
}
|
||||
})).show();
|
||||
} else if (item.value == 'clear') {
|
||||
} else {
|
||||
(new SSE.Views.FormatRulesEditDlg({
|
||||
api: me.api,
|
||||
props : null,
|
||||
type : item.options.type,
|
||||
subtype : item.value,
|
||||
isEdit : false,
|
||||
handler : function(result, settings) {
|
||||
if (result == 'ok' && settings) {
|
||||
}
|
||||
}
|
||||
})).show();
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -108,6 +108,8 @@ define([
|
|||
this.handler = options.handler;
|
||||
this.isEdit = options.isEdit || false;
|
||||
this.props = options.props;
|
||||
this.type = options.type; // rule category
|
||||
this.subtype = options.subtype; // rule
|
||||
|
||||
Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options);
|
||||
},
|
||||
|
@ -120,40 +122,38 @@ define([
|
|||
name: this.textValue,
|
||||
type: Asc.c_oAscCFType.cellIs,
|
||||
rules: [
|
||||
{ name: this.textGreater},
|
||||
{ name: this.textGreaterEq},
|
||||
{ name: this.textLess},
|
||||
{ name: this.textLessEq},
|
||||
{ name: this.textEqual},
|
||||
{ name: this.textNotEqual},
|
||||
{ name: this.textBetween},
|
||||
{ name: this.textNotBetween}
|
||||
{ name: this.textGreater, subtype: 0},
|
||||
{ name: this.textGreaterEq, subtype: 1},
|
||||
{ name: this.textLess, subtype: 2},
|
||||
{ name: this.textLessEq, subtype: 3},
|
||||
{ name: this.textEqual, subtype: 4},
|
||||
{ name: this.textNotEqual, subtype: 5},
|
||||
{ name: this.textBetween, subtype: 6},
|
||||
{ name: this.textNotBetween, subtype: 7}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: this.textRanked,
|
||||
type: Asc.c_oAscCFType.top10,
|
||||
rules: [
|
||||
{ name: this.textTop10},
|
||||
{ name: this.textTop10Per},
|
||||
{ name: this.textBottom10},
|
||||
{ name: this.textBottom10Per}
|
||||
{ name: this.textTop, subtype: 0},
|
||||
{ name: this.textBottom, subtype: 1}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'Average',
|
||||
type: Asc.c_oAscCFType.aboveAverage,
|
||||
rules: [
|
||||
{ name: 'Above'},
|
||||
{ name: 'Below'},
|
||||
{ name: 'Equal or above'},
|
||||
{ name: 'Equal or below'},
|
||||
{ name: '1 std dev above'},
|
||||
{ name: '1 std dev below'},
|
||||
{ name: '2 std dev above'},
|
||||
{ name: '2 std dev below'},
|
||||
{ name: '3 std dev above'},
|
||||
{ name: '3 std dev below'}
|
||||
{ name: 'Above', subtype: 0},
|
||||
{ name: 'Below', subtype: 1},
|
||||
{ name: 'Equal or above', subtype: 2},
|
||||
{ name: 'Equal or below', subtype: 3},
|
||||
{ name: '1 std dev above', subtype: 4},
|
||||
{ name: '1 std dev below', subtype: 5},
|
||||
{ name: '2 std dev above', subtype: 6},
|
||||
{ name: '2 std dev below', subtype: 7},
|
||||
{ name: '3 std dev above', subtype: 8},
|
||||
{ name: '3 std dev below', subtype: 9}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -170,16 +170,16 @@ define([
|
|||
name: 'Date',
|
||||
type: Asc.c_oAscCFType.timePeriod,
|
||||
rules: [
|
||||
{ name: 'Yesterday'},
|
||||
{ name: 'Today'},
|
||||
{ name: 'Tomorrow'},
|
||||
{ name: 'In the last 7 days'},
|
||||
{ name: 'Last week'},
|
||||
{ name: 'This week'},
|
||||
{ name: 'Next week'},
|
||||
{ name: 'Last month'},
|
||||
{ name: 'This month'},
|
||||
{ name: 'Next month'}
|
||||
{ name: 'Yesterday', subtype: 0},
|
||||
{ name: 'Today', subtype: 1},
|
||||
{ name: 'Tomorrow', subtype: 2},
|
||||
{ name: 'In the last 7 days', subtype: 3},
|
||||
{ name: 'Last week', subtype: 4},
|
||||
{ name: 'This week', subtype: 5},
|
||||
{ name: 'Next week', subtype: 6},
|
||||
{ name: 'Last month', subtype: 7},
|
||||
{ name: 'This month', subtype: 8},
|
||||
{ name: 'Next month', subtype: 9}
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -231,7 +231,8 @@ define([
|
|||
rule.rules && _.each(rule.rules, function(item, idx){
|
||||
arr.push({
|
||||
name : item.name,
|
||||
type : (item.type!==undefined) ? item.type : rule.type,
|
||||
type : item.type,
|
||||
subtype : item.subtype,
|
||||
allowSelected : true,
|
||||
selected: false
|
||||
});
|
||||
|
@ -442,32 +443,45 @@ define([
|
|||
},
|
||||
|
||||
_setDefaults: function (props) {
|
||||
if (props) {
|
||||
var type = props.asc_getType(),
|
||||
ruleType;
|
||||
var rec = this.ruleStore.findWhere({type: type});
|
||||
if (!rec) {
|
||||
var store = this.ruleStore;
|
||||
for (var i=0; i<store.length; i++) {
|
||||
var item = store.at(i);
|
||||
if (item.rules && item.rules.findWhere({type: type})) {
|
||||
rec = item;
|
||||
ruleType = type;
|
||||
break;
|
||||
}
|
||||
var type = props ? props.asc_getType() : this.type,
|
||||
ruleType;
|
||||
|
||||
var rec = this.ruleStore.findWhere({type: type});
|
||||
if (!rec) {
|
||||
var store = this.ruleStore;
|
||||
for (var i=0; i<store.length; i++) {
|
||||
var item = store.at(i),
|
||||
rules = item.get('rules');
|
||||
if (rules && rules.findWhere({type: type})) {
|
||||
rec = item;
|
||||
ruleType = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!rec)
|
||||
rec = this.ruleStore.at(0);
|
||||
if (rec) {
|
||||
this.cmbCategory.setValue(rec.get('index'));
|
||||
this.refreshRules(rec.get('index'), ruleType);
|
||||
} else { // find rule
|
||||
var rules = rec.get('rules');
|
||||
if (rules && rules.findWhere({type: type})) {
|
||||
ruleType = type;
|
||||
} else {
|
||||
// find by subtype
|
||||
// var subtype = (props) ? props.asc_getSubtype() : this.subtype;
|
||||
var subtype = this.subtype;
|
||||
if ((subtype!==undefined) && rules && rules.findWhere({subtype: subtype})) {
|
||||
ruleType = subtype;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!rec)
|
||||
rec = this.ruleStore.at(0);
|
||||
if (rec) {
|
||||
this.cmbCategory.setValue(rec.get('index'));
|
||||
this.refreshRules(rec.get('index'), ruleType);
|
||||
}
|
||||
|
||||
if (props) {
|
||||
var val = props.asc_getLocation();
|
||||
this.txtScope.setValue((val) ? val : '');
|
||||
} else {
|
||||
this.cmbCategory.setValue(0);
|
||||
this.refreshRules(0);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -477,7 +491,7 @@ define([
|
|||
var rules = rec.get('rules'),
|
||||
cmbData = [];
|
||||
rules && rules.each(function(rule, idx){
|
||||
cmbData.push({value: rule.get('type'), 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);
|
||||
(cmbData.length>0) && this.cmbRule.setValue((type!==undefined) ? type : cmbData[0].value);
|
||||
|
@ -571,10 +585,8 @@ define([
|
|||
textBetween: 'Between',
|
||||
textNotBetween: 'Not between',
|
||||
textRanked: 'Ranked',
|
||||
textTop10: 'Top 10 items',
|
||||
textTop10Per: 'Top 10%',
|
||||
textBottom10: 'Bottom 10 items',
|
||||
textBottom10Per: 'Bottom 10%',
|
||||
textTop: 'Top',
|
||||
textBottom: 'Bottom',
|
||||
textText: 'Text',
|
||||
textDate: 'Date',
|
||||
textBlank: 'Blank',
|
||||
|
|
|
@ -1878,56 +1878,75 @@ define([
|
|||
items: [
|
||||
{
|
||||
caption : this.textGreater,
|
||||
value : Asc.c_oAscCustomAutoFilter.isGreaterThan
|
||||
type : Asc.c_oAscCFType.cellIs,
|
||||
value : 0
|
||||
},
|
||||
{
|
||||
caption : this.textLess,
|
||||
value : Asc.c_oAscCustomAutoFilter.isLessThan
|
||||
type : Asc.c_oAscCFType.cellIs,
|
||||
value : 2
|
||||
},
|
||||
{
|
||||
caption : this.textEqual,
|
||||
value : Asc.c_oAscCustomAutoFilter.equals
|
||||
type : Asc.c_oAscCFType.cellIs,
|
||||
value : 4
|
||||
},
|
||||
{caption: '--'},
|
||||
{
|
||||
caption : this.textBetween,
|
||||
value : Asc.c_oAscCustomAutoFilter.between
|
||||
type : Asc.c_oAscCFType.cellIs,
|
||||
value : 6
|
||||
},
|
||||
{
|
||||
caption : this.textTop10,
|
||||
value : Asc.c_oAscCustomAutoFilter.top10
|
||||
type : Asc.c_oAscCFType.top10,
|
||||
value : 0
|
||||
},
|
||||
{caption: '--'},
|
||||
{
|
||||
caption : this.textText,
|
||||
value : Asc.c_oAscCustomAutoFilter.text,
|
||||
menu : new Common.UI.Menu({
|
||||
menuAlign : 'tl-tr',
|
||||
items: []
|
||||
items: [
|
||||
{ caption: 'Contains', type: Asc.c_oAscCFType.containsText },
|
||||
{ caption: 'Does not contain', type: Asc.c_oAscCFType.notContainsText },
|
||||
{ caption: 'Begins with', type: Asc.c_oAscCFType.beginsWith },
|
||||
{ caption: 'Ends with', type: Asc.c_oAscCFType.endsWith }
|
||||
]
|
||||
})
|
||||
},
|
||||
{caption: '--'},
|
||||
{
|
||||
caption : this.textDate,
|
||||
value : Asc.c_oAscCustomAutoFilter.date,
|
||||
menu : new Common.UI.Menu({
|
||||
menuAlign : 'tl-tr',
|
||||
items: []
|
||||
items: [
|
||||
{ caption: 'Yesterday', type: Asc.c_oAscCFType.timePeriod, value: 0 },
|
||||
{ caption: 'Today', type: Asc.c_oAscCFType.timePeriod, value: 1},
|
||||
{ caption: 'Tomorrow', type: Asc.c_oAscCFType.timePeriod, value: 2},
|
||||
{ caption: 'In the last 7 days', type: Asc.c_oAscCFType.timePeriod, value: 3},
|
||||
{ caption: 'Last week', type: Asc.c_oAscCFType.timePeriod, value: 4},
|
||||
{ caption: 'This week', type: Asc.c_oAscCFType.timePeriod, value: 5},
|
||||
{ caption: 'Next week', type: Asc.c_oAscCFType.timePeriod, value: 6},
|
||||
{ caption: 'Last month', type: Asc.c_oAscCFType.timePeriod, value: 7},
|
||||
{ caption: 'This month', type: Asc.c_oAscCFType.timePeriod, value: 8},
|
||||
{ caption: 'Next month', type: Asc.c_oAscCFType.timePeriod, value: 9}
|
||||
]
|
||||
})
|
||||
},
|
||||
{caption: '--'},
|
||||
{
|
||||
caption : this.textBlank,
|
||||
value : Asc.c_oAscCustomAutoFilter.blank
|
||||
type : Asc.c_oAscCFType.containsBlanks
|
||||
},
|
||||
{
|
||||
caption : this.textDuplicate,
|
||||
value : Asc.c_oAscCustomAutoFilter.duplicate
|
||||
type : Asc.c_oAscCFType.duplicateValues
|
||||
},
|
||||
{caption: '--'},
|
||||
{
|
||||
caption : this.textDataBars,
|
||||
value : Asc.c_oAscCustomAutoFilter.bars,
|
||||
type : Asc.c_oAscCFType.dataBar,
|
||||
menu : new Common.UI.Menu({
|
||||
menuAlign : 'tl-tr',
|
||||
items: []
|
||||
|
@ -1935,7 +1954,7 @@ define([
|
|||
},
|
||||
{
|
||||
caption : this.textColorScales,
|
||||
value : Asc.c_oAscCustomAutoFilter.scales,
|
||||
type : Asc.c_oAscCFType.colorScale,
|
||||
menu : new Common.UI.Menu({
|
||||
menuAlign : 'tl-tr',
|
||||
items: []
|
||||
|
@ -1943,13 +1962,18 @@ define([
|
|||
},
|
||||
{
|
||||
caption : this.textIconSets,
|
||||
value : Asc.c_oAscCustomAutoFilter.icons,
|
||||
type : Asc.c_oAscCFType.iconSet,
|
||||
menu : new Common.UI.Menu({
|
||||
menuAlign : 'tl-tr',
|
||||
items: []
|
||||
})
|
||||
},
|
||||
{caption: '--'},
|
||||
{
|
||||
caption : 'Formula',
|
||||
type : Asc.c_oAscCFType.expression
|
||||
},
|
||||
{caption: '--'},
|
||||
{
|
||||
caption : this.textNewRule,
|
||||
value : 'new'
|
||||
|
@ -1958,7 +1982,12 @@ define([
|
|||
caption : this.textClearRule,
|
||||
menu : new Common.UI.Menu({
|
||||
menuAlign : 'tl-tr',
|
||||
items: []
|
||||
items: [
|
||||
{ value: 'clear', type: Asc.c_oAscSelectionForCFType.selection, caption: this.textSelection },
|
||||
{ value: 'clear', type: Asc.c_oAscSelectionForCFType.worksheet, caption: this.textThisSheet },
|
||||
{ value: 'clear', type: Asc.c_oAscSelectionForCFType.table, caption: this.textThisTable },
|
||||
{ value: 'clear', type: Asc.c_oAscSelectionForCFType.pivot, caption: this.textThisPivot }
|
||||
]
|
||||
})
|
||||
},
|
||||
{
|
||||
|
@ -2517,6 +2546,10 @@ define([
|
|||
textIconSets: 'Icon Sets',
|
||||
textNewRule: 'New Rule',
|
||||
textClearRule: 'Clear Rules',
|
||||
textSelection: 'From current selection',
|
||||
textThisSheet: 'From this worksheet',
|
||||
textThisTable: 'From this table',
|
||||
textThisPivot: 'From this pivot',
|
||||
textManageRule: 'Manage Rules'
|
||||
|
||||
}, SSE.Views.Toolbar || {}));
|
||||
|
|
Loading…
Reference in a new issue