[DE PE] Make new search: add methods to update result current number

This commit is contained in:
JuliaSvinareva 2022-03-05 15:44:01 +03:00
parent 2c07d642e1
commit 37b0fd88d3
5 changed files with 30 additions and 2 deletions

View file

@ -81,6 +81,7 @@ define([
});
this.$reaultsNumber = $('#search-adv-results-number');
this.updateResultsNumber('no-results');
this.btnBack = new Common.UI.Button({
parentEl: $('#search-adv-back'),
@ -231,7 +232,8 @@ define([
},
updateResultsNumber: function (current, count) {
this.$reaultsNumber.text(Common.Utils.String.format(current, count));
var text = current === 'no-results' ? this.textNoSearchResults : (!count ? this.textNoMatches : Common.Utils.String.format(this.textSearchResults, current + 1, count));
this.$reaultsNumber.text(text);
},
onClickClosePanel: function() {
@ -276,6 +278,10 @@ define([
this.inputText.setValue(val);
},
clearResults: function () {
this.updateResultsNumber('no-results');
},
textFind: 'Find',
textFindAndReplace: 'Find and replace',
textCloseSearch: 'Close search',
@ -295,7 +301,9 @@ define([
textByColumns: 'By columns',
textFormulas: 'Formulas',
textValues: 'Values',
textSearchOptions: 'Search options'
textSearchOptions: 'Search options',
textNoMatches: 'No matches',
textNoSearchResults: 'No search results'
}, Common.Views.SearchPanel || {}));
});

View file

@ -77,6 +77,7 @@ define([
setApi: function (api) {
if (api) {
this.api = api;
this.api.asc_registerCallback('asc_onSetSearchCurrent', _.bind(this.onUpdateSearchCurrent, this));
}
return this;
},
@ -90,6 +91,7 @@ define([
if (opts.textsearch && opts.textsearch.length) {
if (!this.api.asc_findText(opts.textsearch, d != 'back', opts.matchcase)) {
var me = this;
me.view.updateResultsNumber(undefined, 0);
Common.UI.info({
msg: this.textNoTextFound,
callback: function() {
@ -104,6 +106,7 @@ define([
if (!_.isEmpty(opts.textsearch)) {
if (!this.api.asc_replaceText(opts.textsearch, opts.textreplace, false, opts.matchcase)) {
var me = this;
me.view.updateResultsNumber(undefined, 0);
Common.UI.info({
msg: this.textNoTextFound,
callback: function() {
@ -120,6 +123,12 @@ define([
}
},
onUpdateSearchCurrent: function (current, all) {
if (this.view) {
this.view.updateResultsNumber(current, all);
}
},
textNoTextFound: 'The data you have been searching for could not be found. Please adjust your search options.',
}, DE.Controllers.Search || {}));

View file

@ -482,6 +482,7 @@ define([
}
if (this.header.btnSearch.pressed) {
this.searchBar.show(this.api.asc_GetSelectedText());
leftMenu.getView('LeftMenu').panelSearch.clearResults();
} else {
this.searchBar.hide();
}

View file

@ -77,6 +77,7 @@ define([
setApi: function (api) {
if (api) {
this.api = api;
this.api.asc_registerCallback('asc_onSetSearchCurrent', _.bind(this.onUpdateSearchCurrent, this));
}
return this;
},
@ -90,6 +91,7 @@ define([
if (opts.textsearch && opts.textsearch.length) {
if (!this.api.asc_findText(opts.textsearch, d != 'back', opts.matchcase)) {
var me = this;
me.view.updateResultsNumber(undefined, 0);
Common.UI.info({
msg: this.textNoTextFound,
callback: function() {
@ -104,6 +106,7 @@ define([
if (!_.isEmpty(opts.textsearch)) {
if (!this.api.asc_replaceText(opts.textsearch, opts.textreplace, false, opts.matchcase)) {
var me = this;
me.view.updateResultsNumber(undefined, 0);
Common.UI.info({
msg: this.textNoTextFound,
callback: function() {
@ -120,6 +123,12 @@ define([
}
},
onUpdateSearchCurrent: function (current, all) {
if (this.view) {
this.view.updateResultsNumber(current, all);
}
},
textNoTextFound: 'The data you have been searching for could not be found. Please adjust your search options.',
}, PE.Controllers.Search || {}));

View file

@ -534,6 +534,7 @@ define([
}
if (this.header.btnSearch.pressed) {
this.searchBar.show(this.api.asc_GetSelectedText());
leftMenu.getView('LeftMenu').panelSearch.clearResults();
} else {
this.searchBar.hide();
}