4
4
class =" flexcol nogrow movesheet-row"
5
5
:class =" { hidden: node?.forceHidden, highlighted: state.highlighted }"
6
6
data-tooltip-direction =" LEFT"
7
- :data-tourid =" `oracle-${node.dataforgedNode?.$id}`" >
7
+ :data-tourid =" `oracle-${node.dataforgedNode?.$id}`"
8
+ >
8
9
<!-- TODO: split this into two components, yo -->
9
10
<!-- Leaf node -->
10
11
<div v-if =" isLeaf" >
18
19
nogrow
19
20
class =" show-oracle-info"
20
21
icon =" fa:eye"
21
- @click =" toggleDescription()" />
22
+ @click =" toggleDescription()"
23
+ />
22
24
</h4 >
23
25
<CollapseTransition >
24
- <RulesTextOracle
25
- v-if =" state.descriptionExpanded"
26
- :class =" $style.content"
27
- :table-rows =" state.tableRows"
28
- :table-description =" state.tableDescription"
29
- :source =" node.dataforgedNode?.Source"
30
- @moveclick =" moveclick"
31
- @oracleclick =" oracleclick" />
26
+ <div v-if =" state.descriptionExpanded" >
27
+ <h4 v-if =" state.singleDescription" v-html =" state.singleDescription" />
28
+ <RulesTextOracle
29
+ v-for =" table in state.tables"
30
+ :key =" table.id"
31
+ :class =" $style.content"
32
+ :title =" state.tables.length > 1 ? table.title : undefined"
33
+ :table-rows =" table.rows"
34
+ :table-description =" table.description"
35
+ :source =" node.dataforgedNode?.Source"
36
+ @moveclick =" moveclick"
37
+ @oracleclick =" oracleclick"
38
+ />
39
+ </div >
32
40
</CollapseTransition >
33
41
</div >
34
42
43
51
name =" caret-right"
44
52
:rotate ="
45
53
state.manuallyExpanded ? FontAwesome.Rotate['90deg'] : undefined
46
- " />
54
+ "
55
+ />
47
56
</template >
48
57
</IronBtn >
49
58
</h4 >
52
61
<div
53
62
v-show =" state.manuallyExpanded"
54
63
class =" flexcol"
55
- :class =" $style.indent" >
64
+ :class =" $style.indent"
65
+ >
56
66
<oracle-tree-node
57
67
v-for =" child in node?.children"
58
68
:key =" child.displayName"
59
69
ref =" children"
60
70
:node =" child"
61
- @oracleclick =" oracleclick" />
71
+ @oracleclick =" oracleclick"
72
+ />
62
73
</div >
63
74
</CollapseTransition >
64
75
</div >
@@ -78,14 +89,20 @@ import FontIcon from './icon/font-icon.vue'
78
89
import IronIcon from ' ./icon/iron-icon.vue'
79
90
import type { OracleTable } from ' ../../roll-table/oracle-table'
80
91
import type { LegacyTableRow } from ' ../../roll-table/roll-table-types'
92
+ import { enrichHtml } from ' ../vue-plugin'
81
93
82
94
const props = defineProps <{ node: IOracleTreeNode }>()
83
95
84
96
const state = reactive ({
85
97
manuallyExpanded: props .node .forceExpanded ?? false ,
86
98
descriptionExpanded: false ,
87
- tableRows: [] as Array <LegacyTableRow >,
88
- tableDescription: ' ' ,
99
+ singleDescription: undefined as string | undefined ,
100
+ tables: [] as Array <{
101
+ id: string
102
+ title: string
103
+ rows: Array <LegacyTableRow >
104
+ description: string
105
+ }>,
89
106
highlighted: false
90
107
})
91
108
@@ -96,15 +113,34 @@ const isLeaf = computed(() => {
96
113
})
97
114
98
115
async function toggleDescription() {
99
- if (! state .tableDescription ) {
100
- const table = (await fromUuid (props .node .tables [0 ])) as OracleTable
101
- state .tableRows = table .results .map ((row : any ) => ({
102
- low: row .range [0 ],
103
- high: row .range [1 ],
104
- text: row .text ,
105
- selected: false
106
- }))
107
- state .tableDescription = (table as any ).description ?? ' '
116
+ if (state .tables .length === 0 ) {
117
+ state .tables = await Promise .all (
118
+ props .node .tables .map (async (tableUuid ) => {
119
+ const tableData = (await fromUuid (tableUuid )) as OracleTable
120
+ return {
121
+ id: tableUuid ,
122
+ title: tableData .name ?? ' ' ,
123
+ rows: tableData .results .map ((row : any ) => ({
124
+ low: row .range [0 ],
125
+ high: row .range [1 ],
126
+ text: row .text ,
127
+ selected: false
128
+ })),
129
+ description: tableData .description
130
+ }
131
+ })
132
+ )
133
+
134
+ // If all descriptions match, collapse them into one
135
+ if (
136
+ state .tables .every ((t ) => t .description === state .tables [0 ].description )
137
+ ) {
138
+ state .singleDescription = enrichHtml (state .tables [0 ].description )
139
+ for (const t of state .tables ) {
140
+ t .description = ' '
141
+ }
142
+ }
143
+
108
144
await nextTick ()
109
145
}
110
146
state .descriptionExpanded = ! state .descriptionExpanded
0 commit comments