|
111 | 111 | :filter="searchNpc" |
112 | 112 | wrap-cells |
113 | 113 | > |
| 114 | + <template v-slot:header="props"> |
| 115 | + <q-tr :props="props"> |
| 116 | + <q-th auto-width /> |
| 117 | + <q-th |
| 118 | + v-for="col in props.cols" |
| 119 | + :key="col.name" |
| 120 | + :props="props" |
| 121 | + :auto-width="col.name !== 'name'" |
| 122 | + > |
| 123 | + {{ col.label }} |
| 124 | + </q-th> |
| 125 | + </q-tr> |
| 126 | + </template> |
| 127 | + |
114 | 128 | <template v-slot:body="props"> |
115 | 129 | <q-tr :props="props"> |
| 130 | + <q-td auto-width> |
| 131 | + <a @click="toggleCustomNpc(props, props.key)" class="neutral-2"> |
| 132 | + <i |
| 133 | + aria-hidden="true" |
| 134 | + class="fas" |
| 135 | + :class="props.expand ? 'fa-chevron-up' : 'fa-chevron-down'" |
| 136 | + /> |
| 137 | + </a> |
| 138 | + </q-td> |
116 | 139 | <q-td |
117 | 140 | v-for="col in props.cols" |
118 | 141 | :key="col.name" |
|
187 | 210 | </template> |
188 | 211 | </q-td> |
189 | 212 | </q-tr> |
| 213 | + <q-tr v-if="props.expand" :props="props"> |
| 214 | + <q-td colspan="100%" class="p-0" auto-width> |
| 215 | + <hk-loader v-if="!npcExpandData[props.key]" name="monster" /> |
| 216 | + <ViewMonster v-else :data="npcExpandData[props.key]" class="p-0" /> |
| 217 | + </q-td> |
| 218 | + </q-tr> |
190 | 219 | </template> |
191 | 220 | <div slot="no-data" /> |
192 | 221 | <hk-loader slot="loading" name="monsters" /> |
@@ -565,6 +594,7 @@ export default { |
565 | 594 | maxContent: true, |
566 | 595 | }, |
567 | 596 | }, |
| 597 | + npcExpandData: {}, |
568 | 598 | monster_resource_setter: undefined, |
569 | 599 | loading_monsters: true, |
570 | 600 | loading_npcs: true, |
@@ -992,6 +1022,27 @@ export default { |
992 | 1022 | ? this.$set(this.encounter.entities, uuid(), entity) |
993 | 1023 | : this.$set(this.encounter, "entities", { [uuid()]: entity }); |
994 | 1024 | }, |
| 1025 | + async toggleCustomNpc(props, id) { |
| 1026 | + props.expand = !props.expand; |
| 1027 | + if (props.expand && !this.npcExpandData[id]) { |
| 1028 | + try { |
| 1029 | + const npc = await this.get_npc({ uid: this.user.uid, id }); |
| 1030 | + if (!npc) { |
| 1031 | + props.expand = false; |
| 1032 | + this.$snotify.error("This NPC could not be loaded.", "NPC unavailable", { |
| 1033 | + position: "centerTop", |
| 1034 | + }); |
| 1035 | + return; |
| 1036 | + } |
| 1037 | + this.$set(this.npcExpandData, id, npc); |
| 1038 | + } catch (e) { |
| 1039 | + props.expand = false; |
| 1040 | + this.$snotify.error("Failed to load NPC statblock.", "Load error", { |
| 1041 | + position: "centerTop", |
| 1042 | + }); |
| 1043 | + } |
| 1044 | + } |
| 1045 | + }, |
995 | 1046 | setSize(e) { |
996 | 1047 | this.width = e.width; |
997 | 1048 | }, |
|
0 commit comments