Skip to content

Commit

Permalink
JNG-5889 bulk detect hidden by (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
noherczeg authored Aug 22, 2024
1 parent bb8390d commit 0f43d84
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,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 @@ -605,7 +605,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 @@ -467,7 +467,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 @@ -628,7 +628,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

0 comments on commit 0f43d84

Please sign in to comment.