feat(ui): render the Scene panel's shot list and scene options as components

SceneShotList and SceneOptions render the project from a gev-scenes
store instead of scenePresentation building rows with createElement.
SceneControls stays the owner: it publishes the director's state and
attaches the row actions, and a late destroy cannot detach a newer
owner. Rows keep their identity across selection; a rename keeps its
typed text across republishing and ends with its row. The select still
changes its choice only when its options are rendered.

Vue keeps whitespace in every component, so Prettier formats single-file
components with strict whitespace sensitivity, and the test loader parses
templates with the same options as the browser build. The i18n check
reads view text without its interpolations, whose t() calls are scanned
with the sources.
This commit is contained in:
Sameh Khamis committed 2026-10-30 18:13:11 -07:00
1 parent 6802c9c8b0
commit d9fdcfc641
13 files changed
+518 -306

No files matched your search

+7 -2
View File
@@ -1,3 +1,8 @@
<script setup>
import SceneOptions from './SceneOptions.vue';
import SceneShotList from './SceneShotList.vue';
</script>
<template>
<div id="left-panel-stack">
<!-- Data Layer Toggle Panel -->
@@ -154,7 +159,7 @@
</div>
<p class="scene-step-heading" data-i18n>SCENE</p>
<div class="scene-controls">
<select class="gev-field" id="scene-select" aria-label="Scene" data-i18n-aria-label></select>
<select class="gev-field" id="scene-select" aria-label="Scene" data-i18n-aria-label><SceneOptions /></select>
<button id="scene-new-btn" type="button" class="gev-action-button scene-btn" title="Start a new, empty scene" data-i18n data-i18n-title>NEW SCENE</button>
<button id="scene-delete-btn" type="button" class="gev-action-button gev-action-button--danger scene-btn scene-btn-danger" title="Delete this scene and all of its shots" data-i18n data-i18n-title>DELETE</button>
</div>
@@ -163,7 +168,7 @@
<button id="scene-capture-btn" type="button" class="gev-action-button scene-btn scene-btn-primary" title="Add the current view, style and layers as the next shot" data-i18n data-i18n-title>+ CAPTURE SHOT</button>
<button id="scene-update-shot-btn" type="button" class="gev-action-button scene-btn" title="Replace the selected shot with the current view" data-i18n data-i18n-title>UPDATE SHOT</button>
</div>
<div id="scene-shot-list" class="scene-shot-list"></div>
<SceneShotList />
<p class="scene-shot-hint" data-i18n>Click a shot to select it, double-click to rename.</p>
<p class="scene-step-heading" data-i18n>PREVIEW</p>
<div class="scene-controls">
+17
View File
@@ -0,0 +1,17 @@
<script setup>
import { storeToRefs } from 'pinia';
import { useSceneStore } from '../stores/scenes.js';
// The Scene select's options; selecting one stays with SceneControls.
const { scenes, listedSceneId } = storeToRefs(useSceneStore());
</script>
<template>
<option
v-for="scene in scenes"
:key="scene.id"
:value="scene.id"
:selected="scene.id === listedSceneId"
>{{ scene.title }}</option
>
</template>
+122
View File
@@ -0,0 +1,122 @@
<script setup>
import { computed, nextTick, ref, watch } from 'vue';
import { storeToRefs } from 'pinia';
import { t } from '../../i18n/index.js';
import { describeShot } from '../scenePresentation.js';
import { useSceneStore } from '../stores/scenes.js';
// The selected scene's shots. Rows keep their identity across selection so a
// click followed by a double-click lands on the same label.
const store = useSceneStore();
const { scenes, selectedSceneId, selectedShotId, attached } =
storeToRefs(store);
const scene = computed(
() => scenes.value.find((item) => item.id === selectedSceneId.value) ?? null,
);
/** The row being renamed, with the scene it was shown in. */
const editing = ref(null);
const renameInput = ref(null);
// A rename ends with its row: another scene, a deleted shot or no owner.
watch([scene, attached], () => {
if (
editing.value &&
!(
attached.value &&
scene.value?.id === editing.value.sceneId &&
scene.value.shots.some((shot) => shot.id === editing.value.shotId)
)
)
editing.value = null;
});
// Built-in titles arrive localized as displayTitle; the stored title stays
// English, so a rename happens only when the shown text changes.
const shownTitle = (shot) => shot.displayTitle || shot.title;
const isEditing = (shot) => editing.value?.shotId === shot.id;
function act(name, shot, ...args) {
if (scene.value) store.act(name, scene.value.id, shot.id, ...args);
}
async function startRename(shot) {
if (isEditing(shot) || !scene.value) return;
editing.value = { sceneId: scene.value.id, shotId: shot.id };
await nextTick();
const input = renameInput.value?.[0];
if (!input) return;
// Set once: a re-render while typing keeps what was typed.
input.value = shownTitle(shot);
input.focus();
input.select();
}
function finishRename(shot, input, save) {
const rename = editing.value;
if (rename?.shotId !== shot.id) return;
editing.value = null;
const title = input.value.trim();
if (save && title && title !== shownTitle(shot))
store.act('rename', rename.sceneId, shot.id, title);
}
function onRenameKey(shot, event) {
event.stopPropagation();
if (event.key === 'Enter' || event.key === 'Escape') {
event.preventDefault();
finishRename(shot, event.target, event.key === 'Enter');
}
}
</script>
<template>
<div id="scene-shot-list" class="scene-shot-list">
<template v-if="attached">
<div v-if="!scene?.shots.length" class="scene-shot-empty">{{
t('No shots yet. Use CAPTURE SHOT to save current look.')
}}</div>
<template v-else>
<div
v-for="shot in scene.shots"
:key="shot.id"
class="scene-shot-row"
:class="{ active: shot.id === selectedShotId }"
:data-scene-shot-id="shot.id"
>
<div class="scene-shot-top">
<div
class="scene-shot-label"
:title="t('Double-click to rename')"
@click="store.act('select', shot.id)"
@dblclick="startRename(shot)"
><input
v-if="isEditing(shot)"
ref="renameInput"
type="text"
class="scene-shot-rename"
:aria-label="t('Shot name')"
@keydown="onRenameKey(shot, $event)"
@blur="finishRename(shot, $event.target, true)"
/><template v-else>{{ shownTitle(shot) }}</template></div
>
<div class="scene-shot-actions">
<button
type="button"
class="gev-action-button gev-action-button--compact scene-shot-btn"
@click="act('load', shot)"
>{{ t('LOAD') }}</button
>
<button
type="button"
class="gev-action-button gev-action-button--danger gev-action-button--compact scene-shot-btn scene-shot-danger"
@click="act('remove', shot)"
>{{ t('DEL') }}</button
>
</div>
</div>
<div class="scene-shot-meta">{{ describeShot(shot) }}</div>
</div>
</template>
</template>
</div>
</template>