done fixing submit add document in dashboard
This commit is contained in:
parent
b778b7dee4
commit
80dc494a00
@ -22,12 +22,15 @@ class DashboardController extends Controller
|
|||||||
$authMapping = auth()->user()?->dataUser?->mappingUnitKerjaPegawai[0];
|
$authMapping = auth()->user()?->dataUser?->mappingUnitKerjaPegawai[0];
|
||||||
$authUnitKerja = $authMapping->objectunitkerjapegawaifk;
|
$authUnitKerja = $authMapping->objectunitkerjapegawaifk;
|
||||||
$authSubUnitKerja = $authMapping->objectsubunitkerjapegawaifk;
|
$authSubUnitKerja = $authMapping->objectsubunitkerjapegawaifk;
|
||||||
|
|
||||||
|
$allAkses = AksesFile::where(['statusenabled' => true, 'pegawai_id' => auth()->user()?->dataUser->id])->first();
|
||||||
$payload = [
|
$payload = [
|
||||||
'title' => 'Dashboard',
|
'title' => 'Dashboard',
|
||||||
'katDok' => $katDok,
|
'katDok' => $katDok,
|
||||||
'klasifikasiDok' => $klasifikasiDok,
|
'klasifikasiDok' => $klasifikasiDok,
|
||||||
'authUnitKerja' => $authUnitKerja,
|
'authUnitKerja' => $authUnitKerja,
|
||||||
'authSubUnitKerja' => $authSubUnitKerja,
|
'authSubUnitKerja' => $authSubUnitKerja,
|
||||||
|
'allAkses' => $allAkses ?? null
|
||||||
];
|
];
|
||||||
return view('dashboard.index', $payload);
|
return view('dashboard.index', $payload);
|
||||||
}
|
}
|
||||||
@ -78,6 +81,7 @@ class DashboardController extends Controller
|
|||||||
DB::connection('dbDirectory')->beginTransaction();
|
DB::connection('dbDirectory')->beginTransaction();
|
||||||
try {
|
try {
|
||||||
$datas = request()->input('data');
|
$datas = request()->input('data');
|
||||||
|
$result = [];
|
||||||
foreach($datas as $index => $value){
|
foreach($datas as $index => $value){
|
||||||
$file = request()->file("data.$index.file");
|
$file = request()->file("data.$index.file");
|
||||||
$payload = [
|
$payload = [
|
||||||
@ -93,12 +97,13 @@ class DashboardController extends Controller
|
|||||||
Storage::disk('file_directory')->put($imageName, file_get_contents($file));
|
Storage::disk('file_directory')->put($imageName, file_get_contents($file));
|
||||||
$payload['file'] =$imageName;
|
$payload['file'] =$imageName;
|
||||||
}
|
}
|
||||||
FileDirectory::create($payload);
|
$saved = FileDirectory::create($payload);
|
||||||
}
|
}
|
||||||
DB::connection('dbDirectory')->commit();
|
DB::connection('dbDirectory')->commit();
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status' => true,
|
'status' => true,
|
||||||
'message' => 'Data berhasil disimpan',
|
'message' => 'Data berhasil disimpan',
|
||||||
|
'data' => count($result) == 1 ? $result[0] : $result
|
||||||
], 200);
|
], 200);
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
DB::connection('dbDirectory')->rollBack();
|
DB::connection('dbDirectory')->rollBack();
|
||||||
|
|||||||
BIN
public/file/ChatGPT Image Sep 3, 2025, 10_03_15 AM.png
Normal file
BIN
public/file/ChatGPT Image Sep 3, 2025, 10_03_15 AM.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
BIN
public/file/Draft-Point-Reward-IfbboKsH2-2I9w.pdf
Normal file
BIN
public/file/Draft-Point-Reward-IfbboKsH2-2I9w.pdf
Normal file
Binary file not shown.
BIN
public/file/WhatsApp Image 2025-08-19 at 15.44.52_fa672dde.jpg
Normal file
BIN
public/file/WhatsApp Image 2025-08-19 at 15.44.52_fa672dde.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 102 KiB |
@ -23,14 +23,17 @@ formCreate.on('submit', function(e){
|
|||||||
background: "linear-gradient(to right, #00b09b, #96c93d)", // hijau gradasi
|
background: "linear-gradient(to right, #00b09b, #96c93d)", // hijau gradasi
|
||||||
color: "#fff",
|
color: "#fff",
|
||||||
}
|
}
|
||||||
|
|
||||||
}).showToast();
|
}).showToast();
|
||||||
$("#col_add_file").html('');
|
$("#col_add_file").html('');
|
||||||
colCount = 1; // reset counter
|
colCount = 1; // reset counter
|
||||||
formCreate.find('input[type="text"], input[type="file"]').val('');
|
formCreate.find('input[type="text"], input[type="file"]').val('');
|
||||||
formCreate.find('select').val(null).trigger('change');
|
formCreate.find('select').val(null).trigger('change');
|
||||||
|
|
||||||
index()
|
if(!$("#klasifikasi_dok").val() || !$("#kategori_dok").val() || !$("#unit_kerja").val() || !$("#sub_unit_kerja").val()){
|
||||||
|
index()
|
||||||
|
}else{
|
||||||
|
searchData()
|
||||||
|
}
|
||||||
modalCreate.removeEventListener('hidden.bs.modal', handler);
|
modalCreate.removeEventListener('hidden.bs.modal', handler);
|
||||||
};
|
};
|
||||||
modalCreate.addEventListener('hidden.bs.modal', handler);
|
modalCreate.addEventListener('hidden.bs.modal', handler);
|
||||||
|
|||||||
@ -46,8 +46,11 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
$('.klasifikasi_dok').select2();
|
$('.klasifikasi_dok').select2();
|
||||||
$('.kategori_dok').select2();
|
$('.kategori_dok').select2();
|
||||||
|
if(allAkses){
|
||||||
selectOptionUnitKerja(0)
|
selectOptionUnitKerjaV1(0)
|
||||||
|
}else{
|
||||||
|
selectOptionUnitKerjaV2(0)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function addForm(){
|
function addForm(){
|
||||||
@ -97,7 +100,11 @@ function addForm(){
|
|||||||
</div>
|
</div>
|
||||||
`
|
`
|
||||||
col.append(html)
|
col.append(html)
|
||||||
selectOptionUnitKerja(colCount)
|
if(allAkses){
|
||||||
|
selectOptionUnitKerjaV1(colCount)
|
||||||
|
}else{
|
||||||
|
selectOptionUnitKerjaV2(colCount)
|
||||||
|
}
|
||||||
colCount++;
|
colCount++;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -108,7 +115,7 @@ function removeCol(count){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function selectOptionUnitKerja(colCount) {
|
function selectOptionUnitKerjaV1(colCount) {
|
||||||
let selectUnit = $(`#select_id_unit_kerja_${colCount}`);
|
let selectUnit = $(`#select_id_unit_kerja_${colCount}`);
|
||||||
let selectSubUnit = $(`#select_id_sub_unit_kerja_${colCount}`);
|
let selectSubUnit = $(`#select_id_sub_unit_kerja_${colCount}`);
|
||||||
|
|
||||||
@ -161,3 +168,57 @@ function selectOptionUnitKerja(colCount) {
|
|||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function selectOptionUnitKerjaV2(colCount) {
|
||||||
|
let selectUnit = $(`#select_id_unit_kerja_${colCount}`);
|
||||||
|
let selectSubUnit = $(`#select_id_sub_unit_kerja_${colCount}`);
|
||||||
|
|
||||||
|
// Kosongkan dulu
|
||||||
|
selectUnit.empty().append('<option value="" disabled selected>-- Pilih Unit Kerja --</option>');
|
||||||
|
selectSubUnit.empty().append('<option value="" disabled selected>-- Pilih Sub Unit Kerja --</option>');
|
||||||
|
|
||||||
|
// Load semua unit kerja tanpa ajax
|
||||||
|
$.ajax({
|
||||||
|
url: '/select-unit-kerja', // endpoint tetap sama
|
||||||
|
method: 'GET',
|
||||||
|
success: function(response) {
|
||||||
|
if (response?.data) {
|
||||||
|
response.data.forEach(unit => {
|
||||||
|
const option = new Option(unit.name, unit.id, false, false);
|
||||||
|
$(option).data('sub_units', unit.sub_unit_kerja); // simpan sub unit di data attribute
|
||||||
|
selectUnit.append(option);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Inisialisasi select2 tanpa ajax
|
||||||
|
selectUnit.select2({
|
||||||
|
placeholder: '-- Pilih Unit Kerja --',
|
||||||
|
allowClear: true,
|
||||||
|
width: '100%',
|
||||||
|
dropdownParent: selectUnit.parent()
|
||||||
|
});
|
||||||
|
|
||||||
|
selectSubUnit.select2({
|
||||||
|
placeholder: '-- Pilih Sub Unit Kerja --',
|
||||||
|
allowClear: true,
|
||||||
|
width: '100%',
|
||||||
|
dropdownParent: selectSubUnit.parent()
|
||||||
|
});
|
||||||
|
|
||||||
|
// Event ketika unit kerja dipilih
|
||||||
|
selectUnit.on('change', function () {
|
||||||
|
const selectedOption = $(this).find(':selected');
|
||||||
|
const subUnits = selectedOption.data('sub_units') || [];
|
||||||
|
|
||||||
|
selectSubUnit.empty().append('<option value="" disabled selected>-- Pilih Sub Unit Kerja --</option>');
|
||||||
|
|
||||||
|
if (subUnits.length > 0) {
|
||||||
|
subUnits.forEach(sub => {
|
||||||
|
selectSubUnit.append(`<option value="${sub.id}">${sub.name}</option>`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@ -49,7 +49,6 @@ function renderTree(units, katDok) {
|
|||||||
`).join('')}
|
`).join('')}
|
||||||
</ul>
|
</ul>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function index(kategori_dok = null, unitKerja = null, subUnitKerja = null, klasifikasi_id = null) {
|
function index(kategori_dok = null, unitKerja = null, subUnitKerja = null, klasifikasi_id = null) {
|
||||||
|
|||||||
@ -143,6 +143,8 @@
|
|||||||
<script>
|
<script>
|
||||||
const klasifikasiDok = @json($klasifikasiDok);
|
const klasifikasiDok = @json($klasifikasiDok);
|
||||||
const katDok = @json($katDok);
|
const katDok = @json($katDok);
|
||||||
|
const allAkses = @json($allAkses);
|
||||||
|
|
||||||
let currentFile = null;
|
let currentFile = null;
|
||||||
let idDirectory = null;
|
let idDirectory = null;
|
||||||
document.addEventListener('click', function(e) {
|
document.addEventListener('click', function(e) {
|
||||||
@ -209,7 +211,11 @@
|
|||||||
timer: 2000,
|
timer: 2000,
|
||||||
showConfirmButton: false
|
showConfirmButton: false
|
||||||
});
|
});
|
||||||
|
const fileLink = document.querySelector(`a.file-link[data-id="${idDirectory}"]`);
|
||||||
|
if (fileLink) {
|
||||||
|
const li = fileLink.closest('li.file-tree-li');
|
||||||
|
li?.remove();
|
||||||
|
}
|
||||||
// reset preview
|
// reset preview
|
||||||
document.getElementById('file-preview').innerHTML =
|
document.getElementById('file-preview').innerHTML =
|
||||||
`<p>📂 Pilih file untuk melihat preview</p>`;
|
`<p>📂 Pilih file untuk melihat preview</p>`;
|
||||||
@ -217,7 +223,6 @@
|
|||||||
document.getElementById('preview-wrapper').classList.add('d-none');
|
document.getElementById('preview-wrapper').classList.add('d-none');
|
||||||
document.getElementById('tree-wrapper').classList.remove('col-md-6');
|
document.getElementById('tree-wrapper').classList.remove('col-md-6');
|
||||||
document.getElementById('tree-wrapper').classList.add('col-12');
|
document.getElementById('tree-wrapper').classList.add('col-12');
|
||||||
index()
|
|
||||||
currentFile = null; // reset
|
currentFile = null; // reset
|
||||||
} else {
|
} else {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user