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