sementara
This commit is contained in:
147
resources/views/referensi_link/create.blade.php
Normal file
147
resources/views/referensi_link/create.blade.php
Normal file
@@ -0,0 +1,147 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumbs')
|
||||
{{ Breadcrumbs::render(request()->route()->getName()) }}
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||
<form method="POST" action="{{ route('basicdata.referensi-link.store') }}">
|
||||
@csrf
|
||||
<div class="card border border-agi-100 pb-2.5">
|
||||
<div class="card-header bg-agi-50" id="basic_settings">
|
||||
<h3 class="card-title">
|
||||
Tambah Referensi Link
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="{{ route('basicdata.referensi-link.index') }}" class="btn btn-xs btn-info"><i class="ki-filled ki-exit-left"></i> Back</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body grid gap-5">
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Nama Referensi Link <span class="text-danger">*</span>
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('name') border-danger bg-danger-light @enderror"
|
||||
type="text"
|
||||
name="name"
|
||||
value="{{ old('name') }}"
|
||||
placeholder="Masukkan nama referensi link"
|
||||
required>
|
||||
@error('name')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Link URL <span class="text-danger">*</span>
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('link') border-danger bg-danger-light @enderror"
|
||||
type="url"
|
||||
name="link"
|
||||
value="{{ old('link') }}"
|
||||
placeholder="https://example.com"
|
||||
required>
|
||||
@error('link')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
<div class="form-hint">Pastikan link diawali dengan http:// atau https://</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Kategori
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('kategori') border-danger bg-danger-light @enderror"
|
||||
type="text"
|
||||
name="kategori"
|
||||
value="{{ old('kategori') }}"
|
||||
placeholder="Misal: regulasi, panduan, dll">
|
||||
@error('kategori')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
<div class="form-hint">Kosongkan jika tidak ada kategori</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Deskripsi
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<textarea class="textarea @error('deskripsi') border-danger bg-danger-light @enderror"
|
||||
name="deskripsi"
|
||||
rows="4"
|
||||
placeholder="Masukkan deskripsi lengkap referensi link">{{ old('deskripsi') }}</textarea>
|
||||
@error('deskripsi')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Status Aktif
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="is_active" value="1" {{ old('is_active', true) ? 'checked' : '' }}>
|
||||
<span class="switch-slider"></span>
|
||||
</label>
|
||||
<span class="ml-3 text-sm text-gray-600">Aktifkan referensi link ini</span>
|
||||
@error('is_active')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Urutan Tampil
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('urutan') border-danger bg-danger-light @enderror"
|
||||
type="number"
|
||||
name="urutan"
|
||||
value="{{ old('urutan', 0) }}"
|
||||
min="0"
|
||||
placeholder="0">
|
||||
@error('urutan')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
<div class="form-hint">Semakin kecil angka, semakin atas posisinya</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer justify-end">
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<a href="{{ route('basicdata.referensi-link.index') }}" class="btn btn-light">
|
||||
<i class="ki-filled ki-exit-left"></i> Batal
|
||||
</a>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="ki-filled ki-check"></i> Simpan
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
// Auto-add https:// if not present
|
||||
document.querySelector('input[name="link"]').addEventListener('blur', function() {
|
||||
let value = this.value.trim();
|
||||
if (value && !value.match(/^https?:\/\//i)) {
|
||||
this.value = 'https://' + value;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
148
resources/views/referensi_link/edit.blade.php
Normal file
148
resources/views/referensi_link/edit.blade.php
Normal file
@@ -0,0 +1,148 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumbs')
|
||||
{{ Breadcrumbs::render(request()->route()->getName()) }}
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||
<form method="POST" action="{{ route('basicdata.referensi-link.update', $referensiLink->id) }}">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<div class="card border border-agi-100 pb-2.5">
|
||||
<div class="card-header bg-agi-50" id="basic_settings">
|
||||
<h3 class="card-title">
|
||||
Edit Referensi Link
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="{{ route('basicdata.referensi-link.index') }}" class="btn btn-xs btn-info"><i class="ki-filled ki-exit-left"></i> Back</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body grid gap-5">
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Nama Referensi Link <span class="text-danger">*</span>
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('name') border-danger bg-danger-light @enderror"
|
||||
type="text"
|
||||
name="name"
|
||||
value="{{ old('name', $referensiLink->name) }}"
|
||||
placeholder="Masukkan nama referensi link"
|
||||
required>
|
||||
@error('name')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Link URL <span class="text-danger">*</span>
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('link') border-danger bg-danger-light @enderror"
|
||||
type="url"
|
||||
name="link"
|
||||
value="{{ old('link', $referensiLink->link) }}"
|
||||
placeholder="https://example.com"
|
||||
required>
|
||||
@error('link')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
<div class="form-hint">Pastikan link diawali dengan http:// atau https://</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Kategori
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('kategori') border-danger bg-danger-light @enderror"
|
||||
type="text"
|
||||
name="kategori"
|
||||
value="{{ old('kategori', $referensiLink->kategori) }}"
|
||||
placeholder="Misal: regulasi, panduan, dll">
|
||||
@error('kategori')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
<div class="form-hint">Kosongkan jika tidak ada kategori</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Deskripsi
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<textarea class="textarea @error('deskripsi') border-danger bg-danger-light @enderror"
|
||||
name="deskripsi"
|
||||
rows="4"
|
||||
placeholder="Masukkan deskripsi lengkap referensi link">{{ old('deskripsi', $referensiLink->deskripsi) }}</textarea>
|
||||
@error('deskripsi')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Status Aktif
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<label class="switch">
|
||||
<input type="checkbox" name="is_active" value="1" {{ old('is_active', $referensiLink->is_active) ? 'checked' : '' }}>
|
||||
<span class="switch-slider"></span>
|
||||
</label>
|
||||
<span class="ml-3 text-sm text-gray-600">Aktifkan referensi link ini</span>
|
||||
@error('is_active')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Urutan Tampil
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('urutan') border-danger bg-danger-light @enderror"
|
||||
type="number"
|
||||
name="urutan"
|
||||
value="{{ old('urutan', $referensiLink->urutan) }}"
|
||||
min="0"
|
||||
placeholder="0">
|
||||
@error('urutan')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
<div class="form-hint">Semakin kecil angka, semakin atas posisinya</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer justify-end">
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<a href="{{ route('basicdata.referensi-link.index') }}" class="btn btn-light">
|
||||
<i class="ki-filled ki-exit-left"></i> Batal
|
||||
</a>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="ki-filled ki-check"></i> Update
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
// Auto-add https:// if not present
|
||||
document.querySelector('input[name="link"]').addEventListener('blur', function() {
|
||||
let value = this.value.trim();
|
||||
if (value && !value.match(/^https?:\/\//i)) {
|
||||
this.value = 'https://' + value;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
56
resources/views/referensi_link/import.blade.php
Normal file
56
resources/views/referensi_link/import.blade.php
Normal file
@@ -0,0 +1,56 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumbs')
|
||||
{{ Breadcrumbs::render('basicdata.referensi-link') }}
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="grid">
|
||||
<div class="card border border-agi-100 min-w-full">
|
||||
<div class="card-header bg-agi-50 py-5 flex-wrap">
|
||||
<h3 class="card-title">Import Referensi Link</h3>
|
||||
<div class="flex flex-wrap gap-2 lg:gap-5">
|
||||
<a class="btn btn-sm btn-light" href="{{ route('basicdata.referensi-link.download-template') }}">Download Template Excel</a>
|
||||
<a class="btn btn-sm btn-primary" href="{{ route('basicdata.referensi-link.index') }}">Kembali ke Daftar</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form id="importPageForm" action="{{ route('basicdata.referensi-link.import.process') }}" method="POST" enctype="multipart/form-data" class="space-y-6">
|
||||
@csrf
|
||||
<div>
|
||||
<label class="form-label">File Excel</label>
|
||||
<input type="file" name="file" class="input" accept=".xlsx,.xls" required>
|
||||
<div class="form-hint">Format file: .xlsx atau .xls, maksimal 10MB</div>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-info">
|
||||
<div class="alert-description">
|
||||
<strong>Format kolom yang didukung:</strong>
|
||||
<div>Nama, Link, Kategori, Deskripsi, Status Aktif, Urutan</div>
|
||||
<div class="mt-2">Contoh baris:</div>
|
||||
<div class="mt-1">Contoh Referensi | https://example.com | panduan | Deskripsi contoh referensi link | aktif | 1</div>
|
||||
<div>Contoh Regulasi | https://regulasi.example.com | regulasi | Deskripsi regulasi | aktif | 2</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3">
|
||||
<button type="submit" class="btn btn-primary">Import</button>
|
||||
<a href="{{ route('basicdata.referensi-link.index') }}" class="btn btn-light">Batal</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script type="module">
|
||||
const form = document.getElementById('importPageForm');
|
||||
const submitBtn = form.querySelector('button[type="submit"]');
|
||||
|
||||
form.addEventListener('submit', function(e) {
|
||||
submitBtn.disabled = true;
|
||||
submitBtn.innerHTML = '<i class="ki-filled ki-loading"></i> Mengimport...';
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
272
resources/views/referensi_link/index.blade.php
Normal file
272
resources/views/referensi_link/index.blade.php
Normal file
@@ -0,0 +1,272 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumbs')
|
||||
{{ Breadcrumbs::render('basicdata.referensi-link') }}
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="grid">
|
||||
<div class="min-w-full border card border-agi-100 card-grid" data-datatable="false" data-datatable-page-size="10" data-datatable-state-save="false" id="referensi-link-table" data-api-url="{{ route('basicdata.referensi-link.datatables') }}">
|
||||
<div class="flex-wrap py-5 card-header bg-agi-50">
|
||||
<h3 class="card-title">
|
||||
Daftar Referensi Link
|
||||
</h3>
|
||||
<div class="flex flex-wrap gap-2 lg:gap-5">
|
||||
<div class="flex">
|
||||
<label class="input input-sm"> <i class="ki-filled ki-magnifier"> </i>
|
||||
<input placeholder="Search Referensi Link" id="search" type="text" value="">
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2.5">
|
||||
<div class="h-[24px] border border-r-gray-200"></div>
|
||||
<button class="btn btn-sm btn-light" onclick="showImportModal()"> Import Excel </button>
|
||||
<a class="btn btn-sm btn-light" href="{{ route('basicdata.referensi-link.export') }}"> Export to Excel </a>
|
||||
<a class="btn btn-sm btn-primary" href="{{ route('basicdata.referensi-link.create') }}"> Tambah Referensi Link </a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="scrollable-x-auto">
|
||||
<table class="table text-sm font-medium text-gray-700 align-middle table-auto table-border" data-datatable-table="true">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-14">
|
||||
<input class="checkbox checkbox-sm" data-datatable-check="true" type="checkbox"/>
|
||||
</th>
|
||||
<th class="min-w-[200px]" data-datatable-column="name">
|
||||
<span class="sort"> <span class="sort-label"> Nama </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[250px]" data-datatable-column="link">
|
||||
<span class="sort"> <span class="sort-label"> Link </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="kategori">
|
||||
<span class="sort"> <span class="sort-label"> Kategori </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="status_badge">
|
||||
<span class="sort"> <span class="sort-label"> Status </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[80px]" data-datatable-column="urutan">
|
||||
<span class="sort"> <span class="sort-label"> Urutan </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px] text-center" data-datatable-column="actions">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
<div class="flex-col gap-3 justify-center font-medium text-gray-600 card-footer md:justify-between md:flex-row text-2sm">
|
||||
<div class="flex gap-2 items-center">
|
||||
Show
|
||||
<select class="w-16 select select-sm" data-datatable-size="true" name="perpage"> </select>
|
||||
per page
|
||||
</div>
|
||||
<div class="flex gap-4 items-center text-gray-700">
|
||||
<span>Total <span data-datatable-info="true"></span> records</span>
|
||||
<div class="pagination" data-datatable-pagination="true"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Import Modal -->
|
||||
<div class="modal fade" id="importModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-title">Import Referensi Link</h3>
|
||||
<button type="button" class="btn btn-sm btn-icon btn-light btn-clear" data-modal-dismiss="true">
|
||||
<i class="ki-filled ki-cross"></i>
|
||||
</button>
|
||||
</div>
|
||||
<form id="importForm" action="{{ route('basicdata.referensi-link.import.process') }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
<div class="modal-body">
|
||||
<div class="mb-4">
|
||||
<label class="form-label">File Excel</label>
|
||||
<input type="file" name="file" class="input" accept=".xlsx,.xls" required>
|
||||
<div class="form-hint">Format file: .xlsx atau .xls, maksimal 10MB</div>
|
||||
</div>
|
||||
<div class="alert alert-info">
|
||||
<div class="alert-description">
|
||||
<strong>Format file yang didukung:</strong><br>
|
||||
- Nama, Link, Kategori, Deskripsi, Status Aktif, Urutan<br>
|
||||
<a href="{{ route('basicdata.referensi-link.download-template') }}" class="text-primary hover:underline">
|
||||
Download template Excel
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-light" data-modal-dismiss="true">Batal</button>
|
||||
<button type="submit" class="btn btn-primary">Import</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
function deleteData(id) {
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: "You won't be able to revert this!",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete it!'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax(`basic-data/referensi-link/${id}`, {
|
||||
type: 'DELETE'
|
||||
}).then(() => {
|
||||
swal.fire('Deleted!', 'Data berhasil dihapus.', 'success').then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}).catch((error) => {
|
||||
console.error('Error:', error);
|
||||
Swal.fire('Error!', 'Terjadi kesalahan saat menghapus.', 'error');
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<script type="module">
|
||||
const element = document.querySelector('#referensi-link-table');
|
||||
const searchInput = document.getElementById('search');
|
||||
|
||||
const apiUrl = element.getAttribute('data-api-url');
|
||||
const dataTableOptions = {
|
||||
apiEndpoint: apiUrl,
|
||||
pageSize: 5,
|
||||
columns: {
|
||||
select: {
|
||||
render: (item, data) => {
|
||||
const checkbox = document.createElement('input');
|
||||
checkbox.className = 'checkbox checkbox-sm';
|
||||
checkbox.type = 'checkbox';
|
||||
checkbox.value = String(data.id);
|
||||
checkbox.setAttribute('data-datatable-row-check', 'true');
|
||||
return checkbox.outerHTML.trim();
|
||||
},
|
||||
},
|
||||
name: { title: 'Nama' },
|
||||
link: {
|
||||
title: 'Link',
|
||||
render: (item, data) => data.link,
|
||||
},
|
||||
kategori: { title: 'Kategori' },
|
||||
status_badge: {
|
||||
title: 'Status',
|
||||
render: (item, data) => data.status_badge,
|
||||
},
|
||||
urutan: { title: 'Urutan' },
|
||||
actions: {
|
||||
title: 'Status',
|
||||
render: (item, data) => {
|
||||
return `<div class="flex flex-nowrap justify-center">
|
||||
<a class="btn btn-sm btn-icon btn-clear btn-info" href="basic-data/referensi-link/${data.id}/edit">
|
||||
<i class="ki-outline ki-notepad-edit"></i>
|
||||
</a>
|
||||
<a onclick="deleteData(${data.id})" class="delete btn btn-sm btn-icon btn-clear btn-danger">
|
||||
<i class="ki-outline ki-trash"></i>
|
||||
</a>
|
||||
</div>`;
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
let dataTable = new KTDataTable(element, dataTableOptions);
|
||||
searchInput.addEventListener('input', function () {
|
||||
const searchValue = this.value.trim();
|
||||
dataTable.search(searchValue, true);
|
||||
});
|
||||
|
||||
window.showImportModal = function () {
|
||||
const modal = new KTModal('#importModal');
|
||||
modal.show();
|
||||
}
|
||||
|
||||
document.getElementById('importForm').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
const form = this;
|
||||
const submitBtn = form.querySelector('button[type="submit"]');
|
||||
|
||||
submitBtn.disabled = true;
|
||||
submitBtn.innerHTML = '<i class="ki-filled ki-loading"></i> Mengimport...';
|
||||
|
||||
const formData = new FormData(form);
|
||||
|
||||
fetch(form.action, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' }
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
showToast('success', 'Import berhasil!', data.message);
|
||||
dataTable.reload();
|
||||
const modal = KTModal.getInstance('#importModal');
|
||||
modal.hide();
|
||||
form.reset();
|
||||
} else {
|
||||
showToast('error', 'Import gagal!', data.message);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
showToast('error', 'Error!', 'Terjadi kesalahan saat import data');
|
||||
console.error('Import error:', error);
|
||||
})
|
||||
.finally(() => {
|
||||
submitBtn.disabled = false;
|
||||
submitBtn.innerHTML = 'Import';
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
window.toggleStatus = function (id, currentStatus) {
|
||||
const newStatus = !currentStatus;
|
||||
const statusText = newStatus ? 'Aktif' : 'Tidak Aktif';
|
||||
|
||||
if (confirm(`Apakah Anda yakin ingin mengubah status menjadi ${statusText}?`)) {
|
||||
fetch(`{{ url('basicdata/referensi-link') }}/${id}/toggle-status`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ is_active: newStatus })
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
showToast('success', 'Berhasil!', data.message);
|
||||
dataTable.reload();
|
||||
} else {
|
||||
showToast('error', 'Gagal!', data.message);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
showToast('error', 'Error!', 'Terjadi kesalahan saat mengubah status');
|
||||
console.error('Status toggle error:', error);
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
Reference in New Issue
Block a user