v1.0.178: группировка по ZIP в renderFiles — заголовок-секция 📦 + отступ 24px для вложенных файлов
This commit is contained in:
+50
-7
@@ -53,10 +53,51 @@ function statusToHTML(st) {
|
|||||||
function renderFiles(state) {
|
function renderFiles(state) {
|
||||||
if (state.files.length === 0) {
|
if (state.files.length === 0) {
|
||||||
fileTable.innerHTML = '<tr class="empty-row"><td colspan="7">Нет файлов — выберите .docx / .pdf</td></tr>';
|
fileTable.innerHTML = '<tr class="empty-row"><td colspan="7">Нет файлов — выберите .docx / .pdf</td></tr>';
|
||||||
} else {
|
lucide.createIcons();
|
||||||
fileTable.innerHTML = state.files.map(function(f, i) {
|
return;
|
||||||
var rows = '<tr id="row_' + i + '">' +
|
}
|
||||||
'<td class="name-cell" style="cursor:pointer;" onclick="toggleClassifyDetail(' + i + ')">' +
|
|
||||||
|
// Сгруппировать файлы по zip_source
|
||||||
|
var groups = []; // [{zip: "name.zip"|null, files: [f, ...]}]
|
||||||
|
var seen = {};
|
||||||
|
for (var i = 0; i < state.files.length; i++) {
|
||||||
|
var f = state.files[i];
|
||||||
|
var zip = f.zip_source || null;
|
||||||
|
var key = zip || '__naked__';
|
||||||
|
if (!seen[key]) {
|
||||||
|
seen[key] = { zip: zip, files: [] };
|
||||||
|
groups.push(seen[key]);
|
||||||
|
}
|
||||||
|
// Сохраняем оригинальный индекс для id строк
|
||||||
|
f._idx = i;
|
||||||
|
seen[key].files.push(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Рендер: заголовок ZIP → файлы с отступом
|
||||||
|
var rows = [];
|
||||||
|
for (var gi = 0; gi < groups.length; gi++) {
|
||||||
|
var g = groups[gi];
|
||||||
|
|
||||||
|
if (g.zip) {
|
||||||
|
// Заголовок-секция ZIP
|
||||||
|
rows.push(
|
||||||
|
'<tr class="zip-header" style="background:var(--brand-grey-light);">' +
|
||||||
|
'<td colspan="7" style="padding:6px 12px;font-size:12px;font-weight:600;">' +
|
||||||
|
'📦 ' + escHtml(g.zip) + ' — ' + g.files.length + ' файл.' +
|
||||||
|
(g.files.length === 1 ? '' : 'ов') +
|
||||||
|
'</td></tr>'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Файлы внутри группы (с отступом если из ZIP)
|
||||||
|
for (var fi = 0; fi < g.files.length; fi++) {
|
||||||
|
var f = g.files[fi];
|
||||||
|
var i = f._idx;
|
||||||
|
var indent = g.zip ? 'padding-left:24px;' : '';
|
||||||
|
|
||||||
|
rows.push(
|
||||||
|
'<tr id="row_' + i + '">' +
|
||||||
|
'<td class="name-cell" style="cursor:pointer;' + indent + '" onclick="toggleClassifyDetail(' + i + ')">' +
|
||||||
(f.doc_id ? '<span id="expand_' + i + '" style="font-size:10px;margin-right:4px;">▸</span>' : '') +
|
(f.doc_id ? '<span id="expand_' + i + '" style="font-size:10px;margin-right:4px;">▸</span>' : '') +
|
||||||
escHtml(f.name) + '</td>' +
|
escHtml(f.name) + '</td>' +
|
||||||
'<td style="font-size:12px;color:var(--muted);">' + formatDate(f.lastModified) + '</td>' +
|
'<td style="font-size:12px;color:var(--muted);">' + formatDate(f.lastModified) + '</td>' +
|
||||||
@@ -65,10 +106,12 @@ function renderFiles(state) {
|
|||||||
'<td><button class="info-btn' + (f.doc_id ? ' visible' : '') + '" onclick="showText(' + i + ')" title="Текст / Распарсено"><i data-lucide="file-text" style="width:16px;height:16px;"></i></button></td>' +
|
'<td><button class="info-btn' + (f.doc_id ? ' visible' : '') + '" onclick="showText(' + i + ')" title="Текст / Распарсено"><i data-lucide="file-text" style="width:16px;height:16px;"></i></button></td>' +
|
||||||
'<td><button class="remove-btn" onclick="removeFile(' + i + ')" title="Удалить"><i data-lucide="trash-2" style="width:16px;height:16px;"></i></button></td>' +
|
'<td><button class="remove-btn" onclick="removeFile(' + i + ')" title="Удалить"><i data-lucide="trash-2" style="width:16px;height:16px;"></i></button></td>' +
|
||||||
'</tr>' +
|
'</tr>' +
|
||||||
'<tr id="detail_' + i + '" style="display:none;"><td colspan="7" style="padding:4px 12px;font-size:11px;background:var(--brand-grey-light);"><span style="color:var(--muted);">Загрузка...</span></td></tr>';
|
'<tr id="detail_' + i + '" style="display:none;"><td colspan="7" style="padding:4px 12px;font-size:11px;background:var(--brand-grey-light);"><span style="color:var(--muted);">Загрузка...</span></td></tr>'
|
||||||
return rows;
|
);
|
||||||
}).join('');
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fileTable.innerHTML = rows.join('');
|
||||||
lucide.createIcons();
|
lucide.createIcons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user