Skip to content
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

Identitas pelapor #1010

Merged
merged 7 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions app/Enums/Anonim.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/*
* File ini bagian dari:
*
* OpenDK
*
* Aplikasi dan source code ini dirilis berdasarkan lisensi GPL V3
*
* Hak Cipta 2017 - 2024 Perkumpulan Desa Digital Terbuka (https://opendesa.id)
*
* Dengan ini diberikan izin, secara gratis, kepada siapa pun yang mendapatkan salinan
* dari perangkat lunak ini dan file dokumentasi terkait ("Aplikasi Ini"), untuk diperlakukan
* tanpa batasan, termasuk hak untuk menggunakan, menyalin, mengubah dan/atau mendistribusikan,
* asal tunduk pada syarat berikut:
*
* Pemberitahuan hak cipta di atas dan pemberitahuan izin ini harus disertakan dalam
* setiap salinan atau bagian penting Aplikasi Ini. Barang siapa yang menghapus atau menghilangkan
* pemberitahuan ini melanggar ketentuan lisensi Aplikasi Ini.
*
* PERANGKAT LUNAK INI DISEDIAKAN "SEBAGAIMANA ADANYA", TANPA JAMINAN APA PUN, BAIK TERSURAT MAUPUN
* TERSIRAT. PENULIS ATAU PEMEGANG HAK CIPTA SAMA SEKALI TIDAK BERTANGGUNG JAWAB ATAS KLAIM, KERUSAKAN ATAU
* KEWAJIBAN APAPUN ATAS PENGGUNAAN ATAU LAINNYA TERKAIT APLIKASI INI.
*
* @package OpenDK
* @author Tim Pengembang OpenDesa
* @copyright Hak Cipta 2017 - 2024 Perkumpulan Desa Digital Terbuka (https://opendesa.id)
* @license http://www.gnu.org/licenses/gpl.html GPL V3
* @link https://github.com/OpenSID/opendk
*/

namespace App\Enums;

use BenSampo\Enum\Enum;

/**
* Status untuk melihat aktif dan tidak aktif
*/
final class Anonim extends Enum
{
public const Tampilkan = 0;
public const Sembunyikan = 1;
}
32 changes: 31 additions & 1 deletion app/Http/Controllers/Data/AdminKomplainController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

namespace App\Http\Controllers\Data;

use App\Enums\Anonim;
use App\Http\Controllers\Controller;
use App\Models\DataDesa;
use App\Models\JawabKomplain;
Expand Down Expand Up @@ -61,6 +62,7 @@ public function getDataKomplain()
{
return DataTables::of(Komplain::with(['kategori_komplain']))
->addColumn('aksi', function ($row) {
$data['anonim'] = route('admin-komplain.anonim', $row->id);
$data['agree_url'] = route('admin-komplain.setuju', $row->id);
$data['show_url'] = route('admin-komplain.show', $row->id);
$data['delete_url'] = route('admin-komplain.destroy', $row->id);
Expand Down Expand Up @@ -90,7 +92,18 @@ public function getDataKomplain()

return $status;
})
->rawColumns(['aksi', 'status'])->make();
->editColumn('anonim', function ($row) {
$anonim = '';
if ($row->anonim == Anonim::Tampilkan) {
$anonim = '<span class="label label-success">Ditampilkan</span>';
}
if ($row->anonim == Anonim::Sembunyikan) {
$anonim = '<span class="label label-danger">Disembunyikan</span>';
}

return $anonim;
})
->rawColumns(['aksi', 'status', 'anonim'])->make();
}

public function disetujui(Request $request, $id)
Expand All @@ -110,6 +123,23 @@ public function disetujui(Request $request, $id)
return redirect()->route('admin-komplain.index')->with('success', 'Status Keluhan berhasil disimpan!');
}

public function anonim(Request $request, $id)
{
request()->validate([
'anonim' => 'required',
]);

try {
Komplain::findOrFail($id)->update($request->all());
} catch (\Exception $e) {
report($e);

return back()->withInput()->with('error', 'Identitas Pelapor Keluhan gagal diperbarui!');
}

return redirect()->route('admin-komplain.index')->with('success', 'Identitas Pelapor Keluhan berhasil diperbarui!');
}

public function show($id)
{
$komplain = Komplain::findOrFail($id);
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Komplain.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ class Komplain extends Model
'judul',
'slug',
'laporan',
'anonim',
'status',
'lampiran1',
'lampiran2',
'lampiran3',
'lampiran4',
'anonim',
];

protected $with = ['penduduk'];
Expand Down
1 change: 1 addition & 0 deletions catatan_rilis.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Terima kasih pada @uddinmtm telah ikut berkontribusi.

1. [#511](https://github.com/OpenSID/OpenDK/issues/511) Penambahan modul navigasi halaman publik.
2. [#998](https://github.com/OpenSID/OpenDK/issues/998) Penambahan sambutan pada daftar menu navigasi.
3. [#669](https://github.com/OpenSID/OpenDK/issues/669) Penambahan identitas pelapor.


#### BUG
Expand Down
41 changes: 41 additions & 0 deletions database/migrations/2024_08_18_155051_update_komplain_anonim.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

use App\Enums\Anonim;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('das_komplain', function (Blueprint $table) {
$table->dropColumn('anonim');
});

Schema::table('das_komplain', function (Blueprint $table) {
$table->tinyInteger('anonim')->default(Anonim::Sembunyikan);
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('das_komplain', function (Blueprint $table) {
$table->dropColumn('anonim');
});

Schema::table('das_komplain', function (Blueprint $table) {
$table->tinyInteger('anonim')->nullable()->default(NULL);
});
}
};
6 changes: 6 additions & 0 deletions resources/views/forms/aksi.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@
</button>
</a>
@endif
@if (isset($anonim))
<a href="javascript:void(0)" class="{!! empty($anonim) ? 'disabled' : '' !!}" title="Ubah Status" data-href="{!! empty($anonim) ? 'javascript:void(0)' : $anonim !!}" data-button="delete" id="anonimModal">
<button type="button" class="btn btn-icon btn-info btn-sm" style="width: 40px; background-color: #252725; border-color: #252725;"><i class="fa fa-user" aria-hidden="true"></i>
</button>
</a>
@endif
@if (isset($show_web))
<a href="{!! empty($edit_url) ? 'javascript:void(0)' : $show_web !!}" class="{!! empty($show_web) ? 'disabled' : '' !!}" title="Detail" data-button="detail" target="_blank">
<button type="button" class="btn btn-warning btn-sm" style="width: 40px;"><i class="fa fa-eye" aria-hidden="true"></i></button>
Expand Down
44 changes: 44 additions & 0 deletions resources/views/forms/anonim-modal.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<div id="anonim-modal" class="modal fade modal-danger in">
<div class="modal-dialog">
<div class="modal-content">
{!! Form::open(['id' => 'anonim', 'method' => 'PUT']) !!}
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Identitas Pelapor</h4>
</div>
<div class="modal-body">
<p>Apakah Anda ingin menampilkan identitas pelapor?</p>
{{ Form::select('anonim', [0 => 'Tampilkan', 1 => 'Sembunyikan'], null, ['class' => 'form-control']) }}
</div>
<div class="modal-footer">
<a id="active-modal-cancel" href="#" class="btn btn-default waves-effect waves-light" data-dismiss="modal">Batal</a>
{!! Form::submit('Simpan', ['class' => 'btn btn-warning waves-effect waves-light']) !!}
</div>
{!! Form::close() !!}
</div>
</div>
</div>
<script>
$(document).ready(function() {
var _trSelected;
$(document).on('click', '#anonimModal', function(e) {
var url = $(this).attr('data-href');
_trSelected = $(this).closest('tr');
$('#anonim').attr('action', url);
$('#import').attr('method', 'post');
$('#anonim-modal').modal('show');
e.preventDefault();
})

$('#anonim-modal').on('show.bs.modal', function(e) {
// Ambil teks dari kolom 'anonim'
var anonimValue = _trSelected.find('td.anonim').text().trim();

// Konversi teks ke nilai yang sesuai
var selectValue = (anonimValue === 'Disembunyikan') ? '1' : '0';

// Set nilai select
$(this).find('select').val(selectValue);
});
});
</script>
32 changes: 16 additions & 16 deletions resources/views/setting/navigation/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@
<select name="type" id="type" class="form-control select2" required>
<option value="">Pilih URL</option>
<optgroup label="Profil">
@foreach(\App\Enums\MenuTipe::getProfil() as $key => $value)
<option value="1" data-value="{{ 'profil/' . $key }}" @selected('profil/' . $key == optional($navigation)->url))>{{ $value }}</option>
@foreach (\App\Enums\MenuTipe::getProfil() as $key => $value)
<option value="1" data-value="{{ 'profil/' . $key }}" @selected('profil/' . $key == optional($navigation)->url))>{{ $value }}</option>
@endforeach
</optgroup>
<optgroup label="Desa">
@foreach(\App\Enums\MenuTipe::getDesa() as $key => $value)
@php $nama_desa = ucwords($key . ' ' . $value); @endphp
<option value="2" data-value="{{ 'desa/' . Str::slug($nama_desa) }}" @selected('desa/' . Str::slug($nama_desa) == optional($navigation)->url)>{{ $nama_desa }}</option>
@foreach (\App\Enums\MenuTipe::getDesa() as $key => $value)
@php $nama_desa = ucwords($key . ' ' . $value); @endphp
<option value="2" data-value="{{ 'desa/' . Str::slug($nama_desa) }}" @selected('desa/' . Str::slug($nama_desa) == optional($navigation)->url)>{{ $nama_desa }}</option>
@endforeach
</optgroup>
<optgroup label="Statistik">
@foreach(\App\Enums\MenuTipe::getStatistik() as $key => $value)
<option value="3" data-value="{{ 'statistik/' . $key }}" @selected('statistik/' . $key == optional($navigation)->url)>{{ $value }}</option>
@foreach (\App\Enums\MenuTipe::getStatistik() as $key => $value)
<option value="3" data-value="{{ 'statistik/' . $key }}" @selected('statistik/' . $key == optional($navigation)->url)>{{ $value }}</option>
@endforeach
</optgroup>
<optgroup label="Potensi">
@foreach(\App\Enums\MenuTipe::getPotensi() as $key => $value)
<option value="3" data-value="{{ 'potensi/' . $key }}" @selected('potensi/' . $key == optional($navigation)->url)>{{ $value }}</option>
@foreach (\App\Enums\MenuTipe::getPotensi() as $key => $value)
<option value="3" data-value="{{ 'potensi/' . $key }}" @selected('potensi/' . $key == optional($navigation)->url)>{{ $value }}</option>
@endforeach
</optgroup>
<optgroup label="Unduhan">
@foreach(\App\Enums\MenuTipe::getUnduhan() as $key => $value)
<option value="4" data-value="{{ 'unduhan/' . $key }}" @selected('unduhan/' . $key == optional($navigation)->url)>{{ $value }}</option>
@foreach (\App\Enums\MenuTipe::getUnduhan() as $key => $value)
<option value="4" data-value="{{ 'unduhan/' . $key }}" @selected('unduhan/' . $key == optional($navigation)->url)>{{ $value }}</option>
@endforeach
</optgroup>
<option value="0" @selected('0' == optional($navigation)->type)>Eksternal</option>
Expand All @@ -55,9 +55,9 @@
<div class="ln_solid"></div>
@push('scripts')
<script>
$(document).ready(function () {
$(document).ready(function() {
var base = '{{ url('/') }}';

function toggleUrlFields(type) {
var url = $('#url');
var viewUrl = $('#view-url');
Expand All @@ -73,10 +73,10 @@ function toggleUrlFields(type) {
}
}
}
$('#type').on('change', function () {

$('#type').on('change', function() {
toggleUrlFields($(this).val());
}).trigger('change');
});
</script>
@endpush
@endpush
7 changes: 7 additions & 0 deletions resources/views/sistem_komplain/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<th>Pelapor</th>
<th>Kategori</th>
<th>Status</th>
<th>Identitas Pelapor</th>
</tr>
</thead>
</table>
Expand Down Expand Up @@ -69,6 +70,11 @@ class: 'text-center',
name: 'status',
class: 'status'
},
{
data: 'anonim',
name: 'anonim',
class: 'anonim'
},
],
order: [
[1, 'asc']
Expand All @@ -79,4 +85,5 @@ class: 'status'
@include('forms.datatable-vertical')
@include('forms.delete-modal')
@include('forms.agree-modal')
@include('forms.anonim-modal')
@endpush
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@
Route::put('update/{id}', ['as' => 'admin-komplain.update', 'uses' => 'AdminKomplainController@update']);
Route::delete('destroy/{id}', ['as' => 'admin-komplain.destroy', 'uses' => 'AdminKomplainController@destroy']);
Route::put('setuju/{id}', ['as' => 'admin-komplain.setuju', 'uses' => 'AdminKomplainController@disetujui']);
Route::put('anonim/{id}', ['as' => 'admin-komplain.anonim', 'uses' => 'AdminKomplainController@anonim']);
Route::get('statistik', ['as' => 'admin-komplain.statistik', 'uses' => 'AdminKomplainController@statistik']);
Route::get('show/{id}', ['as' => 'admin-komplain.show', 'uses' => 'AdminKomplainController@show']);
Route::delete('deletekomentar/{id}', ['as' => 'admin-komplain.deletekomentar', 'uses' => 'AdminKomplainController@deletekomentar']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<a href="{{ route('sistem-komplain.komplain', $item->slug) }}">{{ $item->judul }}</a>
<a href="#" class="pull-right btn-box-tool"><span class="label label-default">{{ $item->kategori_komplain->nama }}</span></a>
</span>
<span class="description">{{ $item->nama }} melaporkan - {{ diff_for_humans($item->created_at) }}</span>
<span class="description">{{ auth()->guest() && $item->anonim ? 'Anonim' : $item->nama }} melaporkan - {{ diff_for_humans($item->created_at) }}</span>
</div>
<p>
{!! get_words($item->laporan, 35) !!} ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<span class="username">
<a href="{{ route('sistem-komplain.komplain', $komplain->slug) }}">TRACKING ID #{{ $komplain->komplain_id }}</a>
</span>
<span class="description">PELAPOR : {{ $komplain->nama }}</span>
<span class="description">PELAPOR : {{ auth()->guest() && $komplain->anonim ? 'ANONIM' : $komplain->nama }}</span>
</div>
<!-- /.user-block -->
<br>
Expand Down