Skip to content

Commit

Permalink
JNG-5974 JNG-5975 JNG-5973 tag fixes (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
noherczeg authored Oct 21, 2024
1 parent fdbad18 commit c159b6a
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 169 deletions.
208 changes: 104 additions & 104 deletions judo-ui-react-itest/RelationTest/model/RelationTest-ui.model

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ export function TagContainerTransferTagContainerTransfer_View_EditManyAggregatio
await actions.manyAggregationCompostionAutocompleteAddAction!(added);
}
} else if (Array.isArray(removed) && removed.length) {
if (actions.manyAggregationCompostionBulkDeleteAction) {
await actions.manyAggregationCompostionBulkDeleteAction!(removed);
if (actions.manyAggregationCompostionRemoveAction) {
for (let removedEntry of removed) {
await actions.manyAggregationCompostionRemoveAction!(removedEntry);
}
}
}
}}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ public static ActionDefinition getBulkDeleteActionDefinitionForTable(Table table
return (ActionDefinition) table.getTableActionDefinitions().stream().filter(a -> ((ActionDefinition) a).getIsBulkDeleteAction()).findFirst().orElse(null);
}

public static ActionDefinition getRemoveActionDefinitionForTable(Table table) {
return (ActionDefinition) table.getRowActionDefinitions().stream().filter(a -> ((ActionDefinition) a).getIsRemoveAction()).findFirst().orElse(null);
}

public static ActionDefinition getRangeActionDefinitionForTable(Table table) {
return (ActionDefinition) table.getTableActionDefinitions().stream().filter(a -> ((ActionDefinition) a).getIsSelectorRangeAction()).findFirst().orElse(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ export const columnsActionCalculator: ColumnActionsProvider<any, any> = (
getActions: (params: GridRowParams) => [
<ButtonGroup>
{splitActions.filter(a => !a.hidden(params.row)).map((a) => (
<Tooltip title={a.tooltip}>
<Tooltip title={a.tooltip} key={a.id}>
<Button
id={a.id}
key={a.id}
variant="text"
startIcon={a.icon}
disabled={a.disabled ? a.disabled(params.row, isLoading, isRowInEditMode(params.row, rowModesModel), getSelectedRows, ownerData) : false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import CircularProgress from '@mui/material/CircularProgress';
import IconButton from '@mui/material/IconButton';
import InputAdornment from '@mui/material/InputAdornment';
import TextField from '@mui/material/TextField';
import Chip from '@mui/material/Chip';
import { debounce } from '@mui/material/utils';
import clsx from 'clsx';
import { type MouseEvent, type SyntheticEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react';
Expand Down Expand Up @@ -134,8 +135,12 @@ export function Tags<P, T>(props: TagsProps<P, T>) {
const onChange = useCallback(
(event: SyntheticEvent, value: (string | any)[], reason: string) => {
if (typeof onValueChange === 'function') {
const added = value.filter(v => !values.some(vv => vv[identifierAttribute as keyof T] === v[identifierAttribute]));
const removed = values.filter(v => !value.some(vv => vv[identifierAttribute] === v[identifierAttribute as keyof T]));
const added = value.filter(
(v) => !values.some((vv) => vv[identifierAttribute as keyof T] === v[identifierAttribute as keyof T]),
);
const removed = values.filter(
(v) => !value.some((vv) => vv[identifierAttribute as keyof T] === v[identifierAttribute as keyof T]),
);
onValueChange(value as any, added, removed);
}
},
Expand Down Expand Up @@ -201,6 +206,18 @@ export function Tags<P, T>(props: TagsProps<P, T>) {
} : undefined }
onInputChange={onInputChange}
onChange={onChange}
renderTags={(tagValue, getTagProps) =>
tagValue.map((option, index) => {
const { key, ...rest } = getTagProps({ index });
return (
<Chip
key={key}
label={option[autoCompleteAttribute]}
{...rest}
/>
);
})
}
renderInput={(params) => (
<TextField
{...params}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,18 @@ export function {{ componentName table }}(props: {{ componentName table }}Props)
}
{{/ with }}
} else if (Array.isArray(removed) && removed.length) {
{{# with (getBulkDeleteActionDefinitionForTable table) as |bulkDeleteActionDefinition| }}
if (actions.{{ simpleActionDefinitionName bulkDeleteActionDefinition }}) {
await actions.{{ simpleActionDefinitionName bulkDeleteActionDefinition }}!(removed);
{{# with (getRemoveActionDefinitionForTable table) as |removeActionDefinition| }}
if (actions.{{ simpleActionDefinitionName removeActionDefinition }}) {
for (let removedEntry of removed) {
await actions.{{ simpleActionDefinitionName removeActionDefinition }}!(removedEntry);
}
}
{{ else }}
{{# with (getBulkRemoveActionDefinitionForTable table) as |bulkRemoveActionDefinition| }}
if (actions.{{ simpleActionDefinitionName bulkRemoveActionDefinition }}) {
await actions.{{ simpleActionDefinitionName bulkRemoveActionDefinition }}!(removed);
{{# with (getRowDeleteActionDefinitionForTable table) as |rowDeleteActionDefinition| }}
if (actions.{{ simpleActionDefinitionName rowDeleteActionDefinition }}) {
for (let removedEntry of removed) {
await actions.{{ simpleActionDefinitionName rowDeleteActionDefinition }}!(removedEntry);
}
}
{{/ with }}
{{/ with }}
Expand Down

0 comments on commit c159b6a

Please sign in to comment.