mirror of
https://github.com/grocy/grocy.git
synced 2025-08-16 02:34:44 +00:00
Use the now available @once directive instead of the legacy hack to only include component scripts once
This commit is contained in:
@@ -1,13 +1,17 @@
|
|||||||
@if (!GROCY_DISABLE_BROWSER_BARCODE_CAMERA_SCANNING)
|
@if (!GROCY_DISABLE_BROWSER_BARCODE_CAMERA_SCANNING)
|
||||||
|
|
||||||
|
@once
|
||||||
@push('componentScripts')
|
@push('componentScripts')
|
||||||
<script src="{{ $U('/viewjs/components/barcodescanner.js', true) }}?v={{ $version }}"></script>
|
<script src="{{ $U('/viewjs/components/barcodescanner.js', true) }}?v={{ $version }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@endonce
|
||||||
|
|
||||||
|
@once
|
||||||
@push('pageScripts')
|
@push('pageScripts')
|
||||||
<script src="{{ $U('/node_modules/@ericblade/quagga2/dist/quagga.min.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/node_modules/@ericblade/quagga2/dist/quagga.min.js?v=', true) }}{{ $version }}"></script>
|
||||||
<script src="{{ $U('/components_unmanaged/quagga2-reader-datamatrix/index.js', true) }}?v={{ $version }}"></script>
|
<script src="{{ $U('/components_unmanaged/quagga2-reader-datamatrix/index.js', true) }}?v={{ $version }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@endonce
|
||||||
|
|
||||||
@push('pageStyles')
|
@push('pageStyles')
|
||||||
<style>
|
<style>
|
||||||
@@ -22,6 +26,7 @@
|
|||||||
.combobox-container #barcodescanner-start-button {
|
.combobox-container #barcodescanner-start-button {
|
||||||
margin-right: 36px !important;
|
margin-right: 36px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
@endpush
|
@endpush
|
||||||
|
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
|
@once
|
||||||
@push('componentScripts')
|
@push('componentScripts')
|
||||||
<script src="{{ $U('/viewjs/components/batterycard.js', true) }}?v={{ $version }}"></script>
|
<script src="{{ $U('/viewjs/components/batterycard.js', true) }}?v={{ $version }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@endonce
|
||||||
|
|
||||||
<div class="card batterycard">
|
<div class="card batterycard">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
|
@once
|
||||||
@push('componentScripts')
|
@push('componentScripts')
|
||||||
<script src="{{ $U('/viewjs/components/calendarcard.js', true) }}?v={{ $version }}"></script>
|
<script src="{{ $U('/viewjs/components/calendarcard.js', true) }}?v={{ $version }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@endonce
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
|
@once
|
||||||
@push('componentScripts')
|
@push('componentScripts')
|
||||||
<script src="{{ $U('/viewjs/components/chorecard.js', true) }}?v={{ $version }}"></script>
|
<script src="{{ $U('/viewjs/components/chorecard.js', true) }}?v={{ $version }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@endonce
|
||||||
|
|
||||||
<div class="card chorecard">
|
<div class="card chorecard">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
|
@once
|
||||||
@push('componentScripts')
|
@push('componentScripts')
|
||||||
<script src="{{ $U('/viewjs/components/datetimepicker.js', true) }}?v={{ $version }}"></script>
|
<script src="{{ $U('/viewjs/components/datetimepicker.js', true) }}?v={{ $version }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@endonce
|
||||||
|
|
||||||
@php if(!isset($isRequired)) { $isRequired = true; } @endphp
|
@php if(!isset($isRequired)) { $isRequired = true; } @endphp
|
||||||
@php if(!isset($initialValue)) { $initialValue = ''; } @endphp
|
@php if(!isset($initialValue)) { $initialValue = ''; } @endphp
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
|
@once
|
||||||
@push('componentScripts')
|
@push('componentScripts')
|
||||||
<script src="{{ $U('/viewjs/components/datetimepicker2.js', true) }}?v={{ $version }}"></script>
|
<script src="{{ $U('/viewjs/components/datetimepicker2.js', true) }}?v={{ $version }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@endonce
|
||||||
|
|
||||||
@php if(!isset($isRequired)) { $isRequired = true; } @endphp
|
@php if(!isset($isRequired)) { $isRequired = true; } @endphp
|
||||||
@php if(!isset($initialValue)) { $initialValue = ''; } @endphp
|
@php if(!isset($initialValue)) { $initialValue = ''; } @endphp
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
|
@once
|
||||||
@push('componentScripts')
|
@push('componentScripts')
|
||||||
<script src="{{ $U('/viewjs/components/locationpicker.js', true) }}?v={{ $version }}"></script>
|
<script src="{{ $U('/viewjs/components/locationpicker.js', true) }}?v={{ $version }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@endonce
|
||||||
|
|
||||||
@php if(empty($prefillByName)) { $prefillByName = ''; } @endphp
|
@php if(empty($prefillByName)) { $prefillByName = ''; } @endphp
|
||||||
@php if(empty($prefillById)) { $prefillById = ''; } @endphp
|
@php if(empty($prefillById)) { $prefillById = ''; } @endphp
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
|
@once
|
||||||
@push('componentScripts')
|
@push('componentScripts')
|
||||||
<script src="{{ $U('/viewjs/components/numberpicker.js', true) }}?v={{ $version }}"></script>
|
<script src="{{ $U('/viewjs/components/numberpicker.js', true) }}?v={{ $version }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@endonce
|
||||||
|
|
||||||
@php if(!isset($value)) { $value = 1; } @endphp
|
@php if(!isset($value)) { $value = 1; } @endphp
|
||||||
@php if(empty($min)) { $min = 0; } @endphp
|
@php if(empty($min)) { $min = 0; } @endphp
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
|
@once
|
||||||
@push('componentScripts')
|
@push('componentScripts')
|
||||||
<script src="{{ $U('/viewjs/components/productamountpicker.js', true) }}?v={{ $version }}"></script>
|
<script src="{{ $U('/viewjs/components/productamountpicker.js', true) }}?v={{ $version }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@endonce
|
||||||
|
|
||||||
@php if(empty($additionalGroupCssClasses)) { $additionalGroupCssClasses = ''; } @endphp
|
@php if(empty($additionalGroupCssClasses)) { $additionalGroupCssClasses = ''; } @endphp
|
||||||
@php if(empty($additionalHtmlContextHelp)) { $additionalHtmlContextHelp = ''; } @endphp
|
@php if(empty($additionalHtmlContextHelp)) { $additionalHtmlContextHelp = ''; } @endphp
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
|
@once
|
||||||
@push('componentScripts')
|
@push('componentScripts')
|
||||||
<script src="{{ $U('/node_modules/chart.js/dist/Chart.min.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/node_modules/chart.js/dist/Chart.min.js?v=', true) }}{{ $version }}"></script>
|
||||||
<script src="{{ $U('/viewjs/components/productcard.js', true) }}?v={{ $version }}"></script>
|
<script src="{{ $U('/viewjs/components/productcard.js', true) }}?v={{ $version }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@endonce
|
||||||
|
|
||||||
<div class="card productcard">
|
<div class="card productcard">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
|
@once
|
||||||
@push('componentScripts')
|
@push('componentScripts')
|
||||||
<script src="{{ $U('/viewjs/components/productpicker.js', true) }}?v={{ $version }}"></script>
|
<script src="{{ $U('/viewjs/components/productpicker.js', true) }}?v={{ $version }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@endonce
|
||||||
|
|
||||||
@php if(empty($disallowAddProductWorkflows)) { $disallowAddProductWorkflows = false; } @endphp
|
@php if(empty($disallowAddProductWorkflows)) { $disallowAddProductWorkflows = false; } @endphp
|
||||||
@php if(empty($disallowAllProductWorkflows)) { $disallowAllProductWorkflows = false; } @endphp
|
@php if(empty($disallowAllProductWorkflows)) { $disallowAllProductWorkflows = false; } @endphp
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
|
@once
|
||||||
@push('componentScripts')
|
@push('componentScripts')
|
||||||
<script src="{{ $U('/viewjs/components/recipepicker.js', true) }}?v={{ $version }}"></script>
|
<script src="{{ $U('/viewjs/components/recipepicker.js', true) }}?v={{ $version }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@endonce
|
||||||
|
|
||||||
@php if(empty($prefillByName)) { $prefillByName = ''; } @endphp
|
@php if(empty($prefillByName)) { $prefillByName = ''; } @endphp
|
||||||
@php if(empty($prefillById)) { $prefillById = ''; } @endphp
|
@php if(empty($prefillById)) { $prefillById = ''; } @endphp
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
|
@once
|
||||||
@push('componentScripts')
|
@push('componentScripts')
|
||||||
<script src="{{ $U('/viewjs/components/shoppinglocationpicker.js', true) }}?v={{ $version }}"></script>
|
<script src="{{ $U('/viewjs/components/shoppinglocationpicker.js', true) }}?v={{ $version }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@endonce
|
||||||
|
|
||||||
@php if(empty($prefillByName)) { $prefillByName = ''; } @endphp
|
@php if(empty($prefillByName)) { $prefillByName = ''; } @endphp
|
||||||
@php if(empty($prefillById)) { $prefillById = ''; } @endphp
|
@php if(empty($prefillById)) { $prefillById = ''; } @endphp
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
|
@once
|
||||||
@push('componentScripts')
|
@push('componentScripts')
|
||||||
<script src="{{ $U('/viewjs/components/userfieldsform.js', true) }}?v={{ $version }}"></script>
|
<script src="{{ $U('/viewjs/components/userfieldsform.js', true) }}?v={{ $version }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@endonce
|
||||||
|
|
||||||
@if(count($userfields) > 0)
|
@if(count($userfields) > 0)
|
||||||
|
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
|
@once
|
||||||
@push('componentScripts')
|
@push('componentScripts')
|
||||||
<script src="{{ $U('/viewjs/components/userpicker.js', true) }}?v={{ $version }}"></script>
|
<script src="{{ $U('/viewjs/components/userpicker.js', true) }}?v={{ $version }}"></script>
|
||||||
@endpush
|
@endpush
|
||||||
|
@endonce
|
||||||
|
|
||||||
@php if(empty($prefillByUsername)) { $prefillByUsername = ''; } @endphp
|
@php if(empty($prefillByUsername)) { $prefillByUsername = ''; } @endphp
|
||||||
@php if(empty($prefillByUserId)) { $prefillByUserId = ''; } @endphp
|
@php if(empty($prefillByUserId)) { $prefillByUserId = ''; } @endphp
|
||||||
|
@@ -715,36 +715,6 @@
|
|||||||
<script src="{{ $U('/js/grocy_nightmode.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/js/grocy_nightmode.js?v=', true) }}{{ $version }}"></script>
|
||||||
<script src="{{ $U('/js/grocy_clock.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/js/grocy_clock.js?v=', true) }}{{ $version }}"></script>
|
||||||
@stack('pageScripts')
|
@stack('pageScripts')
|
||||||
|
|
||||||
@php
|
|
||||||
// @stack('componentScripts') maybe contains the components JS file reference multiple times
|
|
||||||
// if the component was included more than once in the view
|
|
||||||
//
|
|
||||||
// So this is a ugly hack to keep only unique JS file references there
|
|
||||||
|
|
||||||
// The property is normally protected, so change that
|
|
||||||
$reflection = new \ReflectionClass($__env);
|
|
||||||
$property = $reflection->getProperty('pushes');
|
|
||||||
$property->setAccessible(true);
|
|
||||||
$env = $property->getValue($__env);
|
|
||||||
|
|
||||||
if (array_key_exists('componentScripts', $env))
|
|
||||||
{
|
|
||||||
// Take every line into a new array, one element per line
|
|
||||||
$filteredStack = array_map(function($value)
|
|
||||||
{
|
|
||||||
return explode("#SEP#", str_replace(array("\n", "\r", "\t"), '#SEP#', trim($value)));
|
|
||||||
}, $env['componentScripts']);
|
|
||||||
|
|
||||||
// Flatten the array into a single one, only keep unique lines, remove empty lines, add a defined new line
|
|
||||||
$filteredStack = preg_filter('/$/', "\n", array_filter(array_unique(array_merge(...$filteredStack))));
|
|
||||||
|
|
||||||
// Write it back
|
|
||||||
$env['componentScripts'] = $filteredStack;
|
|
||||||
$property->setValue($__env, $env);
|
|
||||||
}
|
|
||||||
@endphp
|
|
||||||
|
|
||||||
@stack('componentScripts')
|
@stack('componentScripts')
|
||||||
@hasSection('viewJsName')<script src="{{ $U('/viewjs', true) }}/@yield('viewJsName').js?v={{ $version }}"></script>@endif
|
@hasSection('viewJsName')<script src="{{ $U('/viewjs', true) }}/@yield('viewJsName').js?v={{ $version }}"></script>@endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user