Skip to content

Commit 668b037

Browse files
Fixed the active and readonly boolean fields as string representation.
The active and readonly fields now shows "Yes" or "No" instead of "true" or "false".
1 parent f904f2e commit 668b037

1 file changed

Lines changed: 65 additions & 58 deletions

File tree

sormas-ui/src/main/java/de/symeda/sormas/ui/configuration/customizablefield/CustomizableFieldsGrid.java

Lines changed: 65 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -24,72 +24,79 @@
2424
import de.symeda.sormas.api.i18n.Captions;
2525
import de.symeda.sormas.api.i18n.I18nProperties;
2626
import de.symeda.sormas.ui.ControllerProvider;
27+
import de.symeda.sormas.ui.utils.BooleanRenderer;
2728
import de.symeda.sormas.ui.utils.FilteredGrid;
2829
import de.symeda.sormas.ui.utils.ShowDetailsListener;
2930

3031
/**
3132
* Grid for displaying and managing customizable field metadata.
3233
*/
3334
@SuppressWarnings({
34-
"java:S110", // suppress sonar too many parents warning
35-
"java:S2160" // suppress missing equals
35+
"java:S110", // suppress sonar too many parents warning
36+
"java:S2160" // suppress missing equals
3637
})
3738
public class CustomizableFieldsGrid extends FilteredGrid<CustomizableFieldMetadataDto, CustomizableFieldMetadataCriteria> {
3839

39-
private static final long serialVersionUID = 1L;
40-
41-
private static final String CLONE_COLUMN_ID = "clone";
42-
private static final String TOGGLE_ACTIVE_COLUMN_ID = "toggleActive";
43-
private static final String DELETE_COLUMN_ID = "delete";
44-
45-
public CustomizableFieldsGrid(CustomizableFieldMetadataCriteria criteria) {
46-
47-
super(CustomizableFieldMetadataDto.class);
48-
setSizeFull();
49-
50-
setLazyDataProvider(
51-
FacadeProvider.getCustomizableFieldMetadataFacade()::getIndexList,
52-
FacadeProvider.getCustomizableFieldMetadataFacade()::count);
53-
setCriteria(criteria);
54-
55-
setColumns(
56-
CustomizableFieldMetadataDto.NAME,
57-
CustomizableFieldMetadataDto.CONTEXT_CLASS,
58-
CustomizableFieldMetadataDto.UI_GROUP,
59-
CustomizableFieldMetadataDto.FIELD_TYPE,
60-
CustomizableFieldMetadataDto.ACTIVE,
61-
CustomizableFieldMetadataDto.READ_ONLY);
62-
63-
addEditColumn(e -> ControllerProvider.getCustomizableFieldsController().editField(e.getUuid()));
64-
65-
addColumn(e -> VaadinIcons.COPY.getHtml(), new HtmlRenderer()).setId(CLONE_COLUMN_ID)
66-
.setCaption(I18nProperties.getCaption(Captions.actionClone))
67-
.setSortable(false)
68-
.setWidth(40);
69-
70-
addColumn(e -> e.isActive() ? VaadinIcons.CLOSE.getHtml() : VaadinIcons.CHECK.getHtml(), new HtmlRenderer()).setId(TOGGLE_ACTIVE_COLUMN_ID)
71-
.setCaption(I18nProperties.getCaption(Captions.actionEnable) + "/" + I18nProperties.getCaption(Captions.actionDisable))
72-
.setSortable(false)
73-
.setWidth(55);
74-
75-
addColumn(e -> VaadinIcons.TRASH.getHtml(), new HtmlRenderer()).setId(DELETE_COLUMN_ID)
76-
.setCaption(I18nProperties.getCaption(Captions.actionDelete))
77-
.setSortable(false)
78-
.setWidth(40);
79-
80-
addItemClickListener(
81-
new ShowDetailsListener<>(CLONE_COLUMN_ID, false, e -> ControllerProvider.getCustomizableFieldsController().cloneField(e)));
82-
addItemClickListener(
83-
new ShowDetailsListener<>(TOGGLE_ACTIVE_COLUMN_ID, false, e -> ControllerProvider.getCustomizableFieldsController().toggleActive(e)));
84-
addItemClickListener(
85-
new ShowDetailsListener<>(DELETE_COLUMN_ID, false, e -> ControllerProvider.getCustomizableFieldsController().deleteField(e.getUuid(), this)));
86-
87-
for (Column<?, ?> column : getColumns()) {
88-
column.setCaption(I18nProperties.getPrefixCaption(CustomizableFieldMetadataDto.I18N_PREFIX, column.getId(), column.getCaption()));
89-
}
90-
}
91-
92-
public void reload() {
93-
getDataProvider().refreshAll();
94-
}
40+
private static final long serialVersionUID = 1L;
41+
42+
private static final String CLONE_COLUMN_ID = "clone";
43+
private static final String TOGGLE_ACTIVE_COLUMN_ID = "toggleActive";
44+
private static final String DELETE_COLUMN_ID = "delete";
45+
46+
public CustomizableFieldsGrid(CustomizableFieldMetadataCriteria criteria) {
47+
48+
super(CustomizableFieldMetadataDto.class);
49+
setSizeFull();
50+
51+
setLazyDataProvider(
52+
FacadeProvider.getCustomizableFieldMetadataFacade()::getIndexList,
53+
FacadeProvider.getCustomizableFieldMetadataFacade()::count);
54+
setCriteria(criteria);
55+
56+
setColumns(
57+
CustomizableFieldMetadataDto.NAME,
58+
CustomizableFieldMetadataDto.CONTEXT_CLASS,
59+
CustomizableFieldMetadataDto.UI_GROUP,
60+
CustomizableFieldMetadataDto.FIELD_TYPE,
61+
CustomizableFieldMetadataDto.ACTIVE,
62+
CustomizableFieldMetadataDto.READ_ONLY);
63+
64+
((Column<CustomizableFieldMetadataDto, Boolean>) getColumn(CustomizableFieldMetadataDto.READ_ONLY)).setRenderer(new BooleanRenderer());
65+
((Column<CustomizableFieldMetadataDto, Boolean>) getColumn(CustomizableFieldMetadataDto.ACTIVE)).setRenderer(new BooleanRenderer());
66+
67+
addEditColumn(e -> ControllerProvider.getCustomizableFieldsController().editField(e.getUuid()));
68+
69+
addColumn(e -> VaadinIcons.COPY.getHtml(), new HtmlRenderer()).setId(CLONE_COLUMN_ID)
70+
.setCaption(I18nProperties.getCaption(Captions.actionClone))
71+
.setSortable(false)
72+
.setWidth(40);
73+
74+
addColumn(e -> e.isActive() ? VaadinIcons.CLOSE.getHtml() : VaadinIcons.CHECK.getHtml(), new HtmlRenderer()).setId(TOGGLE_ACTIVE_COLUMN_ID)
75+
.setCaption(I18nProperties.getCaption(Captions.actionEnable) + "/" + I18nProperties.getCaption(Captions.actionDisable))
76+
.setSortable(false)
77+
.setWidth(55);
78+
79+
addColumn(e -> VaadinIcons.TRASH.getHtml(), new HtmlRenderer()).setId(DELETE_COLUMN_ID)
80+
.setCaption(I18nProperties.getCaption(Captions.actionDelete))
81+
.setSortable(false)
82+
.setWidth(40);
83+
84+
addItemClickListener(
85+
new ShowDetailsListener<>(CLONE_COLUMN_ID, false, e -> ControllerProvider.getCustomizableFieldsController().cloneField(e)));
86+
addItemClickListener(
87+
new ShowDetailsListener<>(TOGGLE_ACTIVE_COLUMN_ID, false, e -> ControllerProvider.getCustomizableFieldsController().toggleActive(e)));
88+
addItemClickListener(
89+
new ShowDetailsListener<>(
90+
DELETE_COLUMN_ID,
91+
false,
92+
e -> ControllerProvider.getCustomizableFieldsController().deleteField(e.getUuid(), this)));
93+
94+
for (Column<?, ?> column : getColumns()) {
95+
column.setCaption(I18nProperties.getPrefixCaption(CustomizableFieldMetadataDto.I18N_PREFIX, column.getId(), column.getCaption()));
96+
}
97+
}
98+
99+
public void reload() {
100+
getDataProvider().refreshAll();
101+
}
95102
}

0 commit comments

Comments
 (0)