Refonte inventaire et objets #236

Merged
kazhnuz merged 27 commits from inventaire into master 2023-02-18 19:06:28 +01:00
3 changed files with 19 additions and 5 deletions
Showing only changes of commit de0845da11 - Show all commits

View file

@ -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);

View file

@ -6,4 +6,5 @@ export default interface JdrConfig {
sidebar: LinkList[];
hideLinks: HideLink[];
vars: { name: string; value: string }[];
objects: string[];
}

View file

@ -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>