[SSE] Check chard data

This commit is contained in:
Julia Radzhabova 2020-07-10 19:11:55 +03:00
parent 96704a1f1f
commit 15dd23ba04
3 changed files with 72 additions and 33 deletions

View file

@ -150,7 +150,8 @@ define([
el: $('#chart-dlg-series-list', this.$window), el: $('#chart-dlg-series-list', this.$window),
store: new Common.UI.DataViewStore(), store: new Common.UI.DataViewStore(),
emptyText: '', emptyText: '',
scrollAlwaysVisible: true scrollAlwaysVisible: true,
itemTemplate: _.template('<div id="<%= id %>" class="list-item" style="min-height: 15px;"><%= value %></div>')
}); });
this.seriesList.onKeyDown = _.bind(this.onListKeyDown, this, 'series'); this.seriesList.onKeyDown = _.bind(this.onListKeyDown, this, 'series');
this.seriesList.on('item:select', _.bind(this.onSelectSeries, this)); this.seriesList.on('item:select', _.bind(this.onSelectSeries, this));
@ -198,7 +199,8 @@ define([
el: $('#chart-dlg-category-list', this.$window), el: $('#chart-dlg-category-list', this.$window),
store: new Common.UI.DataViewStore(), store: new Common.UI.DataViewStore(),
emptyText: '', emptyText: '',
scrollAlwaysVisible: true scrollAlwaysVisible: true,
itemTemplate: _.template('<div id="<%= id %>" class="list-item" style="min-height: 15px;"><%= value %></div>')
}); });
this.btnEditCategory = new Common.UI.Button({ this.btnEditCategory = new Common.UI.Button({
@ -239,6 +241,7 @@ define([
this.dataRangeValid = value; this.dataRangeValid = value;
this.txtDataRange.validation = function(value) { this.txtDataRange.validation = function(value) {
return true;
if (_.isEmpty(value)) { if (_.isEmpty(value)) {
return true; return true;
} }
@ -276,9 +279,8 @@ define([
isRangeValid: function() { isRangeValid: function() {
var isvalid; var isvalid;
if (!_.isEmpty(this.txtDataRange.getValue())) { if (!_.isEmpty(this.txtDataRange.getValue())) {
//change validation!! isvalid = this.chartSettings.isValidRange(this.txtDataRange.getValue());
isvalid = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, this.txtDataRange.getValue(), true, this.dataDirect===0, this.currentChartType); if (isvalid === true || isvalid == Asc.c_oAscError.ID.No)
if (isvalid == Asc.c_oAscError.ID.No)
return true; return true;
} else } else
return true; return true;
@ -300,7 +302,7 @@ define([
if (me.isRangeValid(settings)) { if (me.isRangeValid(settings)) {
me.dataRangeValid = settings; me.dataRangeValid = settings;
me.txtDataRange.checkValidate(); me.txtDataRange.checkValidate();
me.chartSettings.putRange(me.dataRangeValid); me.chartSettings.setRange(me.dataRangeValid);
me.updateSeriesList(me.chartSettings.getSeries(), 0); me.updateSeriesList(me.chartSettings.getSeries(), 0);
me.updateCategoryList(me.chartSettings.getCatValues()); me.updateCategoryList(me.chartSettings.getCatValues());
@ -314,7 +316,9 @@ define([
var handlerDlg = function(dlg, result) { var handlerDlg = function(dlg, result) {
if (result == 'ok') { if (result == 'ok') {
input.setValue(dlg.getSettings()); input.setValue(dlg.getSettings());
me.changeChartRange(dlg.getSettings()); _.delay(function(){
me.changeChartRange(dlg.getSettings());
},10);
} }
}; };
@ -330,7 +334,8 @@ define([
win.setSettings({ win.setSettings({
api : me.api, api : me.api,
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 type : Asc.c_oAscSelectionDialogType.Chart,
validation: function() {return true;}
}); });
} }
}, },
@ -371,7 +376,7 @@ define([
isScatter = false, isScatter = false,
me = this; me = this;
rec && (isScatter = rec.get('series').asc_IsScatter()); rec && (isScatter = rec.get('series').asc_IsScatter());
// me.setStartPointHistory(); me.chartSettings.startEditData();
var series; var series;
if (isScatter) { if (isScatter) {
series = me.chartSettings.addScatterSeries(); series = me.chartSettings.addScatterSeries();
@ -382,6 +387,8 @@ define([
if (result == 'ok') { if (result == 'ok') {
me.updateSeriesList(me.chartSettings.getSeries(), me.seriesList.store.length-1); me.updateSeriesList(me.chartSettings.getSeries(), me.seriesList.store.length-1);
me.updateButtons(); me.updateButtons();
me.chartSettings.endEditData();
me._isEditRanges = false;
} }
}; };
this.changeDataRange(1, {series: series, isScatter: isScatter}, handlerDlg); this.changeDataRange(1, {series: series, isScatter: isScatter}, handlerDlg);
@ -391,7 +398,8 @@ define([
var rec = this.seriesList.getSelectedRec(); var rec = this.seriesList.getSelectedRec();
if (rec) { if (rec) {
var order = rec.get('order'); var order = rec.get('order');
// this.chartSettings.deleteSeries(rec.get('index')); rec.get('series').asc_Remove();
this.txtDataRange.setValue(this.chartSettings.getRange() || '');
this.updateSeriesList(this.chartSettings.getSeries(), order); this.updateSeriesList(this.chartSettings.getSeries(), order);
} }
this.updateButtons(); this.updateButtons();
@ -406,9 +414,11 @@ define([
var handlerDlg = function(dlg, result) { var handlerDlg = function(dlg, result) {
if (result == 'ok') { if (result == 'ok') {
rec.set('value', series.asc_getSeriesName()); rec.set('value', series.asc_getSeriesName());
me.chartSettings.endEditData();
me._isEditRanges = false;
} }
}; };
// me.setStartPointHistory(); me.chartSettings.startEditData();
this.changeDataRange(1, {series: series, isScatter: isScatter }, handlerDlg); this.changeDataRange(1, {series: series, isScatter: isScatter }, handlerDlg);
} }
}, },
@ -418,10 +428,12 @@ define([
var handlerDlg = function(dlg, result) { var handlerDlg = function(dlg, result) {
if (result == 'ok') { if (result == 'ok') {
me.updateCategoryList(me.chartSettings.getCatValues()); me.updateCategoryList(me.chartSettings.getCatValues());
me.chartSettings.endEditData();
me._isEditRanges = false;
} }
}; };
// me.setStartPointHistory(); me.chartSettings.startEditData();
this.changeDataRange(0, {category: '', values: this.chartSettings.getCatValues()}, handlerDlg); this.changeDataRange(0, {category: this.chartSettings.getCatFormula(), values: this.chartSettings.getCatValues()}, handlerDlg);
}, },
changeDataRange: function(type, props, handlerDlg) { changeDataRange: function(type, props, handlerDlg) {
@ -431,10 +443,12 @@ define([
isScatter: !!props.isScatter, isScatter: !!props.isScatter,
handler: handlerDlg handler: handlerDlg
}).on('close', function() { }).on('close', function() {
me._isEditRanges && me.chartSettings.cancelEditData();
me._isEditRanges = false;
me.show(); me.show();
// me.setEndPointHistory(); when cancel
}); });
me._isEditRanges = true;
var xy = me.$window.offset(); var xy = me.$window.offset();
me.hide(); me.hide();
win.show(xy.left + 160, xy.top + 125); win.show(xy.left + 160, xy.top + 125);
@ -458,7 +472,7 @@ define([
store.add(store.remove(rec), {at: newindex}); store.add(store.remove(rec), {at: newindex});
rec.set('order', neworder); rec.set('order', neworder);
newrec.set('order', order); newrec.set('order', order);
// this.chartSettings.changeSeriesOrder(rec.get('index'), neworder, newrec.get('index'), order); up ? rec.get('series').asc_MoveUp() : rec.get('series').asc_MoveDown();
this.seriesList.selectRecord(rec); this.seriesList.selectRecord(rec);
this.seriesList.scrollToRecord(rec); this.seriesList.scrollToRecord(rec);
} }

View file

@ -223,7 +223,9 @@ define([
var handlerDlg = function(dlg, result) { var handlerDlg = function(dlg, result) {
if (result == 'ok') { if (result == 'ok') {
input.setValue(dlg.getSettings()); input.setValue(dlg.getSettings());
me.updateRangeData(type, dlg.getSettings()); _.delay(function(){
me.updateRangeData(type, dlg.getSettings());
},10);
} }
}; };
@ -246,7 +248,8 @@ define([
win.setSettings({ win.setSettings({
api : me.api, api : me.api,
range : !_.isEmpty(input.getValue()) ? input.getValue() : '', range : !_.isEmpty(input.getValue()) ? input.getValue() : '',
type : Asc.c_oAscSelectionDialogType.Chart type : Asc.c_oAscSelectionDialogType.Chart,
validation: function() {return true;}
}); });
} }
}, },
@ -254,9 +257,26 @@ define([
isRangeValid: function(type, value) { isRangeValid: function(type, value) {
var isvalid; var isvalid;
if (!_.isEmpty(value)) { if (!_.isEmpty(value)) {
//change validation!! switch (type) {
isvalid = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, value, true, false, this.chartSettings.getType()); case 1:
if (isvalid == Asc.c_oAscError.ID.No) if (this.props.series) {
isvalid = this.props.series.asc_IsValidName(value);
} else {
isvalid = this.chartSettings.isValidCatFormula(value);
}
break;
case 2:
if (this.props.isScatter) {
isvalid = this.props.series.asc_IsValidXValues(value);
} else {
isvalid = this.props.series.asc_IsValidValues(value);
}
break;
case 3:
isvalid = this.props.series.asc_IsValidYValues(value);
break;
}
if (isvalid === true || isvalid == Asc.c_oAscError.ID.No)
return true; return true;
} else } else
return true; return true;
@ -300,7 +320,7 @@ define([
break; break;
} }
} else { } else {
// this.chartSettings.setCatFormula(value); this.chartSettings.setCatFormula(value);
var arr = this.chartSettings.getCatValues(); var arr = this.chartSettings.getCatValues();
this.lblRange1.html((this.inputRange1.getValue()!=='') ? ('= ' + (arr ? arr.join('; ') : '')) : this.txtChoose); this.lblRange1.html((this.inputRange1.getValue()!=='') ? ('= ' + (arr ? arr.join('; ') : '')) : this.txtChoose);
} }

View file

@ -899,22 +899,27 @@ define([
onSelectData: function() { onSelectData: function() {
var me = this; var me = this;
var win, props; var props;
if (me.api){ if (me.api){
props = me.api.asc_getChartObject(); props = me.api.asc_getChartObject();
if (props) { if (props) {
(new SSE.Views.ChartDataDialog( me._isEditRanges = true;
{ props.startEdit();
chartSettings: props, var win = new SSE.Views.ChartDataDialog({
api: me.api, chartSettings: props,
handler: function(result, value) { api: me.api,
if (result == 'ok') { handler: function(result, value) {
if (me.api) { if (result == 'ok') {
} props.endEdit();
} me._isEditRanges = false;
Common.NotificationCenter.trigger('edit:complete', me);
} }
})).show(); Common.NotificationCenter.trigger('edit:complete', me);
}
}).on('close', function() {
me._isEditRanges && props.cancelEdit();
me._isEditRanges = false;
});
win.show();
} }
} }
}, },