Add dirty check to all remaining editor modals

Subclass Modal with snapshotValues() for: value source editor, audio
source editor, add device, profile editor, capture template, stream
editor, and PP template modals. Close/cancel now triggers discard
confirmation when form has unsaved changes. Document the convention
in CLAUDE.md.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-24 18:12:30 +03:00
parent 053a56eed3
commit e4c4301a7b
6 changed files with 201 additions and 32 deletions

View File

@@ -17,7 +17,22 @@ import { showToast, showConfirm } from '../core/ui.js';
import { Modal } from '../core/modal.js';
import { loadPictureSources } from './streams.js';
const audioSourceModal = new Modal('audio-source-modal');
class AudioSourceModal extends Modal {
constructor() { super('audio-source-modal'); }
snapshotValues() {
return {
name: document.getElementById('audio-source-name').value,
description: document.getElementById('audio-source-description').value,
type: document.getElementById('audio-source-type').value,
device: document.getElementById('audio-source-device').value,
parent: document.getElementById('audio-source-parent').value,
channel: document.getElementById('audio-source-channel').value,
};
}
}
const audioSourceModal = new AudioSourceModal();
// ── Modal ─────────────────────────────────────────────────────
@@ -60,10 +75,11 @@ export async function showAudioSourceModal(sourceType, editData) {
}
audioSourceModal.open();
audioSourceModal.snapshot();
}
export function closeAudioSourceModal() {
audioSourceModal.forceClose();
export async function closeAudioSourceModal() {
await audioSourceModal.close();
}
export function onAudioSourceTypeChange() {