bug fixed in address pagination
This commit is contained in:
parent
e2d3daf6ea
commit
3e1d6ee4e5
|
@ -5,7 +5,7 @@
|
||||||
<vn-horizontal>
|
<vn-horizontal>
|
||||||
<vn-title vn-one>Addresses</vn-title>
|
<vn-title vn-one>Addresses</vn-title>
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
<vn-horizontal ng-repeat="i in index.model track by i.id" class="pad-medium-top" style="align-items: center;">
|
<vn-horizontal ng-repeat="i in index.model.items track by i.id" class="pad-medium-top" style="align-items: center;">
|
||||||
<vn-one border-radius class="pad-small border-solid"
|
<vn-one border-radius class="pad-small border-solid"
|
||||||
ng-class="{'bg-dark-item': i.isDefaultAddress,'bg-opacity-item': !i.isEnabled && !i.isDefaultAddress}">
|
ng-class="{'bg-dark-item': i.isDefaultAddress,'bg-opacity-item': !i.isEnabled && !i.isDefaultAddress}">
|
||||||
<vn-horizontal style="align-items: center;">
|
<vn-horizontal style="align-items: center;">
|
||||||
|
@ -27,7 +27,9 @@
|
||||||
</vn-horizontal>
|
</vn-horizontal>
|
||||||
</vn-vertical>
|
</vn-vertical>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
<vn-paging index="index"></vn-paging>
|
|
||||||
|
<vn-paging index="index" total="index.model.total"></vn-paging>
|
||||||
|
|
||||||
<vn-float-button
|
<vn-float-button
|
||||||
fixed-bottom-right
|
fixed-bottom-right
|
||||||
ui-sref="clientCard.addresses.create"
|
ui-sref="clientCard.addresses.create"
|
||||||
|
|
|
@ -41,10 +41,32 @@ module.exports = function(Client) {
|
||||||
order: ['isDefaultAddress DESC', 'isEnabled DESC']
|
order: ['isDefaultAddress DESC', 'isEnabled DESC']
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let total = null;
|
||||||
|
let items = null;
|
||||||
|
|
||||||
|
function response(type, value) {
|
||||||
|
if (type === 'total') {
|
||||||
|
total = value;
|
||||||
|
} else {
|
||||||
|
items = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (total !== null && items !== null) {
|
||||||
|
callback(null, {total: total, items: items});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Client.app.models.Address.find(filter, function(err, instances) {
|
Client.app.models.Address.find(filter, function(err, instances) {
|
||||||
if (err)
|
if (err)
|
||||||
return callback(err, null);
|
return callback(err, null);
|
||||||
callback(null, instances);
|
response('find', instances);
|
||||||
|
});
|
||||||
|
|
||||||
|
Client.app.models.Address.count(filter.where, function(err, total) {
|
||||||
|
if (err)
|
||||||
|
return callback(err, null);
|
||||||
|
response('total', total);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue