update os
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
@php
|
||||
// Fix: Get os_group_id from the relationship correctly
|
||||
$selectedOsGroupId = old('os_group_id') ?? ($model?->os?->os_group_id ?? null);
|
||||
|
||||
$selectedOsGroupId = old('os_group_id') ?? ($model?->os_group_id ?? null);
|
||||
|
||||
$lists = collect();
|
||||
if ($model && $model->osGroup) {
|
||||
$lists = collect([$model->osGroup]);
|
||||
}
|
||||
@endphp
|
||||
|
||||
|
||||
@@ -12,7 +17,12 @@ $selectedOsGroupId = old('os_group_id') ?? ($model?->os?->os_group_id ?? null);
|
||||
@if ($selectedOsGroupId && $lists)
|
||||
@foreach ($lists->all() as $item)
|
||||
@if ($item->id == $selectedOsGroupId)
|
||||
<option value="{{ $item->id }}" selected>{{ $item->name }}</option>
|
||||
<option value="{{ $item->id }}" selected>
|
||||
{{ $item->name }}
|
||||
@if($item->host)
|
||||
- {{ $item->host->name }} ({{ $item->host->host_id }})
|
||||
@endif
|
||||
</option>
|
||||
@endif
|
||||
@endforeach
|
||||
@endif
|
||||
@@ -72,8 +82,9 @@ $selectedOsGroupId = old('os_group_id') ?? ($model?->os?->os_group_id ?? null);
|
||||
let options = '<option value="">--- Chọn OS Group ---</option>';
|
||||
response.data.forEach(os => {
|
||||
const selected = preselect == os.id ? 'selected' : '';
|
||||
const hostInfo = os.host ? ` - ${os.host.name} (${os.host.host_id})` : '';
|
||||
options +=
|
||||
`<option value="${os.id}" ${selected}>${os.name}</option>`;
|
||||
`<option value="${os.id}" ${selected}>${os.name}${hostInfo}</option>`;
|
||||
});
|
||||
$osGroup.html(options).prop('disabled', false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user