Skip to content

Commit

Permalink
Merge pull request #251 from entando/ENG-4141-Widget-details-boolean-…
Browse files Browse the repository at this point in the history
…value

ENG-4141 Fix checkbox display in case of true value
  • Loading branch information
alepintus authored Oct 9, 2023
2 parents 03124fc + c5afc4c commit cd3b242
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const fieldType = getJHipsterType(field);
switch (fieldType) {
case 'Boolean':
return `<Checkbox disabled checked={${entityInstance}.${field.fieldName}} />`;
return `<Checkbox disabled checked={isChecked(${entityInstance}.${field.fieldName})} />`;
case 'LocalDate':
return `{${entityInstance}.${field.fieldName} && new Date(${entityInstance}.${field.fieldName}).toLocaleDateString(language)}`;
case 'ZonedDateTime':
Expand Down Expand Up @@ -33,6 +33,10 @@ import Checkbox from '@material-ui/core/Checkbox';

import <%= entityInstance %>Type from 'components/__types__/<%= entityInstance %>';

<%_ if (fields.find(field => field.fieldType === 'Boolean')) { _%>
const isChecked = booleanField => typeof booleanField !== 'undefined' ? booleanField.valueOf() : false;
<%_ } _%>

const <%= entityClass %>FieldTable = ({ t, <% if (fieldsContainDate) { _%>i18n: { language }, <% } _%><%= entityInstance %> }) => (
<Table>
<TableHead>
Expand Down

0 comments on commit cd3b242

Please sign in to comment.