Files

90 lines
2.9 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# План: Порядок файлов вместо Базового radio
**v1.0.106+**
## Суть
Убрать столбец «Базовый» с radio-кнопкой. Вместо этого:
- Первый файл в списке = основной договор (исходная спецификация)
- Порядок файлов определяет последовательность обработки в сравнении
- Перемещение стрелками ↑↓
- Первая строка визуально выделена
## UI (index.cfm)
### Столбцы
`Имя | Изменён | Размер | Парсинг | ↕ | Текст | ✕`
### Строка
```html
<tr class="first-row"> <!-- если первая -->
<td>имя</td>
<td>дата</td>
<td>размер</td>
<td>статус</td>
<td>
<button onclick="moveUp(i)" [disabled если первая]></button>
<button onclick="moveDown(i)" [disabled если последняя]></button>
</td>
<td><button onclick="showText(i)">Текст</button></td>
<td><button onclick="removeFile(i)"></button></td>
</tr>
```
### CSS
```css
.first-row td { background: rgba(37,99,235,.05); font-weight: 600; }
.arrow-btn { cursor: pointer; color: var(--muted); background: none; border: none; padding: 2px 4px; font-size: 12px; }
.arrow-btn:hover { color: var(--brand-primary); }
.arrow-btn:disabled { opacity: .3; cursor: default; }
```
### JS
```js
function moveUp(i) {
if (i <= 0) return;
var tmp = fileQueue[i]; fileQueue[i] = fileQueue[i-1]; fileQueue[i-1] = tmp;
renderTable();
}
function moveDown(i) {
if (i >= fileQueue.length - 1) return;
var tmp = fileQueue[i]; fileQueue[i] = fileQueue[i+1]; fileQueue[i+1] = tmp;
renderTable();
}
```
## Бэкенд (convert_server.py)
### Передача порядка
EventSource URL: `/process-v2?contract_id=X&order=sid1,sid2,sid3`
### Обработка
В `_handle_process_v2`:
- Если есть `order` — обрабатывать supplements в этом порядке
- Если нет — `ORDER BY created_at` (как сейчас)
```python
order = params.get("order", [None])[0]
if order:
ordered_ids = order.split(",")
# Переупорядочить supps по ordered_ids
supps.sort(key=lambda s: ordered_ids.index(s["id"]) if s["id"] in ordered_ids else 999)
```
### UI — построение order
```js
var order = fileQueue.map(function(f) { return f.supp_id; }).filter(Boolean).join(',');
var es = new EventSource('/process-v2?contract_id=' + contractId + '&order=' + order);
```
## Что убрать
- `<th>Базовый</th>` из заголовка
- Radio-кнопки из строк
- `setInitial()` JS-функцию
- `action=set_initial` в api.cfm (опционально, не мешает)
## Приоритет
Сделать когда вернём все security-фиксы и деплой заработает.