feat: add auto-name generation to all remaining creation modals
Some checks failed
Lint & Test / test (push) Failing after 27s
Some checks failed
Lint & Test / test (push) Failing after 27s
Audio sources: type + device/parent/channel/band detail Weather sources: provider + coordinates (updates on geolocation) Sync clocks: "Sync Clocks · Nx" (updates on speed slider) Automations: scene name + condition count/logic Scene presets: "Scenes · N targets" (updates on add/remove) Pattern templates: "Pattern Templates · N rects" (updates on add/remove) All follow the same pattern: name auto-generates on create, stops when user manually edits the name field.
This commit is contained in:
@@ -13,6 +13,17 @@ import { TagInput, renderTagChips } from '../core/tag-input.ts';
|
||||
import { loadPictureSources } from './streams.ts';
|
||||
import type { SyncClock } from '../types.ts';
|
||||
|
||||
// ── Auto-name ──
|
||||
|
||||
let _scNameManuallyEdited = false;
|
||||
|
||||
function _autoGenerateSyncClockName() {
|
||||
if (_scNameManuallyEdited) return;
|
||||
if ((document.getElementById('sync-clock-id') as HTMLInputElement).value) return;
|
||||
const speed = parseFloat((document.getElementById('sync-clock-speed') as HTMLInputElement).value) || 1.0;
|
||||
(document.getElementById('sync-clock-name') as HTMLInputElement).value = `${t('sync_clock.group.title')} · ${speed}x`;
|
||||
}
|
||||
|
||||
// ── Modal ──
|
||||
|
||||
let _syncClockTagsInput: TagInput | null = null;
|
||||
@@ -62,6 +73,12 @@ export async function showSyncClockModal(editData: SyncClock | null): Promise<vo
|
||||
_syncClockTagsInput = new TagInput(document.getElementById('sync-clock-tags-container'), { placeholder: t('tags.placeholder') });
|
||||
_syncClockTagsInput.setValue(isEdit ? (editData.tags || []) : []);
|
||||
|
||||
// Auto-name wiring
|
||||
_scNameManuallyEdited = isEdit;
|
||||
(document.getElementById('sync-clock-name') as HTMLElement).oninput = () => { _scNameManuallyEdited = true; };
|
||||
(document.getElementById('sync-clock-speed') as HTMLElement).oninput = () => _autoGenerateSyncClockName();
|
||||
if (!isEdit) _autoGenerateSyncClockName();
|
||||
|
||||
syncClockModal.open();
|
||||
syncClockModal.snapshot();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user