mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(ui): render the scene sharing dialogs and bar from a store
createSceneDialog keeps its builder but publishes the dialog's lines, fields, buttons and status to a scene sharing store; SceneDialog.vue, teleported to the body from the scene panels view, draws the same modal with the same styles and opens it with Cancel focused. The EDIT DETAILS / SHARE SCENE bar is drawn by that view while sharing offers it. The status directive is shared with Provider Settings, and the two QA scripts that drove the old DOM read the new dialog.
This commit is contained in:
1 parent
fe963a1219
commit
9d9eb267c5
15 files changed
+842
-355
No files matched your search
@@ -1,8 +1,16 @@
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import { useSceneSharingStore } from '../stores/sceneSharing.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';
|
||||
|
||||
// Scene sharing (src/scenes/sharing.js) offers its authoring bar and presents
|
||||
// its dialog through this store; without this view, neither is drawn.
|
||||
const { toolbar, dialog } = storeToRefs(useSceneSharingStore());
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -61,6 +69,10 @@ import StreetLevelPanel from './panels/StreetLevelPanel.vue';
|
||||
<button id="scene-download-btn" type="button" class="gev-action-button scene-btn" title="Download the timing log of the last play" data-i18n data-i18n-title>RUN LOG</button>
|
||||
<input type="file" id="scene-import-file" accept="application/json,.json" hidden />
|
||||
</div>
|
||||
<div v-if="toolbar" data-director-authoring class="scene-controls">
|
||||
<button type="button" class="gev-action-button scene-btn" :title="t('Edit anchors, data packs and shot details')" @click="toolbar.edit()">{{ t('EDIT DETAILS') }}</button>
|
||||
<button type="button" class="gev-action-button scene-btn" :title="t('Download this scene as JSON or an asset bundle')" @click="toolbar.share()">{{ t('SHARE SCENE') }}</button>
|
||||
</div>
|
||||
<div class="scene-progress">
|
||||
<div id="scene-progress-fill">0%</div>
|
||||
</div>
|
||||
@@ -69,4 +81,7 @@ import StreetLevelPanel from './panels/StreetLevelPanel.vue';
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<Teleport to="body">
|
||||
<SceneDialog v-if="dialog" :key="dialog.id" :view="dialog" />
|
||||
</Teleport>
|
||||
</template>
|
||||
@@ -4,6 +4,7 @@ import { computed, onBeforeUnmount, onMounted, shallowRef } from 'vue';
|
||||
import { t } from '../../i18n/index.js';
|
||||
import { vClassToggle } from '../rail/classToggle.js';
|
||||
import { vFieldValue } from '../rail/fieldValue.js';
|
||||
import { vStatusText } from '../rail/statusText.js';
|
||||
import { useLocaleStore } from '../stores/locale.js';
|
||||
import { useProviderSettingsStore } from '../stores/providerSettings.js';
|
||||
import LocalePicker from './panels/LocalePicker.vue';
|
||||
@@ -34,17 +35,7 @@ onMounted(() => {
|
||||
});
|
||||
onBeforeUnmount(() => themeObserver?.disconnect());
|
||||
|
||||
// The status line is a live region: write each message, even a repeated one,
|
||||
// so a screen reader announces it again.
|
||||
const vStatusText = {
|
||||
mounted(el, { value }) {
|
||||
el.textContent = value.text;
|
||||
},
|
||||
updated(el, { value, oldValue }) {
|
||||
if (value.seq !== oldValue?.seq || value.text !== oldValue?.text)
|
||||
el.textContent = value.text;
|
||||
},
|
||||
};
|
||||
// The status line is a live region; vStatusText re-announces repeats.
|
||||
const statusText = computed(() => ({
|
||||
text:
|
||||
view.value?.status ??
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
<script setup>
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { computed, onBeforeUnmount, onMounted, shallowRef, useTemplateRef } from 'vue';
|
||||
import { t, tn } from '../../../i18n/index.js';
|
||||
import { vStatusText } from '../../rail/statusText.js';
|
||||
import { useSceneSharingStore } from '../../stores/sceneSharing.js';
|
||||
|
||||
// One open scene sharing dialog, as src/ui/sceneSharing.js presents it. The
|
||||
// parent keys this by dialog, so each one opens as a fresh modal.
|
||||
const props = defineProps({ view: { type: Object, required: true } });
|
||||
const { controls } = storeToRefs(useSceneSharingStore());
|
||||
|
||||
const root = useTemplateRef('root');
|
||||
onMounted(() => root.value?.showModal?.());
|
||||
onBeforeUnmount(() => {
|
||||
if (root.value?.open) root.value.close();
|
||||
});
|
||||
|
||||
const bodyItems = computed(() => props.view.items.filter((item) => item.place === 'body'));
|
||||
const footerItems = computed(() => props.view.items.filter((item) => item.place === 'footer'));
|
||||
// Typing reaches the item before any republish, so a field is rewritten only
|
||||
// when the owner changes its value, focused or not, as the old code did.
|
||||
const statusText = computed(() => ({ text: props.view.status, seq: props.view.statusSeq }));
|
||||
|
||||
// The browser draws a file input's button and "no file" text in its own
|
||||
// language. The native input is stretched, transparent, over the whole row
|
||||
// (so click, focus and drops stay native) and translated text is drawn under.
|
||||
const focusedFile = shallowRef(null);
|
||||
const chosenText = (item) => {
|
||||
const count = item.files.length;
|
||||
// One file shows its name, like the browser's own picker did.
|
||||
return count === 1
|
||||
? item.files[0].name
|
||||
: count
|
||||
? tn(count, '{count} file selected', '{count} files selected')
|
||||
: t('No file chosen');
|
||||
};
|
||||
const onFiles = (item, event) => controls.value?.setFiles(item.id, event.target.files ?? []);
|
||||
|
||||
const dialogStyle = { background: '#08141e', color: '#e3faff', border: '1px solid #397080', borderRadius: '6px', padding: '20px', width: 'min(720px,calc(100vw - 32px))', boxSizing: 'border-box', position: 'fixed', inset: '0', margin: 'auto', maxHeight: 'calc(100vh - 32px)', overflow: 'auto', font: '14px/1.5 sans-serif' };
|
||||
const buttonStyle = { background: '#10242e', color: '#e3faff', border: '1px solid #397080', borderRadius: '3px', padding: '7px 11px', margin: '6px 6px 6px 0', cursor: 'pointer', font: 'inherit' };
|
||||
const fieldStyle = (multiline) => ({ display: 'block', boxSizing: 'border-box', width: '100%', padding: '7px', margin: '6px 0 14px', color: '#e3faff', background: '#10242e', border: '1px solid #397080', font: multiline ? '12px monospace' : 'inherit' });
|
||||
const fileInputStyle = { ...fieldStyle(false), position: 'absolute', inset: '0', width: '100%', height: '100%', margin: '0', padding: '0', border: '0', opacity: '0', cursor: 'pointer', zIndex: '1' };
|
||||
const fileRowStyle = { display: 'flex', alignItems: 'center', gap: '10px', margin: '6px 0 14px', padding: '7px', background: '#10242e', border: '1px solid #397080' };
|
||||
const chooserStyle = (focused) => ({ padding: '3px 9px', border: '1px solid #397080', borderRadius: '3px', background: '#08141e', cursor: 'pointer', outline: focused ? '2px solid #e3faff' : '' });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<dialog ref="root" data-director-dialog class="director-sharing-dialog" :aria-label="view.title" :style="dialogStyle" @cancel.prevent="controls?.cancel()">
|
||||
<h2 style="margin-bottom: 12px">{{ view.title }}</h2>
|
||||
<div>
|
||||
<template v-for="item in bodyItems" :key="item.id">
|
||||
<p v-if="item.kind === 'text'" style="margin: 8px 0">{{ item.value }}</p>
|
||||
<button v-else-if="item.kind === 'button'" type="button" :style="buttonStyle" :disabled="item.disabled" v-bind="item.hook ? { [item.hook]: '' } : {}" @click="controls?.click(item.id)">{{ item.label }}</button>
|
||||
<label v-else-if="item.type === 'file'" :style="{ display: 'block', position: 'relative' }">{{ item.label }}<input type="file" :aria-label="item.label" :multiple="item.multiple" :webkitdirectory="item.directory || undefined" :style="fileInputStyle" @change="onFiles(item, $event)" @focus="focusedFile = item.id" @blur="focusedFile = null" /><span aria-hidden="true" :style="fileRowStyle"><span :style="chooserStyle(focusedFile === item.id)">{{ t('Choose files') }}</span><span>{{ chosenText(item) }}</span></span></label>
|
||||
<label v-else style="display: block">{{ item.label }}<textarea v-if="item.multiline" rows="9" :aria-label="item.label" :style="fieldStyle(true)" :value="item.value" @input="controls?.setValue(item.id, $event.target.value)"></textarea><input v-else :type="item.type" :aria-label="item.label" :style="fieldStyle(false)" :value="item.value" @input="controls?.setValue(item.id, $event.target.value)" /></label>
|
||||
</template>
|
||||
</div>
|
||||
<p role="status" v-status-text="statusText"></p>
|
||||
<div>
|
||||
<button v-for="item in footerItems" :key="item.id" type="button" :style="buttonStyle" :disabled="item.disabled" :autofocus="item.autofocus || undefined" v-bind="item.hook ? { [item.hook]: '' } : {}" @click="controls?.click(item.id)">{{ item.label }}</button>
|
||||
</div>
|
||||
</dialog>
|
||||
</template>
|
||||
Reference in new issue
Block a user