Skip to content

Commit

Permalink
Merge pull request #23850 from qmonmert/fix/23763
Browse files Browse the repository at this point in the history
[React] Numeric field of an entity is sent as a string in the JSON via REST API
  • Loading branch information
DanielFran authored Oct 20, 2023
2 parents e42c275 + 819ed1e commit e45278d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions generators/base-application/support/prepare-entity.mts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ export function prepareEntityPrimaryKeyForTemplates(entityWithConfig, generator,
if (idField) {
idField.id = true;
} else {
if (entityWithConfig.microserviceName) {
// TODO ignore warning for microfrontends.
generator.log.warn("Microservice entities should have a custom id to make sure gateway and microservice types won't conflict");
}
idField = {
fieldName: 'id',
id: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,18 @@ export const <%= entityReactName %>Update = () => {
}
}, [updateSuccess]);

// eslint-disable-next-line complexity
const saveEntity = values => {
<%_ for (field of fields.filter(field => !field.id)) {
<%_ for (field of fields) {
const fieldName = field.fieldName;
_%>
<%_ if (field.fieldTypeTimed) { _%>
values.<%= fieldName %> = convertDateTimeToServer(values.<%= fieldName %>);
<%_ } _%>
<%_ } else if (field.fieldTypeNumeric) { _%>
if (values.<%= fieldName %> !== undefined && typeof values.<%= fieldName %> !== 'number') {
values.<%= fieldName %> = Number(values.<%= fieldName %>);
}
<%_ } _%>
<%_ } _%>

const entity = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,15 @@ entity Tag {

@ChangelogDate(20210408164813)
entity Product {
@Id id UUID
title String required
price BigDecimal required min(0)
image ImageBlob
}

@ChangelogDate(20210408164814)
entity Notification {
@Id id UUID
title String required
}

Expand Down

0 comments on commit e45278d

Please sign in to comment.