diff --git a/components/content/ListSystems.vue b/components/content/ListSystems.vue index 6c5efb7a4ba25fd42598efd5dd24612c35fccace..94628e9dbc5ac62c3225894690ce317b5d02b06e 100644 --- a/components/content/ListSystems.vue +++ b/components/content/ListSystems.vue @@ -1,16 +1,17 @@ <script setup lang="ts"> - const props = defineProps<{ - systems: any; + headers: Array<Object> + systems: Array<Object> + }>(); const itemsPerParge = ref(25) const search = ref('') const sortBy = ref([{ key: 'system', order: 'asc' }]) -const headers = ref([{ - title: "Systems", - key: "system" -}, { title: "Articles", key: "dois" } -]) +// const headers = ref([{ +// title: "Systems", +// key: "system" +// }, { title: "Articles", key: "doi" } +// ]) </script> <template> @@ -21,14 +22,14 @@ const headers = ref([{ <v-text-field v-model="search" density="compact" variant="underlined" append-inner-icon="mdi-magnify" label="Search" single-line hide-details class="mx-2"></v-text-field> </v-toolbar> - <v-data-table :items-per-page="itemsPerParge" v-model:sort-by="sortBy" :headers="headers" :items="props.systems" + <v-data-table :items-per-page="itemsPerParge" v-model:sort-by="sortBy" :headers="props.headers" :items="props.systems" :search="search"> <template #[`item.system`]="{ item }"> <v-chip variant="text" link :to="`/defense-systems/${item.columns.system.toLowerCase()}`">{{ item.columns.system }}</v-chip> </template> - <template #[`item.dois`]="{ item }"> - <ArticleDoiList :items="item.columns.dois" :divider="false" /> + <template #[`item.doi`]="{ item }"> + <ArticleDoiList v-if="item.columns?.doi" :items="[item.columns.doi]" :divider="false" /> </template> </v-data-table> </v-card> diff --git a/content/2.defense-systems/abi2.md b/content/2.defense-systems/abi2.md index ca92286d5a42166fcbd477479faec67a2e709dcf..7bd6e7b41b76eef226e9377f1d10792a46ecdb8a 100644 --- a/content/2.defense-systems/abi2.md +++ b/content/2.defense-systems/abi2.md @@ -1,5 +1,7 @@ --- title: Abi2 +tableDescription: + doi: 10.1016/j.mib.2005.06.006 --- The Abi2 system is composed of one protein: Abi_2. diff --git a/pages/defense-systems.vue b/pages/defense-systems.vue index 815354623bf11f717a0af65c73c525362360c7e9..b744ef92ec3b33ae0c29f5cb1a2bc5a05072a6d5 100644 --- a/pages/defense-systems.vue +++ b/pages/defense-systems.vue @@ -1,18 +1,44 @@ <script setup lang="ts"> const { data, error, pending } = await useAsyncData('list-defense-systems', () => queryContent('/defense-systems').find()) -const defaultHeaders = ref([{ title: 'System', key: "title" }]) -console.log(data.value) +const defaultHeaders = ref([{ title: 'System', key: "system" }]) const tableDescriptionKey = ref("tableDescription") -const headers = data.value ? ref(Array.from(data.value.reduce((headerSet, df) => { - if (df?.[tableDescriptionKey.value]) { - return new Set([...headerSet, ...Object.keys(df[tableDescriptionKey.value])]) +const headers = computed(() => { + if (data?.value && data.value?.length > 0) { + const uniqHeaders = Array.from(data.value.reduce((headerSet, df) => { + if (df?.[tableDescriptionKey.value]) { + return new Set([...headerSet, ...Object.keys(df[tableDescriptionKey.value])]) + } + else { return headerSet } + }, new Set())) + return [...defaultHeaders.value, ...uniqHeaders.map(value => { return { title: value, key: value } })] } - else { return headerSet } -}, new Set())).map(value => { return { title: value, key: value } }) + else { + return [] + } +}) +const systems = computed(() => { + if (data?.value && data.value?.length > 0) { + return data.value.map(({ title, tableDescription }) => { + return { + system: title, + ...tableDescription + } + }) + } else { + return [] + } + +}) + -) : defaultHeaders console.log(headers.value) +console.log(systems.value) </script> <template> - <v-card :loading="pending"></v-card> + <v-card> + <v-card-title>List systems</v-card-title> + <v-card-text> + <ListSystems :headers=headers :systems="systems"></ListSystems> + </v-card-text> + </v-card> </template> \ No newline at end of file