|
5 | 5 | import { CommonDisplayConfig } from '@aj/systems/node-configs'
|
6 | 6 | import EVENTS from '@aj/util/events'
|
7 | 7 | import { translate } from '@aj/util/translation'
|
8 |
| - import { slide } from 'svelte/transition' |
9 | 8 | import { MODE_ICONS, type CommonOptionMode } from '.'
|
10 | 9 | import TextDisplayPage from './textDisplayPage.svelte'
|
11 | 10 |
|
12 |
| - let selectedThing: TextDisplay | BlockDisplay | ItemDisplay | Group | undefined |
| 11 | + let selectedNode: TextDisplay | BlockDisplay | ItemDisplay | Group | undefined |
13 | 12 | let commonConfig: CommonDisplayConfig | undefined
|
14 | 13 | let commonOptionModes: Map<string, CommonOptionMode>
|
15 | 14 | let commonTabSelected: boolean
|
16 | 15 |
|
17 | 16 | EVENTS.UPDATE_SELECTION.subscribe(() => {
|
18 |
| - selectedThing = undefined |
| 17 | + selectedNode = undefined |
19 | 18 | commonConfig = undefined
|
20 | 19 | commonOptionModes = new Map()
|
21 | 20 |
|
22 | 21 | if (Group.first_selected) {
|
23 |
| - selectedThing = Group.first_selected |
| 22 | + selectedNode = Group.first_selected |
24 | 23 | } else if (TextDisplay.selected.length > 0) {
|
25 |
| - selectedThing = TextDisplay.selected.at(0) |
| 24 | + selectedNode = TextDisplay.selected.at(0) |
26 | 25 | } else if (BlockDisplay.selected.length > 0) {
|
27 |
| - selectedThing = BlockDisplay.selected.at(0) |
| 26 | + selectedNode = BlockDisplay.selected.at(0) |
28 | 27 | } else if (ItemDisplay.selected.length > 0) {
|
29 |
| - selectedThing = ItemDisplay.selected.at(0) |
| 28 | + selectedNode = ItemDisplay.selected.at(0) |
30 | 29 | }
|
31 | 30 |
|
32 |
| - if (selectedThing) { |
33 |
| - commonConfig = new CommonDisplayConfig().fromJSON(selectedThing?.commonConfig) |
| 31 | + if (selectedNode?.commonConfig) { |
| 32 | + commonConfig = new CommonDisplayConfig().fromJSON(selectedNode.commonConfig) |
34 | 33 | commonOptionModes = new Map<string, CommonOptionMode>(
|
35 | 34 | commonConfig.keys().map(key => {
|
36 | 35 | if (commonConfig!.getKeyInheritance(key)) {
|
|
46 | 45 |
|
47 | 46 | // Key is a string, but I need it to be any to make TypeScript happy when indexing into the config object.
|
48 | 47 | function cycleCommonMode(key: any) {
|
49 |
| - if (!selectedThing) { |
| 48 | + if (!selectedNode) { |
50 | 49 | console.error('Attempted to cycle common mode without a selected thing')
|
51 | 50 | return
|
52 | 51 | }
|
|
70 | 69 | }
|
71 | 70 |
|
72 | 71 | console.log('Set', key, 'inheritance mode to', mode?.toUpperCase())
|
73 |
| - Undo.initEdit({ elements: [selectedThing] }) |
74 |
| - selectedThing.commonConfig = commonConfig.toJSON() |
| 72 | + Undo.initEdit({ elements: [selectedNode] }) |
| 73 | + selectedNode.commonConfig = commonConfig.toJSON() |
75 | 74 | Undo.finishEdit(`Set ${key} inheritance mode to ${mode?.toUpperCase()}`, {
|
76 |
| - elements: [selectedThing], |
| 75 | + elements: [selectedNode], |
77 | 76 | })
|
78 | 77 |
|
79 | 78 | commonConfig = commonConfig
|
|
82 | 81 |
|
83 | 82 | <!-- Make sure that we update the panel every time selected thing is assigned, even if it's the same value. -->
|
84 | 83 | <!-- This makes certain that we have the most up-to-date properties of the text display from undo / redo events -->
|
85 |
| -{#if selectedThing} |
86 |
| - <div class="tab-buttons" in:slide={{ duration: 200 }}> |
| 84 | +{#if selectedNode} |
| 85 | + <div class="tab-buttons"> |
87 | 86 | <!-- svelte-ignore a11y-click-events-have-key-events -->
|
88 | 87 | <p
|
89 | 88 | class={'tab-button' + (!commonTabSelected ? ' tab-button-selected' : '')}
|
|
92 | 91 | }}
|
93 | 92 | >
|
94 | 93 | {translate(
|
95 |
| - `panel.display.${selectedThing && Object.getPrototypeOf(selectedThing).constructor.type}.label` |
| 94 | + `panel.display.${selectedNode && Object.getPrototypeOf(selectedNode).constructor.type}.label` |
96 | 95 | )}
|
97 | 96 | </p>
|
98 | 97 | <!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
134 | 133 | {/each}
|
135 | 134 | </ul>
|
136 | 135 | {:else}
|
137 |
| - {#key selectedThing} |
| 136 | + {#key selectedNode} |
138 | 137 | <!-- svelte-ignore missing-declaration -->
|
139 |
| - {#if selectedThing instanceof Group} |
| 138 | + {#if selectedNode instanceof Group} |
140 | 139 | <!-- <div>{selectedThing.name}</div> -->
|
141 |
| - {:else if selectedThing instanceof TextDisplay} |
142 |
| - <TextDisplayPage textDisplay={selectedThing} /> |
143 |
| - {:else if selectedThing instanceof BlockDisplay} |
| 140 | + {:else if selectedNode instanceof TextDisplay} |
| 141 | + <TextDisplayPage textDisplay={selectedNode} /> |
| 142 | + {:else if selectedNode instanceof BlockDisplay} |
144 | 143 | <!-- <div>{selectedThing.name}</div> -->
|
145 |
| - {:else if selectedThing instanceof ItemDisplay} |
| 144 | + {:else if selectedNode instanceof ItemDisplay} |
146 | 145 | <!-- <div>{selectedThing.name}</div> -->
|
147 | 146 | {:else}
|
148 | 147 | <div>Selection has no Display Options</div>
|
|
0 commit comments