[Common] DateView refactoring
This commit is contained in:
parent
7dd267c03e
commit
3bb1f0f7c4
|
@ -245,11 +245,7 @@ define([
|
|||
var picker = this.menuPicker;
|
||||
if (picker) {
|
||||
var record = picker.getSelectedRec();
|
||||
|
||||
if (record) {
|
||||
record = record[0];
|
||||
this.fillComboView(record || picker.store.at(0), !!record, true);
|
||||
}
|
||||
|
||||
picker.onResize();
|
||||
}
|
||||
|
@ -311,7 +307,7 @@ define([
|
|||
},
|
||||
|
||||
onAfterHideMenu: function(e, isFromInputControl) {
|
||||
this.menuPicker.selectedBeforeHideRec = this.menuPicker.getSelectedRec()[0]; // for DataView - onKeyDown - Return key
|
||||
this.menuPicker.selectedBeforeHideRec = this.menuPicker.getSelectedRec(); // for DataView - onKeyDown - Return key
|
||||
(this.showLast) ? this.menuPicker.showLastSelected() : this.menuPicker.deselectAll();
|
||||
this.trigger('hide:after', this, e, isFromInputControl);
|
||||
},
|
||||
|
@ -387,12 +383,9 @@ define([
|
|||
var picker = this.menuPicker;
|
||||
if (picker) {
|
||||
var record = picker.getSelectedRec();
|
||||
if (record) {
|
||||
record = record[0];
|
||||
this.fillComboView(record || picker.store.at(0), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
isDisabled: function() {
|
||||
|
|
|
@ -389,17 +389,7 @@ define([
|
|||
},
|
||||
|
||||
getSelectedRec: function() {
|
||||
if (this.multiSelect) {
|
||||
|
||||
var items = [];
|
||||
_.each(this.store.where({selected: true}), function(rec){
|
||||
items.push(rec);
|
||||
});
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
return this.store.where({selected: true});
|
||||
return (this.multiSelect) ? this.store.where({selected: true}) : this.store.findWhere({selected: true});
|
||||
},
|
||||
|
||||
onAddItem: function(record, store, opts) {
|
||||
|
@ -601,7 +591,7 @@ define([
|
|||
if (_.indexOf(this.moveKeys, data.keyCode)>-1 || data.keyCode==Common.UI.Keys.RETURN) {
|
||||
data.preventDefault();
|
||||
data.stopPropagation();
|
||||
var rec = this.getSelectedRec()[0];
|
||||
var rec = this.getSelectedRec();
|
||||
if (this.lastSelectedRec===null)
|
||||
this.lastSelectedRec = rec;
|
||||
if (data.keyCode==Common.UI.Keys.RETURN) {
|
||||
|
@ -699,8 +689,7 @@ define([
|
|||
this.scrollToRecord(this.lastSelectedRec);
|
||||
this.lastSelectedRec = null;
|
||||
} else {
|
||||
var rec = this.getSelectedRec()[0];
|
||||
if (rec) this.scrollToRecord(rec);
|
||||
this.scrollToRecord(this.getSelectedRec());
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -314,9 +314,7 @@ define([
|
|||
|
||||
gotoBookmark: function(btn, eOpts){
|
||||
var rec = this.bookmarksList.getSelectedRec();
|
||||
if (rec.length>0) {
|
||||
this.props.asc_SelectBookmark(rec[0].get('value'));
|
||||
}
|
||||
rec && this.props.asc_SelectBookmark(rec.get('value'));
|
||||
},
|
||||
|
||||
addBookmark: function(btn, eOpts){
|
||||
|
@ -333,11 +331,11 @@ define([
|
|||
|
||||
deleteBookmark: function(btn, eOpts){
|
||||
var rec = this.bookmarksList.getSelectedRec();
|
||||
if (rec.length>0) {
|
||||
this.props.asc_RemoveBookmark(rec[0].get('value'));
|
||||
if (rec) {
|
||||
this.props.asc_RemoveBookmark(rec.get('value'));
|
||||
var store = this.bookmarksList.store;
|
||||
var idx = _.indexOf(store.models, rec[0]);
|
||||
store.remove(rec[0]);
|
||||
var idx = _.indexOf(store.models, rec);
|
||||
store.remove(rec);
|
||||
this.txtName.setValue('');
|
||||
this.btnAdd.setDisabled(true);
|
||||
this.btnGoto.setDisabled(true);
|
||||
|
@ -350,13 +348,11 @@ define([
|
|||
if (btn.cmpEl && btn.cmpEl.parent().hasClass('open')) return;
|
||||
|
||||
var rec = this.bookmarksList.getSelectedRec();
|
||||
if (rec.length>0) {
|
||||
Common.Gateway.requestMakeActionLink({
|
||||
rec && Common.Gateway.requestMakeActionLink({
|
||||
action: {
|
||||
type: "bookmark", data: rec[0].get('value')
|
||||
type: "bookmark", data: rec.get('value')
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
onRadioSort: function(field, newValue, eOpts) {
|
||||
|
|
|
@ -167,7 +167,7 @@ define([
|
|||
|
||||
if (this._isChartStylesChanged) {
|
||||
if (rec)
|
||||
this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.getSelectedRec()[0],true);
|
||||
this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.getSelectedRec(),true);
|
||||
else
|
||||
this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.store.at(0), true);
|
||||
}
|
||||
|
|
|
@ -252,7 +252,7 @@ define([
|
|||
store.reset(arr);
|
||||
}
|
||||
var rec = this.internalList.getSelectedRec();
|
||||
this.btnOk.setDisabled(rec.length<1 || rec[0].get('level')==0 && rec[0].get('index')>0);
|
||||
this.btnOk.setDisabled(!rec || rec.get('level')==0 && rec.get('index')>0);
|
||||
|
||||
} else
|
||||
this.btnOk.setDisabled(false);
|
||||
|
@ -338,14 +338,14 @@ define([
|
|||
display = url;
|
||||
} else {
|
||||
var rec = this.internalList.getSelectedRec();
|
||||
if (rec.length>0) {
|
||||
props.put_Bookmark(rec[0].get('name'));
|
||||
if (rec[0].get('index')==0)
|
||||
if (rec) {
|
||||
props.put_Bookmark(rec.get('name'));
|
||||
if (rec.get('index')==0)
|
||||
props.put_TopOfDocument();
|
||||
var para = rec[0].get('headingParagraph');
|
||||
var para = rec.get('headingParagraph');
|
||||
if (para)
|
||||
props.put_Heading(para);
|
||||
display = rec[0].get('name');
|
||||
display = rec.get('name');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -382,7 +382,7 @@ define([
|
|||
}
|
||||
} else {
|
||||
var rec = this.internalList.getSelectedRec();
|
||||
if (rec.length<1 || rec[0].get('level')==0 && rec[0].get('index')>0)
|
||||
if (!rec || rec.get('level')==0 && rec.get('index')>0)
|
||||
return;
|
||||
}
|
||||
if (this.inputDisplay.checkValidate() !== true) {
|
||||
|
|
|
@ -1121,10 +1121,10 @@ define([ 'text!documenteditor/main/app/template/ParagraphSettingsAdvanced.tem
|
|||
|
||||
removeTab: function(btn, eOpts){
|
||||
var rec = this.tabList.getSelectedRec();
|
||||
if (rec.length>0) {
|
||||
if (rec) {
|
||||
var store = this.tabList.store;
|
||||
var idx = _.indexOf(store.models, rec[0]);
|
||||
store.remove(rec[0]);
|
||||
var idx = _.indexOf(store.models, rec);
|
||||
store.remove(rec);
|
||||
if (idx>store.length-1) idx = store.length-1;
|
||||
if (store.length>0) {
|
||||
this.tabList.selectByIndex(idx);
|
||||
|
|
|
@ -473,7 +473,7 @@ define([
|
|||
|
||||
if (this._isTemplatesChanged) {
|
||||
if (rec)
|
||||
this.cmbTableTemplate.fillComboView(this.cmbTableTemplate.menuPicker.getSelectedRec()[0],true);
|
||||
this.cmbTableTemplate.fillComboView(this.cmbTableTemplate.menuPicker.getSelectedRec(),true);
|
||||
else
|
||||
this.cmbTableTemplate.fillComboView(this.cmbTableTemplate.menuPicker.store.at(0), true);
|
||||
}
|
||||
|
|
|
@ -150,7 +150,7 @@ define([
|
|||
|
||||
if (this._isChartStylesChanged) {
|
||||
if (rec)
|
||||
this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.getSelectedRec()[0],true);
|
||||
this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.getSelectedRec(),true);
|
||||
else
|
||||
this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.store.at(0), true);
|
||||
}
|
||||
|
|
|
@ -523,10 +523,10 @@ define([ 'text!presentationeditor/main/app/template/ParagraphSettingsAdvanced
|
|||
|
||||
removeTab: function(btn, eOpts){
|
||||
var rec = this.tabList.getSelectedRec();
|
||||
if (rec.length>0) {
|
||||
if (rec) {
|
||||
var store = this.tabList.store;
|
||||
var idx = _.indexOf(store.models, rec[0]);
|
||||
store.remove(rec[0]);
|
||||
var idx = _.indexOf(store.models, rec);
|
||||
store.remove(rec);
|
||||
if (idx>store.length-1) idx = store.length-1;
|
||||
if (store.length>0) {
|
||||
this.tabList.selectByIndex(idx);
|
||||
|
|
|
@ -443,7 +443,7 @@ define([
|
|||
|
||||
if (this._isTemplatesChanged) {
|
||||
if (rec)
|
||||
this.cmbTableTemplate.fillComboView(this.cmbTableTemplate.menuPicker.getSelectedRec()[0],true);
|
||||
this.cmbTableTemplate.fillComboView(this.cmbTableTemplate.menuPicker.getSelectedRec(),true);
|
||||
else
|
||||
this.cmbTableTemplate.fillComboView(this.cmbTableTemplate.menuPicker.store.at(0), true);
|
||||
}
|
||||
|
|
|
@ -274,7 +274,7 @@ define([
|
|||
|
||||
if (this._isTemplatesChanged) {
|
||||
if (rec)
|
||||
view.pivotStyles.fillComboView(view.pivotStyles.menuPicker.getSelectedRec()[0],true);
|
||||
view.pivotStyles.fillComboView(view.pivotStyles.menuPicker.getSelectedRec(),true);
|
||||
else
|
||||
view.pivotStyles.fillComboView(view.pivotStyles.menuPicker.store.at(0), true);
|
||||
}
|
||||
|
|
|
@ -1014,7 +1014,7 @@ define([
|
|||
data.preventDefault();
|
||||
data.stopPropagation();
|
||||
|
||||
this.updateCellCheck(listView, listView.getSelectedRec()[0]);
|
||||
this.updateCellCheck(listView, listView.getSelectedRec());
|
||||
|
||||
} else {
|
||||
Common.UI.DataView.prototype.onKeyDown.call(this.cellsList, e, data);
|
||||
|
|
|
@ -182,7 +182,7 @@ define([
|
|||
|
||||
if (this._isChartStylesChanged) {
|
||||
if (rec)
|
||||
this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.getSelectedRec()[0],true);
|
||||
this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.getSelectedRec(),true);
|
||||
else
|
||||
this.cmbChartStyle.fillComboView(this.cmbChartStyle.menuPicker.store.at(0), true);
|
||||
}
|
||||
|
|
|
@ -1433,7 +1433,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ChartSettingsDlg.template'
|
|||
|
||||
if (this.isChart) {
|
||||
var rec = this.mnuChartTypePicker.getSelectedRec(),
|
||||
type = (rec && rec.length>0) ? rec[0].get('type') : this.currentChartType;
|
||||
type = (rec) ? rec.get('type') : this.currentChartType;
|
||||
|
||||
this.chartSettings.putType(type);
|
||||
|
||||
|
@ -1492,7 +1492,7 @@ define([ 'text!spreadsheeteditor/main/app/template/ChartSettingsDlg.template'
|
|||
var isvalid;
|
||||
if (!_.isEmpty(this.txtDataRange.getValue())) {
|
||||
var rec = this.mnuChartTypePicker.getSelectedRec(),
|
||||
type = (rec && rec.length>0) ? rec[0].get('type') : this.currentChartType;
|
||||
type = (rec) ? rec.get('type') : this.currentChartType;
|
||||
|
||||
isvalid = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, this.txtDataRange.getValue(), true, this.cmbDataDirect.getValue()==0, type);
|
||||
if (isvalid == Asc.c_oAscError.ID.No)
|
||||
|
|
|
@ -218,9 +218,7 @@ define([
|
|||
show: function() {
|
||||
Common.UI.BaseView.prototype.show.call(this,arguments);
|
||||
var item = this.viewSettingsPicker.getSelectedRec();
|
||||
if (item[0]) {
|
||||
item[0].get('panel').show();
|
||||
}
|
||||
item && item.get('panel').show();
|
||||
},
|
||||
|
||||
setMode: function(mode) {
|
||||
|
|
|
@ -71,7 +71,6 @@ define([
|
|||
|
||||
'<label class="header">' + t.textGroupDescription + '</label>',
|
||||
'<div id="formula-dlg-combo-group" class="input-group-nr" style="margin-top: 10px"/>',
|
||||
|
||||
'<label class="header" style="margin-top:10px">' + t.textListDescription + '</label>',
|
||||
'<div id="formula-dlg-combo-functions" class="combo-functions"/>',
|
||||
'<label id="formula-dlg-args" style="margin-top: 7px">' + '</label>',
|
||||
|
|
|
@ -284,8 +284,8 @@ define([ 'text!spreadsheeteditor/main/app/template/NameManagerDlg.template',
|
|||
var me = this,
|
||||
xy = me.$window.offset(),
|
||||
rec = this.rangeList.getSelectedRec(),
|
||||
idx = _.indexOf(this.rangeList.store.models, rec[0]),
|
||||
oldname = (isEdit && rec.length>0) ? new Asc.asc_CDefName(rec[0].get('name'), rec[0].get('range'), rec[0].get('scope'), rec[0].get('isTable'), undefined, undefined, undefined, true) : null;
|
||||
idx = _.indexOf(this.rangeList.store.models, rec),
|
||||
oldname = (isEdit && rec.length>0) ? new Asc.asc_CDefName(rec.get('name'), rec.get('range'), rec.get('scope'), rec.get('isTable'), undefined, undefined, undefined, true) : null;
|
||||
|
||||
var win = new SSE.Views.NamedRangeEditDlg({
|
||||
api: me.api,
|
||||
|
@ -317,9 +317,9 @@ define([ 'text!spreadsheeteditor/main/app/template/NameManagerDlg.template',
|
|||
|
||||
onDeleteRange: function () {
|
||||
var rec = this.rangeList.getSelectedRec();
|
||||
if (rec.length>0) {
|
||||
this.currentNamedRange = _.indexOf(this.rangeList.store.models, rec[0]);
|
||||
this.api.asc_delDefinedNames(new Asc.asc_CDefName(rec[0].get('name'), rec[0].get('range'), rec[0].get('scope'), rec[0].get('isTable'), undefined, undefined, undefined, true));
|
||||
if (rec) {
|
||||
this.currentNamedRange = _.indexOf(this.rangeList.store.models, rec);
|
||||
this.api.asc_delDefinedNames(new Asc.asc_CDefName(rec.get('name'), rec.get('range'), rec.get('scope'), rec.get('isTable'), undefined, undefined, undefined, true));
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ define([
|
|||
|
||||
getSettings: function() {
|
||||
var rec = this.rangeList.getSelectedRec();
|
||||
return (rec.length>0) ? (new Asc.asc_CDefName(rec[0].get('name'), rec[0].get('range'), rec[0].get('scope'), rec[0].get('isTable'), undefined, undefined, undefined, true)) : null;
|
||||
return (rec) ? (new Asc.asc_CDefName(rec.get('name'), rec.get('range'), rec.get('scope'), rec.get('isTable'), undefined, undefined, undefined, true)) : null;
|
||||
},
|
||||
|
||||
onPrimary: function() {
|
||||
|
|
|
@ -522,10 +522,10 @@ define([ 'text!spreadsheeteditor/main/app/template/ParagraphSettingsAdvanced.
|
|||
|
||||
removeTab: function(btn, eOpts){
|
||||
var rec = this.tabList.getSelectedRec();
|
||||
if (rec.length>0) {
|
||||
if (rec) {
|
||||
var store = this.tabList.store;
|
||||
var idx = _.indexOf(store.models, rec[0]);
|
||||
store.remove(rec[0]);
|
||||
var idx = _.indexOf(store.models, rec);
|
||||
store.remove(rec);
|
||||
if (idx>store.length-1) idx = store.length-1;
|
||||
if (store.length>0) {
|
||||
this.tabList.selectByIndex(idx);
|
||||
|
|
|
@ -738,7 +738,7 @@ define([
|
|||
|
||||
if (this.options.handler) {
|
||||
this.options.handler.call(this,
|
||||
event.currentTarget.attributes['result'].value, active[0].get('inindex'));
|
||||
event.currentTarget.attributes['result'].value, active.get('inindex'));
|
||||
}
|
||||
|
||||
this.close();
|
||||
|
@ -746,7 +746,7 @@ define([
|
|||
|
||||
onPrimary: function() {
|
||||
if (this.options.handler) {
|
||||
this.options.handler.call(this, 'ok', this.listNames.getSelectedRec()[0].get('inindex'));
|
||||
this.options.handler.call(this, 'ok', this.listNames.getSelectedRec().get('inindex'));
|
||||
}
|
||||
|
||||
this.close();
|
||||
|
|
|
@ -407,7 +407,7 @@ define([
|
|||
|
||||
if (this._isTemplatesChanged) {
|
||||
if (rec)
|
||||
this.cmbTableTemplate.fillComboView(this.cmbTableTemplate.menuPicker.getSelectedRec()[0],true);
|
||||
this.cmbTableTemplate.fillComboView(this.cmbTableTemplate.menuPicker.getSelectedRec(),true);
|
||||
else
|
||||
this.cmbTableTemplate.fillComboView(this.cmbTableTemplate.menuPicker.store.at(0), true);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue