jhipster / jdl-studio

JDL Studio is an online JHipster Domain Language visual editor
https://start.jhipster.tech/jdl-studio/
Apache License 2.0
405 stars 114 forks source link

Add Default Value For Fields in JDL #29

Closed verrol closed 7 years ago

verrol commented 7 years ago

Please considering adding the ability to specific a default value in the .jdl file.

Use Case: At design time, while working on the .jdl file, hints can be provided for the UI. If there is a default value for a field, that value can be sent both to db when the tables are created and to the generated UI. Hence, making it easier for the default to enforce the design.

Example: entity A{ quantity Integer required min(10) max(100) default(10), model String required default("basic"), count Long default(0) }

deepu105 commented 7 years ago

This is not something JHipster supports at the moment and hence cannot ve supported here as well

verrol commented 7 years ago

@deepu105 , I know that JHipster's JDL Studio doesn't currently support default values. This was a request, may be I used the incorrect issue, to ask for default support to be added.

If you would reconsider, there are several options I can think of:

  1. Write defaults to DTO as supported by Mapstruct. This would make it obvious to the user that there are defaults, as it would show up on the UI.
  2. Initialize the values in the Angular Service or controller. This seems less appealing, thus making and would push the responsibility to an UI developer if another UI is to be used.
  3. SQL supports adding a default. While this might work too, it is not obvious to the user and SQL writes the default value when the record is created.

If considered, I think the first option is the best.

Thanks.

.v

it-sumanp commented 6 years ago

Hi @deepu105 @jdubois Hey friends, I feel this will be a useful feature, can we reconsider adding support for this

deepu105 commented 6 years ago

@it-sumanp we dont have enough bandwidth to do this at the moment. If you are willing to contribute this as PR we will happy to consider

jdubois commented 6 years ago

Doesn't this also needs to be done in the JDL first? Not sure @MathieuAA also have time for this

plfgavilan commented 6 years ago

It would be a nice to have. I was looking for the way to do it right now

MathieuAA commented 6 years ago

@jdubois It's not that difficult, it would be done post v3.1.0

deepu105 commented 6 years ago

Generator doesn't support it anyway so we don't have to do it in JDL unless someone adds support in generator

jiangzhixiao commented 6 years ago

@MathieuAA if you have time,i think it's a wonderful things,thanks mathieuAA