- btn-luxury-primary/secondary + x-delete-confirm-modal
- 膠囊式頁籤(對齊 x-tab-nav 外觀)
- 「新增」改用 __('Create')=新增(不動全域 New=新值,那是 products 變更紀錄用)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
95 lines
6.6 KiB
PHP
95 lines
6.6 KiB
PHP
@extends('layouts.admin')
|
|
|
|
@section('content')
|
|
<div class="px-6 py-8" x-data="{ showCreate: false, isDeleteConfirmOpen: false, deleteFormAction: '' }">
|
|
@include('admin.app._tabs', ['active' => 'elements'])
|
|
|
|
<div class="flex justify-end mb-4">
|
|
<button type="button" @click="showCreate = true" class="btn-luxury-primary">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" d="M12 4v16m8-8H4" /></svg>
|
|
{{ __('Create') }}
|
|
</button>
|
|
</div>
|
|
|
|
<div class="overflow-x-auto">
|
|
<table class="min-w-full bg-white dark:bg-gray-800 rounded-lg overflow-hidden">
|
|
<thead class="bg-gray-100 dark:bg-gray-700">
|
|
<tr>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-600 dark:text-gray-400 uppercase">{{ __('Preview') }}</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-600 dark:text-gray-400 uppercase">{{ __('Name') }}</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-600 dark:text-gray-400 uppercase">{{ __('Category') }}</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-600 dark:text-gray-400 uppercase">{{ __('Created At') }}</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-600 dark:text-gray-400 uppercase">{{ __('Actions') }}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y border-gray-200 dark:border-gray-700">
|
|
@forelse($elements as $element)
|
|
<tr>
|
|
<td class="px-6 py-4">
|
|
@if($element->image_url)
|
|
<img src="{{ $element->image_url }}" alt="{{ $element->name }}"
|
|
class="h-12 w-auto max-w-[140px] object-contain rounded border border-gray-200 dark:border-gray-700 bg-gray-50">
|
|
@else
|
|
<span class="text-gray-400">—</span>
|
|
@endif
|
|
</td>
|
|
<td class="px-6 py-4 text-gray-900 dark:text-gray-200">{{ $element->name }}</td>
|
|
<td class="px-6 py-4">
|
|
<span class="px-2 py-1 rounded-full bg-cyan-100 dark:bg-cyan-500/10 text-cyan-700 dark:text-cyan-400 text-xs font-semibold">{{ $element->part_label }}</span>
|
|
</td>
|
|
<td class="px-6 py-4 text-gray-500 dark:text-gray-400 text-sm">{{ $element->created_at?->format('Y-m-d H:i') }}</td>
|
|
<td class="px-6 py-4">
|
|
<button type="button"
|
|
@click="deleteFormAction = '{{ route('admin.app.ui-elements.destroy', $element) }}'; isDeleteConfirmOpen = true"
|
|
class="text-red-600 hover:text-red-800">{{ __('Delete') }}</button>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr><td colspan="5" class="px-6 py-4 text-center text-gray-600 dark:text-gray-400">{{ __('No data') }}</td></tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
{{-- 新增 UI 元素 Modal --}}
|
|
<div x-show="showCreate" x-cloak class="fixed inset-0 z-50 overflow-y-auto" @keydown.escape.window="showCreate = false">
|
|
<div class="flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:p-0">
|
|
<div class="fixed inset-0 transition-opacity bg-slate-900/60 backdrop-blur-sm" @click="showCreate = false"></div>
|
|
<div class="relative bg-white dark:bg-gray-800 rounded-2xl shadow-xl transform transition-all sm:max-w-lg sm:w-full mx-4 text-left">
|
|
<div class="px-6 py-4 border-b border-gray-200 dark:border-gray-700">
|
|
<h3 class="text-gray-900 dark:text-gray-200 text-lg font-semibold">{{ __('Create') }} — {{ __('UI Elements') }}</h3>
|
|
</div>
|
|
<form action="{{ route('admin.app.ui-elements.store') }}" method="POST" enctype="multipart/form-data">
|
|
@csrf
|
|
<div class="px-6 py-4 space-y-4">
|
|
<div>
|
|
<label class="text-gray-600 dark:text-gray-400 text-sm block mb-1">{{ __('Name') }} <span class="text-rose-500">*</span></label>
|
|
<input type="text" name="name" required class="w-full px-3 py-2 bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 border rounded-md text-gray-900 dark:text-gray-200 focus:ring-2 focus:ring-cyan-500 focus:border-transparent">
|
|
</div>
|
|
<div>
|
|
<label class="text-gray-600 dark:text-gray-400 text-sm block mb-1">{{ __('Category') }} <span class="text-rose-500">*</span></label>
|
|
<select name="part_key" required class="w-full px-3 py-2 bg-white dark:bg-gray-700 border-gray-300 dark:border-gray-600 border rounded-md text-gray-900 dark:text-gray-200 focus:ring-2 focus:ring-cyan-500">
|
|
@foreach($parts as $key => $part)
|
|
<option value="{{ $key }}">{{ $part['label'] }}{{ $part['width'] ? ' — '.$part['width'].'x'.$part['height'] : '' }}</option>
|
|
@endforeach
|
|
</select>
|
|
<p class="text-xs text-gray-400 mt-1">{{ __('Image will be center-cropped to the category size.') }}</p>
|
|
</div>
|
|
<div>
|
|
<label class="text-gray-600 dark:text-gray-400 text-sm block mb-1">{{ __('Upload Image') }} <span class="text-rose-500">*</span></label>
|
|
<input type="file" name="file" accept="image/*" required class="block w-full text-sm text-gray-600 dark:text-gray-300 file:mr-3 file:py-2 file:px-4 file:rounded-md file:border-0 file:bg-cyan-600 file:text-white hover:file:bg-cyan-700">
|
|
</div>
|
|
</div>
|
|
<div class="px-6 py-4 border-t border-gray-200 dark:border-gray-700 flex justify-end space-x-3">
|
|
<button type="button" @click="showCreate = false" class="btn-luxury-secondary">{{ __('Cancel') }}</button>
|
|
<button type="submit" class="btn-luxury-primary">{{ __('Create') }}</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<x-delete-confirm-modal :message="__('Are you sure you want to delete this item? This action cannot be undone.')" />
|
|
</div>
|
|
@endsection
|