2024-10-21 18:05:21 +00:00
|
|
|
<script setup>
|
|
|
|
import WindowHandle from '@/views/partials/WindowHandle.vue';
|
|
|
|
|
|
|
|
import { onMounted, ref, shallowRef } from 'vue';
|
|
|
|
import { ResetPosition, SetMinSize, SetResizable, SetSize, SetupHandle } from '@/services/Windows';
|
|
|
|
import ConceptList from '@/views/partials/ConceptList.vue';
|
|
|
|
import { Global } from '@/services/PluginGlobals';
|
|
|
|
|
|
|
|
const handle = ref(null);
|
|
|
|
|
|
|
|
const props = defineProps(['data']);
|
|
|
|
const data = props.data;
|
|
|
|
|
|
|
|
const Api = Global('dnd-5e').Api;
|
|
|
|
const PluginData = Global('dnd-5e').Data;
|
|
|
|
let dndModule = Global('dnd-5e').DndModule;
|
|
|
|
|
|
|
|
let id = data.id;
|
|
|
|
|
|
|
|
const books = shallowRef([]);
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
SetupHandle(id, handle);
|
|
|
|
SetSize(id, {width: 400, height: 600});
|
|
|
|
ResetPosition(id, "center");
|
|
|
|
SetResizable(id, true);
|
|
|
|
SetMinSize(id, {width: 400, height: 300});
|
|
|
|
|
|
|
|
// Fetch book list
|
|
|
|
FetchBookList();
|
|
|
|
});
|
|
|
|
|
|
|
|
function FetchBookList(){
|
|
|
|
dndModule.getDatagen().then(response => {
|
|
|
|
books.value = response.data.datagens;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-10-21 21:21:56 +00:00
|
|
|
function OpenBook(element){
|
|
|
|
dndModule.getDatagenData(element.id).then(response => {
|
|
|
|
Api.createWindow(PluginData.windows.database, {
|
|
|
|
title: element.name,
|
|
|
|
id: 'campaign-items-window',
|
|
|
|
elements: response.data.elements,
|
2024-10-22 12:53:24 +00:00
|
|
|
transformer: (element) => element.data,
|
2024-10-21 21:21:56 +00:00
|
|
|
topper: {
|
|
|
|
icon: "/plugins/" + element.package + "/" + element.icon,
|
|
|
|
title: element.name,
|
|
|
|
description: element.desc
|
|
|
|
},
|
2024-10-24 19:04:26 +00:00
|
|
|
fromDatagen: true, // Makes read only mode from elements!
|
2024-10-22 12:53:24 +00:00
|
|
|
getConcepts: () => response.data.elements,
|
2024-10-21 21:21:56 +00:00
|
|
|
close: () => Api.clearWindow("campaign-items-window")
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2024-10-21 18:05:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function BookIcon(element){
|
2024-10-21 21:21:56 +00:00
|
|
|
console.log(element);
|
|
|
|
return "/plugins/" + element.package + "/" + element.icon;
|
2024-10-21 18:05:21 +00:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="window-wrapper" :id="'window-wrapper-' + id">
|
|
|
|
<WindowHandle :window="id" ref="handle"></WindowHandle>
|
|
|
|
<div class="main-container">
|
|
|
|
<ConceptList
|
|
|
|
:elements="books"
|
|
|
|
:open="OpenBook"
|
|
|
|
:icon="BookIcon"
|
|
|
|
></ConceptList>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.main-container {
|
|
|
|
height: calc(100% - 24px);
|
|
|
|
}
|
|
|
|
|
|
|
|
.fixed-bottom-buttons {
|
|
|
|
position: absolute;
|
|
|
|
bottom: 10px;
|
|
|
|
right: 10px;
|
|
|
|
z-index: 2;
|
|
|
|
display: flex;
|
|
|
|
}
|
|
|
|
|
|
|
|
.window-wrapper {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
user-select: none;
|
|
|
|
}
|
|
|
|
</style>
|