Fix: Mehrfachauswahl bei Routen-Fotos (multiple attribute + loop)
This commit is contained in:
parent
3144e100f3
commit
9ba78f3b16
2 changed files with 10 additions and 9 deletions
|
|
@ -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); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue