Warenwirtschaft: Review-Fix — Indizes + schlanke API-Bestellungen-Seite

Indizes auf shopping_orders.shipped/shipped_at/created_at (Board-Filter,
Tages-Kacheln) und products.wp_number (SKU-Auflösung). Die
API-Bestellungen-Seite lud das komplette JSON-payload für alle 500 Zeilen
und serialisierte es in Inline-Attribute; jetzt persistierte
positions_count, Liste ohne payload, Inhalt on-demand über show-Endpoint.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-07-20 13:02:47 +00:00
parent f4256bfc89
commit 50243a07b4
8 changed files with 172 additions and 20 deletions

View file

@ -73,7 +73,6 @@
<tbody>
@forelse ($logs as $log)
@php
$lines = $log->payload['lines'] ?? [];
$customer = $log->shoppingUser
? trim(($log->shoppingUser->billing_firstname ?? '').' '.($log->shoppingUser->billing_lastname ?? ''))
: '';
@ -93,7 +92,7 @@
<span class="text-muted">—</span>
@endif
</td>
<td class="text-right">{{ count($lines) ?: '—' }}</td>
<td class="text-right">{{ $log->positions_count ?: '—' }}</td>
<td>
@if ($log->has_errors)
<span class="wawi-pill wawi-pill--danger">{{ __('Fehler') }}</span>
@ -106,14 +105,13 @@
</td>
<td class="text-right">
<button type="button" class="btn btn-sm btn-outline-secondary js-api-log-view"
data-url="{{ route('admin.inventory.api-orders.show', $log->id) }}"
data-meta="{{ json_encode([
'received' => $log->created_at->format('d.m.Y H:i'),
'wp_order_number' => $log->wp_order_number,
'customer' => $customer,
'summary' => $log->error_summary,
'raw' => isset($log->payload['raw']) ? json_encode($log->payload['raw'], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) : null,
]) }}"
data-lines="{{ json_encode($lines) }}">
]) }}">
<span class="far fa-eye mr-1"></span>{{ __('Ansehen') }}
</button>
</td>
@ -131,9 +129,9 @@
</tbody>
</table>
</div>
@if (($listLimit ?? null) !== null && $logs->count() >= $listLimit)
@if (($listLimit ?? null) !== null && ($listTotal ?? 0) > $listLimit)
<p class="text-muted small px-3 pb-2 mb-0">
{{ __('Es werden die neuesten :n Übertragungen angezeigt.', ['n' => $listLimit]) }}
{{ __('Es werden die neuesten :n von :total Übertragungen angezeigt.', ['n' => $listLimit, 'total' => $listTotal]) }}
<a href="{{ route('admin.inventory.api-orders.index', ['all' => 1]) }}">{{ __('Alle anzeigen') }}</a>
</p>
@endif
@ -197,17 +195,7 @@
return message;
}
$('.js-api-log-view').on('click', function () {
var meta = $(this).data('meta') || {};
var lines = $(this).data('lines') || [];
$('#api-log-modal-meta').text(
'{{ __('Eingegangen') }}: ' + (meta.received || '—')
+ ' · {{ __('WP-Bestellnr.') }}: ' + (meta.wp_order_number || '—')
+ (meta.customer ? ' · {{ __('Kunde') }}: ' + meta.customer : '')
);
$('#api-log-modal-summary').toggleClass('d-none', !meta.summary).text(meta.summary || '');
function renderLines(lines, raw) {
var $body = $('#api-log-modal-lines').empty();
$('#api-log-modal-lines-wrap').toggleClass('d-none', lines.length === 0);
$.each(lines, function (_, line) {
@ -222,10 +210,26 @@
$tr.append($('<td>').text(messages).addClass(line.failed ? 'text-danger' : 'text-muted'));
$body.append($tr);
});
$('#api-log-modal-raw').toggleClass('d-none', !raw).text(raw || '');
}
$('#api-log-modal-raw').toggleClass('d-none', !meta.raw).text(meta.raw || '');
$('.js-api-log-view').on('click', function () {
var meta = $(this).data('meta') || {};
var url = $(this).data('url');
$('#api-log-modal-meta').text(
'{{ __('Eingegangen') }}: ' + (meta.received || '—')
+ ' · {{ __('WP-Bestellnr.') }}: ' + (meta.wp_order_number || '—')
+ (meta.customer ? ' · {{ __('Kunde') }}: ' + meta.customer : '')
);
$('#api-log-modal-summary').toggleClass('d-none', !meta.summary).text(meta.summary || '');
// Inhalt erst beim Öffnen laden (Review 20.07.2026)
renderLines([], null);
$('#api-log-modal').modal('show');
$.getJSON(url, function (data) {
renderLines(data.lines || [], data.raw || null);
});
});
});
</script>