[Operator] Perbaikan laman Konsultasi Revisi 2
This commit is contained in:
@@ -6,7 +6,6 @@ use App\Http\Controllers\Controller;
|
||||
use App\Models\Legacy\Account;
|
||||
use App\Support\Legacy\AcademicOverview;
|
||||
use App\Support\Legacy\Consultations;
|
||||
use App\Support\Legacy\PortalException;
|
||||
use App\Support\Prototype\Satu\Catalog;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
@@ -16,7 +15,8 @@ use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* Portal > Konsultasi (slug list_konsultasi) untuk akun DB lama: percakapan pembimbing–mahasiswa asli (x_message)
|
||||
* prodi akun, format tabel SATU. Filter/halaman lewat data() (JSON); Hapus = hapus lunak; Lihat = percakapan.
|
||||
* prodi akun, format tabel SATU. Filter/halaman lewat data() (JSON). Hanya lihat: daftar dan riwayat percakapan (Lihat); tanpa
|
||||
* hapus, kotak centang, dan kolom status.
|
||||
*/
|
||||
class KonsultasiController extends Controller
|
||||
{
|
||||
@@ -32,19 +32,20 @@ class KonsultasiController extends Controller
|
||||
$page = Catalog::page(self::SLUG);
|
||||
$prodi = $this->overview->programs((int) $request->user()->getKey())->keys()->all();
|
||||
$periods = $this->consultations->periods($prodi);
|
||||
$default = $periods->keys()->first();
|
||||
$default = $this->consultations->defaultPeriod($prodi, $periods);
|
||||
|
||||
return view('operator.satu.remote-list', [
|
||||
'page' => $page,
|
||||
'crumbs' => ['Beranda' => route('operator.dashboard')] + array_fill_keys(Catalog::trail(self::SLUG), null) + [$page['title'] => null],
|
||||
'note' => 'Konsultasi pembimbing asli dari SIAKAD untuk program studi yang Anda kelola (pesan pembimbing akademik). Topik diambil dari awal pesan pertama; status tidak tercatat di sumber data.',
|
||||
'note' => 'Konsultasi pembimbing asli dari SIAKAD untuk program studi yang Anda kelola (pesan pembimbing akademik). Topik diambil dari awal pesan pertama. Pilih Lihat untuk membuka riwayat percakapan.',
|
||||
'empty' => $prodi === []
|
||||
? ['icon' => 'building-library', 'title' => 'Akun belum terhubung ke program studi', 'description' => 'Daftar konsultasi tampil setelah akun Anda dipetakan ke program studi oleh Pusat Komputer.']
|
||||
: ['icon' => 'chat-bubble-left-right', 'title' => 'Belum ada konsultasi', 'description' => 'Belum ada pesan pembimbing untuk mahasiswa program studi Anda.'],
|
||||
'url' => route('operator.konsultasi.data'),
|
||||
'viewUrl' => route('operator.konsultasi.show', '__ID__'),
|
||||
'destroyUrl' => route('operator.konsultasi.destroy'),
|
||||
'destroy' => ['title' => 'Hapus konsultasi terpilih?', 'message' => 'Seluruh pesan pada percakapan yang dipilih disembunyikan dari daftar. Pusat Komputer dapat memulihkannya kembali.'],
|
||||
// Hanya lihat: tanpa tombol bilah (Hapus) dan tanpa kotak centang.
|
||||
'tools' => [],
|
||||
'selectable' => false,
|
||||
'filters' => [
|
||||
['name' => 'periode', 'label' => $page['filters'][0], 'options' => $periods->all(), 'value' => $default],
|
||||
],
|
||||
@@ -56,7 +57,6 @@ class KonsultasiController extends Controller
|
||||
['key' => 'topik', 'label' => 'Topik'],
|
||||
['key' => 'terakhir', 'label' => 'Post Terakhir'],
|
||||
['key' => 'krs', 'label' => 'KRS Disetujui', 'badge' => true],
|
||||
['key' => 'status', 'label' => 'Status'],
|
||||
],
|
||||
'perPage' => Consultations::PER_PAGE,
|
||||
'data' => $default === null ? null : $this->payload($this->search($request, $prodi, $periods, $default)),
|
||||
@@ -67,7 +67,7 @@ class KonsultasiController extends Controller
|
||||
{
|
||||
[$prodi, $periods] = $this->scope($request);
|
||||
|
||||
return response()->json($this->payload($this->search($request, $prodi, $periods, $periods->keys()->first())));
|
||||
return response()->json($this->payload($this->search($request, $prodi, $periods, $this->consultations->defaultPeriod($prodi, $periods))));
|
||||
}
|
||||
|
||||
/** Percakapan satu pasangan; `$pasangan` = "idmhs-iddosen" (id baris tabel). */
|
||||
@@ -87,21 +87,6 @@ class KonsultasiController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
/** Hapus lunak pasangan terpilih; JSON agar daftar dimuat ulang di tempat. */
|
||||
public function destroy(Request $request): JsonResponse
|
||||
{
|
||||
[$prodi] = $this->scope($request);
|
||||
$ids = $request->validate(['ids' => ['required', 'array', 'max:100'], 'ids.*' => ['string', 'regex:/^\d+-\d+$/']])['ids'];
|
||||
|
||||
try {
|
||||
$count = $this->consultations->softDelete($prodi, $ids);
|
||||
} catch (PortalException $e) {
|
||||
return response()->json(['message' => $e->getMessage()], 422);
|
||||
}
|
||||
|
||||
return response()->json(['message' => $count === 0 ? 'Tidak ada konsultasi yang dihapus.' : "{$count} pesan konsultasi dihapus.", 'count' => $count]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hanya akun DB lama yang memegang prodi dengan data konsultasi.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user