Dieser Commit ist enthalten in:
hendrik_gebhardt@gmx.de
2026-01-10 10:32:52 +00:00
committet von Server Deploy
Ursprung 7d67557be4
Commit ef153789cc
20 geänderte Dateien mit 13613 neuen und 333 gelöschten Zeilen

Datei anzeigen

@ -18,6 +18,7 @@ class KnowledgeManager {
this.expandedEntries = new Set();
this.initialized = false;
this.searchDebounceTimer = null;
this.pendingFiles = null;
// Drag & Drop State
this.draggedCategoryId = null;
@ -140,6 +141,14 @@ class KnowledgeManager {
// File Upload
this.fileInput?.addEventListener('change', (e) => this.handleFileSelect(e));
// Click on file upload area to trigger file input
this.fileUploadArea?.addEventListener('click', (e) => {
// Don't trigger if clicking on the label (it has its own handler)
if (!e.target.closest('.file-input-label')) {
this.fileInput?.click();
}
});
// Drag & Drop for file upload
if (this.fileUploadArea) {
@ -382,8 +391,8 @@ class KnowledgeManager {
<div class="knowledge-attachment-item" data-attachment-id="${att.id}">
<svg viewBox="0 0 24 24" width="18" height="18"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" stroke="currentColor" stroke-width="2" fill="none"/><path d="M14 2v6h6" stroke="currentColor" stroke-width="2" fill="none"/></svg>
<div class="knowledge-attachment-info">
<span class="knowledge-attachment-name">${this.escapeHtml(att.original_name)}</span>
<span class="knowledge-attachment-size">${this.formatFileSize(att.size_bytes)}</span>
<span class="knowledge-attachment-name">${this.escapeHtml(att.originalName || att.original_name || '')}</span>
<span class="knowledge-attachment-size">${this.formatFileSize(att.sizeBytes || att.size_bytes || 0)}</span>
</div>
<div class="knowledge-attachment-actions">
<a href="${api.getKnowledgeAttachmentDownloadUrl(att.id)}" class="btn-icon" title="Herunterladen" download>
@ -957,7 +966,8 @@ class KnowledgeManager {
this.entryModalTitle.textContent = isEdit ? 'Eintrag bearbeiten' : 'Neuer Eintrag';
this.entryForm?.reset();
this.deleteEntryBtn?.classList.toggle('hidden', !isEdit);
this.attachmentsSection.style.display = isEdit ? 'block' : 'none';
// Show attachments section always, but with a note for new entries
this.attachmentsSection.style.display = 'block';
if (isEdit) {
const entry = await this.loadEntryWithAttachments(entryId);
@ -972,7 +982,7 @@ class KnowledgeManager {
} else {
this.entryIdInput.value = '';
this.entryCategoryIdInput.value = this.selectedCategory?.id || '';
this.attachmentsContainer.innerHTML = '';
this.attachmentsContainer.innerHTML = '<p class="text-muted" style="text-align: center; padding: 20px; color: var(--text-secondary); font-size: var(--text-sm);">Speichern Sie zuerst den Eintrag, um Dateien hochzuladen.</p>';
}
this.openModal(this.entryModal, 'knowledge-entry-modal');
@ -1010,8 +1020,15 @@ class KnowledgeManager {
await api.updateKnowledgeEntry(entryId, data);
this.showToast('Eintrag aktualisiert', 'success');
} else {
await api.createKnowledgeEntry(data);
const newEntry = await api.createKnowledgeEntry(data);
this.showToast('Eintrag erstellt', 'success');
// If there are pending files, upload them now
if (this.pendingFiles && this.pendingFiles.length > 0) {
this.showToast('Lade Dateien hoch...', 'info');
await this.uploadFiles(this.pendingFiles);
this.pendingFiles = null;
}
}
this.closeEntryModal();
@ -1071,7 +1088,10 @@ class KnowledgeManager {
async uploadFiles(files) {
const entryId = parseInt(this.entryIdInput?.value);
if (!entryId) {
this.showToast('Bitte zuerst den Eintrag speichern', 'error');
// For new entries, show a more helpful message
this.showToast('Speichern Sie zuerst den Eintrag, dann können Sie Dateien hochladen', 'info');
// Store files temporarily to upload after save
this.pendingFiles = files;
return;
}