[SSE] Update watches list

This commit is contained in:
Julia Radzhabova 2022-07-01 13:57:19 +03:00
parent 9475364cfb
commit faf7c75f6e

View file

@ -149,33 +149,55 @@ define([ 'text!spreadsheeteditor/main/app/template/WatchDialog.template',
this.api.asc_registerCallback('asc_onUpdateCellWatches', this.wrapEvents.onRefreshWatchList); this.api.asc_registerCallback('asc_onUpdateCellWatches', this.wrapEvents.onRefreshWatchList);
}, },
refreshList: function() { refreshList: function(watches) {
var arr = []; if (watches) { // change existing watches
var watches = this.api.asc_getCellWatches(); for (var idx in watches) {
if (watches) { if (watches.hasOwnProperty(idx)) {
for (var i=0; i<watches.length; i++) { var index = parseInt(idx),
var watch = watches[i]; item = watches[idx],
arr.push({ store = this.watchList.store;
book: watch.asc_getWorkbook(), if (index>=0 && index<store.length) {
sheet: watch.asc_getSheet(), var rec = store.at(index);
name: watch.asc_getName(), rec.set({
cell: watch.asc_getCell(), book: item.asc_getWorkbook(),
value: watch.asc_getValue(), sheet: item.asc_getSheet(),
formula: watch.asc_getFormula(), name: item.asc_getName(),
props: watch cell: item.asc_getCell(),
}); value: item.asc_getValue(),
formula: item.asc_getFormula(),
props: item
});
}
}
} }
} else { // get list of watches
var arr = [];
watches = this.api.asc_getCellWatches();
if (watches) {
for (var i=0; i<watches.length; i++) {
var watch = watches[i];
arr.push({
book: watch.asc_getWorkbook(),
sheet: watch.asc_getSheet(),
name: watch.asc_getName(),
cell: watch.asc_getCell(),
value: watch.asc_getValue(),
formula: watch.asc_getFormula(),
props: watch
});
}
}
this.watchList.store.reset(arr);
if (this._deletedIndex!==undefined) {
var store = this.watchList.store;
(store.length>0) && this.watchList.selectByIndex(this._deletedIndex<store.length ? this._deletedIndex : store.length-1);
this.watchList.scrollToRecord(this.watchList.getSelectedRec());
this._fromKeyDown && this.watchList.focus();
this._fromKeyDown = false;
this._deletedIndex=undefined;
}
this.updateButtons();
} }
this.watchList.store.reset(arr);
if (this._deletedIndex!==undefined) {
var store = this.watchList.store;
(store.length>0) && this.watchList.selectByIndex(this._deletedIndex<store.length ? this._deletedIndex : store.length-1);
this.watchList.scrollToRecord(this.watchList.getSelectedRec());
this._fromKeyDown && this.watchList.focus();
this._fromKeyDown = false;
this._deletedIndex=undefined;
}
this.updateButtons();
}, },
onAddWatch: function() { onAddWatch: function() {