283 lines
18 KiB
PHP
283 lines
18 KiB
PHP
@extends('layout.main')
|
|
|
|
@section('content')
|
|
<div class="container-xxl flex-grow-1 container-p-y">
|
|
<div class="card">
|
|
<div class="card-header border-bottom d-flex justify-content-between align-items-center">
|
|
<h5 class="card-title mb-0">Formulir untuk Tabel Basis Data Ekosistem: {{ $tabel->label }}</h5>
|
|
|
|
<div class="d-flex gap-2">
|
|
<form action="{{ route('tabel.formulir.generate', $tabel->id) }}" method="POST">
|
|
@csrf
|
|
<button class="btn btn-sm btn-label-primary" type="submit">
|
|
<i class="ti tabler-automation me-1"></i> Generate Formulir
|
|
</button>
|
|
</form>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
<div class="nav-align-top pt-4">
|
|
<ul class="nav nav-pills" role="tablist">
|
|
<li class="nav-item">
|
|
<button
|
|
type="button"
|
|
class="nav-link active"
|
|
role="tab"
|
|
data-bs-toggle="tab"
|
|
data-bs-target="#navs-pills-form"
|
|
aria-controls="navs-pills-form"
|
|
aria-selected="true">
|
|
<i class="ti tabler-forms me-1"></i> Rancangan
|
|
</button>
|
|
</li>
|
|
<li class="nav-item">
|
|
<button
|
|
type="button"
|
|
class="nav-link"
|
|
role="tab"
|
|
data-bs-toggle="tab"
|
|
data-bs-target="#navs-pills-preview"
|
|
aria-controls="navs-pills-preview"
|
|
aria-selected="false">
|
|
<i class="ti tabler-eye me-1"></i> Pratinjau
|
|
</button>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="tab-content p-0">
|
|
<div class="tab-pane fade show active" id="navs-pills-form" role="tabpanel">
|
|
<div class="row pt-4">
|
|
<div class="col-6 mb-4">
|
|
<h6>Rancangan Form</h6>
|
|
<ul class="list-group list-group-flush" id="list-form">
|
|
<li class="list-group-item drag-item cursor-move ">
|
|
<div class="d-flex justify-content-between align-items-center">
|
|
<span class="lead"><strong>Formulir: {{ $tabel->label }}</strong></span>
|
|
<div class="align-text-bottom">
|
|
<a href="javascript:;" class="btn btn-icon btn-text-primary rounded-pill add-row"
|
|
data-bs-toggle="tooltip" data-bs-placement="top" data-bs-original-title="Tambah Baris">
|
|
<i class="ti tabler-row-insert-bottom ti-md"></i></a>
|
|
<a href="javascript:;" class="btn btn-icon btn-text-primary rounded-pill add-section"
|
|
data-bs-toggle="tooltip" data-bs-placement="top" data-bs-original-title="Tambah Section">
|
|
<i class="ti tabler-new-section ti-md"></i></a>
|
|
<a href="javascript:;" class="btn btn-icon btn-text-primary rounded-pill add-hr-line"
|
|
data-bs-toggle="tooltip" data-bs-placement="top" data-bs-original-title="Tambah Garis Pembatas">
|
|
<i class="ti tabler-separator ti-md"></i></a>
|
|
</div>
|
|
</div>
|
|
</li>
|
|
@foreach($tabel->form as $form)
|
|
<li class="list-group-item drag-item cursor-move pl-4">
|
|
<div class="d-flex justify-content-between align-items-center">
|
|
<span>{{ $form->tipe->label() }}
|
|
@if($form->tipe->value == 'form-section')
|
|
: {{ $form->section_label }}
|
|
@endif
|
|
</span>
|
|
<div class="align-text-bottom">
|
|
@if (!$loop->first)
|
|
<button type="button"
|
|
class="btn btn-icon btn-text-secondary move-up"
|
|
data-id="{{ $form->id }}" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-original-title="Pindah ke Urutan Sebelumnya">
|
|
<i class="ti tabler-arrow-up"></i>
|
|
</button>
|
|
@endif
|
|
@if (!$loop->last)
|
|
<button type="button"
|
|
class="btn btn-icon btn-text-secondary move-down"
|
|
data-id="{{ $form->id }}" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-original-title="Pindah ke Urutan Selanjutnya">
|
|
<i class="ti tabler-arrow-down"></i>
|
|
</button>
|
|
@endif
|
|
@if($form->tipe->value == 'form-row')
|
|
<a href="javascript:;" class="btn btn-icon btn-text-primary rounded-pill add-column"
|
|
data-parent="{{ $form->id }}"
|
|
data-bs-toggle="tooltip" data-bs-placement="top" data-bs-original-title="Tambah Kolom">
|
|
<i class="ti tabler-column-insert-right ti-md"></i></a>
|
|
@elseif($form->tipe->value == 'form-section')
|
|
<a href="javascript:;" class="btn btn-icon btn-text-primary rounded-pill edit-section" data-id="{{ $form->id }}"
|
|
data-bs-toggle="tooltip" data-bs-placement="top" data-bs-original-title="Edit Section">
|
|
<i class="ti tabler-section ti-md"></i></a>
|
|
@endif
|
|
<a href="javascript:;" class="btn btn-icon btn-text-danger rounded-pill delete-record"
|
|
data-id="{{ $form->id }}" data-nama="{{ $form->tipe->label() }}"
|
|
data-bs-toggle="tooltip" data-bs-placement="top" data-bs-original-title="Hapus">
|
|
<i class="ti tabler-trash ti-md"></i></a>
|
|
</div>
|
|
</div>
|
|
@if($form->tipe->value == 'form-row')
|
|
<ul class="list-group list-group-flush nested-list">
|
|
@foreach($form->form as $childForm)
|
|
<li class="list-group-item drag-item cursor-move">
|
|
<div class="d-flex justify-content-between align-items-center">
|
|
<span>{{ $childForm->tipe->label() }}
|
|
@if($childForm->tipe->value == 'form-column')
|
|
: col-{{ $childForm->column_width }}
|
|
@endif
|
|
</span>
|
|
<div class="align-text-bottom">
|
|
@if (!$loop->first)
|
|
<button type="button"
|
|
class="btn btn-icon btn-text-secondary move-up"
|
|
data-id="{{ $childForm->id }}" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-original-title="Pindah ke Urutan Sebelumnya">
|
|
<i class="ti tabler-arrow-up"></i>
|
|
</button>
|
|
@endif
|
|
@if (!$loop->last)
|
|
<button type="button"
|
|
class="btn btn-icon btn-text-secondary move-down"
|
|
data-id="{{ $childForm->id }}" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-original-title="Pindah ke Urutan Selanjutnya">
|
|
<i class="ti tabler-arrow-down"></i>
|
|
</button>
|
|
@endif
|
|
@if($childForm->tipe->value == 'form-column')
|
|
<a href="javascript:;" class="btn btn-icon btn-text-primary rounded-pill edit-column"
|
|
data-parent="{{ $form->id }}" data-id="{{ $childForm->id }}"
|
|
data-bs-toggle="tooltip" data-bs-placement="top" data-bs-original-title="Edit Kolom">
|
|
<i class="ti tabler-columns ti-md"></i></a>
|
|
<a href="javascript:;" class="btn btn-icon btn-text-primary rounded-pill move-column"
|
|
data-parent="{{ $form->id }}" data-id="{{ $childForm->id }}"
|
|
data-bs-toggle="tooltip" data-bs-placement="top" data-bs-original-title="Pindah Kolom ke Row Berbeda">
|
|
<i class="ti tabler-transition-top ti-md"></i></a>
|
|
<a href="javascript:;" class="btn btn-icon btn-text-primary rounded-pill add-value"
|
|
data-parent="{{ $childForm->id }}"
|
|
data-bs-toggle="tooltip" data-bs-placement="top" data-bs-original-title="Tambah Form Nilai">
|
|
<i class="ti tabler-file-plus ti-md"></i></a>
|
|
@endif
|
|
<a href="javascript:;" class="btn btn-icon btn-text-danger rounded-pill delete-record"
|
|
data-id="{{ $childForm->id }}" data-nama="{{ $childForm->tipe->label() }}"
|
|
data-bs-toggle="tooltip" data-bs-placement="top" data-bs-original-title="Hapus">
|
|
<i class="ti tabler-trash ti-md"></i></a>
|
|
</div>
|
|
</div>
|
|
@if($childForm->tipe->value == 'form-column')
|
|
<ul class="list-group list-group-flush nested-list">
|
|
@foreach($childForm->form as $grandchildForm)
|
|
<li class="list-group-item drag-item cursor-move">
|
|
<div class="d-flex justify-content-between align-items-center">
|
|
<span>{{ $grandchildForm->tipe->label() }}
|
|
@if($grandchildForm->tipe->value == 'form-value')
|
|
: {{ $grandchildForm->kolom->label }}
|
|
@endif
|
|
</span>
|
|
<div class="align-text-bottom">
|
|
<a href="javascript:;" class="btn btn-icon btn-text-primary rounded-pill edit-value"
|
|
data-parent="{{ $childForm->id }}" data-id="{{ $grandchildForm->id }}"
|
|
data-bs-toggle="tooltip" data-bs-placement="top" data-bs-original-title="Edit Form Nilai">
|
|
<i class="ti tabler-file-text ti-md"></i></a>
|
|
<a href="javascript:;" class="btn btn-icon btn-text-danger rounded-pill delete-record"
|
|
data-id="{{ $grandchildForm->id }}" data-nama="{{ $grandchildForm->tipe->label() }}"
|
|
data-bs-toggle="tooltip" data-bs-placement="top" data-bs-original-title="Hapus">
|
|
<i class="ti tabler-trash ti-md"></i></a>
|
|
</div>
|
|
</div>
|
|
</li>
|
|
@endforeach
|
|
</ul>
|
|
@endif
|
|
</li>
|
|
@endforeach
|
|
</ul>
|
|
@endif
|
|
</li>
|
|
@endforeach
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="tab-pane fade" id="navs-pills-preview" role="tabpanel">
|
|
<div class="row pt-4">
|
|
<div class="col-12 mb-4">
|
|
<h6>Pratinjau Formulir</h6>
|
|
{!! $tabel->renderHtml('preview') !!}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mt-4 text-end">
|
|
<a href="{{ route('tabel.show', $tabel->id) }}" class="btn btn-label-secondary me-2">Kembali</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@include('ekosistem.form-basis-data.add-row')
|
|
@include('ekosistem.form-basis-data.add-section')
|
|
@include('ekosistem.form-basis-data.edit-section')
|
|
@include('ekosistem.form-basis-data.add-hr-line')
|
|
@include('ekosistem.form-basis-data.add-column')
|
|
@include('ekosistem.form-basis-data.edit-column')
|
|
@include('ekosistem.form-basis-data.move-column')
|
|
@include('ekosistem.form-basis-data.add-value')
|
|
@include('ekosistem.form-basis-data.edit-value')
|
|
@endsection
|
|
|
|
@push('scripts')
|
|
<script src="https://cdn.jsdelivr.net/npm/sortablejs@1.15.7/Sortable.min.js"></script>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
$(".move-up").click(function (e) {
|
|
e.preventDefault();
|
|
let id = $(this).data('id');
|
|
|
|
$.post("{{ route('tabel.formulir.move-up', [$tabel->id, ':id']) }}".replace(':id', id), {
|
|
_token: '{{ csrf_token() }}',
|
|
_method: 'PUT'
|
|
}, function (res) {
|
|
if (res.status === 'success') {
|
|
location.reload();
|
|
}
|
|
});
|
|
});
|
|
|
|
$(".move-down").click(function (e) {
|
|
e.preventDefault();
|
|
let id = $(this).data('id');
|
|
|
|
$.post("{{ route('tabel.formulir.move-down', [$tabel->id, ':id']) }}".replace(':id', id), {
|
|
_token: '{{ csrf_token() }}',
|
|
_method: 'PUT'
|
|
}, function (res) {
|
|
if (res.status === 'success') {
|
|
location.reload();
|
|
}
|
|
});
|
|
});
|
|
|
|
$(".delete-record").click(function (e) {
|
|
e.preventDefault();
|
|
const id = $(this).data('id');
|
|
const name = $(this).data('nama');
|
|
|
|
Swal.fire({
|
|
title: 'Hapus?',
|
|
text: `Form ${name} akan dihapus!`,
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonText: 'Ya, Hapus!',
|
|
customClass: { confirmButton: 'btn btn-danger me-3', cancelButton: 'btn btn-label-secondary' },
|
|
buttonsStyling: false
|
|
}).then(function (result) {
|
|
if (result.value) {
|
|
$.ajax({
|
|
url: "{{ route('tabel.formulir.destroy', [$tabel->id, ':id']) }}".replace(':id', id),
|
|
type: 'POST',
|
|
data: {
|
|
_token: '{{ csrf_token() }}',
|
|
_method: 'DELETE'
|
|
},
|
|
success: function () {
|
|
Swal.fire({ icon: 'success', title: 'Terhapus!', showConfirmButton: false, timer: 1500 })
|
|
.then(() => location.reload());
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
@endpush |