[DE PE] Make new search: add methods to update result current number
This commit is contained in:
parent
2c07d642e1
commit
37b0fd88d3
|
@ -81,6 +81,7 @@ define([
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$reaultsNumber = $('#search-adv-results-number');
|
this.$reaultsNumber = $('#search-adv-results-number');
|
||||||
|
this.updateResultsNumber('no-results');
|
||||||
|
|
||||||
this.btnBack = new Common.UI.Button({
|
this.btnBack = new Common.UI.Button({
|
||||||
parentEl: $('#search-adv-back'),
|
parentEl: $('#search-adv-back'),
|
||||||
|
@ -231,7 +232,8 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
updateResultsNumber: function (current, count) {
|
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() {
|
onClickClosePanel: function() {
|
||||||
|
@ -276,6 +278,10 @@ define([
|
||||||
this.inputText.setValue(val);
|
this.inputText.setValue(val);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clearResults: function () {
|
||||||
|
this.updateResultsNumber('no-results');
|
||||||
|
},
|
||||||
|
|
||||||
textFind: 'Find',
|
textFind: 'Find',
|
||||||
textFindAndReplace: 'Find and replace',
|
textFindAndReplace: 'Find and replace',
|
||||||
textCloseSearch: 'Close search',
|
textCloseSearch: 'Close search',
|
||||||
|
@ -295,7 +301,9 @@ define([
|
||||||
textByColumns: 'By columns',
|
textByColumns: 'By columns',
|
||||||
textFormulas: 'Formulas',
|
textFormulas: 'Formulas',
|
||||||
textValues: 'Values',
|
textValues: 'Values',
|
||||||
textSearchOptions: 'Search options'
|
textSearchOptions: 'Search options',
|
||||||
|
textNoMatches: 'No matches',
|
||||||
|
textNoSearchResults: 'No search results'
|
||||||
|
|
||||||
}, Common.Views.SearchPanel || {}));
|
}, Common.Views.SearchPanel || {}));
|
||||||
});
|
});
|
|
@ -77,6 +77,7 @@ define([
|
||||||
setApi: function (api) {
|
setApi: function (api) {
|
||||||
if (api) {
|
if (api) {
|
||||||
this.api = api;
|
this.api = api;
|
||||||
|
this.api.asc_registerCallback('asc_onSetSearchCurrent', _.bind(this.onUpdateSearchCurrent, this));
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
@ -90,6 +91,7 @@ define([
|
||||||
if (opts.textsearch && opts.textsearch.length) {
|
if (opts.textsearch && opts.textsearch.length) {
|
||||||
if (!this.api.asc_findText(opts.textsearch, d != 'back', opts.matchcase)) {
|
if (!this.api.asc_findText(opts.textsearch, d != 'back', opts.matchcase)) {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
me.view.updateResultsNumber(undefined, 0);
|
||||||
Common.UI.info({
|
Common.UI.info({
|
||||||
msg: this.textNoTextFound,
|
msg: this.textNoTextFound,
|
||||||
callback: function() {
|
callback: function() {
|
||||||
|
@ -104,6 +106,7 @@ define([
|
||||||
if (!_.isEmpty(opts.textsearch)) {
|
if (!_.isEmpty(opts.textsearch)) {
|
||||||
if (!this.api.asc_replaceText(opts.textsearch, opts.textreplace, false, opts.matchcase)) {
|
if (!this.api.asc_replaceText(opts.textsearch, opts.textreplace, false, opts.matchcase)) {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
me.view.updateResultsNumber(undefined, 0);
|
||||||
Common.UI.info({
|
Common.UI.info({
|
||||||
msg: this.textNoTextFound,
|
msg: this.textNoTextFound,
|
||||||
callback: function() {
|
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.',
|
textNoTextFound: 'The data you have been searching for could not be found. Please adjust your search options.',
|
||||||
|
|
||||||
}, DE.Controllers.Search || {}));
|
}, DE.Controllers.Search || {}));
|
||||||
|
|
|
@ -482,6 +482,7 @@ define([
|
||||||
}
|
}
|
||||||
if (this.header.btnSearch.pressed) {
|
if (this.header.btnSearch.pressed) {
|
||||||
this.searchBar.show(this.api.asc_GetSelectedText());
|
this.searchBar.show(this.api.asc_GetSelectedText());
|
||||||
|
leftMenu.getView('LeftMenu').panelSearch.clearResults();
|
||||||
} else {
|
} else {
|
||||||
this.searchBar.hide();
|
this.searchBar.hide();
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,7 @@ define([
|
||||||
setApi: function (api) {
|
setApi: function (api) {
|
||||||
if (api) {
|
if (api) {
|
||||||
this.api = api;
|
this.api = api;
|
||||||
|
this.api.asc_registerCallback('asc_onSetSearchCurrent', _.bind(this.onUpdateSearchCurrent, this));
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
@ -90,6 +91,7 @@ define([
|
||||||
if (opts.textsearch && opts.textsearch.length) {
|
if (opts.textsearch && opts.textsearch.length) {
|
||||||
if (!this.api.asc_findText(opts.textsearch, d != 'back', opts.matchcase)) {
|
if (!this.api.asc_findText(opts.textsearch, d != 'back', opts.matchcase)) {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
me.view.updateResultsNumber(undefined, 0);
|
||||||
Common.UI.info({
|
Common.UI.info({
|
||||||
msg: this.textNoTextFound,
|
msg: this.textNoTextFound,
|
||||||
callback: function() {
|
callback: function() {
|
||||||
|
@ -104,6 +106,7 @@ define([
|
||||||
if (!_.isEmpty(opts.textsearch)) {
|
if (!_.isEmpty(opts.textsearch)) {
|
||||||
if (!this.api.asc_replaceText(opts.textsearch, opts.textreplace, false, opts.matchcase)) {
|
if (!this.api.asc_replaceText(opts.textsearch, opts.textreplace, false, opts.matchcase)) {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
me.view.updateResultsNumber(undefined, 0);
|
||||||
Common.UI.info({
|
Common.UI.info({
|
||||||
msg: this.textNoTextFound,
|
msg: this.textNoTextFound,
|
||||||
callback: function() {
|
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.',
|
textNoTextFound: 'The data you have been searching for could not be found. Please adjust your search options.',
|
||||||
|
|
||||||
}, PE.Controllers.Search || {}));
|
}, PE.Controllers.Search || {}));
|
||||||
|
|
|
@ -534,6 +534,7 @@ define([
|
||||||
}
|
}
|
||||||
if (this.header.btnSearch.pressed) {
|
if (this.header.btnSearch.pressed) {
|
||||||
this.searchBar.show(this.api.asc_GetSelectedText());
|
this.searchBar.show(this.api.asc_GetSelectedText());
|
||||||
|
leftMenu.getView('LeftMenu').panelSearch.clearResults();
|
||||||
} else {
|
} else {
|
||||||
this.searchBar.hide();
|
this.searchBar.hide();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue