Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add suport to Vite #1308

Merged
merged 13 commits into from
Oct 5, 2024
14 changes: 8 additions & 6 deletions config/adminlte.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,19 +267,21 @@

/*
|--------------------------------------------------------------------------
| Laravel Mix
| Laravel Asset Bundling
|--------------------------------------------------------------------------
|
| Here we can enable the Laravel Mix option for the admin panel.
| Here we can enable the Laravel Asset Bundling option for the admin panel.
| Currently, two modes are supported: 'mix' and 'vite'.
| If you are not using any of these, leave it as 'false'.
|
| For detailed instructions you can look the laravel mix section here:
| For detailed instructions you can look the laravel asset bundling section here:
| https://github.com/jeroennoten/Laravel-AdminLTE/wiki/Other-Configuration
|
*/

'enabled_laravel_mix' => false,
'laravel_mix_css_path' => 'css/app.css',
'laravel_mix_js_path' => 'js/app.js',
'laravel_asset_bundling' => false,
'laravel_css_path' => 'css/app.css',
'laravel_js_path' => 'js/app.js',

/*
|--------------------------------------------------------------------------
Expand Down
112 changes: 56 additions & 56 deletions resources/views/components/form/date-range.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,86 +18,86 @@

@push('js')
<script>
document.addEventListener("DOMContentLoaded", function() {
$(() => {
let usrCfg = _AdminLTE_DateRange.parseCfg( @json($config) );

$(() => {
let usrCfg = _AdminLTE_DateRange.parseCfg( @json($config) );
// Add support to display a placeholder. In this situation, the related
// input won't be updated automatically and the cancel button will be
// used to clear the input.

// Add support to display a placeholder. In this situation, the related
// input won't be updated automatically and the cancel button will be
// used to clear the input.
@if($attributes->has('placeholder'))

@if($attributes->has('placeholder'))
usrCfg.autoUpdateInput = false;

usrCfg.autoUpdateInput = false;
$('#{{ $id }}').on('apply.daterangepicker', function(ev, picker)
{
let startDate = picker.startDate.format(picker.locale.format);
let endDate = picker.endDate.format(picker.locale.format);

$('#{{ $id }}').on('apply.daterangepicker', function(ev, picker)
{
let startDate = picker.startDate.format(picker.locale.format);
let endDate = picker.endDate.format(picker.locale.format);
let value = picker.singleDatePicker
? startDate
: startDate + picker.locale.separator + endDate;

let value = picker.singleDatePicker
? startDate
: startDate + picker.locale.separator + endDate;
$(this).val(value);
});

$(this).val(value);
});
$('#{{ $id }}').on('cancel.daterangepicker', function(ev, picker)
{
$(this).val('');
});

$('#{{ $id }}').on('cancel.daterangepicker', function(ev, picker)
{
$(this).val('');
});
@endif

@endif
// Check if the default set of ranges should be enabled, and if a
// default range should be set at initialization.

// Check if the default set of ranges should be enabled, and if a
// default range should be set at initialization.
@isset($enableDefaultRanges)

@isset($enableDefaultRanges)
usrCfg.ranges = usrCfg.ranges || _AdminLTE_DateRange.defaultRanges;
let range = usrCfg.ranges[ @json($enableDefaultRanges) ];

usrCfg.ranges = usrCfg.ranges || _AdminLTE_DateRange.defaultRanges;
let range = usrCfg.ranges[ @json($enableDefaultRanges) ];

if (Array.isArray(range) && range.length > 1) {
usrCfg.startDate = range[0];
usrCfg.endDate = range[1];
}

@endisset
if (Array.isArray(range) && range.length > 1) {
usrCfg.startDate = range[0];
usrCfg.endDate = range[1];
}

// Add support to auto select the previous submitted value in case
// of validation errors. Note the previous value may be a date range or
// a single date depending on the plugin configuration.
@endisset

@if($errors->any() && $enableOldSupport)
// Add support to auto select the previous submitted value in case
// of validation errors. Note the previous value may be a date range or
// a single date depending on the plugin configuration.

let oldRange = @json($getOldValue($errorKey, ""));
let separator = " - ";
@if($errors->any() && $enableOldSupport)

if (usrCfg.locale && usrCfg.locale.separator) {
separator = usrCfg.locale.separator;
}
let oldRange = @json($getOldValue($errorKey, ""));
let separator = " - ";

// Update the related input.
if (usrCfg.locale && usrCfg.locale.separator) {
separator = usrCfg.locale.separator;
}

if (! usrCfg.autoUpdateInput) {
$('#{{ $id }}').val(oldRange);
}
// Update the related input.

// Update the internal plugin data.
if (! usrCfg.autoUpdateInput) {
$('#{{ $id }}').val(oldRange);
}

if (oldRange) {
oldRange = oldRange.split(separator);
usrCfg.startDate = oldRange.length > 0 ? oldRange[0] : null;
usrCfg.endDate = oldRange.length > 1 ? oldRange[1] : null;
}
// Update the internal plugin data.

@endif
if (oldRange) {
oldRange = oldRange.split(separator);
usrCfg.startDate = oldRange.length > 0 ? oldRange[0] : null;
usrCfg.endDate = oldRange.length > 1 ? oldRange[1] : null;
}

// Setup the underlying date range plugin.
@endif

$('#{{ $id }}').daterangepicker(usrCfg);
})
// Setup the underlying date range plugin.

$('#{{ $id }}').daterangepicker(usrCfg);
})
});
</script>
@endpush

Expand Down
45 changes: 23 additions & 22 deletions resources/views/components/form/input-color.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,38 @@

@push('js')
<script>
document.addEventListener("DOMContentLoaded", function() {
$(() => {

$(() => {
// Create a method to set the addon color.

// Create a method to set the addon color.
let setAddonColor = function()
{
let color = $('#{{ $id }}').data('colorpicker').getValue();

let setAddonColor = function()
{
let color = $('#{{ $id }}').data('colorpicker').getValue();
$('#{{ $id }}').closest('.input-group')
.find('.input-group-text > i')
.css('color', color);
}

$('#{{ $id }}').closest('.input-group')
.find('.input-group-text > i')
.css('color', color);
}
// Init the plugin and register the change event listener.

// Init the plugin and register the change event listener.
$('#{{ $id }}').colorpicker( @json($config) )
.on('change', setAddonColor);

$('#{{ $id }}').colorpicker( @json($config) )
.on('change', setAddonColor);
// Add support to auto select the previous submitted value in case
// of validation errors.

// Add support to auto select the previous submitted value in case
// of validation errors.
@if($errors->any() && $enableOldSupport)
let oldColor = @json($getOldValue($errorKey, ""));
$('#{{ $id }}').val(oldColor).change();
@endif

@if($errors->any() && $enableOldSupport)
let oldColor = @json($getOldValue($errorKey, ""));
$('#{{ $id }}').val(oldColor).change();
@endif
// Set the initial color for the addon.

// Set the initial color for the addon.

setAddonColor();
})
setAddonColor();
})

});
</script>
@endpush
24 changes: 12 additions & 12 deletions resources/views/components/form/input-date.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@

@push('js')
<script>

$(() => {
let usrCfg = _AdminLTE_InputDate.parseCfg( @json($config) );
$('#{{ $id }}').datetimepicker(usrCfg);

// Add support to auto display the old submitted value or values in case
// of validation errors.

let value = @json($getOldValue($errorKey, $attributes->get('value')));
$('#{{ $id }}').val(value || "");
})

document.addEventListener("DOMContentLoaded", function() {
$(() => {
let usrCfg = _AdminLTE_InputDate.parseCfg( @json($config) );
$('#{{ $id }}').datetimepicker(usrCfg);

// Add support to auto display the old submitted value or values in case
// of validation errors.

let value = @json($getOldValue($errorKey, $attributes->get('value')));
$('#{{ $id }}').val(value || "");
})
});
</script>
@endpush

Expand Down
43 changes: 22 additions & 21 deletions resources/views/components/form/input-file-krajee.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,34 @@
@push('js')
<script>

$(() => {
document.addEventListener("DOMContentLoaded", function() {
$(() => {

// Initialize the plugin.
// Initialize the plugin.

$('#{{ $id }}').fileinput( @json($config) );
$('#{{ $id }}').fileinput( @json($config) );

// Workaround to force setup of invalid class.
// Workaround to force setup of invalid class.

@if($isInvalid())
$('#{{ $id }}').closest('.file-input')
.find('.file-caption-name')
.addClass('is-invalid')
@if($isInvalid())
$('#{{ $id }}').closest('.file-input')
.find('.file-caption-name')
.addClass('is-invalid')

$('#{{ $id }}').closest('.file-input')
.find('.file-preview')
.css('box-shadow', '0 .15rem 0.25rem rgba(255,0,0,.25)');
@endif
$('#{{ $id }}').closest('.file-input')
.find('.file-preview')
.css('box-shadow', '0 .15rem 0.25rem rgba(255,0,0,.25)');
@endif

// Make custom style for particular scenarios (modes).

@if($presetMode == 'avatar')
$('#{{ $id }}').closest('.file-input')
.addClass('text-center')
.find('.file-drop-zone')
.addClass('border-0');
@endif
})
// Make custom style for particular scenarios (modes).

@if($presetMode == 'avatar')
$('#{{ $id }}').closest('.file-input')
.addClass('text-center')
.find('.file-drop-zone')
.addClass('border-0');
@endif
})
});
</script>
@endpush
10 changes: 5 additions & 5 deletions resources/views/components/form/input-file.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
@once
@push('js')
<script>

$(() => {
bsCustomFileInput.init();
})

document.addEventListener("DOMContentLoaded", function() {
$(() => {
bsCustomFileInput.init();
})
});
</script>
@endpush
@endonce
Expand Down
Loading