[SSE] Add sparkline

This commit is contained in:
Julia Radzhabova 2021-03-23 17:51:50 +03:00
parent 5ab470ec5f
commit 8489136021
3 changed files with 45 additions and 45 deletions

View file

@ -62,7 +62,8 @@ define([
'spreadsheeteditor/main/app/view/ScaleDialog', 'spreadsheeteditor/main/app/view/ScaleDialog',
'spreadsheeteditor/main/app/view/FormatRulesManagerDlg', 'spreadsheeteditor/main/app/view/FormatRulesManagerDlg',
'spreadsheeteditor/main/app/view/SlicerAddDialog', 'spreadsheeteditor/main/app/view/SlicerAddDialog',
'spreadsheeteditor/main/app/view/AdvancedSeparatorDialog' 'spreadsheeteditor/main/app/view/AdvancedSeparatorDialog',
'spreadsheeteditor/main/app/view/CreateSparklineDialog'
], function () { 'use strict'; ], function () { 'use strict';
SSE.Controllers.Toolbar = Backbone.Controller.extend(_.extend({ SSE.Controllers.Toolbar = Backbone.Controller.extend(_.extend({
@ -1079,52 +1080,39 @@ define([
if (!this.editMode) return; if (!this.editMode) return;
var me = this, var me = this,
info = me.api.asc_getCellInfo(), info = me.api.asc_getCellInfo(),
seltype = info.asc_getSelectionType(), seltype = info.asc_getSelectionType();
isSpark = (group == 'menu-chart-group-sparkcolumn' || group == 'menu-chart-group-sparkline' || group == 'menu-chart-group-sparkwin');
if (me.api) { if (me.api) {
var win, props; var win, props;
if (isSpark && (seltype==Asc.c_oAscSelectionType.RangeCells || seltype==Asc.c_oAscSelectionType.RangeCol || var ischartedit = ( seltype == Asc.c_oAscSelectionType.RangeChart || seltype == Asc.c_oAscSelectionType.RangeChartText);
seltype==Asc.c_oAscSelectionType.RangeRow || seltype==Asc.c_oAscSelectionType.RangeMax)) { props = me.api.asc_getChartObject(true); // don't lock chart object
var sparkLineInfo = info.asc_getSparklineInfo(); if (props) {
if (!!sparkLineInfo) { (ischartedit) ? props.changeType(type) : props.putType(type);
var props = new Asc.sparklineGroup(); var range = props.getRange(),
props.asc_setType(type); isvalid = (!_.isEmpty(range)) ? me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, range, true, props.getInRows(), props.getType()) : Asc.c_oAscError.ID.No;
this.api.asc_setSparklineGroup(sparkLineInfo.asc_getId(), props); if (isvalid == Asc.c_oAscError.ID.No) {
(ischartedit) ? me.api.asc_editChartDrawingObject(props) : me.api.asc_addChartDrawingObject(props);
} else { } else {
// add sparkline var msg = me.txtInvalidRange;
} switch (isvalid) {
} else if (!isSpark) { case isvalid == Asc.c_oAscError.ID.StockChartError:
var ischartedit = ( seltype == Asc.c_oAscSelectionType.RangeChart || seltype == Asc.c_oAscSelectionType.RangeChartText); msg = me.errorStockChart;
props = me.api.asc_getChartObject(true); // don't lock chart object break;
if (props) { case isvalid == Asc.c_oAscError.ID.MaxDataSeriesError:
(ischartedit) ? props.changeType(type) : props.putType(type); msg = me.errorMaxRows;
var range = props.getRange(), break;
isvalid = (!_.isEmpty(range)) ? me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, range, true, props.getInRows(), props.getType()) : Asc.c_oAscError.ID.No; case isvalid == Asc.c_oAscError.ID.ComboSeriesError:
if (isvalid == Asc.c_oAscError.ID.No) { msg = me.errorComboSeries;
(ischartedit) ? me.api.asc_editChartDrawingObject(props) : me.api.asc_addChartDrawingObject(props); break;
} else {
var msg = me.txtInvalidRange;
switch (isvalid) {
case isvalid == Asc.c_oAscError.ID.StockChartError:
msg = me.errorStockChart;
break;
case isvalid == Asc.c_oAscError.ID.MaxDataSeriesError:
msg = me.errorMaxRows;
break;
case isvalid == Asc.c_oAscError.ID.ComboSeriesError:
msg = me.errorComboSeries;
break;
}
Common.UI.warning({
msg: msg,
callback: function() {
_.defer(function(btn) {
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
})
}
});
} }
Common.UI.warning({
msg: msg,
callback: function() {
_.defer(function(btn) {
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
})
}
});
} }
} }
} }
@ -1146,7 +1134,19 @@ define([
props.asc_setType(type); props.asc_setType(type);
this.api.asc_setSparklineGroup(sparkLineInfo.asc_getId(), props); this.api.asc_setSparklineGroup(sparkLineInfo.asc_getId(), props);
} else { } else {
// add sparkline var me = this;
(new SSE.Views.CreateSparklineDialog(
{
api: me.api,
handler: function(result, settings) {
if (result == 'ok' && settings) {
me.view && me.view.fireEvent('insertspark', me.view);
if (settings.destination)
me.api.asc_addSparklineGroup(type, settings.source, settings.destination);
}
Common.NotificationCenter.trigger('edit:complete', me);
}
})).show();
} }
} }
} }

View file

@ -2689,6 +2689,6 @@ define([
textAutoColor: 'Automatic', textAutoColor: 'Automatic',
textItems: 'Items', textItems: 'Items',
tipInsertSpark: 'Insert sparkline', tipInsertSpark: 'Insert sparkline',
capInsertSpark: 'Sparkline' capInsertSpark: 'Sparklines'
}, SSE.Views.Toolbar || {})); }, SSE.Views.Toolbar || {}));
}); });

View file

@ -3258,7 +3258,7 @@
"SSE.Views.Toolbar.txtUnmerge": "Unmerge Cells", "SSE.Views.Toolbar.txtUnmerge": "Unmerge Cells",
"SSE.Views.Toolbar.txtYen": "¥ Yen", "SSE.Views.Toolbar.txtYen": "¥ Yen",
"SSE.Views.Toolbar.tipInsertSpark": "Insert sparkline", "SSE.Views.Toolbar.tipInsertSpark": "Insert sparkline",
"SSE.Views.Toolbar.capInsertSpark": "Sparkline", "SSE.Views.Toolbar.capInsertSpark": "Sparklines",
"SSE.Views.Top10FilterDialog.textType": "Show", "SSE.Views.Top10FilterDialog.textType": "Show",
"SSE.Views.Top10FilterDialog.txtBottom": "Bottom", "SSE.Views.Top10FilterDialog.txtBottom": "Bottom",
"SSE.Views.Top10FilterDialog.txtBy": "by", "SSE.Views.Top10FilterDialog.txtBy": "by",