diff --git a/views/components/barcodescanner.blade.php b/views/components/barcodescanner.blade.php index cd18a70c..8031e8c0 100644 --- a/views/components/barcodescanner.blade.php +++ b/views/components/barcodescanner.blade.php @@ -1,13 +1,17 @@ @if (!GROCY_DISABLE_BROWSER_BARCODE_CAMERA_SCANNING) +@once @push('componentScripts') @endpush +@endonce +@once @push('pageScripts') @endpush +@endonce @push('pageStyles') @endpush diff --git a/views/components/batterycard.blade.php b/views/components/batterycard.blade.php index 09bc336f..14106591 100644 --- a/views/components/batterycard.blade.php +++ b/views/components/batterycard.blade.php @@ -1,6 +1,8 @@ +@once @push('componentScripts') @endpush +@endonce
diff --git a/views/components/calendarcard.blade.php b/views/components/calendarcard.blade.php index bbde0cb2..bd155f91 100644 --- a/views/components/calendarcard.blade.php +++ b/views/components/calendarcard.blade.php @@ -1,6 +1,8 @@ +@once @push('componentScripts') @endpush +@endonce
diff --git a/views/components/chorecard.blade.php b/views/components/chorecard.blade.php index ec8dcd67..9163bee4 100644 --- a/views/components/chorecard.blade.php +++ b/views/components/chorecard.blade.php @@ -1,6 +1,8 @@ +@once @push('componentScripts') @endpush +@endonce
diff --git a/views/components/datetimepicker.blade.php b/views/components/datetimepicker.blade.php index 9e5ac05f..5d111e94 100644 --- a/views/components/datetimepicker.blade.php +++ b/views/components/datetimepicker.blade.php @@ -1,6 +1,8 @@ +@once @push('componentScripts') @endpush +@endonce @php if(!isset($isRequired)) { $isRequired = true; } @endphp @php if(!isset($initialValue)) { $initialValue = ''; } @endphp diff --git a/views/components/datetimepicker2.blade.php b/views/components/datetimepicker2.blade.php index e44977f1..e75c7d31 100644 --- a/views/components/datetimepicker2.blade.php +++ b/views/components/datetimepicker2.blade.php @@ -1,6 +1,8 @@ +@once @push('componentScripts') @endpush +@endonce @php if(!isset($isRequired)) { $isRequired = true; } @endphp @php if(!isset($initialValue)) { $initialValue = ''; } @endphp diff --git a/views/components/locationpicker.blade.php b/views/components/locationpicker.blade.php index 71cf70b9..e83d929e 100644 --- a/views/components/locationpicker.blade.php +++ b/views/components/locationpicker.blade.php @@ -1,6 +1,8 @@ +@once @push('componentScripts') @endpush +@endonce @php if(empty($prefillByName)) { $prefillByName = ''; } @endphp @php if(empty($prefillById)) { $prefillById = ''; } @endphp diff --git a/views/components/numberpicker.blade.php b/views/components/numberpicker.blade.php index 4eceda4f..1d0822b8 100644 --- a/views/components/numberpicker.blade.php +++ b/views/components/numberpicker.blade.php @@ -1,6 +1,8 @@ +@once @push('componentScripts') @endpush +@endonce @php if(!isset($value)) { $value = 1; } @endphp @php if(empty($min)) { $min = 0; } @endphp diff --git a/views/components/productamountpicker.blade.php b/views/components/productamountpicker.blade.php index 276d769b..74769ee0 100644 --- a/views/components/productamountpicker.blade.php +++ b/views/components/productamountpicker.blade.php @@ -1,6 +1,8 @@ +@once @push('componentScripts') @endpush +@endonce @php if(empty($additionalGroupCssClasses)) { $additionalGroupCssClasses = ''; } @endphp @php if(empty($additionalHtmlContextHelp)) { $additionalHtmlContextHelp = ''; } @endphp diff --git a/views/components/productcard.blade.php b/views/components/productcard.blade.php index f159af70..7fc24c76 100644 --- a/views/components/productcard.blade.php +++ b/views/components/productcard.blade.php @@ -1,7 +1,9 @@ +@once @push('componentScripts') @endpush +@endonce
diff --git a/views/components/productpicker.blade.php b/views/components/productpicker.blade.php index 0a93c550..a48ff463 100644 --- a/views/components/productpicker.blade.php +++ b/views/components/productpicker.blade.php @@ -1,6 +1,8 @@ +@once @push('componentScripts') @endpush +@endonce @php if(empty($disallowAddProductWorkflows)) { $disallowAddProductWorkflows = false; } @endphp @php if(empty($disallowAllProductWorkflows)) { $disallowAllProductWorkflows = false; } @endphp diff --git a/views/components/recipepicker.blade.php b/views/components/recipepicker.blade.php index dccf71fa..ef70a8ab 100644 --- a/views/components/recipepicker.blade.php +++ b/views/components/recipepicker.blade.php @@ -1,6 +1,8 @@ +@once @push('componentScripts') @endpush +@endonce @php if(empty($prefillByName)) { $prefillByName = ''; } @endphp @php if(empty($prefillById)) { $prefillById = ''; } @endphp diff --git a/views/components/shoppinglocationpicker.blade.php b/views/components/shoppinglocationpicker.blade.php index 17624786..fe3e4ce2 100644 --- a/views/components/shoppinglocationpicker.blade.php +++ b/views/components/shoppinglocationpicker.blade.php @@ -1,6 +1,8 @@ +@once @push('componentScripts') @endpush +@endonce @php if(empty($prefillByName)) { $prefillByName = ''; } @endphp @php if(empty($prefillById)) { $prefillById = ''; } @endphp diff --git a/views/components/userfieldsform.blade.php b/views/components/userfieldsform.blade.php index 73809fbe..becb74ce 100644 --- a/views/components/userfieldsform.blade.php +++ b/views/components/userfieldsform.blade.php @@ -1,6 +1,8 @@ +@once @push('componentScripts') @endpush +@endonce @if(count($userfields) > 0) diff --git a/views/components/userpicker.blade.php b/views/components/userpicker.blade.php index 8ab6dcd9..d532638c 100644 --- a/views/components/userpicker.blade.php +++ b/views/components/userpicker.blade.php @@ -1,6 +1,8 @@ +@once @push('componentScripts') @endpush +@endonce @php if(empty($prefillByUsername)) { $prefillByUsername = ''; } @endphp @php if(empty($prefillByUserId)) { $prefillByUserId = ''; } @endphp diff --git a/views/layout/default.blade.php b/views/layout/default.blade.php index 0ee3a4c5..b786f41d 100644 --- a/views/layout/default.blade.php +++ b/views/layout/default.blade.php @@ -715,36 +715,6 @@ @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') @hasSection('viewJsName')@endif