feat: use categories of current jdr
This commit is contained in:
parent
07e8986ed6
commit
de0845da11
3 changed files with 19 additions and 5 deletions
|
@ -14,6 +14,10 @@ const props = defineProps({
|
|||
type: Array as PropType<string[]>,
|
||||
default: () => [],
|
||||
},
|
||||
category: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
});
|
||||
|
||||
const DEFAULT_MAX_ITEM_BY_PAGE = 10;
|
||||
|
@ -33,15 +37,21 @@ const paginatedList = computed(() => {
|
|||
});
|
||||
|
||||
onMounted(() => {
|
||||
setTimeout(() => {
|
||||
refresh();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
function refresh() {
|
||||
table.fields = props.fields;
|
||||
for (const file of props.files) {
|
||||
const listItems = `/jdr/objets/${file}.json`;
|
||||
const listItems = `/jdr/${props.category}/${file}.json`;
|
||||
axios.get(listItems).then((response) => {
|
||||
table.addItems(response.data);
|
||||
table.currentPage = 0;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function switchFilter(filterSet: string | number, filterName: string | number) {
|
||||
table.switchFilter(filterSet as string, filterName as string);
|
||||
|
|
|
@ -6,4 +6,5 @@ export default interface JdrConfig {
|
|||
sidebar: LinkList[];
|
||||
hideLinks: HideLink[];
|
||||
vars: { name: string; value: string }[];
|
||||
objects: string[];
|
||||
}
|
||||
|
|
|
@ -1,24 +1,27 @@
|
|||
<script setup lang="ts">
|
||||
import DynTable from "@/components/tableaux/DynTable.vue";
|
||||
import { useConfigStore } from "@/stores/config";
|
||||
import { onMounted } from "vue";
|
||||
import { onMounted, computed } from "vue";
|
||||
import { useRoute } from "vue-router";
|
||||
import MarkdownFile from "../components/MarkdownFile.vue";
|
||||
import { objectFields } from "@/data/fields";
|
||||
|
||||
const store = useConfigStore();
|
||||
const route = useRoute();
|
||||
const objectTest = ["base", "potions"];
|
||||
|
||||
onMounted(() => {
|
||||
store.loadJdr(`${route.params.jdr}`);
|
||||
});
|
||||
|
||||
const objects = computed(() => {
|
||||
return store.jdrConfig?.objects ?? [];
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main>
|
||||
<MarkdownFile :path="`rules/inventaire/objets`">
|
||||
<DynTable :fields="objectFields" :files="objectTest" />
|
||||
<DynTable :fields="objectFields" :files="objects" category="objets" />
|
||||
</MarkdownFile>
|
||||
</main>
|
||||
</template>
|
||||
|
|
Loading…
Reference in a new issue