character rules
This commit is contained in:
@@ -13,7 +13,9 @@ const addCharacter = () => {
|
||||
|
||||
<template>
|
||||
<div class="grid mb-2 mt-4">
|
||||
<button class="justify-self-end" @click="addCharacter">Add chacarcter</button>
|
||||
<div class="mb-4 border-b-1 flex justify-end">
|
||||
<button class="mb-2" @click="addCharacter">Add chacarcter</button>
|
||||
</div>
|
||||
<div v-for="character in characters" :key="character.characterId" class="flex items-center mb-2">
|
||||
<CharacterLabel :character="character" />
|
||||
</div>
|
||||
|
||||
+1
-15
@@ -1,21 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import {mammonAddCharacterUrl} from "@/mammon";
|
||||
import {storeToRefs} from "pinia";
|
||||
import {CharacterLabel, useCharactersStore} from "@/characters";
|
||||
import {PencilSquareIcon} from "@heroicons/vue/24/outline";
|
||||
|
||||
const {characters} = storeToRefs(useCharactersStore());
|
||||
|
||||
const addCharacter = () => {
|
||||
window.location.replace(mammonAddCharacterUrl);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="grid mb-2 mt-4">
|
||||
<div v-for="character in characters" :key="character.characterId" class="flex items-center mb-2">
|
||||
<CharacterLabel class="flex grow" :character="character" />
|
||||
<button class="btn-icon ms-2" @click=""><PencilSquareIcon /></button>
|
||||
</div>
|
||||
</div>
|
||||
<RouterView />
|
||||
</template>
|
||||
@@ -0,0 +1,30 @@
|
||||
<script setup lang="ts">
|
||||
import {Character, CharacterLabel, useCharactersStore} from "@/characters";
|
||||
import {useRoute} from "vue-router";
|
||||
import {ref, watch} from "vue";
|
||||
import log from "loglevel";
|
||||
|
||||
const {findById} = useCharactersStore();
|
||||
|
||||
const character = ref<Character>();
|
||||
|
||||
watch(useRoute(), async route => {
|
||||
if (route.params.characterId) {
|
||||
const id = parseInt(typeof route.params.characterId === 'string' ? route.params.characterId : route.params.characterId[0]);
|
||||
|
||||
character.value = findById(id);
|
||||
log.info('Loaded character:', character.value);
|
||||
} else {
|
||||
character.value = undefined;
|
||||
log.info('No character to load');
|
||||
}
|
||||
}, { immediate: true })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="character" class="grid mb-2 mt-4">
|
||||
<div class="mb-4 border-b-1 flex">
|
||||
<CharacterLabel class="flex grow mb-2" :character="character" size="128" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import {storeToRefs} from "pinia";
|
||||
import {CharacterLabel, useCharactersStore} from "@/characters";
|
||||
import {PencilSquareIcon} from "@heroicons/vue/24/outline";
|
||||
|
||||
const {characters} = storeToRefs(useCharactersStore());
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="grid mb-2 mt-4">
|
||||
<div v-for="character in characters" :key="character.characterId" class="flex items-center mb-2">
|
||||
<CharacterLabel class="flex grow" :character="character" />
|
||||
<RouterLink class="btn-icon ms-2" :to="{ name: 'character-rulebook', params: { characterId: character.characterId } }"><PencilSquareIcon /></RouterLink>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user