April 2026 waren Wirtschaft Feedback
This commit is contained in:
parent
02f2a4c23e
commit
9ce711d6b2
167 changed files with 25278 additions and 8518 deletions
|
|
@ -0,0 +1,79 @@
|
|||
<script>
|
||||
(function ($) {
|
||||
function toggleBlocks() {
|
||||
var t = $('#entry_type').val();
|
||||
var isIng = t === 'ingredient';
|
||||
$('#stock-entry-ingredient-block').toggle(isIng);
|
||||
$('#stock-entry-packaging-block').toggle(!isIng);
|
||||
$('#price-per-kg-block').toggle(isIng);
|
||||
$('#price-total-block').toggle(!isIng);
|
||||
}
|
||||
|
||||
function initIngredientSelect2() {
|
||||
var $el = $('#ingredient_id');
|
||||
if ($el.data('select2')) {
|
||||
$el.select2('destroy');
|
||||
}
|
||||
$el.select2({
|
||||
theme: 'default',
|
||||
width: '100%',
|
||||
placeholder: '{{ __('Inhaltsstoff suchen…') }}',
|
||||
allowClear: true,
|
||||
ajax: {
|
||||
url: $el.data('search-url'),
|
||||
dataType: 'json',
|
||||
delay: 250,
|
||||
data: function (params) {
|
||||
return {q: params.term || ''};
|
||||
},
|
||||
processResults: function (data) {
|
||||
return {results: data.results || []};
|
||||
},
|
||||
cache: true
|
||||
},
|
||||
minimumInputLength: 1
|
||||
});
|
||||
}
|
||||
|
||||
function initPackagingSelect2() {
|
||||
var $el = $('#packaging_item_id');
|
||||
if ($el.data('select2')) {
|
||||
$el.select2('destroy');
|
||||
}
|
||||
$el.select2({
|
||||
theme: 'default',
|
||||
width: '100%',
|
||||
placeholder: '{{ __('Verpackungsartikel suchen…') }}',
|
||||
allowClear: true,
|
||||
ajax: {
|
||||
url: $el.data('search-url'),
|
||||
dataType: 'json',
|
||||
delay: 250,
|
||||
data: function (params) {
|
||||
return {
|
||||
q: params.term || '',
|
||||
entry_type: $('#entry_type').val()
|
||||
};
|
||||
},
|
||||
processResults: function (data) {
|
||||
return {results: data.results || []};
|
||||
},
|
||||
cache: true
|
||||
},
|
||||
minimumInputLength: 0
|
||||
});
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
toggleBlocks();
|
||||
initIngredientSelect2();
|
||||
initPackagingSelect2();
|
||||
|
||||
$('#entry_type').on('change', function () {
|
||||
toggleBlocks();
|
||||
$('#packaging_item_id').val(null).trigger('change');
|
||||
initPackagingSelect2();
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
</script>
|
||||
Loading…
Add table
Add a link
Reference in a new issue