From 8aa2548dcc3c07ff84e919bd680b86d7cbf332c2 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Sat, 14 Jan 2023 20:15:12 +0300 Subject: [PATCH] [DE PE SSE] Fix bug 58268 --- apps/common/main/lib/view/SearchPanel.js | 12 ++++++--- .../main/app/controller/Search.js | 10 ++++--- .../main/app/controller/Search.js | 10 ++++--- apps/presentationeditor/main/locale/en.json | 2 ++ .../main/app/controller/Search.js | 27 +++++++++++-------- apps/spreadsheeteditor/main/locale/en.json | 2 ++ 6 files changed, 40 insertions(+), 23 deletions(-) diff --git a/apps/common/main/lib/view/SearchPanel.js b/apps/common/main/lib/view/SearchPanel.js index b41a1caaab..1e14633561 100644 --- a/apps/common/main/lib/view/SearchPanel.js +++ b/apps/common/main/lib/view/SearchPanel.js @@ -357,10 +357,10 @@ define([ updateResultsNumber: function (current, count) { var text; - if (this.$resultsContainer) { + if (this.$resultsContainer && current !== 'content-changed' && current !== 'replace-all' && current !== 'replace') { if (count > 300) { this.showToManyResults(); - } else if (current !== 'content-changed') { + } else { this.$resultsContainer.find('.many-results').remove(); if (window.SSE) { this.$resultsTable.show(); @@ -370,7 +370,9 @@ define([ text = current === 'no-results' ? this.textNoSearchResults : (current === 'stop' ? this.textSearchHasStopped : (current === 'content-changed' ? (this.textContentChanged + ' ' + Common.Utils.String.format(this.textSearchAgain, '','')) : - (!count ? this.textNoMatches : Common.Utils.String.format(this.textSearchResults, current + 1, count)))); + (current === 'replace-all' ? Common.Utils.String.format(this.textItemsSuccessfullyReplaced, count) : + (current === 'replace' ? Common.Utils.String.format(this.textPartOfItemsNotReplaced, count[0], count[1], count[2]) : + (!count ? this.textNoMatches : Common.Utils.String.format(this.textSearchResults, current + 1, count)))))); if (current === 'content-changed') { var me = this; this.$reaultsNumber.html(text); @@ -480,7 +482,9 @@ define([ textFormula: 'Formula', textSearchHasStopped: 'Search has stopped', textContentChanged: 'Document changed.', - textSearchAgain: '{0}Perform new search{1} for accurate results.' + textSearchAgain: '{0}Perform new search{1} for accurate results.', + textItemsSuccessfullyReplaced: '{0} items successfully replaced.', + textPartOfItemsNotReplaced: '{0}/{1} items replaced. Remaining {2} items are locked by other users.' }, Common.Views.SearchPanel || {})); }); \ No newline at end of file diff --git a/apps/documenteditor/main/app/controller/Search.js b/apps/documenteditor/main/app/controller/Search.js index f4be7bdad1..41f2728b8e 100644 --- a/apps/documenteditor/main/app/controller/Search.js +++ b/apps/documenteditor/main/app/controller/Search.js @@ -271,13 +271,13 @@ define([ searchSettings.put_WholeWords(this._state.matchWord); this.api.asc_replaceText(searchSettings, textReplace, true); - this.removeResultItems(); + this.removeResultItems('replace-all'); } }, removeResultItems: function (type) { this.resultItems = []; - this.view.updateResultsNumber(type, 0); // type === undefined, count === 0 -> no matches + type !== 'replace-all' && this.view.updateResultsNumber(type, 0); // type === undefined, count === 0 -> no matches this.hideResults(); this.view.disableReplaceButtons(true); this._state.currentResult = 0; @@ -471,8 +471,10 @@ define([ onApiTextReplaced: function(found, replaced) { if (found) { !(found - replaced > 0) ? - Common.UI.info( {msg: Common.Utils.String.format(this.textReplaceSuccess, replaced)} ) : - Common.UI.warning( {msg: Common.Utils.String.format(this.textReplaceSkipped, found-replaced)} ); + /*Common.UI.info( {msg: Common.Utils.String.format(this.textReplaceSuccess, replaced)} ) : + Common.UI.warning( {msg: Common.Utils.String.format(this.textReplaceSkipped, found-replaced)} );*/ + this.view.updateResultsNumber('replace-all', replaced) : + this.view.updateResultsNumber('replace', [replaced, found, found-replaced]); } else { Common.UI.info({msg: this.textNoTextFound}); } diff --git a/apps/presentationeditor/main/app/controller/Search.js b/apps/presentationeditor/main/app/controller/Search.js index 50356cb6d6..0b882b2720 100644 --- a/apps/presentationeditor/main/app/controller/Search.js +++ b/apps/presentationeditor/main/app/controller/Search.js @@ -237,13 +237,13 @@ define([ searchSettings.put_WholeWords(this._state.matchWord); this.api.asc_replaceText(searchSettings, textReplace, true); - this.removeResultItems(); + this.removeResultItems('replace-all'); } }, removeResultItems: function (type) { this.resultItems = []; - this.view.updateResultsNumber(type, 0); // type === undefined, count === 0 -> no matches + type !== 'replace-all' && this.view.updateResultsNumber(type, 0); // type === undefined, count === 0 -> no matches this.hideResults(); this.view.disableReplaceButtons(true); this._state.currentResult = 0; @@ -421,8 +421,10 @@ define([ onApiTextReplaced: function(found, replaced) { if (found) { !(found - replaced > 0) ? - Common.UI.info( {msg: Common.Utils.String.format(this.textReplaceSuccess, replaced)} ) : - Common.UI.warning( {msg: Common.Utils.String.format(this.textReplaceSkipped, found-replaced)} ); + /*Common.UI.info( {msg: Common.Utils.String.format(this.textReplaceSuccess, replaced)} ) : + Common.UI.warning( {msg: Common.Utils.String.format(this.textReplaceSkipped, found-replaced)} );*/ + this.view.updateResultsNumber('replace-all', replaced) : + this.view.updateResultsNumber('replace', [replaced, found, found-replaced]); } else { Common.UI.info({msg: this.textNoTextFound}); } diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index 98d6cdd307..27b123a6f4 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -739,6 +739,8 @@ "Common.Views.SearchPanel.textWholeWords": "Whole words only", "Common.Views.SearchPanel.tipNextResult": "Next result", "Common.Views.SearchPanel.tipPreviousResult": "Previous result", + "Common.Views.SearchPanel.textItemsSuccessfullyReplaced": "{0} items successfully replaced.", + "Common.Views.SearchPanel.textPartOfItemsNotReplaced": "{0}/{1} items replaced. Remaining {2} items are locked by other users.", "Common.Views.SelectFileDlg.textLoading": "Loading", "Common.Views.SelectFileDlg.textTitle": "Select data source", "Common.Views.SignDialog.textBold": "Bold", diff --git a/apps/spreadsheeteditor/main/app/controller/Search.js b/apps/spreadsheeteditor/main/app/controller/Search.js index 9b0465b4b4..ba14d0560d 100644 --- a/apps/spreadsheeteditor/main/app/controller/Search.js +++ b/apps/spreadsheeteditor/main/app/controller/Search.js @@ -341,29 +341,34 @@ define([ var me = this; if (this.api.isReplaceAll) { if (!found) { - this.removeResultItems(); + this.removeResultItems('replace-all', true); } else { - !(found-replaced) && this.removeResultItems(); - Common.UI.info({ + !(found-replaced) && this.removeResultItems('replace-all'); + /*Common.UI.info({ msg: (!(found-replaced) || replaced > found) ? Common.Utils.String.format(this.textReplaceSuccess,replaced) : Common.Utils.String.format(this.textReplaceSkipped,found-replaced), callback: function() { me.view.focus(); } - }); + });*/ + !(found - replaced) || replaced > found ? + this.view.updateResultsNumber('replace-all', replaced) : + this.view.updateResultsNumber('replace', [replaced, found, found-replaced]); } } else { this.onQuerySearch(); } }, - removeResultItems: function (type) { + removeResultItems: function (type, noHide) { this.resultItems = []; - this.view.updateResultsNumber(type, 0); // type === undefined, count === 0 -> no matches - this.hideResults(); - this._state.currentResult = 0; - this._state.resultsNumber = 0; - this.view.disableNavButtons(); - Common.NotificationCenter.trigger('search:updateresults', undefined, 0); + type !== 'replace-all' && this.view.updateResultsNumber(type, 0); // type === undefined, count === 0 -> no matches + if (!noHide) { + this.hideResults(); + this._state.currentResult = 0; + this._state.resultsNumber = 0; + this.view.disableNavButtons(); + Common.NotificationCenter.trigger('search:updateresults', undefined, 0); + } }, onApiRemoveTextAroundSearch: function (arr) { diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 345fb3e428..394ffb2890 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -598,6 +598,8 @@ "Common.Views.SearchPanel.textWorkbook": "Workbook", "Common.Views.SearchPanel.tipNextResult": "Next result", "Common.Views.SearchPanel.tipPreviousResult": "Previous result", + "Common.Views.SearchPanel.textItemsSuccessfullyReplaced": "{0} items successfully replaced.", + "Common.Views.SearchPanel.textPartOfItemsNotReplaced": "{0}/{1} items replaced. Remaining {2} items are locked by other users.", "Common.Views.SelectFileDlg.textLoading": "Loading", "Common.Views.SelectFileDlg.textTitle": "Select data source", "Common.Views.SignDialog.textBold": "Bold",