refactor: replace client-side clipboard copy logic with server-side JS injection and Filament notifications
This commit is contained in:
@@ -32,14 +32,18 @@ class EditProposal extends EditRecord
|
||||
->icon('heroicon-o-clipboard-document-check')
|
||||
->color('info')
|
||||
->action(function () {
|
||||
// JS ile kopyalama yapar, bildirim göster
|
||||
})
|
||||
->extraAttributes(function () {
|
||||
$url = route('proposals.show', $this->record->slug);
|
||||
return [
|
||||
'x-data' => '',
|
||||
'x-on:click' => "navigator.clipboard.writeText('{$url}').then(() => { \$dispatch('open-notification', { title: '" . __('proposal.link_copied') . "', type: 'success' }) })",
|
||||
];
|
||||
|
||||
// Livewire v3: sunucu tarafında JS enjekte et (user-gesture gerektirmez)
|
||||
$escaped = addslashes($url);
|
||||
$this->js("(function(){var t=document.createElement('textarea');t.value='{$escaped}';t.style.position='fixed';t.style.opacity='0';document.body.appendChild(t);t.focus();t.select();try{document.execCommand('copy')}catch(e){}document.body.removeChild(t);})();");
|
||||
|
||||
Notification::make()
|
||||
->title(__('proposal.link_copied'))
|
||||
->body($url)
|
||||
->success()
|
||||
->duration(6000)
|
||||
->send();
|
||||
})
|
||||
->visible(fn () => $this->record !== null),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user