fix show more
This commit is contained in:
@@ -46,6 +46,8 @@ Espo.define('collection', [], function () {
|
||||
|
||||
whereAdditional: null,
|
||||
|
||||
lengthCorrection: 0,
|
||||
|
||||
_user: null,
|
||||
|
||||
initialize: function (models, options) {
|
||||
@@ -122,7 +124,7 @@ Espo.define('collection', [], function () {
|
||||
options.data.maxSize = options.maxSize;
|
||||
}
|
||||
|
||||
options.data.offset = options.more ? this.length : this.offset;
|
||||
options.data.offset = options.more ? this.length + this.lengthCorrection : this.offset;
|
||||
options.data.sortBy = this.sortBy;
|
||||
options.data.asc = this.asc;
|
||||
options.data.where = this.getWhere();
|
||||
@@ -143,5 +145,3 @@ Espo.define('collection', [], function () {
|
||||
return Collection;
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -1149,12 +1149,11 @@ Espo.define('views/record/list', 'view', function (Dep) {
|
||||
this.notify('Loading...');
|
||||
|
||||
var final = function () {
|
||||
$showMore.parent().append($showMore);
|
||||
if (
|
||||
(collection.total > collection.length || collection.total == -1)
|
||||
(collection.total > collection.length + collection.lengthCorrection || collection.total == -1)
|
||||
) {
|
||||
this.$el.find('.more-count').text(collection.total - this.collection.length);
|
||||
$showMore.removeClass('hide');
|
||||
this.$el.find('.more-count').text(collection.total - collection.length - collection.lengthCorrection);
|
||||
$showMore.removeClass('hidden');
|
||||
}
|
||||
$showMore.children('a').removeClass('disabled');
|
||||
|
||||
@@ -1169,12 +1168,13 @@ Espo.define('views/record/list', 'view', function (Dep) {
|
||||
|
||||
var success = function () {
|
||||
this.notify(false);
|
||||
$showMore.addClass('hide');
|
||||
|
||||
var temp = collection.models[initialCount - 1];
|
||||
$showMore.addClass('hidden');
|
||||
|
||||
var rowCount = collection.length - initialCount;
|
||||
var rowsReady = 0;
|
||||
if (collection.length <= initialCount) {
|
||||
final();
|
||||
}
|
||||
for (var i = initialCount; i < collection.length; i++) {
|
||||
var model = collection.at(i);
|
||||
this.buildRow(i, model, function (view) {
|
||||
@@ -1197,6 +1197,12 @@ Espo.define('views/record/list', 'view', function (Dep) {
|
||||
this.noRebuild = true;
|
||||
}.bind(this);
|
||||
|
||||
this.listenToOnce(collection, 'update', function (collection, o) {
|
||||
if (o.changes.merged.length) {
|
||||
collection.lengthCorrection += o.changes.merged.length;
|
||||
}
|
||||
}, this);
|
||||
|
||||
collection.fetch({
|
||||
success: success,
|
||||
remove: false,
|
||||
|
||||
Reference in New Issue
Block a user