[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,9 +149,30 @@ 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) {
if (watches) { // change existing watches
for (var idx in watches) {
if (watches.hasOwnProperty(idx)) {
var index = parseInt(idx),
item = watches[idx],
store = this.watchList.store;
if (index>=0 && index<store.length) {
var rec = store.at(index);
rec.set({
book: item.asc_getWorkbook(),
sheet: item.asc_getSheet(),
name: item.asc_getName(),
cell: item.asc_getCell(),
value: item.asc_getValue(),
formula: item.asc_getFormula(),
props: item
});
}
}
}
} else { // get list of watches
var arr = []; var arr = [];
var watches = this.api.asc_getCellWatches(); watches = this.api.asc_getCellWatches();
if (watches) { if (watches) {
for (var i=0; i<watches.length; i++) { for (var i=0; i<watches.length; i++) {
var watch = watches[i]; var watch = watches[i];
@ -176,6 +197,7 @@ define([ 'text!spreadsheeteditor/main/app/template/WatchDialog.template',
this._deletedIndex=undefined; this._deletedIndex=undefined;
} }
this.updateButtons(); this.updateButtons();
}
}, },
onAddWatch: function() { onAddWatch: function() {