-
Notifications
You must be signed in to change notification settings - Fork 145
feat: penambahan fitur manajemen jenis dokumen PPID #1414 #1420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Arjumnr
wants to merge
5
commits into
OpenSID:dev
Choose a base branch
from
Arjumnr:fitur-ppid-1414
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0b5cd41
feat: implementasi manajemen jenis dokumen ppid dan automated testing…
Arjumnr ade064b
fix: rename folder to Ppid and fix validation slug logic
Arjumnr 2dbc7ac
fix: perbaikan logic toggle status dan penambahan unit test lengkap
Arjumnr a28f526
fix: follow reviewer suggestion (html helper & timestamps seeder)
Arjumnr df52e59
fix(ppid): perbaiki bug pencarian datatables dan tingkatkan fitur pen…
Arjumnr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
403 changes: 403 additions & 0 deletions
403
app/Http/Controllers/Ppid/JenisDokumenPpidController.php
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| <?php | ||
|
|
||
| namespace App\Models; | ||
|
|
||
| use Illuminate\Database\Eloquent\Model; | ||
| use Illuminate\Database\Eloquent\SoftDeletes; | ||
|
|
||
| class PpidJenisDokumen extends Model | ||
| { | ||
| use SoftDeletes; | ||
| protected $table = 'ppid_jenis_dokumen'; | ||
| protected $fillable = [ | ||
| 'nama', | ||
| 'slug', | ||
| 'deskripsi', | ||
| 'kode', | ||
| 'icon', | ||
| 'urut', | ||
| 'status', | ||
| ]; | ||
|
|
||
| protected static function boot() | ||
| { | ||
| parent::boot(); | ||
|
|
||
| // Pastikan slug dibuat saat creating | ||
| static::creating(function ($model) { | ||
| if (empty($model->slug)) { | ||
| $model->slug = \Str::slug($model->nama); | ||
| } | ||
| }); | ||
|
|
||
| // PROTEKSI: Mencegah perubahan slug untuk 3 data utama saat update | ||
| static::updating(function ($model) { | ||
| $protectedSlugs = ['secara-berkala', 'serta-merta', 'tersedia-setiap-saat']; | ||
|
|
||
| // Jika slug lama masuk daftar proteksi, kembalikan slug ke nilai originalnya | ||
| if (in_array($model->getOriginal('slug'), $protectedSlugs)) { | ||
| $model->slug = $model->getOriginal('slug'); | ||
| } else { | ||
| // Untuk data non-proteksi, slug boleh berubah mengikuti nama | ||
| if ($model->isDirty('nama')) { | ||
| $model->slug = \Str::slug($model->nama); | ||
| } | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| public function scopeAktif($query) | ||
| { | ||
| return $query->where('status', '1'); | ||
| } | ||
|
|
||
| public function getStatusLabelAttribute() | ||
| { | ||
| return $this->status == '1' | ||
| ? '<span class="label label-success">Aktif</span>' | ||
| : '<span class="label label-danger">Tidak-Aktif</span>'; | ||
| } | ||
| } |
35 changes: 35 additions & 0 deletions
35
database/migrations/2026_01_29_152221_create_ppid_jenis_dokumen_table.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <?php | ||
|
|
||
| use Illuminate\Database\Migrations\Migration; | ||
| use Illuminate\Database\Schema\Blueprint; | ||
| use Illuminate\Support\Facades\Schema; | ||
|
|
||
| return new class extends Migration | ||
| { | ||
| /** | ||
| * Run the migrations. | ||
| */ | ||
| public function up(): void | ||
| { | ||
| Schema::create('ppid_jenis_dokumen', function (Blueprint $table) { | ||
| $table->id(); | ||
| $table->string('nama', 150); | ||
| $table->string('slug', 150)->unique(); | ||
| $table->text('deskripsi')->nullable(); | ||
| $table->string('kode', 50)->nullable(); | ||
| $table->string('icon', 100)->nullable(); | ||
| $table->integer('urut')->default(0); | ||
| $table->enum('status', ['0', '1'])->default('1')->comment('0=tidak aktif, 1=aktif'); | ||
| $table->timestamps(); | ||
| $table->softDeletes(); | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Reverse the migrations. | ||
| */ | ||
| public function down(): void | ||
| { | ||
| Schema::dropIfExists('ppid_jenis_dokumen'); | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| <?php | ||
|
|
||
| namespace Database\Seeders; | ||
|
|
||
| use App\Models\PpidJenisDokumen; | ||
| use Illuminate\Database\Seeder; | ||
| use Illuminate\Support\Facades\DB; | ||
|
|
||
| class PpidJenisDokumenSeeder extends Seeder | ||
| { | ||
| /** | ||
| * Run the database seeds. | ||
| * | ||
| * @return void | ||
| */ | ||
| public function run() | ||
| { | ||
| $data = [ | ||
| [ | ||
| 'nama' => 'Secara Berkala', | ||
| 'slug' => 'secara-berkala', | ||
| 'deskripsi' => 'Informasi yang rutin diterbitkan dan diperbaharui untuk publik.', | ||
| 'kode' => '#0e15d8', | ||
| 'icon' => 'fa fa-calendar', | ||
| 'urut' => 1, | ||
| 'status' => '1', | ||
| ], | ||
| [ | ||
| 'nama' => 'Serta Merta', | ||
| 'slug' => 'serta-merta', | ||
| 'deskripsi' => 'Informasi yang wajib diumumkan segera karena penting bagi masyarakat.', | ||
| 'kode' => '#059e17', | ||
| 'icon' => 'fa fa-bolt', | ||
| 'urut' => 2, | ||
| 'status' => '1', | ||
| ], | ||
| [ | ||
| 'nama' => 'Tersedia Setiap Saat', | ||
| 'slug' => 'tersedia-setiap-saat', | ||
| 'deskripsi' => 'Informasi yang tersedia dan dapat diakses setiap saat.', | ||
| 'kode' => '#ff9900', | ||
| 'icon' => 'fa fa-globe', | ||
| 'urut' => 3, | ||
| 'status' => '1', | ||
| ], | ||
| ]; | ||
|
|
||
| foreach ($data as $item) { | ||
| PpidJenisDokumen::updateOrCreate( | ||
| ['slug' => $item['slug']], | ||
| array_merge($item, [ | ||
| 'created_at' => now(), | ||
| 'updated_at' => now(), | ||
| ]) | ||
| ); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| <div class="row"> | ||
| <div class="col-md-9"> | ||
| <div class="box box-primary"> | ||
| <div class="box-header with-border"> | ||
| <a href="{{ route('ppid.jenis-dokumen.index') }}" class="btn btn-info btn-sm"> | ||
| <i class="fa fa-arrow-left"></i> Kembali | ||
| </a> | ||
| </div> | ||
| <div class="box-body"> | ||
| <div class="form-group {{ $errors->has('nama') ? 'has-error' : '' }}"> | ||
| <label class="control-label" for="nama">Nama Jenis Dokumen <span | ||
| class="text-danger">*</span></label> | ||
| {!! html()->text('nama', old('nama', $jenis->nama ?? null))->class('form-control')->placeholder('Masukkan nama dokumen...')->id('nama') !!} | ||
| @if ($errors->has('nama')) | ||
| <span class="help-block" style="color:red">{{ $errors->first('nama') }}</span> | ||
| @endif | ||
| @if ($errors->has('slug')) | ||
| <span class="help-block" style="color:red">{{ $errors->first('slug') }}</span> | ||
| @endif | ||
| </div> | ||
|
|
||
| <div class="form-group"> | ||
| <label class="control-label" for="deskripsi">Deskripsi</label> | ||
| {!! html()->textarea('deskripsi', old('deskripsi', $jenis->deskripsi ?? null))->class('form-control')->rows(3)->placeholder('Penjelasan singkat...')->id('deskripsi') !!} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="col-md-3"> | ||
| <div class="box box-primary"> | ||
| <div class="box-body"> | ||
| <div class="form-group"> | ||
| <label class="control-label">Warna Label</label> | ||
| {!! html()->input('color', 'kode', old('kode', $jenis->kode ?? '#000000'))->class('form-control')->style('height: 38px;') !!} | ||
| </div> | ||
|
|
||
| <div class="form-group"> | ||
| <label class="control-label">Pilih Icon</label> | ||
| <div class="input-group" style="display: table; width: 100%;"> <input type="hidden" id="icon" | ||
| name="icon" value="{{ old('icon', $jenis->icon ?? 'fa fa-file') }}"> | ||
|
|
||
| <span class="input-group-addon" style="width: 45px; background: #eee;"> | ||
| <i id="icon-preview" class="fa {{ old('icon', $jenis->icon ?? 'fa fa-file') }}"></i> | ||
| </span> | ||
|
|
||
| <div class="input-group-btn" style="width: 100%;"> | ||
| <button type="button" class="btn btn-default" data-toggle="collapse" | ||
| data-target="#icon-list" style="width: 100%; text-align: left;"> | ||
| Pilih Icon <span class="caret pull-right" style="margin-top: 7px;"></span> | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div id="icon-list" class="collapse" | ||
| style="border: 1px solid #ddd; border-radius: 4px; padding: 10px; margin-bottom: 15px;"> | ||
| <div class="row text-center" style="max-height: 150px; overflow-y: auto; margin: 0;"> | ||
| @foreach ($icons as $icon) | ||
| <div class="col-xs-3 icon-item" style="padding: 5px; cursor: pointer;"> | ||
| <i class="fa {{ $icon }} fa-2x select-this-icon" | ||
| data-icon="fa {{ $icon }}"></i> | ||
| </div> | ||
| @endforeach | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="form-group"> | ||
| <label class="control-label" for="status">Status</label> | ||
| {!! html()->select('status', ['1' => 'Aktif', '0' => 'Tidak Aktif'], old('status', $jenis->status ?? '1'))->class('form-control')->id('status') !!} | ||
| </div> | ||
| </div> | ||
| <div class="box-footer"> | ||
| @include('partials.button_reset_submit') | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
|
|
||
| @push('scripts') | ||
| <script> | ||
| $(document).ready(function() { | ||
| $(document).on('click', '.select-this-icon', function() { | ||
| var iconClass = $(this).data('icon'); | ||
| $('#icon').val(iconClass); | ||
| $('#icon-preview').attr('class', iconClass); | ||
| $('#icon-list').collapse('hide'); | ||
| }); | ||
| }); | ||
| </script> | ||
| @endpush |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| @extends('layouts.dashboard_template') | ||
|
|
||
| @section('content') | ||
| <section class="content-header block-breadcrumb"> | ||
| <h1>{{ $page_title }} <small>{{ $page_description }}</small></h1> | ||
| <ol class="breadcrumb"> | ||
| <li><a href="{{ route('dashboard') }}"><i class="fa fa-dashboard"></i> Dashboard</a></li> | ||
| <li><a href="{{ route('ppid.jenis-dokumen.index') }}">Daftar Jenis Dokumen</a></li> | ||
| <li class="active">Tambah</li> | ||
| </ol> | ||
| </section> | ||
|
|
||
| <section class="content container-fluid"> | ||
| {!! html()->form('POST', route('ppid.jenis-dokumen.store'))->id('form-ppid')->open() !!} | ||
| @include('ppid.jenis_dokumen._form') | ||
| {!! html()->form()->close() !!} | ||
| </section> | ||
| @endsection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| @extends('layouts.dashboard_template') | ||
|
|
||
| @section('content') | ||
| <section class="content-header block-breadcrumb"> | ||
| <h1> | ||
| {{ $page_title }} | ||
| <small>{{ $page_description }}</small> | ||
| </h1> | ||
| <ol class="breadcrumb"> | ||
| <li><a href="{{ route('dashboard') }}"><i class="fa fa-dashboard"></i> Dashboard</a></li> | ||
| <li><a href="{{ route('ppid.jenis-dokumen.index') }}">Daftar Jenis Dokumen PPID</a></li> | ||
| <li class="active">{{ $page_description }}</li> | ||
| </ol> | ||
| </section> | ||
| <section class="content container-fluid"> | ||
| {!! html()->form('PUT', route('ppid.jenis-dokumen.update', $jenis->id))->attribute('enctype', 'multipart/form-data')->open() !!} | ||
| @include('ppid.jenis_dokumen._form') | ||
| {!! html()->form()->close() !!} | ||
| </section> | ||
| @endsection |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.