Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to edit entity and add pagination in Jhipster generated project

Already several entities are created. Initially infinite scroll option was selected while creating entities. Now I want to implement pagination instead of infinite scroll. Should I overwrite the entities?

like image 594
fatCop Avatar asked May 29 '16 11:05

fatCop


People also ask

How do I import a JDL file?

If you do not want to regenerate your entities while importing a JDL, you can use the --json-only flag to skip the entity creation part and create only the json files in . jhipster folder. If you want to use it in your project, you can add do so by doing: NPM: npm install jhipster-core --save.

How to update an existing entity in JHipster?

Updating an existing entity. The entity configuration is saved in a specific .json file, in the .jhipster directory. So if you run the sub-generator again, using an existing entity name, you can update or regenerate the entity.

What is a custom JHipster pagination?

JHipster provides a custom implementation of this specification on both the server (Spring MVC REST) and client (Angular/React) sides. When the entity is generated, JHipster provides 4 pagination options: No pagination (in that case, the back-end won’t be paginated) A complete pagination system, based on the Bootstrap pagination component

How to use sub generator in JHipster?

The sub generator can be invoked by running jhipster entity <entityName> -- [options]. Reference for those options can be found by typing jhipster entity --help Below are the supported options.

What is the “entity” sub-generator?

The “entity” sub-generator will create all the necessary files, and provide a CRUD front-end for each entity (see Angular project structure and React project structure ). The sub generator can be invoked by running jhipster entity <entityName> -- [options]. Reference for those options can be found by typing jhipster entity --help


2 Answers

In JHipster, the difference between pagination and infinite scroll are only on the client side. You can regenerate each of your entities, but when Yeoman asks if you want to overwrite preexisting files, press n to choose no for every file except the AngularJS router, controller, and 'entities' list html. This should allow you to implement pagination with minimal impact.

You can regenerate your entities by changing "pagination": "infinite-scroll" to "pagination": "pagination" in your entity JSONs under .jhipster then re-running yo jhipster:entity entityName.

like image 52
geraldhumphries Avatar answered Nov 15 '22 09:11

geraldhumphries


There are following 2 cases,

You can identify your case by observing "pagination" option from EntityName.json file from ./ProjectName/.jhipster directory,

Case 1: "pagination": "infinite-scroll" i.e. existing pagination is available

In this case, you can regenerate entities with a less impact. Refer @geraldhumphries answer. How to edit entity and add pagination in Jhipster generated project

Case 2: "pagination": "no" i.e. existing pagination is not available

To add pagination to existing entity change "pagination" option from "pagination": "no" to "pagination": true and update entities by using, yo jhipster:entity EntityName or by importing jhipster import-jdl jdl.jh[In case of JDL]

but In this case, the impact will be on both the server and client side.
On the server side mainly EntityNameResource.java and EntityNameService.java will change.
On the client side EntityName.component.html, multiple supporting.ts files will change.

like image 28
Vaibhav Avatar answered Nov 15 '22 10:11

Vaibhav