update
This commit is contained in:
@@ -1,41 +1,41 @@
|
||||
@php
|
||||
$tag = 'button';
|
||||
$href = null;
|
||||
$tag = 'button';
|
||||
$href = null;
|
||||
|
||||
if ($route) {
|
||||
$href = route($route, $params);
|
||||
$tag = 'a';
|
||||
} elseif ($url) {
|
||||
$href = $url;
|
||||
$tag = 'a';
|
||||
} elseif ($attributes->has('href')) {
|
||||
$href = $attributes->get('href');
|
||||
$tag = 'a';
|
||||
}
|
||||
if ($route) {
|
||||
$href = route($route, $params);
|
||||
$tag = 'a';
|
||||
} elseif ($url) {
|
||||
$href = $url;
|
||||
$tag = 'a';
|
||||
} elseif ($attributes->has('href')) {
|
||||
$href = $attributes->get('href');
|
||||
$tag = 'a';
|
||||
}
|
||||
|
||||
$baseClasses = 'd-inline-flex gap-2 align-items-center justify-content-center text-white border-0 shadow-md px-2 py-1 rounded-2';
|
||||
$baseClasses = 'd-inline-flex gap-2 align-items-center justify-content-center text-white border-0 shadow-md px-2 py-1 rounded-2';
|
||||
|
||||
$variants = [
|
||||
'primary' => 'bg-primary',
|
||||
'secondary' => 'bg-secondary',
|
||||
'outline' => 'bg-outline',
|
||||
'ghost' => 'bg-ghost',
|
||||
'link' => 'bg-link',
|
||||
'danger' => 'bg-danger',
|
||||
'destructive' => 'bg-destructive',
|
||||
];
|
||||
$variants = [
|
||||
'primary' => 'bg-primary',
|
||||
'secondary' => 'bg-secondary',
|
||||
'outline' => 'bg-outline',
|
||||
'ghost' => 'bg-ghost',
|
||||
'link' => 'bg-link',
|
||||
'danger' => 'bg-danger',
|
||||
'destructive' => 'bg-destructive',
|
||||
];
|
||||
|
||||
$sizes = [
|
||||
'default' => 'h-10',
|
||||
'sm' => 'h-6',
|
||||
'lg' => 'h-12',
|
||||
'icon' => 'h-10',
|
||||
];
|
||||
$sizes = [
|
||||
'default' => 'h-10',
|
||||
'sm' => 'h-6',
|
||||
'lg' => 'h-12',
|
||||
'icon' => 'h-10',
|
||||
];
|
||||
|
||||
$variantClass = $variants[$variant] ?? $variants['primary'];
|
||||
$sizeClass = $sizes[$size] ?? $sizes['default'];
|
||||
$variantClass = $variants[$variant] ?? $variants['primary'];
|
||||
$sizeClass = $sizes[$size] ?? $sizes['default'];
|
||||
|
||||
$classes = "{$baseClasses} {$variantClass} {$sizeClass}";
|
||||
$classes = "{$baseClasses} {$variantClass} {$sizeClass}";
|
||||
@endphp
|
||||
|
||||
@if($tag === 'a')
|
||||
@@ -48,7 +48,7 @@
|
||||
@else
|
||||
<button type="{{ $type }}" {{ $attributes->merge(['class' => $classes]) }}>
|
||||
@if($icon)
|
||||
<i data-lucide="{{ $icon }}" class="w-1 h-1 mr-2"></i>
|
||||
<i data-lucide="{{ $icon }}" class="mr-2" style="height: 15px; width: 15px"></i>
|
||||
@endif
|
||||
{{ $slot }}
|
||||
</button>
|
||||
|
||||
@@ -24,54 +24,45 @@
|
||||
@push('custom-scripts')
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
// Prevent multiple initializations using namespace
|
||||
if (window.vcenterComponentInitialized) {
|
||||
return;
|
||||
}
|
||||
window.vcenterComponentInitialized = true;
|
||||
// Prevent multiple initializations using namespace
|
||||
if (window.vcenterComponentInitialized) {
|
||||
return;
|
||||
}
|
||||
window.vcenterComponentInitialized = true;
|
||||
|
||||
$('.select2').select2({
|
||||
width: '100%'
|
||||
});
|
||||
$('.select2').select2({
|
||||
width: '100%'
|
||||
});
|
||||
|
||||
const $vcenter = $('.vcenter_id');
|
||||
const $datacenter = $('.datacenter_id');
|
||||
const $host = $('.host_id');
|
||||
const $vcenter = $('.vcenter_id');
|
||||
const $datacenter = $('.datacenter_id');
|
||||
const $host = $('.host_id');
|
||||
|
||||
// Disable datacenter and host initially
|
||||
// Note: In edit view these might be inputs not selects, so this logic might need adjustment if intended for cascading selects.
|
||||
// For now, keeping logic but ensuring it doesn't break if elements aren't selects.
|
||||
if ($datacenter.is('select')) {
|
||||
$datacenter.prop('disabled', true);
|
||||
}
|
||||
if ($host.is('select')) {
|
||||
$host.prop('disabled', true);
|
||||
}
|
||||
|
||||
// Remove existing event handlers and bind new ones with namespace
|
||||
$vcenter.off('change.vcenterComponent').on('change.vcenterComponent', function () {
|
||||
const vcenterId = $(this).val();
|
||||
|
||||
// Reset and disable datacenter and host if they are selects
|
||||
if ($datacenter.is('select')) {
|
||||
$datacenter.html('<option value="">--- Chọn Datacenter ---</option>').prop('disabled', true);
|
||||
$datacenter.prop('disabled', true);
|
||||
}
|
||||
if ($host.is('select')) {
|
||||
$host.html('<option value="">--- Chọn Host ---</option>').prop('disabled', true);
|
||||
$host.prop('disabled', true);
|
||||
}
|
||||
|
||||
// Enable datacenter if vcenter is selected
|
||||
if (vcenterId) {
|
||||
$vcenter.off('change.vcenterComponent').on('change.vcenterComponent', function () {
|
||||
const vcenterId = $(this).val();
|
||||
|
||||
if ($datacenter.is('select')) {
|
||||
$datacenter.html('<option value="">--- Chọn Datacenter ---</option>').prop('disabled', true);
|
||||
}
|
||||
if ($host.is('select')) {
|
||||
$host.html('<option value="">--- Chọn Host ---</option>').prop('disabled', true);
|
||||
}
|
||||
|
||||
if (vcenterId) {
|
||||
if ($datacenter.is('select')) $datacenter.prop('disabled', false);
|
||||
}
|
||||
});
|
||||
|
||||
if ($vcenter.val()) {
|
||||
if ($datacenter.is('select')) $datacenter.prop('disabled', false);
|
||||
}
|
||||
});
|
||||
|
||||
// Trigger initial state
|
||||
if ($vcenter.val()) {
|
||||
if ($datacenter.is('select')) $datacenter.prop('disabled', false);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
|
||||
@endpush
|
||||
Reference in New Issue
Block a user