Closed HJK181 closed 4 years ago
Updated to newest 1.4.0
release, with the same outcome.
Confirmed the issue I wanted to do a new release of Vue.js but this one should be easy to fix, so I postpone the release, so if someone want to fix this ?
I'm changing the label as in fact, it's not a bug. It's simply something which was not implemented initialy.
I'm using Vue-infinite-loading plugin.
Installation
npm install vue-infinite-loading --save
Usage
main.ts
import InfiniteLoading from 'vue-infinite-loading';
Vue.component('infinite-loading', InfiniteLoading);
Entity Vue
Insert code before table closing tag ""
<infinite-loading
v-if="entityarray && entityarray.length > 0 && links != {} && page < links['last']"
:identifier="infiniteId"
slot="append"
@infinite="loadPage"
force-use-infinite-wrapper=".el-table__body-wrapper"
:distance='50'>
<template slot="no-more">No more data</template>
</infinite-loading>
JhiDataUtils method to parse header links to get maximum loading count
parseLinks(header) {
if (header.length === 0) {
throw new Error('input must not be of zero length');
}
// Split parts by comma
var parts = header.split(',');
var links = {};
// Parse each part into a named link
parts.forEach((p) => {
var section = p.split('>;');
if (section.length !== 2) {
throw new Error('section could not be split on ">;"');
}
var url = section[0].replace(/<(.*)/, '$1').trim();
var queryString = {page:null};
url.replace(
new RegExp('([^?=&]+)(=([^&]*))?', 'g'),
function($0, $1, $2, $3) { queryString[$1] = $3; }
);
var page = queryString.page;
if (typeof page == 'string') {
page = parseInt(page);
}
var name = section[1].replace(/rel="(.*)"/, '$1').trim();
links[name] = page;
});
return links;
}
Entity component changes
Changes in entity service then callback function
for (var i = 0; i < res.data.length; i++) {
this.entityarray.push(res.data[i]);
}
this.totalItems = Number(res.headers['x-total-count']);
this.links = this.parseLinks(res.headers.link);
this.isFetching = false;
if(this.state != null) {
this.state.loaded();
if(this.page == this.links['last'])
this.state.complete();
}
Method load next page on scrolling
public loadPage($state): void {
this.state = $state;
if(this.page >= this.links['last'])
this.state.complete();
if(!this.isFetching) {
this.page++;
this.retrieveAllEntities();
}
}
@pascalgrimaud is the bug-bounty still there? I'm in dire need of funding for my 4 social projects.
@skmaingi : yes, the bounty is still there. You seem to know how to fix it, so would you like to contribute ? Don't hesitate to ask me if you need help
@pascalgrimaud yes, I would like to contribute.
@pascalgrimaud I need access to commit the code for infinite-scroll feature
@skmaingi : for contributing to Open Source project, you need:
git clone https://github.com/skmaingi/jhipster-vuejs
git remote add upstream https://github.com/jhipster/jhipster-vuejs
git push origin <your branch>
-> so you'll push to your fork and not to main project@pascalgrimaud : I have added the new feature.
The v-if directive in infinite-loading component is optional. One can omit it to display the component's template if there is no more data to load.
@skmaingi : nice ! waiting your pull request so we can review :)
@skmaingi : I'm increasing the bounty as I saw you spent a lot of time to achieve your 1st contribution to the project, so it is well deserved !
@pascalgrimaud Thank you so much
Overview of the issue
The pagination option
infinite-scroll
does not have any effect.Reproduce the error
First create the application via
jhipster --blueprints vuejs
, than run eitherjhipster import-jdl some-entities.jdl
orjhipster entity Picture
.JHipster Version(s)
JHipster configuration, a
.yo-rc.json
file generated in the root folder.yo-rc.json file
Entity configuration(s)
entityName.json
files generated in the.jhipster
directoryPicture.json
Browsers and Operating System