41 lines
1.3 KiB
JavaScript
41 lines
1.3 KiB
JavaScript
export default OakComponent({
|
|
entity() {
|
|
return this.props.entity;
|
|
},
|
|
properties: {
|
|
entity: '',
|
|
},
|
|
isList: true,
|
|
lifetimes: {
|
|
ready() {
|
|
const { oakPagination } = this.state;
|
|
if (oakPagination?.total) {
|
|
this.setState({ newTotal: oakPagination?.total });
|
|
}
|
|
},
|
|
},
|
|
listeners: {
|
|
oakPagination(prev, next) {
|
|
let newTotal2 = 0;
|
|
if (prev.oakPagination?.total !== next.oakPagination?.total) {
|
|
const { total } = next.oakPagination || {};
|
|
if (total) {
|
|
this.setState({ newTotal: total });
|
|
newTotal2 = total;
|
|
}
|
|
}
|
|
if (prev.oakPagination?.currentPage !== next.oakPagination?.currentPage) {
|
|
const { pageSize, currentPage, more, } = next.oakPagination || {};
|
|
const { newTotal } = this.state;
|
|
let newTotal3 = newTotal || newTotal2;
|
|
if (newTotal3 && pageSize) {
|
|
if (Math.ceil(newTotal3 / pageSize) === currentPage && more) {
|
|
this.setState({ newTotal: newTotal3 + pageSize });
|
|
}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {},
|
|
});
|