Fix: Mehrfachauswahl bei Routen-Fotos (multiple attribute + loop)

This commit is contained in:
rene 2026-04-19 11:31:38 +02:00
parent 3144e100f3
commit 9ba78f3b16
2 changed files with 10 additions and 9 deletions

View file

@ -3,7 +3,7 @@
Router, State-Management, Navigation, Initialisierung.
============================================================ */
const APP_VER = '227'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
const APP_VER = '228'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen
const App = (() => {

View file

@ -705,12 +705,12 @@ window.Page_routes = (() => {
${photos.map(u => `<img src="${UI.escape(u)}" class="rk-photo-thumb" onclick="window.open('${UI.escape(u)}','_blank')">`).join('')}
${isOwn ? `<label class="rk-photo-add" title="Foto hinzufügen">
<span>+</span>
<input type="file" id="rk-photo-input" accept="image/*" style="display:none">
<input type="file" id="rk-photo-input" accept="image/*" multiple style="display:none">
</label>` : ''}
</div>` :
isOwn ? `<label class="rk-photo-add-empty">
${UI.icon('camera')} Foto hinzufügen
<input type="file" id="rk-photo-input" accept="image/*" style="display:none">
<input type="file" id="rk-photo-input" accept="image/*" multiple style="display:none">
</label>` : '';
const body = `
@ -853,13 +853,14 @@ window.Page_routes = (() => {
// Foto-Upload
document.getElementById('rk-photo-input')?.addEventListener('change', async e => {
const file = e.target.files?.[0];
if (!file) return;
const files = Array.from(e.target.files || []);
if (!files.length) return;
try {
const res = await API.routes.addPhoto(route.id, file);
route.foto_urls = res.foto_urls;
UI.toast.success('Foto gespeichert!');
// Reload detail
for (const file of files) {
const res = await API.routes.addPhoto(route.id, file);
route.foto_urls = res.foto_urls;
}
UI.toast.success(files.length > 1 ? `${files.length} Fotos gespeichert!` : 'Foto gespeichert!');
UI.modal.close();
setTimeout(() => _openDetail(route.id), 200);
} catch (err) { UI.toast.error(err.message); }