The dnd plugin now uses more api
This commit is contained in:
parent
0d0b322766
commit
b1b7fc5827
@ -6,11 +6,11 @@ import { GetCampaign } from "@/services/Dragonroll";
|
||||
|
||||
let data = reactive({});
|
||||
|
||||
let Api = Global('dnd-5e')['api'];
|
||||
let Api = Global('dnd-5e').Api;
|
||||
let dndModule = Global('dnd-5e')['dndModule'];
|
||||
|
||||
function InitData(){
|
||||
Api = Global('dnd-5e')['api'];
|
||||
Api = Global('dnd-5e').Api;
|
||||
dndModule = Global('dnd-5e')['dndModule'];
|
||||
|
||||
data.value = {
|
||||
@ -30,7 +30,7 @@ function FetchData(){
|
||||
}
|
||||
|
||||
let GetConcepts = () => data.value.concepts;
|
||||
let GetConcept = (id) => Server().get('/concept/get?campaign=' + GetCampaign()._id + "&id=" + id)
|
||||
let GetConcept = (id) => dndModule.router.get('/item/get', {id})
|
||||
|
||||
|
||||
export {
|
||||
|
@ -4,7 +4,7 @@ import { Global } from '@/services/PluginGlobals';
|
||||
var dndModule;
|
||||
|
||||
function Main(Api){
|
||||
Global('dnd-5e')['api'] = Api;
|
||||
Global('dnd-5e')['Api'] = Api;
|
||||
|
||||
console.log("Module registered!");
|
||||
dndModule = Api.createModule('dnd-5e');
|
||||
@ -24,9 +24,13 @@ function Main(Api){
|
||||
let databaseWindow = Api.registerWindow('database', Api.createView('Database'));
|
||||
let actorsWindow = Api.registerWindow('actors', Api.createView('Actors'));
|
||||
|
||||
Api.registerWindow('character_sheet', Api.createView('CharacterSheet'));
|
||||
Api.registerWindow('item_sheet', Api.createView('ItemSheet'));
|
||||
Api.registerWindow('create_item_prompt', Api.createView('CreateItemPrompt'));
|
||||
Global('dnd-5e').Data = {
|
||||
windows: {
|
||||
character_sheet: Api.registerWindow('character_sheet', Api.createView('CharacterSheet')),
|
||||
item_sheet: Api.registerWindow('item_sheet', Api.createView('ItemSheet')),
|
||||
create_item_prompt: Api.registerWindow('create_item_prompt', Api.createView('CreateItemPrompt'))
|
||||
}
|
||||
}
|
||||
|
||||
dndModule.setButtons({
|
||||
right: [
|
||||
@ -58,11 +62,6 @@ function Main(Api){
|
||||
FetchConcepts();
|
||||
});
|
||||
|
||||
|
||||
// Api.windows.registerWindow('character_sheet', Api.createView('CharacterSheet'));
|
||||
// Api.windows.registerWindow('item_sheet', Api.createView('ItemSheet'));
|
||||
// Api.windows.registerWindow('create_item_prompt', Api.createView('CreateItemPrompt'));
|
||||
|
||||
dndModule.onInit = () => {
|
||||
InitData();
|
||||
FetchData();
|
||||
|
@ -1,10 +1,9 @@
|
||||
<script setup>
|
||||
import WindowHandle from '@/views/partials/WindowHandle.vue';
|
||||
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { SetupHandle, SetSize, ResetPosition } from '@/services/Windows';
|
||||
import { ClearWindow, CreateWindow } from '@/services/Windows';
|
||||
import { GetCampaignModuleName } from '../../../../client/src/services/Campaign';
|
||||
import { Global } from '@/services/PluginGlobals';
|
||||
|
||||
const props = defineProps(['data']);
|
||||
const data = props.data;
|
||||
|
||||
@ -12,6 +11,8 @@ const handle = ref(null);
|
||||
let id = data.id;
|
||||
|
||||
const radioContainer = ref(null);
|
||||
const Api = Global('dnd-5e').Api;
|
||||
const PluginData = Global('dnd-5e').Data;
|
||||
|
||||
onMounted(() => {
|
||||
SetupHandle(id, handle);
|
||||
@ -24,15 +25,15 @@ function ConfirmSelection(){
|
||||
if(!selected) return;
|
||||
let value = selected.value;
|
||||
|
||||
CreateWindow(`${GetCampaignModuleName()}/item_sheet`, {
|
||||
Api.createWindow(PluginData.windows.item_sheet, {
|
||||
id: 'item_sheet',
|
||||
title: 'Edit Item',
|
||||
item_type: value,
|
||||
item_create: true,
|
||||
close: () => ClearWindow('item_sheet')
|
||||
close: () => Api.clearWindow('item_sheet')
|
||||
});
|
||||
|
||||
ClearWindow(id);
|
||||
Api.clearWindow(id);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
@ -2,11 +2,11 @@
|
||||
import WindowHandle from '@/views/partials/WindowHandle.vue';
|
||||
|
||||
import { onMounted, ref, shallowRef, watch } from 'vue';
|
||||
import { ClearWindow, CreateWindow, ResetPosition, SetMinSize, SetResizable, SetSize, SetupHandle } from '@/services/Windows';
|
||||
import { ResetPosition, SetMinSize, SetResizable, SetSize, SetupHandle } from '@/services/Windows';
|
||||
import ConceptList from '@/views/partials/ConceptList.vue';
|
||||
import Tabs from '@/views/partials/Tabs.vue';
|
||||
import { GetCampaignModuleName } from '@/services/Campaign';
|
||||
import FixedBottomButtons from '@/views/partials/FixedBottomButtons.vue';
|
||||
import { Global } from '@/services/PluginGlobals';
|
||||
|
||||
import { FetchConcepts, GetConcepts } from './../data.js'
|
||||
|
||||
@ -15,6 +15,9 @@ 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 id = data.id;
|
||||
const elements = shallowRef([]);
|
||||
|
||||
@ -32,15 +35,15 @@ onMounted(() => {
|
||||
FetchConcepts();
|
||||
});
|
||||
function OpenCreateItemPrompt(){
|
||||
CreateWindow(`${GetCampaignModuleName()}/create_item_prompt`, {id: 'create_item_prompt', title: 'Create Item', close: () => ClearWindow('create_item_prompt')})
|
||||
Api.createWindow(PluginData.windows.create_item_prompt, {id: 'create_item_prompt', title: 'Create Item', close: () => Api.clearWindow('create_item_prompt')})
|
||||
}
|
||||
|
||||
function OpenConcept(element){
|
||||
CreateWindow(`${GetCampaignModuleName()}/item_sheet`, {
|
||||
Api.createWindow(PluginData.windows.item_sheet, {
|
||||
id: 'item_sheet_' + element._id,
|
||||
title: 'Edit Item',
|
||||
item_id: element._id,
|
||||
close: () => ClearWindow('item_sheet_' + element._id)
|
||||
close: () => Api.clearWindow('item_sheet_' + element._id)
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user