Skip to content

Commit

Permalink
JNG-5745 fix missing table heading
Browse files Browse the repository at this point in the history
  • Loading branch information
noherczeg committed May 31, 2024
1 parent 50609bd commit f533b22
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import static hu.blackbelt.judo.ui.generator.react.ReactStoredVariableHelper.DEFAULT_I18N_LANGUAGE;
import static hu.blackbelt.judo.ui.generator.react.UiActionsHelper.translationElementForBulkAction;
import static hu.blackbelt.judo.ui.generator.react.UiWidgetHelper.collectVisualElementsMatchingCondition;
import static hu.blackbelt.judo.ui.generator.react.UiWidgetHelper.flexHasLabel;
import static hu.blackbelt.judo.ui.generator.react.UiWidgetHelper.elementHasLabel;
import static hu.blackbelt.judo.ui.generator.typescript.rest.commons.UiCommonsHelper.restParamName;
import static java.util.Arrays.stream;

Expand Down Expand Up @@ -309,7 +309,7 @@ public static Map<String, String> getApplicationTranslations(Application applica
});

List<VisualElement> flexElements = new ArrayList<>();
collectVisualElementsMatchingCondition(container, (v) -> v instanceof Flex flex && flexHasLabel(flex) && !(v instanceof PageContainer), flexElements);
collectVisualElementsMatchingCondition(container, (v) -> v instanceof Flex flex && elementHasLabel(flex) && !(v instanceof PageContainer), flexElements);
flexElements.forEach(f -> {
translations.put(getTranslationKeyForVisualElement(f), f.getLabel());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public static String containerButtonGroupButtonDisabledConditions(Button button,
}

public static boolean cardHasHeaderContent(Flex flex) {
return (flexHasIconOrLabel(flex) || flex.getActionButtonGroup() != null) && !(flex.eContainer() instanceof Tab);
return (elementHasIconOrLabel(flex) || flex.getActionButtonGroup() != null) && !(flex.eContainer() instanceof Tab);
}

public static boolean containerHasDateOrDateTimeInput(PageContainer container) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,12 +419,16 @@ public static boolean flexParentIsNotTab(Flex flex) {
return !(flex.eContainer() instanceof Tab);
}

public static boolean flexHasIconOrLabel(Flex flex) {
return flex.getIcon() != null || flexHasLabel(flex);
public static boolean elementHasIconOrLabel(VisualElement element) {
return elementHasIcon(element) || elementHasLabel(element);
}

public static boolean flexHasLabel(Flex flex) {
return flex.getLabel() != null && !flex.getLabel().trim().isBlank();
public static boolean elementHasIcon(VisualElement element) {
return element.getIcon() != null && element.getIcon().getIconName() != null && element.getIcon().getIconName().trim().isBlank();
}

public static boolean elementHasLabel(VisualElement element) {
return element.getLabel() != null && !element.getLabel().trim().isBlank();
}

public static Column getSortColumnForLink(Link link) {
Expand All @@ -437,4 +441,8 @@ public static Column getSortColumnForLink(Link link) {
public static boolean isLinkAssociation(Link link) {
return link.getRelationType().getIsRelationKindAssociation();
}

public static boolean displayTableHeading(Table table, PageContainer container) {
return elementHasIconOrLabel(table) && !container.isIsSelector() && !container.isTable();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
<CardContent>
{{# if (cardHasHeaderContent this) }}
<Grid container direction="row" alignItems="center" justifyContent="space-between" spacing={2} sx={ { mb: 2 } }>
{{# if (flexHasIconOrLabel this) }}
{{# if (elementHasIconOrLabel this) }}
<Grid item>
<Grid container direction="row" alignItems="center" justifyContent="flex-start">
{{# if this.icon }}
{{# if (elementHasIcon this) }}
<MdiIcon path="{{ this.icon.iconName }}" sx={ { marginRight: 1 } } />
{{/ if }}
{{# if this.label }}
{{# if (elementHasLabel this) }}
<Typography variant="h5" component="h1">
{ t('{{ getTranslationKeyForVisualElement this }}', { defaultValue: '{{ this.label }}' }) }
</Typography>
Expand Down Expand Up @@ -68,13 +68,13 @@
</Card>
{{ else }}
<Grid container direction="row" spacing={2}>
{{# and (flexHasIconOrLabel this) (flexParentIsNotTab this) }}
{{# and (elementHasIconOrLabel this) (flexParentIsNotTab this) }}
<Grid item xs={12} sm={12}>
<Grid container direction="row" alignItems="center" justifyContent="flex-start">
{{# if this.icon }}
{{# if (elementHasIcon this) }}
<MdiIcon path="{{ this.icon.iconName }}" sx={ { marginRight: 1 } } />
{{/ if }}
{{# if this.label }}
{{# if (elementHasLabel this) }}
<Typography variant="h5" component="h1">
{ t('{{ getTranslationKeyForVisualElement this }}', { defaultValue: '{{ this.label }}' }) }
</Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,46 @@
{{/ unless }}
>
{{/ if }}
<Grid id="{{ getXMIID child }}" container direction="column" alignItems="stretch" justifyContent="flex-start">
<{{ componentName child }}
uniqueId={'{{ getXMIID child }}'}
actions={actions}
{{# if container.isSelector }}
selectionDiff={selectionDiff}
setSelectionDiff={setSelectionDiff}
{{/ if }}
{{# if container.isRelationSelector }}
alreadySelected={alreadySelected}
{{/ if }}
{{# unless container.table }}
ownerData={data}
editMode={editMode}
isFormUpdateable={isFormUpdateable}
{{# unless child.isSelectorTable }}
validationError={validation.get('{{ child.dataElement.name }}')}
{{/ unless }}
{{/ unless }}
refreshCounter={refreshCounter}
isOwnerLoading={isLoading}
/>
<Grid container direction="row" spacing={2}>
{{# if (displayTableHeading child container) }}
<Grid item xs={12} sm={12}>
<Grid container direction="row" alignItems="center" justifyContent="flex-start">
{{# if (elementHasIcon child) }}
<MdiIcon path="{{ child.icon.iconName }}" sx={ { marginRight: 1 } } />
{{/ if }}
{{# if (elementHasLabel child) }}
<Typography variant="h5" component="h1">
{ t('{{ getTranslationKeyForVisualElement child }}', { defaultValue: '{{ child.label }}' }) }
</Typography>
{{/ if }}
</Grid>
</Grid>
{{/ if }}
<Grid item xs={12} sm={12}>
<Grid id="{{ getXMIID child }}" container direction="column" alignItems="stretch" justifyContent="flex-start">
<{{ componentName child }}
uniqueId={'{{ getXMIID child }}'}
actions={actions}
{{# if container.isSelector }}
selectionDiff={selectionDiff}
setSelectionDiff={setSelectionDiff}
{{/ if }}
{{# if container.isRelationSelector }}
alreadySelected={alreadySelected}
{{/ if }}
{{# unless container.table }}
ownerData={data}
editMode={editMode}
isFormUpdateable={isFormUpdateable}
{{# unless child.isSelectorTable }}
validationError={validation.get('{{ child.dataElement.name }}')}
{{/ unless }}
{{/ unless }}
refreshCounter={refreshCounter}
isOwnerLoading={isLoading}
/>
</Grid>
</Grid>
</Grid>
{{# if child.customImplementation }}
</ComponentProxy>
Expand Down

0 comments on commit f533b22

Please sign in to comment.