Skip to content

Commit

Permalink
Removing and adding taggroups in admin also supports preview
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoJokhan committed Jan 2, 2024
1 parent 9aa7faf commit cd17382
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function WidgetResourceOverview() {
updateConfig: (config: ResourceOverviewWidgetProps) =>
updateConfig({ ...widget.config, ...config }),

onFieldChanged: (key: keyof ResourceOverviewWidgetProps, value: string) => {
onFieldChanged: (key: keyof ResourceOverviewWidgetProps, value: any) => {
if (previewConfig) {
updatePreview({
...previewConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,30 @@ export default function WidgetResourceOverviewTags(
) > -1
}
onCheckedChange={(checked: any) => {
return checked
? field.onChange([
...field.value,
{
type: groupName,
multiple: false,
label: '',
},
])
: field.onChange(
field.value?.filter(
(val) => val.type !== groupName
)
);
if (checked) {
const updatedFields = [
...field.value,
{
type: groupName,
multiple: false,
label: '',
},
];
field.onChange(updatedFields);
props.onFieldChanged(
'tagGroups',
updatedFields
);
} else {
const updatedFields = field.value?.filter(
(val) => val.type !== groupName
);
field.onChange(updatedFields);
props.onFieldChanged(
'tagGroups',
updatedFields
);
}
}}
/>
</FormControl>
Expand Down

0 comments on commit cd17382

Please sign in to comment.