mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Authoring: pick any scene again, and select the first scene on load
Restores the scene picker and its selection on load, after a delete and after an import, so PLAY and NEXT work after a reload. Open in GEV selecting a shot and NEW SCENE stay as they are.
This commit is contained in:
1 parent
1cb3e88027
commit
0a39b05cdb
30 files changed
+301
-210
No files matched your search
@@ -64,7 +64,7 @@ export class SceneControls {
|
||||
this.run(this.actions.reviewImport ? 'reviewImport' : 'import', file),
|
||||
});
|
||||
this.presentPanel({});
|
||||
// Scene and shot titles are shown translated; the scene name and the list
|
||||
// Scene and shot titles are shown translated; the select and the list
|
||||
// show them again.
|
||||
this.offLocale = onLocaleChange(() => {
|
||||
this.presentPanel({ playLabel: t('PLAY', { context: 'scene' }) });
|
||||
@@ -173,9 +173,9 @@ export class SceneControls {
|
||||
}
|
||||
}
|
||||
|
||||
/** Publish the project to the scene name and the SceneShotList view. */
|
||||
/** Publish the project to the SceneOptions and SceneShotList views. */
|
||||
renderSceneSelect() {
|
||||
if (!this.destroyed) this.store.publish(this.read());
|
||||
if (!this.destroyed) this.store.publishOptions(this.read());
|
||||
}
|
||||
|
||||
/** NEW SCENE: ask for a name and create the scene. @returns {boolean} */
|
||||
|
||||
@@ -37,7 +37,7 @@ function fixture() {
|
||||
const byId = (id) => document.getElementById(id);
|
||||
const elements = {
|
||||
panel: byId('scene-panel'),
|
||||
name: byId('scene-name'),
|
||||
select: byId('scene-select'),
|
||||
new: byId('scene-new-btn'),
|
||||
delete: byId('scene-delete-btn'),
|
||||
capture: byId('scene-capture-btn'),
|
||||
@@ -80,6 +80,7 @@ function fixture() {
|
||||
const calls = [];
|
||||
const actions = Object.fromEntries(
|
||||
[
|
||||
'selectScene',
|
||||
'selectShot',
|
||||
'renameShot',
|
||||
'create',
|
||||
@@ -128,8 +129,8 @@ test('Scene controls render the supplied selection and running/download states',
|
||||
const f = fixture();
|
||||
try {
|
||||
await nextTick();
|
||||
assert.equal(f.elements.name.textContent, '<Scene A>');
|
||||
assert.equal(document.getElementById('scene-select'), null);
|
||||
assert.equal(f.elements.select.children[0].textContent, '<Scene A>');
|
||||
assert.equal(f.elements.select.value, 'scene-a');
|
||||
assert.equal(f.label().textContent, '<Shot A>');
|
||||
assert.equal(
|
||||
f.elements.shots.children[0].children[1].textContent,
|
||||
@@ -410,7 +411,6 @@ test('the real director preserves a selected shot label for the following double
|
||||
},
|
||||
});
|
||||
director = new SceneDirector({ camera: { cancelFlight() {} } }, {}, {});
|
||||
director.selectShot('scene-a');
|
||||
await nextTick();
|
||||
const label = f.label();
|
||||
label.click();
|
||||
@@ -432,7 +432,7 @@ test('the real director preserves a selected shot label for the following double
|
||||
}
|
||||
});
|
||||
|
||||
test('the real director names the scene it selects and saves it to Stories', async () => {
|
||||
test('the real director shows the scene it selects and saves it to Stories', async () => {
|
||||
const f = fixture();
|
||||
const previousStorage = globalThis.localStorage;
|
||||
let saved = null;
|
||||
@@ -452,15 +452,12 @@ test('the real director names the scene it selects and saves it to Stories', asy
|
||||
});
|
||||
director = new SceneDirector({ camera: { cancelFlight() {} } }, {}, {});
|
||||
await nextTick();
|
||||
// Nothing is selected on load.
|
||||
assert.equal(f.elements.name.textContent, 'No scene yet');
|
||||
// The first scene is selected on load, as before Stories.
|
||||
assert.equal(f.elements.select.value, 'scene-a');
|
||||
assert.equal(
|
||||
f.elements.shots.querySelectorAll('.scene-shot-row').length,
|
||||
0,
|
||||
1,
|
||||
);
|
||||
director.selectShot('scene-a');
|
||||
await nextTick();
|
||||
assert.equal(f.elements.name.textContent, '<Scene A>');
|
||||
assert.equal(f.elements.stories.textContent, 'SAVE TO STORIES');
|
||||
f.elements.stories.click();
|
||||
await nextTick();
|
||||
@@ -468,10 +465,10 @@ test('the real director names the scene it selects and saves it to Stories', asy
|
||||
assert.equal(f.elements.status.textContent, 'Saved to Stories');
|
||||
assert.equal(f.elements.stories.textContent, 'REMOVE FROM STORIES');
|
||||
|
||||
// Stories' "Open in GEV" selects programmatically; the name follows.
|
||||
// Stories' "Open in GEV" selects programmatically; the select follows.
|
||||
assert.equal(director.selectShot('scene-b'), true);
|
||||
await nextTick();
|
||||
assert.equal(f.elements.name.textContent, 'Scene B');
|
||||
assert.equal(f.elements.select.value, 'scene-b');
|
||||
assert.equal(f.elements.stories.textContent, 'SAVE TO STORIES');
|
||||
assert.equal(f.elements.stories.disabled, true);
|
||||
|
||||
@@ -555,22 +552,40 @@ test('a rename keeps typed text across republishing and ends with its scene', as
|
||||
}
|
||||
});
|
||||
|
||||
test('the read-only scene name follows the selected scene', async () => {
|
||||
test('the scene select follows option renders, as before', async () => {
|
||||
const f = fixture();
|
||||
try {
|
||||
await nextTick();
|
||||
f.state.scenes.push({ id: 'scene-b', title: 'B', shots: [] });
|
||||
f.state.selectedSceneId = 'scene-b';
|
||||
f.owner.renderSceneSelect();
|
||||
await nextTick();
|
||||
assert.equal(f.elements.name.textContent, 'B');
|
||||
assert.equal(f.elements.name.classList.contains('scene-name-empty'), false);
|
||||
f.state.scenes = [];
|
||||
f.state.selectedSceneId = null;
|
||||
f.state.selectedSceneId = 'scene-b';
|
||||
f.owner.renderShotList();
|
||||
await nextTick();
|
||||
assert.equal(f.elements.name.textContent, 'No scene yet');
|
||||
assert.equal(f.elements.name.classList.contains('scene-name-empty'), true);
|
||||
assert.equal(f.elements.select.value, 'scene-a');
|
||||
f.owner.renderSceneSelect();
|
||||
await nextTick();
|
||||
assert.equal(f.elements.select.value, 'scene-b');
|
||||
} finally {
|
||||
f.restore();
|
||||
}
|
||||
});
|
||||
|
||||
test('an option render restores the published scene after a local pick', async () => {
|
||||
const f = fixture();
|
||||
try {
|
||||
f.state.scenes.push({ id: 'scene-b', title: 'B', shots: [] });
|
||||
f.owner.renderSceneSelect();
|
||||
await nextTick();
|
||||
assert.equal(f.elements.select.value, 'scene-a');
|
||||
// The person picks B; the owner re-renders the shot list only.
|
||||
f.elements.select.value = 'scene-b';
|
||||
f.owner.renderShotList();
|
||||
await nextTick();
|
||||
// Something reloads A and renders the options with the same choice.
|
||||
f.owner.renderSceneSelect();
|
||||
await nextTick();
|
||||
assert.equal(f.elements.select.value, 'scene-a');
|
||||
} finally {
|
||||
f.restore();
|
||||
}
|
||||
@@ -777,7 +792,6 @@ test('CAPTURE SHOT with no scene asks for a name, creates the scene, then captur
|
||||
f.owner.renderSceneSelect();
|
||||
f.owner.setButtons(false);
|
||||
await nextTick();
|
||||
assert.equal(f.elements.name.textContent, 'No scene yet');
|
||||
let asked = 0;
|
||||
window.prompt = () => (asked++ ? null : 'Harbour');
|
||||
f.elements.capture.click();
|
||||
@@ -862,7 +876,7 @@ test('Stories tag chips and THUMBNAIL follow the current scene', async () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('authoring can reopen a saved empty draft and capture from an empty panel', async () => {
|
||||
test('after a reload, authoring picks any scene, and PLAY and NEXT work', async () => {
|
||||
const f = fixture();
|
||||
const previousStorage = globalThis.localStorage;
|
||||
let saved = null;
|
||||
@@ -879,6 +893,11 @@ test('authoring can reopen a saved empty draft and capture from an empty panel',
|
||||
scenes: [
|
||||
...f.state.scenes,
|
||||
{ id: 'empty-draft', title: 'Empty draft', shots: [] },
|
||||
{
|
||||
id: 'scene-c',
|
||||
title: 'Scene C',
|
||||
shots: [{ id: 'shot-c', title: 'Shot C' }],
|
||||
},
|
||||
],
|
||||
}),
|
||||
setItem: (_key, value) => {
|
||||
@@ -901,18 +920,59 @@ test('authoring can reopen a saved empty draft and capture from an empty panel',
|
||||
},
|
||||
{ getAll: () => [], getLayerParams: () => null },
|
||||
);
|
||||
const runs = [];
|
||||
director.startScene = (id) => runs.push(['start', id]);
|
||||
director.runNextScene = () => runs.push(['next']);
|
||||
await nextTick();
|
||||
assert.equal(f.elements.name.textContent, 'No scene yet');
|
||||
const drafts = document.getElementById('empty-scene-select');
|
||||
assert.ok(drafts);
|
||||
drafts.value = 'empty-draft';
|
||||
drafts.dispatchEvent(new Event('change'));
|
||||
// The first scene and its first shot are selected, as before a reload.
|
||||
assert.deepEqual(director.selection(), {
|
||||
sceneId: 'scene-a',
|
||||
shotId: 'shot-a',
|
||||
});
|
||||
assert.equal(f.elements.start.disabled, false);
|
||||
assert.equal(f.elements.next.disabled, false);
|
||||
f.elements.start.click();
|
||||
f.elements.next.click();
|
||||
assert.deepEqual(runs, [['start', 'scene-a'], ['next']]);
|
||||
|
||||
// The select lists every scene, with shots or not.
|
||||
assert.deepEqual(
|
||||
[...f.elements.select.options].map(({ value }) => value),
|
||||
['scene-a', 'empty-draft', 'scene-c'],
|
||||
);
|
||||
f.elements.select.value = 'scene-c';
|
||||
f.elements.select.dispatchEvent(new Event('change'));
|
||||
await nextTick();
|
||||
assert.equal(f.elements.name.textContent, 'Empty draft');
|
||||
assert.deepEqual(director.selection(), {
|
||||
sceneId: 'scene-c',
|
||||
shotId: 'shot-c',
|
||||
});
|
||||
|
||||
f.elements.select.value = 'empty-draft';
|
||||
f.elements.select.dispatchEvent(new Event('change'));
|
||||
await nextTick();
|
||||
assert.equal(director.selection().sceneId, 'empty-draft');
|
||||
assert.equal(
|
||||
director.draftScenes().some(({ id }) => id === 'empty-draft'),
|
||||
false,
|
||||
);
|
||||
// CAPTURE SHOT adds to the picked scene without asking for a name.
|
||||
window.prompt = () => {
|
||||
throw new Error('no name is asked for');
|
||||
};
|
||||
f.elements.capture.click();
|
||||
await nextTick();
|
||||
const draft = saved.scenes.find(({ id }) => id === 'empty-draft');
|
||||
assert.equal(draft.shots.length, 1);
|
||||
assert.equal(f.elements.thumb.disabled, false);
|
||||
f.chips()[0].click();
|
||||
await nextTick();
|
||||
assert.deepEqual(
|
||||
saved.scenes.find(({ id }) => id === 'empty-draft').storyTags,
|
||||
['Floods'],
|
||||
);
|
||||
|
||||
// Deleting it selects the first scene again.
|
||||
window.confirm = () => true;
|
||||
f.elements.delete.click();
|
||||
await nextTick();
|
||||
@@ -920,29 +980,8 @@ test('authoring can reopen a saved empty draft and capture from an empty panel',
|
||||
saved.scenes.some(({ id }) => id === 'empty-draft'),
|
||||
false,
|
||||
);
|
||||
window.prompt = () => 'Harbour';
|
||||
f.elements.capture.click();
|
||||
await nextTick();
|
||||
assert.equal(f.elements.name.textContent, 'Harbour');
|
||||
assert.equal(saved.scenes.at(-1).title, 'Harbour');
|
||||
assert.equal(saved.scenes.at(-1).shots.length, 1);
|
||||
assert.equal(
|
||||
f.elements.shots.querySelectorAll('.scene-shot-row').length,
|
||||
1,
|
||||
);
|
||||
assert.equal(f.elements.thumb.disabled, false);
|
||||
|
||||
f.chips()[0].click();
|
||||
await nextTick();
|
||||
assert.deepEqual(saved.scenes.at(-1).storyTags, ['Floods']);
|
||||
assert.equal(f.chips()[0].getAttribute('aria-pressed'), 'true');
|
||||
|
||||
// Deleting it goes back to no scene.
|
||||
window.confirm = () => true;
|
||||
f.elements.delete.click();
|
||||
await nextTick();
|
||||
assert.equal(f.elements.name.textContent, 'No scene yet');
|
||||
assert.equal(f.elements.delete.disabled, true);
|
||||
assert.equal(f.elements.select.value, 'scene-a');
|
||||
assert.equal(director.selection().sceneId, 'scene-a');
|
||||
} finally {
|
||||
await director?.destroy();
|
||||
Object.defineProperty(globalThis, 'localStorage', {
|
||||
|
||||
@@ -81,6 +81,7 @@ export function sceneButtonsDisabled(
|
||||
for (const name of [
|
||||
'start',
|
||||
'next',
|
||||
'select',
|
||||
'new',
|
||||
'delete',
|
||||
'capture',
|
||||
|
||||
+18
-3
@@ -3,7 +3,7 @@ import { computed, markRaw, shallowRef } from 'vue';
|
||||
|
||||
/**
|
||||
* @typedef {object} SceneRowHandlers
|
||||
* @property {(sceneId: string) => void} selectScene
|
||||
* @property {(sceneId: string) => void} selectScene The select's choice.
|
||||
* @property {(shotId: string) => void} select
|
||||
* @property {(sceneId: string, shotId: string, title: string) => void} rename
|
||||
* @property {(sceneId: string, shotId: string) => void} load
|
||||
@@ -24,7 +24,12 @@ export const useSceneStore = defineStore('gev-scenes', () => {
|
||||
const scenes = shallowRef(markRaw([]));
|
||||
const selectedSceneId = shallowRef(null);
|
||||
const selectedShotId = shallowRef(null);
|
||||
/** The scene being edited, whose name the panel shows, or null. */
|
||||
// The select's choice, updated only when its options are rendered.
|
||||
const listedSceneId = shallowRef(null);
|
||||
// Counts option renders: each one re-applies the select's choice, which
|
||||
// the person may have changed since.
|
||||
const listedRevision = shallowRef(0);
|
||||
/** The selected scene, whose Stories details the panel shows, or null. */
|
||||
const currentScene = computed(
|
||||
() =>
|
||||
scenes.value.find((scene) => scene.id === selectedSceneId.value) ?? null,
|
||||
@@ -64,6 +69,13 @@ export const useSceneStore = defineStore('gev-scenes', () => {
|
||||
selectedShotId.value = state.selectedShotId ?? null;
|
||||
}
|
||||
|
||||
/** Publish the project and the select's choice. */
|
||||
function publishOptions(state) {
|
||||
publish(state);
|
||||
listedSceneId.value = state.selectedSceneId ?? null;
|
||||
listedRevision.value++;
|
||||
}
|
||||
|
||||
/** @param {string|null} id */
|
||||
function selectShot(id) {
|
||||
selectedShotId.value = id ?? null;
|
||||
@@ -77,7 +89,7 @@ export const useSceneStore = defineStore('gev-scenes', () => {
|
||||
if (token !== owner) return;
|
||||
owner = null;
|
||||
attached.value = false;
|
||||
publish({});
|
||||
publishOptions({});
|
||||
}
|
||||
|
||||
/** @returns {boolean} Whether `token` is the owner presenting now. */
|
||||
@@ -98,12 +110,15 @@ export const useSceneStore = defineStore('gev-scenes', () => {
|
||||
scenes,
|
||||
selectedSceneId,
|
||||
selectedShotId,
|
||||
listedSceneId,
|
||||
listedRevision,
|
||||
currentScene,
|
||||
attached,
|
||||
panel,
|
||||
publishPanel,
|
||||
attach,
|
||||
publish,
|
||||
publishOptions,
|
||||
selectShot,
|
||||
detach,
|
||||
owns,
|
||||
|
||||
@@ -92,8 +92,8 @@ test('SCENES actions stay on one line in English', () => {
|
||||
.length,
|
||||
0,
|
||||
);
|
||||
const [name] = unguardedRules(css('scenes.css'), '#scene-name');
|
||||
assert.equal(declaration(name, 'white-space'), undefined);
|
||||
const [select] = unguardedRules(css('scenes.css'), '#scene-select');
|
||||
assert.equal(declaration(select, 'white-space'), undefined);
|
||||
});
|
||||
|
||||
test('Display and parameter rows keep their English layout', () => {
|
||||
|
||||
+10
-13
@@ -162,24 +162,21 @@
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
/* The scene being edited, read-only, takes its own row; NEW SCENE / DELETE
|
||||
share the next. A long name wraps. */
|
||||
#scene-name {
|
||||
/* The scene's name takes its own row; NEW SCENE / DELETE share the next. */
|
||||
#scene-select {
|
||||
flex: 1 1 100%;
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
min-height: 32px;
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
#scene-name.scene-name-empty {
|
||||
color: var(--scene-quiet);
|
||||
}
|
||||
|
||||
#empty-scene-select {
|
||||
flex: 1 1 100%;
|
||||
min-width: 0;
|
||||
html:not([lang='en']) #scene-select {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 10px;
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
/* A translated action longer than its button wraps inside the button instead
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import UiButton from '../kit/UiButton.vue';
|
||||
@@ -9,11 +8,13 @@ import { useSceneStore } from '../stores/scenes.js';
|
||||
import { STORY_TAG_LIMIT, STORY_TAGS } from '../../scenes/storyTags.js';
|
||||
import { vClassToggle } from '../rail/classToggle.js';
|
||||
import SceneDialog from './panels/SceneDialog.vue';
|
||||
import SceneOptions from './SceneOptions.vue';
|
||||
import SceneShotList from './SceneShotList.vue';
|
||||
import CctvPanel from './panels/CctvPanel.vue';
|
||||
import StreetLevelPanel from './panels/StreetLevelPanel.vue';
|
||||
import DrawControls from './panels/DrawControls.vue';
|
||||
import GeoImport from './panels/GeoImport.vue';
|
||||
import UiSelect from '../kit/UiSelect.js';
|
||||
import LayerSectionIndex from './panels/LayerSectionIndex.vue';
|
||||
import LayerFinder from './panels/LayerFinder.vue';
|
||||
import DataLibraryBrowse from './panels/DataLibraryBrowse.vue';
|
||||
@@ -25,7 +26,6 @@ const { toolbar, dialog } = storeToRefs(useSceneSharingStore());
|
||||
// answers the buttons through the store.
|
||||
const scenes = useSceneStore();
|
||||
const { panel: scene, currentScene } = storeToRefs(scenes);
|
||||
const emptyScenes = computed(() => scenes.scenes.filter(({ shots }) => !shots.length));
|
||||
const off = (name) => scene.value?.disabled[name] ?? false;
|
||||
// The current scene's Stories tags; a chip not yet on is off at the limit.
|
||||
const tagOn = (tag) => currentScene.value?.storyTags?.includes(tag) ?? false;
|
||||
@@ -76,18 +76,7 @@ async function importChosen(event) {
|
||||
<RailPanel id="scene-panel" start-collapsed v-class-toggle="{ running: scene?.running, 'has-shots': scene?.hasShots }" :title="t('AUTHORING')" :hint="t('Create and edit scenes')" scroll>
|
||||
<p class="scene-step-heading">{{ t('SCENE') }}</p>
|
||||
<div class="scene-controls">
|
||||
<p id="scene-name" :class="{ 'scene-name-empty': !currentScene }">{{ currentScene?.title ?? t('No scene yet') }}</p>
|
||||
<select
|
||||
v-if="emptyScenes.length"
|
||||
id="empty-scene-select"
|
||||
:aria-label="t('Empty drafts')"
|
||||
:disabled="off('new')"
|
||||
:value="currentScene?.shots.length === 0 ? currentScene.id : ''"
|
||||
@change="scenes.act('selectScene', $event.target.value)"
|
||||
>
|
||||
<option value="" disabled>{{ t('Empty drafts') }}</option>
|
||||
<option v-for="draft in emptyScenes" :key="draft.id" :value="draft.id">{{ draft.title }}</option>
|
||||
</select>
|
||||
<UiSelect class="gev-field" id="scene-select" :aria-label="t('Scene')" :disabled="off('select')" @update:model-value="scenes.act('selectScene', $event)"><SceneOptions /></UiSelect>
|
||||
<UiButton id="scene-new-btn" type="button" :disabled="off('new')" @click="scenes.act('create')" class="gev-action-button scene-btn" :title="t('Start a new, empty scene')">{{ t('NEW SCENE') }}</UiButton>
|
||||
<UiButton tone="alert" id="scene-delete-btn" type="button" :disabled="off('delete')" @click="scenes.act('deleteScene')" class="gev-action-button gev-action-button--danger scene-btn scene-btn-danger" :title="t('Delete this scene and all of its shots')">{{ t('DELETE') }}</UiButton>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { getCurrentInstance, watch } from 'vue';
|
||||
import { useSceneStore } from '../stores/scenes.js';
|
||||
|
||||
// The Scene select's options; selecting one stays with SceneControls.
|
||||
const { scenes, listedSceneId, listedRevision } = storeToRefs(useSceneStore());
|
||||
|
||||
// Every option render shows the published scene, as the select did before:
|
||||
// `selected` alone is written only when it changes, so it would leave a
|
||||
// person's later pick standing.
|
||||
const instance = getCurrentInstance();
|
||||
watch(
|
||||
listedRevision,
|
||||
() => {
|
||||
const select = instance.proxy.$el?.parentNode;
|
||||
if (select && listedSceneId.value) select.value = listedSceneId.value;
|
||||
},
|
||||
{ flush: 'post' },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<option
|
||||
v-for="scene in scenes"
|
||||
:key="scene.id"
|
||||
:value="scene.id"
|
||||
:selected="scene.id === listedSceneId"
|
||||
>{{ scene.title }}</option
|
||||
>
|
||||
</template>
|
||||
Reference in new issue
Block a user