character rules

This commit is contained in:
Sirttas
2026-05-23 23:47:06 +02:00
parent e233e609e6
commit a1dbe41b6c
8 changed files with 65 additions and 22 deletions
+5 -2
View File
@@ -4,14 +4,17 @@ import {Character} from "./chartacters.ts";
interface Props { interface Props {
character: Character; character: Character;
size?: number;
} }
const props = defineProps<Props>(); const props = withDefaults(defineProps<Props>(), {
size: 32
})
</script> </script>
<template> <template>
<div class="flex"> <div class="flex">
<img class="me-2" :src="`https://images.evetech.net/characters/${character.characterId}/portrait?size=32`" /> <img class="me-2" :src="`https://images.evetech.net/characters/${character.characterId}/portrait?size=${size}`" />
<span>{{ character.name }}</span> <span>{{ character.name }}</span>
</div> </div>
</template> </template>
+3 -1
View File
@@ -8,9 +8,11 @@ export type Character = CharacterResponse
export const useCharactersStore = defineStore('characters', () => { export const useCharactersStore = defineStore('characters', () => {
const characters = ref<Character[]>([]); const characters = ref<Character[]>([]);
const findById = (characterId: number): Character | undefined => characters.value.find(c => c.characterId === characterId);
const refresh = () => characterControllerApi.getCharacters().then(response => characters.value = response.data); const refresh = () => characterControllerApi.getCharacters().then(response => characters.value = response.data);
refresh(); refresh();
return {characters, refresh}; return {characters, findById, refresh};
}) })
+3 -1
View File
@@ -13,7 +13,9 @@ const addCharacter = () => {
<template> <template>
<div class="grid mb-2 mt-4"> <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"> <div v-for="character in characters" :key="character.characterId" class="flex items-center mb-2">
<CharacterLabel :character="character" /> <CharacterLabel :character="character" />
</div> </div>
+1 -15
View File
@@ -1,21 +1,7 @@
<script setup lang="ts"> <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> </script>
<template> <template>
<div class="grid mb-2 mt-4"> <RouterView />
<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>
</template> </template>
+30
View File
@@ -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>
+17
View File
@@ -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>
+6 -3
View File
@@ -4,11 +4,14 @@ export const routes: RouteRecordRaw[] = [
{path: '/', name: 'home', component: () => import('@/pages/Index.vue')}, {path: '/', name: 'home', component: () => import('@/pages/Index.vue')},
{path: '/callback', name: 'callback', component: () => import('@/pages/Index.vue')}, {path: '/callback', name: 'callback', component: () => import('@/pages/Index.vue')},
{path: '/ledgers', component: () => import('./pages/Ledgers.vue'), children: [ {path: '/ledgers', component: () => import('@/pages/Ledgers.vue'), children: [
{path: '', component: () => import('./pages/ledger/ListLedgers.vue')}, {path: '', component: () => import('@/pages/ledger/ListLedgers.vue')},
]}, ]},
{path: '/rules', component: () => import('@/pages/Rules.vue')}, {path: '/rules', component: () => import('@/pages/Rules.vue'), children: [
{path: '', component: () => import('./pages/rules/ListRuleBooks.vue')},
{path: ':characterId', name: 'character-rulebook', component: () => import('@/pages/rules/EditRuleBook.vue')},
]},
{path: '/market', component: () => import('@/pages/Market.vue'), children: [ {path: '/market', component: () => import('@/pages/Market.vue'), children: [
{path: '', redirect: '/market/types'}, {path: '', redirect: '/market/types'},
View File