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-5889 bulk detect hidden by #450

Merged
merged 2 commits into from
Aug 22, 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 @@ -424,7 +424,7 @@ export function EagerTable<T extends GridValidRowModel, TStored extends T, S ext
<GridToolbarContainer>
{toolBarActions.map((toolBarAction: ToolBarActionProps<T>) =>
actions[toolBarAction.name] &&
toolBarAction.enabled(data, selectionModel, ownerData, isFormUpdateable) ? (
toolBarAction.enabled(data, selectionModel, getSelectedRows(), ownerData, isFormUpdateable) ? (
<Button
key={toolBarAction.id}
id={toolBarAction.id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ export function LazyTable<T extends GridValidRowModel, TStored extends T, S exte
<GridToolbarContainer>
{toolBarActions.map((toolBarAction: ToolBarActionProps<T>) =>
actions[toolBarAction.name] &&
toolBarAction.enabled(data, selectionModel, ownerData, isFormUpdateable) ? (
toolBarAction.enabled(data, selectionModel, getSelectedRows(), ownerData, isFormUpdateable) ? (
<Button
key={toolBarAction.id}
id={toolBarAction.id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ export function ViewGalaxyTableTableComponent(props: ViewGalaxyTableTableCompone
enabled: (
data: ViewGalaxyStored[],
selectionModel: GridRowSelectionModel,
selectedRows: ViewGalaxyStored[],
ownerData?: any,
isFormUpdateable?: () => boolean,
): boolean => true,
Expand All @@ -296,6 +297,7 @@ export function ViewGalaxyTableTableComponent(props: ViewGalaxyTableTableCompone
enabled: (
data: ViewGalaxyStored[],
selectionModel: GridRowSelectionModel,
selectedRows: ViewGalaxyStored[],
ownerData?: any,
isFormUpdateable?: () => boolean,
): boolean => true,
Expand All @@ -311,6 +313,7 @@ export function ViewGalaxyTableTableComponent(props: ViewGalaxyTableTableCompone
enabled: (
data: ViewGalaxyStored[],
selectionModel: GridRowSelectionModel,
selectedRows: ViewGalaxyStored[],
ownerData?: any,
isFormUpdateable?: () => boolean,
): boolean => true,
Expand All @@ -326,6 +329,7 @@ export function ViewGalaxyTableTableComponent(props: ViewGalaxyTableTableCompone
enabled: (
data: ViewGalaxyStored[],
selectionModel: GridRowSelectionModel,
selectedRows: ViewGalaxyStored[],
ownerData?: any,
isFormUpdateable?: () => boolean,
): boolean => true,
Expand All @@ -341,6 +345,7 @@ export function ViewGalaxyTableTableComponent(props: ViewGalaxyTableTableCompone
enabled: (
data: ViewGalaxyStored[],
selectionModel: GridRowSelectionModel,
selectedRows: ViewGalaxyStored[],
ownerData?: any,
isFormUpdateable?: () => boolean,
): boolean => true,
Expand All @@ -356,6 +361,7 @@ export function ViewGalaxyTableTableComponent(props: ViewGalaxyTableTableCompone
enabled: (
data: ViewGalaxyStored[],
selectionModel: GridRowSelectionModel,
selectedRows: ViewGalaxyStored[],
ownerData?: any,
isFormUpdateable?: () => boolean,
): boolean => true,
Expand All @@ -371,6 +377,7 @@ export function ViewGalaxyTableTableComponent(props: ViewGalaxyTableTableCompone
enabled: (
data: ViewGalaxyStored[],
selectionModel: GridRowSelectionModel,
selectedRows: ViewGalaxyStored[],
ownerData?: any,
isFormUpdateable?: () => boolean,
): boolean => data.length > 0,
Expand All @@ -386,6 +393,7 @@ export function ViewGalaxyTableTableComponent(props: ViewGalaxyTableTableCompone
enabled: (
data: ViewGalaxyStored[],
selectionModel: GridRowSelectionModel,
selectedRows: ViewGalaxyStored[],
ownerData?: any,
isFormUpdateable?: () => boolean,
): boolean => selectionModel.length > 0,
Expand All @@ -401,6 +409,7 @@ export function ViewGalaxyTableTableComponent(props: ViewGalaxyTableTableCompone
enabled: (
data: ViewGalaxyStored[],
selectionModel: GridRowSelectionModel,
selectedRows: ViewGalaxyStored[],
ownerData?: any,
isFormUpdateable?: () => boolean,
): boolean => selectionModel.length > 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@ public static MaskEntry getMaskForTable(Table table, PageDefinition pageDefiniti
}
}

for (Button button: table.getTableActionButtonGroup().getButtons()) {
if (button.getHiddenBy() != null) {
mask.addPrimitives(button.getHiddenBy().getName());
}
if (button.getEnabledBy() != null) {
mask.addPrimitives(button.getEnabledBy().getName());
}
}

return mask;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,11 @@ public static String tableButtonVisibilityConditions(Button button, Table table,
result += "selectionModel.length > 0";
if (container.isView() && button.getActionDefinition().getIsCallOperationAction()) {
return result + " && !editMode";
} else if (button.getActionDefinition().getIsBulkCallOperationAction() && button.getHiddenBy() != null) {
if (container.isView()) {
result += " && !editMode";
}
return result + " && selectedRows.every(s => !s." + button.getHiddenBy().getName() + ")";
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ export function EagerTable<T extends GridValidRowModel, TStored extends T, S ext
toolbar: () => (
<GridToolbarContainer>
{
toolBarActions.map( (toolBarAction: ToolBarActionProps<T>) => actions[toolBarAction.name] && toolBarAction.enabled(data, selectionModel, ownerData, isFormUpdateable) ? (
toolBarActions.map( (toolBarAction: ToolBarActionProps<T>) => actions[toolBarAction.name] && toolBarAction.enabled(data, selectionModel, getSelectedRows(), ownerData, isFormUpdateable) ? (
<Button
key={toolBarAction.id}
id={toolBarAction.id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ export function LazyTable<T extends GridValidRowModel, TStored extends T, S exte
toolbar: () => (
<GridToolbarContainer>
{
toolBarActions.map( (toolBarAction: ToolBarActionProps<T>) => actions[toolBarAction.name] && toolBarAction.enabled(data, selectionModel, ownerData, isFormUpdateable) ? (
toolBarActions.map( (toolBarAction: ToolBarActionProps<T>) => actions[toolBarAction.name] && toolBarAction.enabled(data, selectionModel, getSelectedRows(), ownerData, isFormUpdateable) ? (
<Button
key={toolBarAction.id}
id={toolBarAction.id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export function {{ componentName table }}(props: {{ componentName table }}Props)
variant: {{{ variantForButton button }}},
hiddenBy: {{# if button.hiddenBy }}true{{ else }}false{{/ if }},
label: { 'translationKey': '{{ getTranslationKeyForVisualElement button }}', 'defaultValue': '{{ button.label }}' },
enabled: (data: {{# with (getReferenceClassType table) as |classType| }}{{# if classType.isMapped }}{{ classDataName (getReferenceClassType table) 'Stored' }}[]{{ else }}{{ classDataName (getReferenceClassType table) '' }}[]{{/ if }}{{/ with }}, selectionModel: GridRowSelectionModel, ownerData?: any, isFormUpdateable?: () => boolean): boolean => {{{ tableButtonVisibilityConditions button table container }}},
enabled: (data: {{# with (getReferenceClassType table) as |classType| }}{{ classDataName (getReferenceClassType table) '' }}{{# if classType.isMapped }}Stored{{/ if }}[]{{/ with }}, selectionModel: GridRowSelectionModel, selectedRows: {{# with (getReferenceClassType table) as |classType| }}{{ classDataName (getReferenceClassType table) '' }}{{# if classType.isMapped }}Stored{{/ if }}[]{{/ with }}, ownerData?: any, isFormUpdateable?: () => boolean): boolean => {{{ tableButtonVisibilityConditions button table container }}},
isBulk: {{ boolValue actionDefinition.isBulk }},
{{# if button.confirmation }}
confirmation: t('{{ getTranslationKeyForVisualElement button }}.confirmation', { defaultValue: '{{ button.confirmation.confirmationMessage }}' }) as string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export interface ToolBarActionProps<T> {
enabled: (
data: T[],
selectionModel: GridRowSelectionModel,
selectedRows: T[],
ownerData?: any,
isFormUpdateable?: () => boolean,
) => boolean;
Expand Down
Loading