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