From f555773a1e25614c465a27ecebb30a1953847263 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Fri, 26 Aug 2022 13:45:08 +0300 Subject: [PATCH] [SSE] Add updating of modified search results --- .../main/app/controller/Search.js | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/apps/spreadsheeteditor/main/app/controller/Search.js b/apps/spreadsheeteditor/main/app/controller/Search.js index f615ab4dc..f830b7c41 100644 --- a/apps/spreadsheeteditor/main/app/controller/Search.js +++ b/apps/spreadsheeteditor/main/app/controller/Search.js @@ -125,6 +125,7 @@ define([ this.api.asc_registerCallback('asc_onRemoveTextAroundSearch', _.bind(this.onApiRemoveTextAroundSearch, this)); this.api.asc_registerCallback('asc_onActiveSheetChanged', _.bind(this.onActiveSheetChanged, this)); this.api.asc_registerCallback('asc_onModifiedDocument', _.bind(this.onApiModifiedDocument, this)); + this.api.asc_registerCallback('asc_onUpdateSearchElem', _.bind(this.onApiUpdateSearchElem, this)); } return this; }, @@ -475,8 +476,12 @@ define([ var cells = [item.find('.sheet'), item.find('.name'), item.find('.cell'), item.find('.value'), item.find('.formula')], tips = [data[1], data[2], data[3], data[4], data[5]]; cells.forEach(function (el, ind) { + if (el.data('bs.tooltip')) { + el.removeData('bs.tooltip'); + } var tip = tips[ind]; if (tip) { + el.off('mouseenter'); el.one('mouseenter', function () { el.attr('data-toggle', 'tooltip'); el.tooltip({ @@ -592,6 +597,33 @@ define([ return this._state.searchText; }, + onApiUpdateSearchElem: function (data) { // [id, sheet, name, cell, value, formula] + if (this.resultItems && this.resultItems.length > 0) { + var me = this; + data.forEach(function (item) { + var resultItem = _.findWhere(me.resultItems, {id: item[0]}); + if (resultItem) { + resultItem.data = item; + resultItem.el = '
' + + '
' + (item[1] ? item[1] : '') + '
' + + '
' + (item[2] ? item[2] : '') + '
' + + '
' + (item[3] ? item[3] : '') + '
' + + '
' + (item[4] ? item[4] : '') + '
' + + '
' + (item[5] ? item[5] : '') + '
' + + '
'; + if (me.view.$el.is(':visible')) { + resultItem.$el.find('.sheet').text(item[1] ? item[1] : ''); + resultItem.$el.find('.name').text(item[2] ? item[2] : ''); + resultItem.$el.find('.cell').text(item[3] ? item[3] : ''); + resultItem.$el.find('.value').text(item[4] ? item[4] : ''); + resultItem.$el.find('.formula').text(item[5] ? item[5] : ''); + me.addTooltips(resultItem.$el, item); + } + } + }); + } + }, + textNoTextFound: 'The data you have been searching for could not be found. Please adjust your search options.', textReplaceSuccess: 'Search has been done. {0} occurrences have been replaced', textReplaceSkipped: 'The replacement has been made. {0} occurrences were skipped.',