fix bug
This commit is contained in:
parent
685beea7de
commit
3dbd356d2f
@ -41,16 +41,16 @@
|
|||||||
<table class="w-full table-fixed border border-gray-300 text-left">
|
<table class="w-full table-fixed border border-gray-300 text-left">
|
||||||
<thead class="bg-gray-100">
|
<thead class="bg-gray-100">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-[10%] p-2 border border-gray-300 text-center">ID</th>
|
<th class="w-[10%] p-2 border border-gray-300 text-center">No</th>
|
||||||
<th class="w-[60%] p-2 border border-gray-300 text-center">Deskripsi</th>
|
<th class="w-[60%] p-2 border border-gray-300 text-center">Deskripsi</th>
|
||||||
<th class="w-[30%] p-2 border border-gray-300 text-center">Aksi</th>
|
<th class="w-[30%] p-2 border border-gray-300 text-center">Aksi</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@forelse ($kategoriFitur as $item)
|
@forelse ($kategoriFitur as $index => $item)
|
||||||
<tr class="hover:bg-gray-50">
|
<tr class="hover:bg-gray-50">
|
||||||
<td class="py-4 px-2 border border-gray-300 text-center">
|
<td class="py-4 px-2 border border-gray-300 text-center">
|
||||||
{{ $item->id }}
|
{{ ($kategoriFitur->currentPage() - 1) * $kategoriFitur->perPage() + $loop->iteration }}
|
||||||
</td>
|
</td>
|
||||||
<td class="py-4 px-2 border border-gray-300">
|
<td class="py-4 px-2 border border-gray-300">
|
||||||
{{ $item->deskripsi }}
|
{{ $item->deskripsi }}
|
||||||
@ -287,4 +287,4 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
@ -282,124 +282,149 @@
|
|||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<!-- Modal Edit Template - Fixed Version -->
|
<!-- Modal Edit Template - Fixed Version -->
|
||||||
@foreach ($templates as $template)
|
@foreach ($templates as $template)
|
||||||
<div id="modalEdit{{ $template->id }}" class="fixed inset-0 hidden items-center justify-center z-50">
|
<div id="modalEdit{{ $template->id }}" class="fixed inset-0 hidden items-center justify-center z-50">
|
||||||
<div class="absolute inset-0 bg-black opacity-50 closeEditOverlay" data-id="{{ $template->id }}"></div>
|
<div class="absolute inset-0 bg-black opacity-50 closeEditOverlay" data-id="{{ $template->id }}"></div>
|
||||||
<div class="bg-white rounded-lg shadow-lg w-full max-w-md z-50 flex flex-col max-h-[90vh]">
|
<div class="bg-white rounded-lg shadow-lg w-full max-w-md z-50 flex flex-col max-h-[90vh]">
|
||||||
|
|
||||||
<!-- PINDAHKAN FORM KE LUAR AGAR MENCAKUP SEMUA ELEMEN -->
|
<!-- PINDAHKAN FORM KE LUAR AGAR MENCAKUP SEMUA ELEMEN -->
|
||||||
<form id="editForm{{ $template->id }}" action="{{ route('templates.update', $template->id) }}" method="POST" enctype="multipart/form-data" class="h-full flex flex-col">
|
<form id="editForm{{ $template->id }}" action="{{ route('templates.update', $template->id) }}"
|
||||||
@csrf @method('PUT')
|
method="POST" enctype="multipart/form-data" class="h-full flex flex-col">
|
||||||
|
@csrf @method('PUT')
|
||||||
<!-- Header -->
|
|
||||||
<div class="p-4 border-b sticky top-0 bg-white z-10">
|
|
||||||
<h5 class="text-lg font-medium">Edit Template</h5>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Scrollable content -->
|
<!-- Header -->
|
||||||
<div class="p-4 space-y-4 overflow-y-auto flex-1">
|
<div class="p-4 border-b sticky top-0 bg-white z-10">
|
||||||
<div class="flex-1 space-y-4">
|
<h5 class="text-lg font-medium">Edit Template</h5>
|
||||||
<div>
|
</div>
|
||||||
<label class="block text-sm font-medium">Nama Template</label>
|
|
||||||
<input type="text" name="nama_template"
|
|
||||||
value="{{ old('nama_template', $template->nama_template) }}"
|
|
||||||
class="w-full p-2 border rounded" required>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label class="block text-sm font-medium">Kategori</label>
|
|
||||||
<select name="kategori_id" id="kategoriSelectEdit{{ $template->id }}"
|
|
||||||
class="w-full p-2 border rounded">
|
|
||||||
<option value="">-- Pilih Kategori --</option>
|
|
||||||
@foreach ($kategoris as $kategoriItem)
|
|
||||||
<option value="{{ $kategoriItem->id }}" @selected($kategoriItem->id == old('kategori_id', $template->kategori_id))>
|
|
||||||
{{ $kategoriItem->nama }}
|
|
||||||
</option>
|
|
||||||
@endforeach
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- FITUR -->
|
<!-- Scrollable content -->
|
||||||
<div>
|
<div class="p-4 space-y-4 overflow-y-auto flex-1">
|
||||||
<label class="block text-sm font-medium">Fitur</label>
|
<div class="flex-1 space-y-4">
|
||||||
<div id="fiturContainerEdit{{ $template->id }}"
|
<div>
|
||||||
class="space-y-3 max-h-64 overflow-auto p-2 border rounded">
|
<label class="block text-sm font-medium">Nama Template</label>
|
||||||
@foreach ($kategoriFiturs as $kategoriFitur)
|
<input type="text" name="nama_template"
|
||||||
<div>
|
value="{{ old('nama_template', $template->nama_template) }}"
|
||||||
<p class="font-semibold text-gray-700 mb-1">
|
class="w-full p-2 border rounded" required>
|
||||||
{{ $kategoriFitur->deskripsi }}
|
</div>
|
||||||
</p>
|
<div>
|
||||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-2">
|
<label class="block text-sm font-medium">Kategori</label>
|
||||||
@foreach ($fiturs->where('kategori_fitur_id', $kategoriFitur->id) as $fiturItem)
|
<select name="kategori_id" id="kategoriSelectEdit{{ $template->id }}"
|
||||||
<label class="flex items-center space-x-2">
|
class="w-full p-2 border rounded">
|
||||||
<input type="radio" name="fitur_id[{{ $kategoriFitur->id }}]"
|
<option value="">-- Pilih Kategori --</option>
|
||||||
value="{{ $fiturItem->id }}"
|
@foreach ($kategoris as $kategoriItem)
|
||||||
data-harga="{{ $fiturItem->harga }}"
|
<option value="{{ $kategoriItem->id }}" @selected($kategoriItem->id == old('kategori_id', $template->kategori_id))>
|
||||||
{{ old("fitur_id.$kategoriFitur->id") == $fiturItem->id || $template->fiturs->contains($fiturItem->id) ? 'checked' : '' }}>
|
{{ $kategoriItem->nama }}
|
||||||
<span class="text-sm">
|
</option>
|
||||||
{{ \Illuminate\Support\Str::limit($fiturItem->deskripsi, 80) }}
|
@endforeach
|
||||||
(Rp {{ number_format($fiturItem->harga, 0, ',', '.') }})
|
</select>
|
||||||
</span>
|
</div>
|
||||||
</label>
|
|
||||||
@endforeach
|
<!-- FITUR -->
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-medium">Fitur</label>
|
||||||
|
<div id="fiturContainerEdit{{ $template->id }}"
|
||||||
|
class="space-y-3 max-h-64 overflow-auto p-2 border rounded">
|
||||||
|
@foreach ($kategoriFiturs as $kategoriFitur)
|
||||||
|
<div>
|
||||||
|
<p class="font-semibold text-gray-700 mb-1">
|
||||||
|
{{ $kategoriFitur->deskripsi }}
|
||||||
|
</p>
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-2">
|
||||||
|
@foreach ($fiturs->where('kategori_fitur_id', $kategoriFitur->id) as $fiturItem)
|
||||||
|
<label class="flex items-center space-x-2">
|
||||||
|
<input type="radio" name="fitur_id[{{ $kategoriFitur->id }}]"
|
||||||
|
value="{{ $fiturItem->id }}"
|
||||||
|
data-harga="{{ $fiturItem->harga }}"
|
||||||
|
{{ old("fitur_id.$kategoriFitur->id") == $fiturItem->id || $template->fiturs->contains($fiturItem->id) ? 'checked' : '' }}>
|
||||||
|
<span class="text-sm">
|
||||||
|
{{ \Illuminate\Support\Str::limit($fiturItem->deskripsi, 80) }}
|
||||||
|
(Rp {{ number_format($fiturItem->harga, 0, ',', '.') }})
|
||||||
|
</span>
|
||||||
|
</label>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
@endforeach
|
||||||
@endforeach
|
|
||||||
|
|
||||||
@if ($fitursTanpaKategori->count())
|
@if ($fitursTanpaKategori->count())
|
||||||
<div>
|
<div>
|
||||||
<p class="font-semibold text-gray-700 mb-1">Fitur Lainnya</p>
|
<p class="font-semibold text-gray-700 mb-1">Fitur Lainnya</p>
|
||||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-2">
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-2">
|
||||||
@foreach ($fitursTanpaKategori as $fitur)
|
@foreach ($fitursTanpaKategori as $fitur)
|
||||||
<label class="flex items-center space-x-2">
|
<label class="flex items-center space-x-2">
|
||||||
<input type="checkbox" name="fitur_id[]"
|
<input type="checkbox" name="fitur_id[]"
|
||||||
value="{{ $fitur->id }}" data-harga="{{ $fitur->harga }}"
|
value="{{ $fitur->id }}" data-harga="{{ $fitur->harga }}"
|
||||||
{{ (is_array(old('fitur_id')) && in_array($fitur->id, old('fitur_id'))) || $template->fiturs->contains($fitur->id) ? 'checked' : '' }}>
|
{{ (is_array(old('fitur_id')) && in_array($fitur->id, old('fitur_id'))) || $template->fiturs->contains($fitur->id) ? 'checked' : '' }}>
|
||||||
<span class="text-sm">
|
<span class="text-sm">
|
||||||
{{ \Illuminate\Support\Str::limit($fitur->deskripsi, 80) }}
|
{{ \Illuminate\Support\Str::limit($fitur->deskripsi, 80) }}
|
||||||
(Rp {{ number_format($fitur->harga, 0, ',', '.') }})
|
(Rp {{ number_format($fitur->harga, 0, ',', '.') }})
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-medium">Harga</label>
|
||||||
|
<input type="text" name="harga" value="{{ old('harga', $template->harga) }}"
|
||||||
|
class="w-full p-2 border rounded" required min="0">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label class="block text-sm font-medium">Foto (opsional)</label>
|
||||||
|
@if ($template->foto)
|
||||||
|
<div class="mb-2">
|
||||||
|
<small class="text-gray-500">Foto saat ini:</small>
|
||||||
|
<div
|
||||||
|
class="w-20 h-20 mt-1 overflow-hidden rounded bg-gray-100 flex items-center justify-center border">
|
||||||
|
<img src="{{ asset('storage/' . $template->foto) }}" alt="foto"
|
||||||
|
class="max-w-full max-h-full object-contain">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
<input type="file" name="foto" class="w-full p-2 border rounded" accept="image/*">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
|
||||||
<label class="block text-sm font-medium">Harga</label>
|
|
||||||
<input type="text" name="harga" value="{{ old('harga', $template->harga) }}"
|
|
||||||
class="w-full p-2 border rounded" required min="0">
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label class="block text-sm font-medium">Foto (opsional)</label>
|
|
||||||
@if ($template->foto)
|
|
||||||
<div class="mb-2">
|
|
||||||
<small class="text-gray-500">Foto saat ini:</small>
|
|
||||||
<div
|
|
||||||
class="w-20 h-20 mt-1 overflow-hidden rounded bg-gray-100 flex items-center justify-center border">
|
|
||||||
<img src="{{ asset('storage/' . $template->foto) }}" alt="foto"
|
|
||||||
class="max-w-full max-h-full object-contain">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
<input type="file" name="foto" class="w-full p-2 border rounded" accept="image/*">
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Footer - SEKARANG DI DALAM FORM -->
|
||||||
|
<div class="p-4 border-t flex justify-end space-x-2 sticky bottom-0 bg-white z-10">
|
||||||
|
<button type="button" class="bg-gray-300 text-black px-3 py-1 rounded closeEditBtn"
|
||||||
|
data-id="{{ $template->id }}">Batal</button>
|
||||||
|
<!-- TAMBAHKAN type="submit" -->
|
||||||
|
<button type="submit" class="bg-blue-600 text-white px-3 py-1 rounded">Simpan Perubahan</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
<!-- Modal Konfirmasi Hapus Template -->
|
||||||
|
<div id="modalDeleteTemplate" class="fixed inset-0 hidden items-center justify-center z-50">
|
||||||
|
<div class="absolute inset-0 bg-black opacity-50" id="modalDeleteTemplateOverlay"></div>
|
||||||
|
<div class="bg-white rounded-lg shadow-lg w-full max-w-md z-50 overflow-hidden">
|
||||||
|
<form id="deleteTemplateForm" method="POST">
|
||||||
|
@csrf
|
||||||
|
@method('DELETE')
|
||||||
|
<div class="p-4 border-b">
|
||||||
|
<h5 class="text-lg font-medium">Hapus Template</h5>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="p-4">
|
||||||
<!-- Footer - SEKARANG DI DALAM FORM -->
|
Apakah Anda yakin ingin menghapus template <strong id="deleteTemplateName">—</strong>?
|
||||||
<div class="p-4 border-t flex justify-end space-x-2 sticky bottom-0 bg-white z-10">
|
</div>
|
||||||
<button type="button" class="bg-gray-300 text-black px-3 py-1 rounded closeEditBtn"
|
<div class="p-4 border-t flex justify-end space-x-2">
|
||||||
data-id="{{ $template->id }}">Batal</button>
|
<button type="button" id="closeDeleteTemplateModal"
|
||||||
<!-- TAMBAHKAN type="submit" -->
|
class="bg-gray-300 text-black px-3 py-1 rounded">Batal</button>
|
||||||
<button type="submit" class="bg-blue-600 text-white px-3 py-1 rounded">Simpan Perubahan</button>
|
<button type="submit" class="bg-red-600 text-white px-3 py-1 rounded">
|
||||||
|
Ya, Hapus
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endforeach
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user