[SSE] Select data ranges for sparklines.

This commit is contained in:
Julia Radzhabova 2016-12-13 15:54:58 +03:00
parent 6c75dbabde
commit d5df1f4302
2 changed files with 85 additions and 8 deletions

View file

@ -112,17 +112,17 @@ define([
if (settings.api) {
me.api = settings.api;
me.api.asc_setSelectionDialogMode(Asc.c_oAscSelectionDialogType.Chart, settings.range ? settings.range : '');
me.api.asc_setSelectionDialogMode(settings.type, settings.range ? settings.range : '');
me.api.asc_unregisterCallback('asc_onSelectionRangeChanged', _.bind(me.onApiRangeChanged, me));
me.api.asc_registerCallback('asc_onSelectionRangeChanged', _.bind(me.onApiRangeChanged, me));
Common.NotificationCenter.trigger('cells:range', Asc.c_oAscSelectionDialogType.Chart);
Common.NotificationCenter.trigger('cells:range', settings.type);
}
me.inputRange.validation = function(value) {
if (settings.validation) {
return settings.validation.call(me, value);
} else {
var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, value, false);
var isvalid = me.api.asc_checkDataRange(settings.type, value, false);
return (isvalid==Asc.c_oAscError.ID.DataRangeError) ? me.txtInvalidRange : true;
}
};

View file

@ -94,6 +94,8 @@ define([ 'text!spreadsheeteditor/main/app/template/ChartSettingsDlg.template'
this.horAxisProps = null;
this.currentAxisProps = null;
this.dataRangeValid = '';
this.sparkDataRangeValid = '';
this.dataLocationRangeValid = '';
this.currentChartType = this._state.ChartType;
this.storageName = (this.isChart) ? 'sse-chart-settings-adv-category' : 'sse-spark-settings-adv-category';
},
@ -853,7 +855,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ChartSettingsDlg.template'
this.btnSelectSparkData = new Common.UI.Button({
el: $('#spark-dlg-btn-data')
});
// this.btnSelectSparkData.on('click', _.bind(this.onSelectData, this));
this.btnSelectSparkData.on('click', _.bind(this.onSelectSparkData, this));
this.txtSparkDataLocation = new Common.UI.InputField({
el : $('#spark-dlg-txt-location'),
@ -865,10 +867,9 @@ define([ 'text!spreadsheeteditor/main/app/template/ChartSettingsDlg.template'
});
this.btnSelectLocationData = new Common.UI.Button({
el: $('#spark-dlg-btn-data')
el: $('#spark-dlg-btn-location-data')
});
// this.btnSelectLocationData.on('click', _.bind(this.onSelectData, this));
this.btnSelectLocationData.on('click', _.bind(this.onSelectLocationData, this));
this._arrEmptyCells = [
{ value: Asc.c_oAscEDispBlanksAs.Gap, displayValue: this.textGaps },
@ -1375,6 +1376,24 @@ define([ 'text!spreadsheeteditor/main/app/template/ChartSettingsDlg.template'
if (value && value.length==2) {
this.txtSparkDataRange.setValue((value[0]) ? value[0] : '');
this.txtSparkDataLocation.setValue((value[1]) ? value[1] : '');
this.sparkDataRangeValid = value[0];
this.txtSparkDataRange.validation = function(value) {
if (_.isEmpty(value))
return true;
var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, value, false);
return (isvalid==Asc.c_oAscError.ID.DataRangeError) ? me.textInvalidRange : true;
};
this.dataLocationRangeValid = value[1];
this.txtSparkDataLocation.validation = function(value) {
if (_.isEmpty(value))
return true;
var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.FormatTable, value, false);
return (isvalid==Asc.c_oAscError.ID.DataRangeError) ? me.textInvalidRange : true;
};
}
this._changedProps = new Asc.sparklineGroup();
@ -1478,7 +1497,8 @@ define([ 'text!spreadsheeteditor/main/app/template/ChartSettingsDlg.template'
win.setSettings({
api : me.api,
isRows : (me.cmbDataDirect.getValue()==0),
range : (!_.isEmpty(me.txtDataRange.getValue()) && (me.txtDataRange.checkValidate()==true)) ? me.txtDataRange.getValue() : me.dataRangeValid
range : (!_.isEmpty(me.txtDataRange.getValue()) && (me.txtDataRange.checkValidate()==true)) ? me.txtDataRange.getValue() : me.dataRangeValid,
type : Asc.c_oAscSelectionDialogType.Chart
});
}
},
@ -1495,6 +1515,63 @@ define([ 'text!spreadsheeteditor/main/app/template/ChartSettingsDlg.template'
}
},
onSelectSparkData: function() {
var me = this;
if (me.api) {
var handlerDlg = function(dlg, result) {
if (result == 'ok') {
me.sparkDataRangeValid = dlg.getSettings();
me.txtSparkDataRange.setValue(me.sparkDataRangeValid);
me.txtSparkDataRange.checkValidate();
}
};
var win = new SSE.Views.CellRangeDialog({
handler: handlerDlg
}).on('close', function() {
me.show();
});
var xy = me.$window.offset();
me.hide();
win.show(xy.left + 160, xy.top + 125);
win.setSettings({
api : me.api,
range : (!_.isEmpty(me.txtSparkDataRange.getValue()) && (me.txtSparkDataRange.checkValidate()==true)) ? me.txtSparkDataRange.getValue() : me.sparkDataRangeValid,
type : Asc.c_oAscSelectionDialogType.Chart
});
}
},
onSelectLocationData: function() {
var me = this;
if (me.api) {
var handlerDlg = function(dlg, result) {
if (result == 'ok') {
me.dataLocationRangeValid = dlg.getSettings();
me.txtSparkDataLocation.setValue(me.dataLocationRangeValid);
me.txtSparkDataLocation.checkValidate();
}
};
var win = new SSE.Views.CellRangeDialog({
handler: handlerDlg
}).on('close', function() {
me.show();
});
var xy = me.$window.offset();
me.hide();
win.show(xy.left + 160, xy.top + 125);
win.setSettings({
api : me.api,
range : (!_.isEmpty(me.txtSparkDataLocation.getValue()) && (me.txtSparkDataLocation.checkValidate()==true)) ? me.txtSparkDataLocation.getValue() : me.dataLocationRangeValid,
type : Asc.c_oAscSelectionDialogType.FormatTable
});
}
},
show: function() {
Common.Views.AdvancedSettingsWindow.prototype.show.apply(this, arguments);