Commit cb05587b authored by Julia Radzhabova's avatar Julia Radzhabova

[DE] [PE] Change chart type from the toolbar when chart is selected .

parent 3fe8ee25
......@@ -563,6 +563,7 @@ define([
var pr, sh, i = -1, type,
paragraph_locked = false,
header_locked = false,
image_locked = false,
can_add_table = false,
can_add_image = false,
enable_dropcap = undefined,
......@@ -590,6 +591,7 @@ define([
in_header = true;
} else if (type === Asc.c_oAscTypeSelectElement.Image) {
in_image = in_header = true;
image_locked = pr.get_Locked();
if (pr && pr.get_ChartProperties())
in_chart = true;
} else if (type === Asc.c_oAscTypeSelectElement.Math) {
......@@ -670,16 +672,18 @@ define([
}
need_disable = paragraph_locked || header_locked || !can_add_image || in_equation;
if (need_disable != toolbar.btnInsertChart.isDisabled()) {
toolbar.btnInsertChart.setDisabled(need_disable);
if (need_disable != toolbar.btnInsertImage.isDisabled()) {
toolbar.btnInsertImage.setDisabled(need_disable);
toolbar.btnInsertShape.setDisabled(need_disable);
toolbar.btnInsertText.setDisabled(need_disable);
}
need_disable = need_disable || in_image;
if (need_disable != toolbar.mnuInsertTextArt.isDisabled())
toolbar.mnuInsertTextArt.setDisabled(need_disable);
if ((need_disable || in_image) != toolbar.mnuInsertTextArt.isDisabled())
toolbar.mnuInsertTextArt.setDisabled(need_disable || in_image);
need_disable = in_chart && image_locked || !in_chart && need_disable;
if (need_disable != toolbar.btnInsertChart.isDisabled())
toolbar.btnInsertChart.setDisabled(need_disable);
need_disable = paragraph_locked || header_locked || in_chart || !can_add_image&&!in_equation;
if (need_disable !== toolbar.btnInsertEquation.isDisabled()) toolbar.btnInsertEquation.setDisabled(need_disable);
......@@ -1675,8 +1679,30 @@ define([
onSelectChart: function(picker, item, record) {
var me = this,
type = record.get('type');
type = record.get('type'),
chart = false;
var selectedElements = me.api.getSelectedElements();
if (selectedElements && _.isArray(selectedElements)) {
for (var i = 0; i< selectedElements.length; i++) {
if (Asc.c_oAscTypeSelectElement.Image == selectedElements[i].get_ObjectType()) {
var elValue = selectedElements[i].get_ObjectValue().get_ChartProperties();
if (elValue) {
chart = elValue;
break;
}
}
}
}
if (chart) {
var props = new Asc.asc_CImgProperty();
chart.changeType(type);
props.put_ChartProperties(chart);
this.api.ImgApply(props);
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
} else {
if (!this.diagramEditor)
this.diagramEditor = this.getApplication().getController('Common.Controllers.ExternalDiagramEditor').getView('Common.Views.ExternalDiagramEditor');
......@@ -1684,12 +1710,13 @@ define([
this.diagramEditor.setEditMode(false);
this.diagramEditor.show();
var chart = me.api.asc_getChartObject(type);
chart = me.api.asc_getChartObject(type);
if (chart) {
this.diagramEditor.setChartData(new Asc.asc_CChartBinary(chart));
}
me.toolbar.fireEvent('insertchart', me.toolbar);
}
}
},
onInsertPageNumberClick: function(picker, item, record) {
......
......@@ -1450,8 +1450,26 @@ define([
onSelectChart: function(picker, item, record) {
var me = this,
type = record.get('type');
type = record.get('type'),
chart = false;
var selectedElements = me.api.getSelectedElements();
if (selectedElements && _.isArray(selectedElements)) {
for (var i = 0; i< selectedElements.length; i++) {
if (Asc.c_oAscTypeSelectElement.Chart == selectedElements[i].get_ObjectType()) {
chart = true;
break;
}
}
}
if (chart) {
var props = new Asc.CAscChartProp();
props.changeType(type);
this.api.ChartApply(props);
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
} else {
if (!this.diagramEditor)
this.diagramEditor = this.getApplication().getController('Common.Controllers.ExternalDiagramEditor').getView('Common.Views.ExternalDiagramEditor');
......@@ -1459,12 +1477,13 @@ define([
this.diagramEditor.setEditMode(false);
this.diagramEditor.show();
var chart = me.api.asc_getChartObject(type);
chart = me.api.asc_getChartObject(type);
if (chart) {
this.diagramEditor.setChartData(new Asc.asc_CChartBinary(chart));
}
me.toolbar.fireEvent('insertchart', me.toolbar);
}
}
},
onListThemeSelect: function(combo, record) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment