Files
Virtnet.bond/extensions/Servers/Proxmox/views/components/ui/editable-field.blade.php
Joseph.Rawlings e7b33a2f6c Refactor Proxmox server views for improved UI consistency and usability
- Updated server card component to use new UI elements and improved layout.
- Enhanced status display with badges and better status indicators.
- Refined quick info row for server details with consistent styling.
- Reorganized server configuration statistics into stat cards for clarity.
- Improved help modals for statistics and storage management sections.
- Streamlined alerts and warnings for better user experience.
- Updated storage management view to utilize new UI components and improve readability.
2025-12-17 11:24:17 -05:00

149 lines
6.3 KiB
PHP

{{--
Editable Field Component - TailServer Theme
A field with display value and edit button that opens a modal
Usage:
<x-proxmox::ui.editable-field
label="Hostname"
:value="$server->hostname"
:editing="$isEditingHostname"
wire:model="hostname"
edit-click="startEditingHostname"
cancel-click="cancelEditingHostname"
save-click="updateHostname"
>
<x-slot:hint>
Additional information about the field...
</x-slot:hint>
</x-proxmox::ui.editable-field>
--}}
@props([
'label',
'value',
'placeholder' => null,
'editing' => false,
'editClick' => null,
'cancelClick' => null,
'saveClick' => null,
'applyClick' => null,
'applyLabel' => 'Save & Apply',
'error' => null,
])
<div class="space-y-2" x-data="{ showEditModal: @entangle($attributes->wire('model')->value() ? 'isEditing' . ucfirst($label) : 'editing') }">
<label class="text-sm font-semibold text-base/80">{{ $label }}</label>
<div class="space-y-2">
<div class="flex items-center gap-2 border border-neutral/20 rounded-lg bg-neutral/5 px-3 py-2 text-sm text-base">
<span class="truncate flex-1">{{ $value ?? 'Not set' }}</span>
@if($editClick)
<button
wire:click="{{ $editClick }}"
type="button"
class="text-base/50 hover:text-base/70 transition-colors"
aria-label="Edit {{ $label }}"
>
<x-ri-edit-line class="size-4" />
</button>
@endif
</div>
</div>
@if($editing !== false)
<!-- Edit Modal Backdrop -->
<div
x-cloak
x-show="showEditModal"
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100"
x-transition:leave-end="opacity-0"
@click="showEditModal = false; @if($cancelClick) $wire.{{ $cancelClick }}() @endif"
@keydown.escape.window="showEditModal = false; @if($cancelClick) $wire.{{ $cancelClick }}() @endif"
class="fixed inset-0 z-50 bg-black/50 backdrop-blur-sm"
style="display: none;"
></div>
<!-- Edit Modal -->
<div
x-cloak
x-show="showEditModal"
x-transition:enter="transition ease-out duration-200"
x-transition:enter-start="opacity-0 scale-95"
x-transition:enter-end="opacity-100 scale-100"
x-transition:leave="transition ease-in duration-150"
x-transition:leave-start="opacity-100 scale-100"
x-transition:leave-end="opacity-0 scale-95"
@click.away="showEditModal = false; @if($cancelClick) $wire.{{ $cancelClick }}() @endif"
class="fixed inset-0 z-50 flex items-center justify-center p-4"
style="display: none;"
>
<div class="relative bg-background border border-neutral/20 rounded-xl shadow-2xl w-full max-w-xl p-5 space-y-4">
<div class="flex items-center justify-between">
<h4 class="text-base font-semibold text-base/90">Edit {{ $label }}</h4>
<button
type="button"
class="p-1.5 rounded-lg hover:bg-neutral/10 transition-colors"
@click="showEditModal = false; @if($cancelClick) $wire.{{ $cancelClick }}() @endif"
aria-label="Close"
>
<x-ri-close-line class="size-4 text-base/60" />
</button>
</div>
<div class="space-y-3">
<div>
<label class="text-xs font-semibold text-base/70">{{ $label }}</label>
<input
type="text"
{{ $attributes->whereStartsWith('wire:model') }}
class="w-full mt-1 px-3 py-2 bg-neutral/5 border border-neutral/20 rounded-lg text-sm text-base placeholder:text-base/40 focus:outline-none focus:ring-2 focus:ring-primary/50"
placeholder="{{ $placeholder ?? 'Enter ' . strtolower($label) }}"
/>
</div>
@if($error)
<div class="text-sm text-danger">{{ $error }}</div>
@endif
@if(isset($hint))
<div class="text-xs text-base/60">{{ $hint }}</div>
@endif
</div>
<div class="flex justify-end gap-2 pt-2">
@if($cancelClick)
<button
type="button"
@click="showEditModal = false; $wire.{{ $cancelClick }}()"
class="px-4 py-2 text-sm font-medium text-base/70 hover:text-base bg-neutral/5 hover:bg-neutral/10 rounded-lg transition-colors"
>
Cancel
</button>
@endif
@if($saveClick)
<button
type="button"
wire:click="{{ $saveClick }}"
class="px-4 py-2 text-sm font-medium text-white bg-primary hover:bg-primary/90 rounded-lg transition-colors"
>
Save
</button>
@endif
@if($applyClick)
<button
type="button"
wire:click="{{ $applyClick }}"
class="px-4 py-2 text-sm font-medium text-white bg-primary hover:bg-primary/90 rounded-lg transition-colors"
>
{{ $applyLabel }}
</button>
@endif
</div>
</div>
</div>
@endif
</div>