jhipster / generator-jhipster

JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.
https://www.jhipster.tech
Apache License 2.0
21.53k stars 4.02k forks source link

Wrong table headers generated with entity generator #1121

Closed etiennedaspe closed 9 years ago

etiennedaspe commented 9 years ago

After using jhipster:entity generator, wrong translate keys have been put in html. You can find below the trace of entities generated, and the wrong html code generated. ----------------------- Entities Generated -----------------------

C:\jhipster-demo\workspace\aclmanager>yo jhipster:entity subject
The entity subject is being created.
Generating field #1
? Do you want to add a field to your entity? Yes
? What is the name of your field? identifier
? What is the type of your field? String
===========Subject==============
identifier (String)
Generating field #2
? Do you want to add a field to your entity? No
===========Subject==============
identifier (String)
Generating relationships with other entities
? Do you want to add a relationship to another entity? Yes
? What is the name of the other entity? acl
? What is the type of the relationship? one-to-many
===========Subject==============
identifier (String)
-------------------
acl (one-to-many)
Generating relationships with other entities
? Do you want to add a relationship to another entity? No
===========Subject==============
identifier (String)
-------------------
acl (one-to-many)
Everything is configured, generating the entity...
   create .jhipster.subject.json
   create src\main\java\com\orange\soft\aclmanager\domain\Subject.java
   create src\main\java\com\orange\soft\aclmanager\repository\SubjectRepository.java
   create src\main\java\com\orange\soft\aclmanager\web\rest\SubjectResource.java

   create src\main\resources\config\liquibase\changelog\20150211100223_added_entity_Subject.xml
   create src\main\webapp\scripts\app\entities\subject\subjects.html
   create src\main\webapp\scripts\app\entities\subject\subject-detail.html
   create src\main\webapp\scripts\app\entities\subject\subject.js
   create src\main\webapp\scripts\app\entities\subject\subject.controller.js
   create src\main\webapp\scripts\app\entities\subject\subject-detail.controller.js
   create src\main\webapp\scripts\components\entities\subject\subject.service.js

   create src\test\java\com\orange\soft\aclmanager\web\rest\SubjectResourceTest.java
   create src\main\webapp\i18n\en\subject.json
   create src\main\webapp\i18n\fr\subject.json

C:\jhipster-demo\workspace\aclmanager>yo jhipster:entity country
The entity country is being created.
Generating field #1
? Do you want to add a field to your entity? Yes
? What is the name of your field? name
? What is the type of your field? String
===========Country==============
name (String)
Generating field #2
? Do you want to add a field to your entity? Yes
? What is the name of your field? code
? What is the type of your field? String
===========Country==============
name (String)
code (String)
Generating field #3
? Do you want to add a field to your entity? No
===========Country==============
name (String)
code (String)
Generating relationships with other entities
? Do you want to add a relationship to another entity? Yes
? What is the name of the other entity? acl
? What is the type of the relationship? one-to-many
===========Country==============
name (String)
code (String)
-------------------
acl (one-to-many)
Generating relationships with other entities
? Do you want to add a relationship to another entity? No
===========Country==============
name (String)
code (String)
-------------------
acl (one-to-many)
Everything is configured, generating the entity...
   create .jhipster.country.json
   create src\main\java\com\orange\soft\aclmanager\domain\Country.java
   create src\main\java\com\orange\soft\aclmanager\repository\CountryRepository.java
   create src\main\java\com\orange\soft\aclmanager\web\rest\CountryResource.java

   create src\main\resources\config\liquibase\changelog\20150211100315_added_entity_Country.xml
   create src\main\webapp\scripts\app\entities\country\countrys.html
   create src\main\webapp\scripts\app\entities\country\country-detail.html
   create src\main\webapp\scripts\app\entities\country\country.js
   create src\main\webapp\scripts\app\entities\country\country.controller.js
   create src\main\webapp\scripts\app\entities\country\country-detail.controller.js
   create src\main\webapp\scripts\components\entities\country\country.service.js

   create src\test\java\com\orange\soft\aclmanager\web\rest\CountryResourceTest.java
   create src\main\webapp\i18n\en\country.json
   create src\main\webapp\i18n\fr\country.json

C:\jhipster-demo\workspace\aclmanager>yo jhipster:entity operation
The entity operation is being created.
Generating field #1
? Do you want to add a field to your entity? Yes
? What is the name of your field? opcode
? What is the type of your field? String
===========Operation==============
opcode (String)
Generating field #2
? Do you want to add a field to your entity? Yes
? What is the name of your field? description
? What is the type of your field? String
===========Operation==============
opcode (String)
description (String)
Generating field #3
? Do you want to add a field to your entity? No
===========Operation==============
opcode (String)
description (String)
Generating relationships with other entities
? Do you want to add a relationship to another entity? Yes
? What is the name of the other entity? acl
? What is the type of the relationship? one-to-many
===========Operation==============
opcode (String)
description (String)
-------------------
acl (one-to-many)
Generating relationships with other entities
? Do you want to add a relationship to another entity? No
===========Operation==============
opcode (String)
description (String)
-------------------
acl (one-to-many)
Everything is configured, generating the entity...
   create .jhipster.operation.json
   create src\main\java\com\orange\soft\aclmanager\domain\Operation.java
   create src\main\java\com\orange\soft\aclmanager\repository\OperationRepository.java
   create src\main\java\com\orange\soft\aclmanager\web\rest\OperationResource.java
   create src\main\resources\config\liquibase\changelog\20150211100422_added_entity_Operation.xml
   create src\main\webapp\scripts\app\entities\operation\operations.html
   create src\main\webapp\scripts\app\entities\operation\operation-detail.html
   create src\main\webapp\scripts\app\entities\operation\operation.js
   create src\main\webapp\scripts\app\entities\operation\operation.controller.js

   create src\main\webapp\scripts\app\entities\operation\operation-detail.controller.js
   create src\main\webapp\scripts\components\entities\operation\operation.service.js
   create src\test\java\com\orange\soft\aclmanager\web\rest\OperationResourceTest.java
   create src\main\webapp\i18n\en\operation.json
   create src\main\webapp\i18n\fr\operation.json

C:\jhipster-demo\workspace\aclmanager>yo jhipster:entity acl
The entity acl is being created.
Generating field #1
? Do you want to add a field to your entity? No
===========Acl==============
Generating relationships with other entities
? Do you want to add a relationship to another entity? Yes
? What is the name of the other entity? subject
? What is the type of the relationship? many-to-one
? When you display this relationship with AngularJS, which field from 'subject'
? When you display this relationship with AngularJS, which field from 'subject' do you want to use? identifier
===========Acl==============
-------------------
subject (many-to-one)
Generating relationships with other entities
? Do you want to add a relationship to another entity? Yes
? What is the name of the other entity? country
? What is the type of the relationship? many-to-one
? When you display this relationship with AngularJS, which field from 'country'
? When you display this relationship with AngularJS, which field from 'country' do you want to use? name
===========Acl==============
-------------------
subject (many-to-one)
country (many-to-one)
Generating relationships with other entities
? Do you want to add a relationship to another entity? Yes
? What is the name of the other entity? operation
? What is the type of the relationship? many-to-one
? When you display this relationship with AngularJS, which field from 'operation
? When you display this relationship with AngularJS, which field from 'operation' do you want to use? opcode
===========Acl==============
-------------------
subject (many-to-one)
country (many-to-one)
operation (many-to-one)
Generating relationships with other entities
? Do you want to add a relationship to another entity? No
===========Acl==============
-------------------
subject (many-to-one)
country (many-to-one)
operation (many-to-one)
Everything is configured, generating the entity...
   create .jhipster.acl.json
   create src\main\java\com\orange\soft\aclmanager\domain\Acl.java
   create src\main\java\com\orange\soft\aclmanager\repository\AclRepository.java

   create src\main\java\com\orange\soft\aclmanager\web\rest\AclResource.java
   create src\main\resources\config\liquibase\changelog\20150211100523_added_entity_Acl.xml
   create src\main\webapp\scripts\app\entities\acl\acls.html
   create src\main\webapp\scripts\app\entities\acl\acl-detail.html
   create src\main\webapp\scripts\app\entities\acl\acl.js
   create src\main\webapp\scripts\app\entities\acl\acl.controller.js
   create src\main\webapp\scripts\app\entities\acl\acl-detail.controller.js
   create src\main\webapp\scripts\components\entities\acl\acl.service.js
   create src\test\java\com\orange\soft\aclmanager\web\rest\AclResourceTest.java

   create src\main\webapp\i18n\en\acl.json
   create src\main\webapp\i18n\fr\acl.json

----------------------- Wrong Table Headers (translate keys) in entities/acl/acls.html -----------------------

          <thead>
                <tr>
                    <th>ID</th>
                    <th translate="aclmanagerApp.acl.operation">subject</th>
                    <th translate="aclmanagerApp.acl.operation">country</th>
                    <th translate="aclmanagerApp.acl.operation">operation</th>
                    <th></th>
                </tr>
            </thead>
\```
etiennedaspe commented 9 years ago

It seems that this problem is fixed in the current version on Github. But it hasn't been deployed yet. Indeed, I have the lastest version of JHipster on my computer (I downloaded it last Monday). But I compared the _entities.html file on my computer with the one on Github and I noticed a difference at the bug's location.

My file _entities.html line 110 :
<th translate="<%= keyPrefix + otherEntityName%>"><%=relationships[relationshipId].otherEntityName%></th><% } } %>

(so temporarily I just changed "keyPrefix + otherEntityName" to "keyPrefix + relationships[relationshipId].otherEntityName" to correct the bug)

The current _entities.html file on Github line 110 :
<th translate="<%= keyPrefix + relationships[relationshipId].relationshipName%>"><%=relationships[relationshipId].relationshipName%></th><% } } %>
\```