Skip to content

Commit

Permalink
update minor
Browse files Browse the repository at this point in the history
  • Loading branch information
punkestu committed Jan 27, 2025
1 parent 6689b02 commit 2a09559
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/Http/Controllers/API/Rotasi/CabangController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public function editNode(Request $request)
['cabang_id' => $request->cabang_id],
['cabang_id' => $request->cabang_id, 'root_id' => $request->root_id]
);
return response()->json(['message' => 'success']);
$cabangNodes = CabangNode::with('cabang')->get();
return response()->json(['message' => 'success', 'cabangNodes' => $cabangNodes]);
}
public function deleteNode($cabang_id)
{
Expand Down
15 changes: 15 additions & 0 deletions resources/views/rotasi/cabang/struktur-edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ function edit(id) {
}).then(response => response.json())
.then(data => {
console.log(data);
const newNodes = data.cabangNodes;
document.querySelectorAll('#nodes > div select').forEach(node => {
const selectedNode = node.value;
node.innerHTML = '';
node.innerHTML = '<option value="">PUSAT</option>';
newNodes.forEach(newNode => {
const option = document.createElement('option');
option.value = newNode.id;
option.textContent = newNode.cabang.nama;
if (newNode.id == selectedNode) {
option.selected = true;
}
node.appendChild(option);
});
});
alert('Berhasil disimpan');
})
.catch(error => console.error(error));
Expand Down

0 comments on commit 2a09559

Please sign in to comment.