changeset 3ce73faa127b in sao:default
details: https://hg.tryton.org/sao?cmd=changeset;node=3ce73faa127b
description:
Reduce offset when no search result
issue7966
review60461002
diffstat:
CHANGELOG | 1 +
src/screen.js | 19 +++++++++++++++----
2 files changed, 16 insertions(+), 4 deletions(-)
diffs (44 lines):
diff -r 867cf78ac8a8 -r 3ce73faa127b CHANGELOG
--- a/CHANGELOG Fri Jan 18 10:23:13 2019 +0100
+++ b/CHANGELOG Fri Jan 18 11:17:07 2019 +0100
@@ -1,3 +1,4 @@
+* Reduce offset when no search result
* Add support for plugins
* Add support for expand, height and width attributes
* Add drag & drop support on attachment button
diff -r 867cf78ac8a8 -r 3ce73faa127b src/screen.js
--- a/src/screen.js Fri Jan 18 10:23:13 2019 +0100
+++ b/src/screen.js Fri Jan 18 11:17:07 2019 +0100
@@ -907,9 +907,20 @@
if (this.screen_container.but_active.hasClass('active')) {
context.active_test = false;
}
- return this.model.execute(
- 'search', [domain, this.offset, this.limit, this.order],
- context).then(function(ids) {
+ var search = function() {
+ return this.model.execute(
+ 'search', [domain, this.offset, this.limit, this.order],
+ context)
+ .then(function(ids) {
+ if (ids.length || this.offset <= 0) {
+ return ids;
+ } else {
+ this.offset = Math.max(this.offset - this.limit,
0);
+ return search();
+ }
+ }.bind(this));
+ }.bind(this);
+ return search().then(function(ids) {
this.search_count = ids.length;
var count_prm = jQuery.when(this.search_count);
if ((!only_ids) &&
@@ -1579,7 +1590,7 @@
},
search_prev: function(search_string) {
if (this.limit) {
- this.offset -= this.limit;
+ this.offset = Math.max(this.offset - this.limit, 0);
}
this.search_filter(search_string);
},