Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JNG-5745 fix row actions with mapped inputs #409

Merged
merged 4 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,11 @@ public static String getSelectorOpenActionParameters(Action action, PageContaine
tokens.add("[]");
}
} else {
tokens.add("data");
if (action.getActionDefinition().getTargetType() != null) {
tokens.add("target!");
} else {
tokens.add("data");
}
noherczeg marked this conversation as resolved.
Show resolved Hide resolved
}

if (action.getTargetPageDefinition().getContainer().isIsRelationSelector()) {
Expand Down
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 @@ -14,18 +14,18 @@
<Grid container sx={ { height: DIVIDER_HEIGHT } } alignItems="center">
<Grid item xs={12}>
<Divider id="{{ getXMIID child }}">
{{# or child.icon child.label }}
{{# if (elementHasIconOrLabel child) }}
<Box sx={ { display: 'flex', flexDirection: 'row', alignItems: 'center' } }>
{{# if child.icon }}
{{# if (elementHasIcon child) }}
<MdiIcon path="{{ child.icon.iconName }}" {{# if child.label }}sx={ { mr: '.2rem' } }{{/ if }} />
{{/ if }}
{{# if child.label }}
{{# if (elementHasLabel child) }}
<Typography id="{{ getXMIID child }}">
{ t('{{ getTranslationKeyForVisualElement child }}', { defaultValue: '{{ child.label }}' }) as string }
</Typography>
{{/ if }}
</Box>
{{/ or }}
{{/ if }}
</Divider>
</Grid>
</Grid>
Expand Down
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {{ simpleActionDefinitionName action.actionDefinition }} = async () => {
const {{ simpleActionDefinitionName action.actionDefinition }} = async ({{# if action.actionDefinition.targetType }}target?: {{ classDataName action.actionDefinition.targetType 'Stored' }}{{/ if }}) => {
const { result, data: returnedData } = await open{{ pageName action.targetPageDefinition }}({{{ getSelectorOpenActionParameters action page.container }}});
if (result === 'submit') {
{{# if page.container.view }}
Expand Down
Loading