Refactor server icon modal trigger and remove redundant event listener

This commit is contained in:
2025-12-06 16:29:44 -05:00
parent b5a22f2c2f
commit 2fbfe74bc9
2 changed files with 3 additions and 9 deletions

View File

@@ -43,11 +43,6 @@
initialIcon: {{ $server->user_set_icon ? "'" . $server->user_set_icon . "'" : 'null' }}, initialIcon: {{ $server->user_set_icon ? "'" . $server->user_set_icon . "'" : 'null' }},
initialColor: {{ $server->user_set_icon_color ? "'" . $server->user_set_icon_color . "'" : 'null' }}, initialColor: {{ $server->user_set_icon_color ? "'" . $server->user_set_icon_color . "'" : 'null' }},
initialPrefix: {{ $server->user_set_icon_prefix ? "'" . $server->user_set_icon_prefix . "'" : "'ri'" }} initialPrefix: {{ $server->user_set_icon_prefix ? "'" . $server->user_set_icon_prefix . "'" : "'ri'" }}
})"
x-init="window.addEventListener('open-server-icon-modal', (event) => {
if (event.detail && String(event.detail.serverId) === String(serverId)) {
openModal();
}
})"> })">
<button @click="openModal()" :title="icon ? 'Customize server icon' : 'Set server icon'" class="flex items-center gap-3 hover:opacity-80 transition-opacity"> <button @click="openModal()" :title="icon ? 'Customize server icon' : 'Set server icon'" class="flex items-center gap-3 hover:opacity-80 transition-opacity">
<div x-show="icon" :style="color ? 'color: ' + color : ''" x-html="getIconSvg(icon, iconPrefix)" class="size-6"></div> <div x-show="icon" :style="color ? 'color: ' + color : ''" x-html="getIconSvg(icon, iconPrefix)" class="size-6"></div>

View File

@@ -29,9 +29,8 @@
@php @php
$hasCustomIcon = optional($service->product->server)->extension === 'Proxmox' && isset($proxmoxServer) && $proxmoxServer && $proxmoxServer->user_set_icon; $hasCustomIcon = optional($service->product->server)->extension === 'Proxmox' && isset($proxmoxServer) && $proxmoxServer && $proxmoxServer->user_set_icon;
$iconColor = $hasCustomIcon ? $proxmoxServer->user_set_icon_color : null; $iconColor = $hasCustomIcon ? $proxmoxServer->user_set_icon_color : null;
@endphp @endphp
<div class="relative flex items-center mr-6 cursor-pointer group" <div class="relative flex items-center mr-6">
onclick="window.dispatchEvent(new CustomEvent('open-server-icon-modal', { detail: { serverId: '{{ optional($proxmoxServer)->id }}' } }))">
@if($hasCustomIcon) @if($hasCustomIcon)
@php @php
$iconPrefix = $proxmoxServer->user_set_icon_prefix ?? 'ri'; $iconPrefix = $proxmoxServer->user_set_icon_prefix ?? 'ri';
@@ -47,7 +46,7 @@
<x-ri-box-3-fill class="w-14 h-14 text-primary" /> <x-ri-box-3-fill class="w-14 h-14 text-primary" />
@endif @endif
<!-- Small edit indicator in upper-right of the icon --> <!-- Small edit indicator in upper-right of the icon -->
<div class="absolute -top-1 -right-1 flex items-center justify-center w-5 h-5 rounded-full bg-white shadow-md border border-primary/30 group-hover:scale-105 transition-transform"> <div class="absolute -top-1 -right-1 flex items-center justify-center w-5 h-5 rounded-full bg-white shadow-md border border-primary/30">
<x-ri-pencil-line class="w-3.5 h-3.5 text-primary" /> <x-ri-pencil-line class="w-3.5 h-3.5 text-primary" />
</div> </div>
</div> </div>