Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions src/components/encounters/Entities.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,31 @@
:filter="searchNpc"
wrap-cells
>
<template v-slot:header="props">
<q-tr :props="props">
<q-th auto-width />
<q-th
v-for="col in props.cols"
:key="col.name"
:props="props"
:auto-width="col.name !== 'name'"
>
{{ col.label }}
</q-th>
</q-tr>
</template>

<template v-slot:body="props">
<q-tr :props="props">
<q-td auto-width>
<a @click="toggleCustomNpc(props, props.key)" class="neutral-2">

Check warning on line 131 in src/components/encounters/Entities.vue

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Anchors must have content and the content must be accessible by a screen reader.

See more on https://sonarcloud.io/project/issues?id=HarmlessKey_HarmlessKey&issues=AZ5fMMssWbuHVY7gsGHk&open=AZ5fMMssWbuHVY7gsGHk&pullRequest=338
<i
aria-hidden="true"
class="fas"
:class="props.expand ? 'fa-chevron-up' : 'fa-chevron-down'"
/>
</a>
</q-td>
<q-td
v-for="col in props.cols"
:key="col.name"
Expand Down Expand Up @@ -187,6 +210,12 @@
</template>
</q-td>
</q-tr>
<q-tr v-if="props.expand" :props="props">
<q-td colspan="100%" class="p-0" auto-width>
<hk-loader v-if="!npcExpandData[props.key]" name="monster" />
<ViewMonster v-else :data="npcExpandData[props.key]" class="p-0" />
</q-td>
</q-tr>
</template>
<div slot="no-data" />
<hk-loader slot="loading" name="monsters" />
Expand Down Expand Up @@ -565,6 +594,7 @@
maxContent: true,
},
},
npcExpandData: {},
monster_resource_setter: undefined,
loading_monsters: true,
loading_npcs: true,
Expand Down Expand Up @@ -992,6 +1022,27 @@
? this.$set(this.encounter.entities, uuid(), entity)
: this.$set(this.encounter, "entities", { [uuid()]: entity });
},
async toggleCustomNpc(props, id) {
props.expand = !props.expand;
if (props.expand && !this.npcExpandData[id]) {
try {
const npc = await this.get_npc({ uid: this.user.uid, id });
if (!npc) {
props.expand = false;
this.$snotify.error("This NPC could not be loaded.", "NPC unavailable", {
position: "centerTop",
});
return;
}
this.$set(this.npcExpandData, id, npc);
} catch (e) {
props.expand = false;
this.$snotify.error("Failed to load NPC statblock.", "Load error", {
position: "centerTop",
});
}
}
},
setSize(e) {
this.width = e.width;
},
Expand Down
Loading