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];
|
||||
$authUnitKerja = $authMapping->objectunitkerjapegawaifk;
|
||||
$authSubUnitKerja = $authMapping->objectsubunitkerjapegawaifk;
|
||||
|
||||
$allAkses = AksesFile::where(['statusenabled' => true, 'pegawai_id' => auth()->user()?->dataUser->id])->first();
|
||||
$payload = [
|
||||
'title' => 'Dashboard',
|
||||
'katDok' => $katDok,
|
||||
'klasifikasiDok' => $klasifikasiDok,
|
||||
'authUnitKerja' => $authUnitKerja,
|
||||
'authSubUnitKerja' => $authSubUnitKerja,
|
||||
'allAkses' => $allAkses ?? null
|
||||
];
|
||||
return view('dashboard.index', $payload);
|
||||
}
|
||||
@ -78,6 +81,7 @@ class DashboardController extends Controller
|
||||
DB::connection('dbDirectory')->beginTransaction();
|
||||
try {
|
||||
$datas = request()->input('data');
|
||||
$result = [];
|
||||
foreach($datas as $index => $value){
|
||||
$file = request()->file("data.$index.file");
|
||||
$payload = [
|
||||
@ -93,12 +97,13 @@ class DashboardController extends Controller
|
||||
Storage::disk('file_directory')->put($imageName, file_get_contents($file));
|
||||
$payload['file'] =$imageName;
|
||||
}
|
||||
FileDirectory::create($payload);
|
||||
$saved = FileDirectory::create($payload);
|
||||
}
|
||||
DB::connection('dbDirectory')->commit();
|
||||
return response()->json([
|
||||
'status' => true,
|
||||
'message' => 'Data berhasil disimpan',
|
||||
'data' => count($result) == 1 ? $result[0] : $result
|
||||
], 200);
|
||||
} catch (\Throwable $th) {
|
||||
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
|
||||
color: "#fff",
|
||||
}
|
||||
|
||||
}).showToast();
|
||||
$("#col_add_file").html('');
|
||||
colCount = 1; // reset counter
|
||||
formCreate.find('input[type="text"], input[type="file"]').val('');
|
||||
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.addEventListener('hidden.bs.modal', handler);
|
||||
|
||||
@ -46,8 +46,11 @@ $(document).ready(function() {
|
||||
|
||||
$('.klasifikasi_dok').select2();
|
||||
$('.kategori_dok').select2();
|
||||
|
||||
selectOptionUnitKerja(0)
|
||||
if(allAkses){
|
||||
selectOptionUnitKerjaV1(0)
|
||||
}else{
|
||||
selectOptionUnitKerjaV2(0)
|
||||
}
|
||||
});
|
||||
|
||||
function addForm(){
|
||||
@ -97,7 +100,11 @@ function addForm(){
|
||||
</div>
|
||||
`
|
||||
col.append(html)
|
||||
selectOptionUnitKerja(colCount)
|
||||
if(allAkses){
|
||||
selectOptionUnitKerjaV1(colCount)
|
||||
}else{
|
||||
selectOptionUnitKerjaV2(colCount)
|
||||
}
|
||||
colCount++;
|
||||
|
||||
}
|
||||
@ -108,7 +115,7 @@ function removeCol(count){
|
||||
}
|
||||
|
||||
|
||||
function selectOptionUnitKerja(colCount) {
|
||||
function selectOptionUnitKerjaV1(colCount) {
|
||||
let selectUnit = $(`#select_id_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('')}
|
||||
</ul>
|
||||
`;
|
||||
|
||||
}
|
||||
|
||||
function index(kategori_dok = null, unitKerja = null, subUnitKerja = null, klasifikasi_id = null) {
|
||||
|
||||
@ -143,6 +143,8 @@
|
||||
<script>
|
||||
const klasifikasiDok = @json($klasifikasiDok);
|
||||
const katDok = @json($katDok);
|
||||
const allAkses = @json($allAkses);
|
||||
|
||||
let currentFile = null;
|
||||
let idDirectory = null;
|
||||
document.addEventListener('click', function(e) {
|
||||
@ -209,7 +211,11 @@
|
||||
timer: 2000,
|
||||
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
|
||||
document.getElementById('file-preview').innerHTML =
|
||||
`<p>📂 Pilih file untuk melihat preview</p>`;
|
||||
@ -217,7 +223,6 @@
|
||||
document.getElementById('preview-wrapper').classList.add('d-none');
|
||||
document.getElementById('tree-wrapper').classList.remove('col-md-6');
|
||||
document.getElementById('tree-wrapper').classList.add('col-12');
|
||||
index()
|
||||
currentFile = null; // reset
|
||||
} else {
|
||||
Swal.fire({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user