feat: типы конфигураций из qt_settings в модалке проекта, копия сохраняет config_type

- модалка «Новая конфигурация в проекте» строит кнопки типа из
  qt_settings.config_types (новый тип «Сеть» появляется без релиза);
- ручная полная синхронизация (/api/sync/all) тянет qt_settings;
- копирование конфигурации (в т.ч. из версии) сохраняет config_type —
  раньше копия СХД/сети становилась «сервером».

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Mikhail ChusavitinandClaude Opus 5.5 committed 2026-09-24 16:59:42 +03:00
1 parent 54a7c7cc8d
commit a939a5f36c
5 files changed
+109 -10

No files matched your search

+40 -7
View File
@@ -82,12 +82,12 @@
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Тип оборудования</label>
<div class="inline-flex rounded-lg border border-gray-200 overflow-hidden w-full">
<button type="button" id="pd-type-server-btn" onclick="pdSetCreateType('server')"
<div id="pd-config-type-buttons" class="inline-flex rounded-lg border border-gray-200 overflow-hidden w-full">
<button type="button" data-type="server" onclick="pdSetCreateType('server')"
class="flex-1 py-2 text-sm font-medium bg-blue-600 text-white">
Сервер
</button>
<button type="button" id="pd-type-storage-btn" onclick="pdSetCreateType('storage')"
<button type="button" data-type="storage" onclick="pdSetCreateType('storage')"
class="flex-1 py-2 text-sm font-medium bg-white text-gray-700 hover:bg-gray-50 border-l border-gray-200">
СХД
</button>
@@ -626,17 +626,50 @@ async function loadConfigs() {
let pdCreateConfigType = 'server';
let pdConfigTypesLoaded = false;
// Config types come from qt_settings.config_types (server-driven, see
// bible-local/server-contract-qt-settings.md); the two static buttons in the
// markup are only a fallback until/unless the settings load.
async function pdLoadConfigTypeButtons() {
if (pdConfigTypesLoaded) return;
let types = null;
try {
const r = await fetch('/api/configurator-settings');
if (r.ok) types = (await r.json()).config_types;
} catch (e) { /* keep static fallback buttons */ }
if (!Array.isArray(types) || !types.length) return;
const el = document.getElementById('pd-config-type-buttons');
if (!el) return;
el.replaceChildren(...[...types]
.sort((a, b) => (a.display_order || 0) - (b.display_order || 0))
.map(t => {
const btn = document.createElement('button');
btn.type = 'button';
btn.dataset.type = t.code;
btn.textContent = t.name_ru || t.code;
btn.addEventListener('click', () => pdSetCreateType(t.code));
return btn;
}));
pdConfigTypesLoaded = true;
const codes = types.map(t => t.code);
pdSetCreateType(codes.includes(pdCreateConfigType) ? pdCreateConfigType : codes[0]);
}
function pdSetCreateType(type) {
pdCreateConfigType = type;
document.getElementById('pd-type-server-btn').className = 'flex-1 py-2 text-sm font-medium ' +
(type === 'server' ? 'bg-blue-600 text-white' : 'bg-white text-gray-700 hover:bg-gray-50');
document.getElementById('pd-type-storage-btn').className = 'flex-1 py-2 text-sm font-medium border-l border-gray-200 ' +
(type === 'storage' ? 'bg-blue-600 text-white' : 'bg-white text-gray-700 hover:bg-gray-50');
document.querySelectorAll('#pd-config-type-buttons button').forEach((btn, i) => {
const active = btn.dataset.type === type;
btn.className = 'flex-1 py-2 text-sm font-medium ' +
(i > 0 ? 'border-l border-gray-200 ' : '') +
(active ? 'bg-blue-600 text-white' : 'bg-white text-gray-700 hover:bg-gray-50');
});
}
function openCreateModal() {
pdCreateConfigType = 'server';
pdSetCreateType('server');
pdLoadConfigTypeButtons();
document.getElementById('create-name').value = '';
document.getElementById('create-modal').classList.remove('hidden');
document.getElementById('create-modal').classList.add('flex');