[Operator] Perbaikan Laman Jadwal
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Operator;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Controllers\Operator\Concerns\ServesLegacyList;
|
||||
use App\Support\Legacy\AcademicOverview;
|
||||
use App\Support\Legacy\ClassSchedule;
|
||||
use App\Support\Prototype\Satu\Catalog;
|
||||
use Illuminate\Contracts\View\View;
|
||||
@@ -17,16 +18,17 @@ class TahunAjaranController extends Controller
|
||||
|
||||
private const string SLUG = 'ms_tahunajaran';
|
||||
|
||||
public function __construct(private readonly ClassSchedule $schedule) {}
|
||||
public function __construct(private readonly ClassSchedule $schedule, private readonly AcademicOverview $overview) {}
|
||||
|
||||
public function __invoke(): View
|
||||
public function __invoke(Request $request): View
|
||||
{
|
||||
$page = Catalog::page(self::SLUG);
|
||||
[$active, $scope] = $this->active($request);
|
||||
|
||||
return view('operator.satu.remote-list', [
|
||||
'page' => $page,
|
||||
'crumbs' => $this->crumbs(self::SLUG, $page),
|
||||
'note' => 'Tahun ajaran asli dari periode kuliah SIAKAD.',
|
||||
'note' => 'Tahun ajaran asli dari periode kuliah SIAKAD.'.($active === null ? '' : " Baris berarsir = tahun ajaran periode kuliah aktif {$scope} ({$active})."),
|
||||
'empty' => ['icon' => 'calendar', 'title' => 'Belum ada tahun ajaran', 'description' => 'Tahun ajaran tampil setelah ada periode kuliah.'],
|
||||
'url' => route('operator.tahun-ajaran.data'),
|
||||
'filters' => [],
|
||||
@@ -35,14 +37,27 @@ class TahunAjaranController extends Controller
|
||||
['key' => 'nama', 'label' => 'Nama Tahun'],
|
||||
],
|
||||
'perPage' => ClassSchedule::PER_PAGE,
|
||||
'data' => $this->payload($this->schedule->academicYears('', ClassSchedule::PER_PAGE[0])),
|
||||
'data' => $this->payload($this->schedule->academicYears('', ClassSchedule::PER_PAGE[0], 1, $active)),
|
||||
]);
|
||||
}
|
||||
|
||||
public function data(Request $request): JsonResponse
|
||||
{
|
||||
$this->legacyOnly($request);
|
||||
[$active] = $this->active($request);
|
||||
|
||||
return response()->json($this->payload($this->schedule->academicYears($this->query($request), $this->perPage($request, ClassSchedule::PER_PAGE), max(1, $request->integer('page', 1)))));
|
||||
return response()->json($this->payload($this->schedule->academicYears($this->query($request), $this->perPage($request, ClassSchedule::PER_PAGE), max(1, $request->integer('page', 1)), $active)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tahun ajaran periode kuliah aktif prodi yang dikelola akun (akun tanpa prodi: seluruh universitas) dan sebutan cakupannya.
|
||||
*
|
||||
* @return array{0: ?string, 1: string}
|
||||
*/
|
||||
private function active(Request $request): array
|
||||
{
|
||||
$prodi = $this->overview->programs((int) $request->user()->getKey())->keys()->all();
|
||||
|
||||
return [$this->schedule->activeYear($prodi === [] ? null : $prodi), $prodi === [] ? 'universitas' : 'program studi Anda'];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user