From 2d6db7570cd96884cbe85fe93b09bfa8bd8b6fdf Mon Sep 17 00:00:00 2001 From: yuri Date: Tue, 8 Oct 2019 11:44:47 +0300 Subject: [PATCH] fix record next/prev --- client/src/views/modals/detail.js | 9 ++++----- client/src/views/record/detail.js | 13 ++++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/client/src/views/modals/detail.js b/client/src/views/modals/detail.js index 6a82cd961f..8755e94679 100644 --- a/client/src/views/modals/detail.js +++ b/client/src/views/modals/detail.js @@ -394,14 +394,13 @@ Espo.define('views/modals/detail', 'views/modal', function (Dep) { } else { var initialCount = collection.length; - this.listenToOnce(collection, 'sync', function () { - var model = collection.at(indexOfRecord); - this.switchToModelByIndex(indexOfRecord); - }, this); collection.fetch({ more: true, remove: false, - }); + }).then(function () { + var model = collection.at(indexOfRecord); + this.switchToModelByIndex(indexOfRecord); + }.bind(this)); } }, diff --git a/client/src/views/record/detail.js b/client/src/views/record/detail.js index 440602131e..4b252374a8 100644 --- a/client/src/views/record/detail.js +++ b/client/src/views/record/detail.js @@ -975,6 +975,8 @@ define('views/record/detail', ['views/record/base', 'view-record-helper'], funct }, actionPrevious: function () { + this.model.abortLastFetch(); + var collection; if (!this.model.collection) { collection = this.collection; @@ -992,6 +994,8 @@ define('views/record/detail', ['views/record/base', 'view-record-helper'], funct }, actionNext: function () { + this.model.abortLastFetch(); + var collection; if (!this.model.collection) { collection = this.collection; @@ -1011,14 +1015,13 @@ define('views/record/detail', ['views/record/base', 'view-record-helper'], funct } else { var initialCount = collection.length; - this.listenToOnce(collection, 'sync', function () { - var model = collection.at(indexOfRecord); - this.switchToModelByIndex(indexOfRecord); - }, this); collection.fetch({ more: true, remove: false, - }); + }).then(function () { + var model = collection.at(indexOfRecord); + this.switchToModelByIndex(indexOfRecord); + }.bind(this)); } },