fix: print and open-standalone icon-only, right-aligned in toolbar
This commit is contained in:
@@ -15,7 +15,7 @@ function ToolbarButton({ item }: { item: ToolbarItem }) {
|
|||||||
title={item.label}
|
title={item.label}
|
||||||
>
|
>
|
||||||
{item.icon && <span className="w-4 h-4 flex-shrink-0">{item.icon}</span>}
|
{item.icon && <span className="w-4 h-4 flex-shrink-0">{item.icon}</span>}
|
||||||
<span className="hidden sm:inline">{item.label}</span>
|
{!item.iconOnly && <span className="hidden sm:inline">{item.label}</span>}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -214,26 +214,32 @@ export function PluginToolbar() {
|
|||||||
groups[g].push(item);
|
groups[g].push(item);
|
||||||
}
|
}
|
||||||
const groupNames = Object.keys(groups);
|
const groupNames = Object.keys(groups);
|
||||||
|
const rightGroupNames = groupNames.filter((g) => g.startsWith('zz-right'));
|
||||||
|
const leftGroupNames = groupNames.filter((g) => !g.startsWith('zz-right'));
|
||||||
|
|
||||||
|
const renderGroup = (groupName: string, gi: number) => (
|
||||||
|
<React.Fragment key={groupName}>
|
||||||
|
{gi > 0 && <div className="w-px h-5 bg-secondary-200 mx-1" />}
|
||||||
|
<div className="flex items-center gap-1">
|
||||||
|
{groups[groupName].map((item) => {
|
||||||
|
if (item.type === 'search') return <ToolbarSearch key={item.id} item={item} />;
|
||||||
|
if (item.type === 'select') return <ToolbarSelect key={item.id} item={item} />;
|
||||||
|
if (item.type === 'dropdown') return <ToolbarDropdown key={item.id} item={item} />;
|
||||||
|
if (item.type === 'custom' && item.customComponent) return <React.Fragment key={item.id}>{item.customComponent}</React.Fragment>;
|
||||||
|
return <ToolbarButton key={item.id} item={item} />;
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="flex items-center gap-1 px-2 sm:px-3 py-1.5 bg-white border-b border-secondary-200 min-h-[43px] overflow-visible relative z-30"
|
className="flex items-center gap-1 px-2 sm:px-3 py-1.5 bg-white border-b border-secondary-200 min-h-[43px] overflow-visible relative z-30"
|
||||||
data-testid="plugin-toolbar"
|
data-testid="plugin-toolbar"
|
||||||
>
|
>
|
||||||
{groupNames.map((groupName, gi) => (
|
{leftGroupNames.map((groupName, gi) => renderGroup(groupName, gi))}
|
||||||
<React.Fragment key={groupName}>
|
{rightGroupNames.length > 0 && <div className="flex-1" />}
|
||||||
{gi > 0 && <div className="w-px h-5 bg-secondary-200 mx-1" />}
|
{rightGroupNames.map((groupName, gi) => renderGroup(groupName, gi))}
|
||||||
<div className="flex items-center gap-1">
|
|
||||||
{groups[groupName].map((item) => {
|
|
||||||
if (item.type === 'search') return <ToolbarSearch key={item.id} item={item} />;
|
|
||||||
if (item.type === 'select') return <ToolbarSelect key={item.id} item={item} />;
|
|
||||||
if (item.type === 'dropdown') return <ToolbarDropdown key={item.id} item={item} />;
|
|
||||||
if (item.type === 'custom' && item.customComponent) return <React.Fragment key={item.id}>{item.customComponent}</React.Fragment>;
|
|
||||||
return <ToolbarButton key={item.id} item={item} />;
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</React.Fragment>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -351,24 +351,26 @@ export function ContactsListPage() {
|
|||||||
icon: <Bookmark className="w-3.5 h-3.5" strokeWidth={2} />,
|
icon: <Bookmark className="w-3.5 h-3.5" strokeWidth={2} />,
|
||||||
onClick: () => setSavedFiltersOpen(true),
|
onClick: () => setSavedFiltersOpen(true),
|
||||||
},
|
},
|
||||||
// Print
|
// Print — icon only, right side
|
||||||
{
|
{
|
||||||
id: 'print',
|
id: 'print',
|
||||||
plugin: 'contacts',
|
plugin: 'contacts',
|
||||||
label: t('common.print', 'Drucken'),
|
label: t('common.print', 'Drucken'),
|
||||||
type: 'button' as const,
|
type: 'button' as const,
|
||||||
group: 'actions',
|
group: 'zz-right',
|
||||||
icon: <Printer className="w-3.5 h-3.5" strokeWidth={2} />,
|
icon: <Printer className="w-3.5 h-3.5" strokeWidth={2} />,
|
||||||
|
iconOnly: true,
|
||||||
onClick: () => window.print(),
|
onClick: () => window.print(),
|
||||||
},
|
},
|
||||||
// Open standalone
|
// Open standalone — icon only, right side
|
||||||
{
|
{
|
||||||
id: 'open-standalone',
|
id: 'open-standalone',
|
||||||
plugin: 'contacts',
|
plugin: 'contacts',
|
||||||
label: 'In neuem Fenster',
|
label: 'In neuem Fenster',
|
||||||
type: 'button' as const,
|
type: 'button' as const,
|
||||||
group: 'actions',
|
group: 'zz-right',
|
||||||
icon: <ExternalLink className="w-3.5 h-3.5" strokeWidth={2} />,
|
icon: <ExternalLink className="w-3.5 h-3.5" strokeWidth={2} />,
|
||||||
|
iconOnly: true,
|
||||||
onClick: () => window.open('/contacts-standalone', '_blank', 'width=1200,height=800'),
|
onClick: () => window.open('/contacts-standalone', '_blank', 'width=1200,height=800'),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user