refactor: Update front-end assets by removing Select2 integration from various forms and adjusting the build configuration.

This commit is contained in:
pbao9
2026-02-28 21:29:13 +07:00
parent 5c97768707
commit 6b18c3ff12
36 changed files with 79 additions and 493 deletions
@@ -22,7 +22,7 @@ if (!$selectedDatacenterId && $model) {
<div class="row form-group align-items-center mb-0">
<label for="datacenter_id" class="col-md-3 text-right">Chọn Datacenter</label>
<div class="col-md-9 p-1 bg-customer">
<select class="form-control select2 single__select datacenter_id" name="module_datacenter_id"
<select class="form-control datacenter_id" name="module_datacenter_id"
data-selected="{{ $selectedDatacenterId }}" data-placeholder="--- Chọn Datacenter ---">
</select>
</div>
@@ -116,6 +116,10 @@ if (!$selectedDatacenterId && $model) {
// Enable host if datacenter is selected
if (datacenterId) {
$host.prop('disabled', false);
// Trigger host load
if ($host.is('select')) {
$host.trigger('change.hostComponent');
}
}
});
@@ -127,6 +131,11 @@ if (!$selectedDatacenterId && $model) {
// If only vcenter is selected, load datacenters without preselection
debounceLoadDatacenters($vcenter.val());
}
// Also trigger host load when datacenter is already selected on page load
if ($datacenter.val()) {
$datacenter.trigger('change.datacenterComponent');
}
});
</script>
@endpush
@@ -7,7 +7,7 @@ $selectedHostId = old('module_host_id') ?? ($model?->module_host_id ?? ($model?-
<div class="row form-group align-items-center mb-0">
<label for="host_id" class="col-md-3 text-right">Chọn Host</label>
<div class="col-md-9 p-1 bg-customer">
<select class="form-control select2 single__select host_id" name="module_host_id"
<select class="form-control host_id" name="module_host_id"
data-selected="{{ $selectedHostId }}"
data-placeholder="--- Chọn Host ---">
</select>
@@ -22,11 +22,6 @@ $selectedHostId = old('module_host_id') ?? ($model?->module_host_id ?? ($model?-
}
window.hostComponentInitialized = true;
// Initialize Select2 using global function
if (typeof window.initSelect2 === 'function') {
window.initSelect2();
}
const $datacenter = $('.datacenter_id');
const $host = $('.host_id');
@@ -1,7 +1,7 @@
<div class="row form-group align-items-center mb-0">
<label for="network_id" class="col-md-3 text-right">Network</label>
<div class="col-md-9 p-1 bg-customer">
<select class="custom-select select2 network_id" id="network_id" data-route="{{ route('api.getNetwork') }}"
<select class="custom-select network_id" id="network_id" data-route="{{ route('module-vcenter.getNetwork') }}"
name="module_network_id" style="width: 100%;">
<option value="0">---------</option>
@if($networks)
@@ -12,7 +12,7 @@ if ($model && $model->osGroup) {
<div class="row form-group align-items-center mb-0">
<label for="os_group_id" class="col-md-3 text-right">Os Family</label>
<div class="col-md-9 p-1 bg-customer">
<select class="form-control os_group_id select2 single__select" name="os_group_id"
<select class="form-control os_group_id single__select" name="os_group_id"
data-selected="{{ $selectedOsGroupId }}" data-placeholder="--- Chọn OS Group ---">
@if ($selectedOsGroupId && $lists)
@foreach ($lists->all() as $item)
@@ -1,16 +1,17 @@
@php
$selectedVcenterId = old('vcenter_id') ??
($model?->host?->datacenter?->vcenter_id ?? (
$model?->datacenter?->vcenter_id ??
($model?->ipaddress?->host?->datacenter?->vcenter?->id ??
$model?->vcenter_id ?? null)
));
$selectedVcenterId = old('vcenter_id') ??
($model instanceof \App\Models\vCenter ? $model->id : (
$model?->host?->datacenter?->vcenter_id ??
($model?->datacenter?->vcenter_id ??
($model?->ipaddress?->host?->datacenter?->vcenter?->id ?? null)
)
));
@endphp
<div class="row form-group align-items-center mb-0">
<label for="vcenter_id" class="col-md-3 text-right">Chọn vCenter</label>
<div class="col-md-9 p-1 bg-customer">
<select class="form-control select2 single__select vcenter_id" name="vcenter_id"
<select class="form-control vcenter_id" name="vcenter_id"
data-selected="{{ $selectedVcenterId }}">
<option value="">--- Chọn vCenter ---</option>
@if(isset($vcenters) && $vcenters->count())
@@ -31,10 +32,6 @@ $selectedVcenterId = old('vcenter_id') ??
}
window.vcenterComponentInitialized = true;
$('.select2').select2({
width: '100%'
});
const $vcenter = $('.vcenter_id');
const $datacenter = $('.datacenter_id');
const $host = $('.host_id');
@@ -63,6 +60,7 @@ $selectedVcenterId = old('vcenter_id') ??
if ($vcenter.val()) {
if ($datacenter.is('select')) $datacenter.prop('disabled', false);
$vcenter.trigger('change.vcenterComponent');
}
});
</script>