[SSE] Change applying conditional format presets

This commit is contained in:
Julia Radzhabova 2021-03-03 00:30:04 +03:00
parent 6c7ebc300a
commit 84e7d66330
3 changed files with 46 additions and 15 deletions

View file

@ -43,6 +43,18 @@ define([
], function(Backbone){ 'use strict'; ], function(Backbone){ 'use strict';
SSE.Collections.ConditionalFormatIcons = Backbone.Collection.extend({ SSE.Collections.ConditionalFormatIcons = Backbone.Collection.extend({
model: Backbone.Model.extend({
defaults: function() {
return {
id: Common.UI.getId(),
index: 0,
icon: null
}
}
})
});
SSE.Collections.ConditionalFormatIconsPresets = Backbone.Collection.extend({
model: Backbone.Model.extend({ model: Backbone.Model.extend({
defaults: function() { defaults: function() {
return { return {

View file

@ -89,6 +89,7 @@ define([
'EquationGroups', 'EquationGroups',
'TableTemplates', 'TableTemplates',
'ConditionalFormatIcons', 'ConditionalFormatIcons',
'ConditionalFormatIconsPresets',
'Common.Collections.TextArt' 'Common.Collections.TextArt'
], ],
views: [], views: [],
@ -2037,11 +2038,25 @@ define([
artStore.reset(arr); artStore.reset(arr);
}, },
fillCondFormatIcons: function(iconSets){ fillCondFormatIcons: function(icons){
if (_.isEmpty(iconSets)) return; if (_.isEmpty(icons)) return;
var arr = [], var arr = [],
store = this.getCollection('ConditionalFormatIcons'); store = this.getCollection('ConditionalFormatIcons');
_.each(icons, function(icon, index){
arr.push({
icon : icon,
index : index
});
});
store.reset(arr);
},
fillCondFormatIconsPresets: function(iconSets){
if (_.isEmpty(iconSets)) return;
var arr = [],
store = this.getCollection('ConditionalFormatIconsPresets');
_.each(iconSets, function(iconSet, index){ _.each(iconSets, function(iconSet, index){
arr.push({ arr.push({
icons : iconSet, icons : iconSet,

View file

@ -1589,10 +1589,14 @@ define([
}, },
onShowBeforeCondFormat: function() { onShowBeforeCondFormat: function() {
var collection = SSE.getCollection('ConditionalFormatIcons'); if (SSE.getCollection('ConditionalFormatIconsPresets').length>0) return;
if (collection.length>0) return; var presets = this.api.asc_getCFIconsByType();
SSE.getController('Main').fillCondFormatIconsPresets(presets);
var collectionIcons = SSE.getCollection('ConditionalFormatIcons');
if (collectionIcons.length<1)
SSE.getController('Main').fillCondFormatIcons(this.api.asc_getFullCFIcons());
SSE.getController('Main').fillCondFormatIcons(this.api.asc_getCFIcons());
var me = this; var me = this;
var menuItem = this.toolbar.mnuDataBars; var menuItem = this.toolbar.mnuDataBars;
@ -1672,23 +1676,22 @@ define([
arr = []; arr = [];
var indexes = [Asc.EIconSetType.Arrows3, Asc.EIconSetType.Arrows3Gray, Asc.EIconSetType.Triangles3, Asc.EIconSetType.Arrows4Gray, Asc.EIconSetType.Arrows4, Asc.EIconSetType.Arrows5Gray, Asc.EIconSetType.Arrows5]; var indexes = [Asc.EIconSetType.Arrows3, Asc.EIconSetType.Arrows3Gray, Asc.EIconSetType.Triangles3, Asc.EIconSetType.Arrows4Gray, Asc.EIconSetType.Arrows4, Asc.EIconSetType.Arrows5Gray, Asc.EIconSetType.Arrows5];
for (var i=0; i<indexes.length; i++) { for (var i=0; i<indexes.length; i++) {
var item = collection.at(indexes[i]); var item = presets[indexes[i]];
arr.push({group: 'menu-iconset-group-direct', data: {index: item.get('data'), icons: item.get('icons')}}); arr.push({group: 'menu-iconset-group-direct', data: {index: indexes[i], iconSet: presets[indexes[i]], icons: collectionIcons}});
} }
indexes = [Asc.EIconSetType.Traffic3Lights1, Asc.EIconSetType.Traffic3Lights2, Asc.EIconSetType.Signs3, Asc.EIconSetType.Traffic4Lights, Asc.EIconSetType.RedToBlack4]; indexes = [Asc.EIconSetType.Traffic3Lights1, Asc.EIconSetType.Traffic3Lights2, Asc.EIconSetType.Signs3, Asc.EIconSetType.Traffic4Lights, Asc.EIconSetType.RedToBlack4];
for (var i=0; i<indexes.length; i++) { for (var i=0; i<indexes.length; i++) {
var item = collection.at(indexes[i]); arr.push({group: 'menu-iconset-group-shape', data: {index: indexes[i], iconSet: presets[indexes[i]], icons: collectionIcons}});
arr.push({group: 'menu-iconset-group-shape', data: {index: item.get('data'), icons: item.get('icons')}});
} }
indexes = [Asc.EIconSetType.Symbols3, Asc.EIconSetType.Symbols3_2, Asc.EIconSetType.Flags3]; indexes = [Asc.EIconSetType.Symbols3, Asc.EIconSetType.Symbols3_2, Asc.EIconSetType.Flags3];
for (var i=0; i<indexes.length; i++) { for (var i=0; i<indexes.length; i++) {
var item = collection.at(indexes[i]); var item = presets[indexes[i]];
arr.push({group: 'menu-iconset-group-indicator', data: {index: item.get('data'), icons: item.get('icons')}}); arr.push({group: 'menu-iconset-group-indicator', data: {index: indexes[i], iconSet: presets[indexes[i]], icons: collectionIcons}});
} }
indexes = [Asc.EIconSetType.Stars3, Asc.EIconSetType.Rating4, Asc.EIconSetType.Quarters5, Asc.EIconSetType.Rating5, Asc.EIconSetType.Boxes5]; indexes = [Asc.EIconSetType.Stars3, Asc.EIconSetType.Rating4, Asc.EIconSetType.Quarters5, Asc.EIconSetType.Rating5, Asc.EIconSetType.Boxes5];
for (var i=0; i<indexes.length; i++) { for (var i=0; i<indexes.length; i++) {
var item = collection.at(indexes[i]); var item = presets[indexes[i]];
arr.push({group: 'menu-iconset-group-rating', data: {index: item.get('data'), icons: item.get('icons')}}); arr.push({group: 'menu-iconset-group-rating', data: {index: indexes[i], iconSet: presets[indexes[i]], icons: collectionIcons}});
} }
picker = new Common.UI.DataView({ picker = new Common.UI.DataView({
el: $('#id-toolbar-menu-iconsets', menuItem.$el), el: $('#id-toolbar-menu-iconsets', menuItem.$el),
@ -1700,9 +1703,10 @@ define([
{id: 'menu-iconset-group-rating', caption: this.textRating} {id: 'menu-iconset-group-rating', caption: this.textRating}
]), ]),
store: new Common.UI.DataViewStore(arr), store: new Common.UI.DataViewStore(arr),
showLast: false,
itemTemplate: _.template('<div class="item-iconset" id="<%= id %>">' + itemTemplate: _.template('<div class="item-iconset" id="<%= id %>">' +
'<% _.each(data.icons, function(icon) { %>' + '<% _.each(data.iconSet, function(icon) { %>' +
'<img src="<%= icon %>" style="width:16px;height:16px;">' + '<img src="<%= data.icons.at(icon-1).get(\'icon\') %>" style="width:16px;height:16px;">' +
'<% }) %>' + '<% }) %>' +
'</div>') '</div>')
}); });