[DE PE SSE] Fix bug 58268

This commit is contained in:
JuliaSvinareva
2023-01-14 20:15:12 +03:00
parent dbdf1ceeb7
commit 8aa2548dcc
6 changed files with 40 additions and 23 deletions

View File

@ -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, '<a class="search-again">','</a>')) :
(!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 || {}));
});

View File

@ -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});
}

View File

@ -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});
}

View File

@ -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",

View File

@ -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) {

View File

@ -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",