From 72b8f3434f6232d7b24994f9c2ac1ebe7f92f57d Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 17 Oct 2022 11:51:59 +0300 Subject: [PATCH] Refactoring --- apps/common/main/lib/component/DataView.js | 2 +- apps/spreadsheeteditor/main/app/view/WatchDialog.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/common/main/lib/component/DataView.js b/apps/common/main/lib/component/DataView.js index 5eb020022..8bb1399aa 100644 --- a/apps/common/main/lib/component/DataView.js +++ b/apps/common/main/lib/component/DataView.js @@ -858,7 +858,7 @@ define([ var selectedRec = this.getSelectedRec(); if (!this.multiSelect) this.scrollToRecord(selectedRec); - else if(selectedRec.length > 0) + else if(selectedRec && selectedRec.length > 0) this.scrollToRecord(selectedRec[selectedRec.length - 1]); } }, diff --git a/apps/spreadsheeteditor/main/app/view/WatchDialog.js b/apps/spreadsheeteditor/main/app/view/WatchDialog.js index c938922b5..80c78c8c2 100644 --- a/apps/spreadsheeteditor/main/app/view/WatchDialog.js +++ b/apps/spreadsheeteditor/main/app/view/WatchDialog.js @@ -193,7 +193,7 @@ define([ 'text!spreadsheeteditor/main/app/template/WatchDialog.template', var store = this.watchList.store; (store.length>0) && this.watchList.selectByIndex(this._deletedIndex 0) && this.watchList.scrollToRecord(selectedRec[0]); + (selectedRec && selectedRec.length > 0) && this.watchList.scrollToRecord(selectedRec[0]); this._fromKeyDown && this.watchList.focus(); this._fromKeyDown = false; this._deletedIndex=undefined; @@ -261,7 +261,8 @@ define([ 'text!spreadsheeteditor/main/app/template/WatchDialog.template', }, updateButtons: function() { - this.btnDelete.setDisabled(this.watchList.store.length<1 || this.watchList.getSelectedRec().length==0); + var rec = this.watchList.getSelectedRec(); + this.btnDelete.setDisabled(!(rec && rec.length>0)); this.watchList.scroller && this.watchList.scroller.update({alwaysVisibleY: true}); },