Modify the entity model file generator to not define all entity fields as optional #14828
Closed
1 task done
Labels
area: enhancement 🔧
$$ bug-bounty $$
https://www.jhipster.tech/bug-bounties/
resolution: lack of interest
theme: angular
$100
https://www.jhipster.tech/bug-bounties/
Milestone
Overview of the feature request
Right now when generating entities on the frontend Angular project, all fields are marked as optional, even if a fields has been specified as required. The idea is to modify the model file entity-name.model.ts to reflect the content of the JDL modeling.
Taking as example the 21-points projects, specifically the Points entity, the JDL section is the following:
but the points.model.ts is the following:
The date field should not have the optional character (?) because when the point exists it will surely have the date value. That obviously would lead to a situation like the following:
I was also wondering why needing a class for the entity. The constructor is used only in two places, the resolver and the update component and could be replaced by an undefined value.
Entity resolver (taking Points as reference)
EntityUpdateComponent (taking Points as reference)
The constructor is also used into the spec file of EntityUpdateComponent, but just for create a return value, it could be replaced with:
Similarly in the EntityService spec file for the
'should create a Points'
test.Motivation for or Use Case
Should be clear what fields surely are valorized and which not when an entity object is being used. Any developer seeing the model can easily get confused.
Related issues or PR
The text was updated successfully, but these errors were encountered: