Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
José Luis Pereira committed Sep 5, 2022
1 parent ac2ecc6 commit 4818bf2
Show file tree
Hide file tree
Showing 21 changed files with 128 additions and 115 deletions.
1 change: 1 addition & 0 deletions src/components/Gallery/GalleryThumbnail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
>
<img
class="max-h-20 max-w-24 h-20 w-24 object-cover rounded"
:alt="title"
:src="image.thumb"
>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/modules/otus/components/CommonNames.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<script setup>
import { computed, ref, watch } from 'vue'
import OtuService from '../services/OtuService'
import TaxonWorks from '../services/TaxonWorks'
const props = defineProps({
otuId: {
Expand All @@ -20,7 +20,7 @@ watch(
() => props.otuId,
id => {
if (id) {
OtuService.getDescendants(id, {
TaxonWorks.getOtuDescendants(id, {
max_descendants_depth: 0,
extend: ['common_names']
}).then(({ data }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<div class="text-sm">
<CitationRow
v-for="citation in citationList.start"
v-for="citation in citationList.first"
:key="citation.id"
:citation="citation"
/>
Expand Down Expand Up @@ -40,9 +40,9 @@

<script setup>
import { ref, watch, computed } from 'vue'
import OtuService from '../../services/OtuService'
import CitationRow from './CitationRow.vue'
import CitationRowShowMore from './CitationRowShowMore.vue'
import TaxonWorks from '../../../services/TaxonWorks'
import CitationRow from './PanelCitationRow.vue'
import CitationRowShowMore from './PanelCitationShowMore.vue'
const MAX_CITATIONS = 3
Expand All @@ -57,21 +57,27 @@ const showAll = ref(false)
const citations = ref([])
const citationList = computed(() => {
const copyArr = citations.value.slice()
const start = copyArr.splice(0, MAX_CITATIONS)
const first = copyArr.splice(0, MAX_CITATIONS)
const last = copyArr.splice(-MAX_CITATIONS)
const middle = copyArr
return {
start,
first,
middle,
last
}
})
watch(() => props.otuId, async () => {
if (!props.otuId) { return }
watch(
() => props.otuId,
async () => {
if (!props.otuId) { return }
citations.value = (await OtuService.getTaxonNameCitations(props.otuId)).data
}, { immediate: true })
citations.value = (await TaxonWorks.getTaxonNameCitations(props.otuId)).data
},
{
immediate: true
}
)
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<ContentTopic
v-for="(text, title) in contentList"
:key="title"
class="last:mb-0"
:title="title"
:text-list="text"
/>
Expand All @@ -12,8 +11,8 @@

<script setup>
import { computed, ref, watch } from 'vue'
import OtuService from '../../services/OtuService'
import ContentTopic from './ContentTopic.vue'
import TaxonWorks from '../../../services/TaxonWorks'
import ContentTopic from './PanelContentTopic.vue'
const props = defineProps({
otuId: {
Expand All @@ -40,7 +39,7 @@ watch(
() => props.otuId,
id => {
if (id) {
OtuService.getContent(id).then(({ data }) => {
TaxonWorks.getOtuContent(id).then(({ data }) => {
contents.value = data
})
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<VCardContent class="text-sm">
<ul class="tree ml-2">
<AnimationOpacity>
<TreeView
<DescendantsTree
v-if="taxonomy && (taxonomy.nomenclatural_synonyms.length || taxonomy.descendants.length)"
:taxonomy="taxonomy"
/>
Expand All @@ -19,9 +19,9 @@
</template>

<script setup>
import { ref, watch } from 'vue';
import TreeView from '@/components/TreeView.vue'
import OtuService from '../services/OtuService';
import { ref, watch } from 'vue'
import DescendantsTree from './DescendantsTree.vue'
import TaxonWorks from '../../../services/TaxonWorks'
const props = defineProps({
otuId: {
Expand All @@ -35,7 +35,7 @@ const taxonomy = ref(null)
watch(() => props.otuId, async () => {
if (!props.otuId) { return }
OtuService.getDescendants(props.otuId, { max_descendants_depth: 1 }).then(({ data }) => {
TaxonWorks.getOtuDescendants(props.otuId, { max_descendants_depth: 1 }).then(({ data }) => {
taxonomy.value = data
})
}, { immediate: true })
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
:to="{ name: 'otus-id', params: { id: taxonomy.otu_id } }"
v-html="taxonomy.name"
/>
<SynonymList
<DescendantsSynonymList
v-if="taxonomy.nomenclatural_synonyms.length"
class="pb-4"
:list="taxonomy.nomenclatural_synonyms"
Expand All @@ -28,7 +28,7 @@
:key="item.otu_id"
>
<AnimationOpacity>
<TreeView
<DescendantsTree
v-if="isTreeVisible"
:taxonomy="item"
/>
Expand All @@ -40,9 +40,9 @@
</template>

<script setup>
import TreeView from '@/components/TreeView.vue'
import SynonymList from './SynonymList.vue'
import OtuService from '@/modules/otus/services/OtuService'
import DescendantsTree from './DescendantsTree.vue'
import DescendantsSynonymList from './DescendantsSynonymList.vue'
import TaxonWorks from '../../../services/TaxonWorks'
import { ref, watch } from 'vue'
const props = defineProps({
Expand Down Expand Up @@ -71,7 +71,7 @@ watch(
const loadDescendants = () => {
if (descendants.value.length) { return }
OtuService.getDescendants(props.taxonomy.otu_id, { max_descendants_depth: 1 }).then(({ data }) => {
TaxonWorks.getOtuDescendants(props.taxonomy.otu_id, { max_descendants_depth: 1 }).then(({ data }) => {
descendants.value = data.descendants
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<script setup>
import { ref, watch } from 'vue'
import OtuService from '../services/OtuService'
import TaxonWorks from '../../../services/TaxonWorks'
const props = defineProps({
otuId: {
Expand All @@ -27,7 +27,7 @@ watch(
otu_scope: ['all']
}
images.value = (await OtuService.getOtuImages(props.otuId, params)).data
images.value = (await TaxonWorks.getOtuImages(props.otuId, params)).data
},
{ immediate: true }
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<script setup>
import { ref, watch } from "vue"
import OtuService from "../services/OtuService"
import TaxonWorks from '../../../services/TaxonWorks'
const props = defineProps({
otuId: {
Expand All @@ -42,7 +42,7 @@ watch(
if(newId === oldId) return
isLoading.value = true
OtuService.getGeoJSON(props.otuId).then(({ data }) => {
TaxonWorks.getOtuDistribution(props.otuId).then(({ data }) => {
geojson.value = data.request_too_large
? null
: data
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<template>
<VCard>
<VCardHeader>
<h1 class="text-md">
Type
</h1>
</VCardHeader>
<VCardContent class="text-sm">
<p v-html="typeDesignationLabel" />
</VCardContent>
</VCard>
</template>

<script setup>
import { ref, watch, computed } from 'vue'
import TaxonWorks from '../../../services/TaxonWorks'
const props = defineProps({
taxonId: {
type: [String, Number],
required: true
}
})
const typeDesignation = ref({})
const typeDesignationLabel = computed(() =>
[
typeDesignation.value.subject_object_tag || '',
typeDesignation.value.subject_status_tag || '',
typeDesignation.value.object_object_tag || ''
].join(' '))
watch(
() => props.taxonId,
async () => {
if (!props.taxonId) { return }
TaxonWorks.getTaxonTypeDesignation(props.taxonId).then(({ data }) => {
typeDesignation.value = data.type_taxon_name_relationship
})
},
{ immediate: true }
)
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

<script setup>
import { ref, watch } from 'vue'
import { SPECIMEN_TYPES } from '../constants'
import OtuService from '../services/OtuService'
import { SPECIMEN_TYPES } from '../../../constants'
import TaxonWorks from '../../../services/TaxonWorks'
const props = defineProps({
otuId: {
Expand All @@ -32,7 +32,7 @@ watch(
() => {
if (!props.otuId) { return }
OtuService.getTypes(props.otuId).then(({ data }) => {
TaxonWorks.getOtuTypeMaterial(props.otuId).then(({ data }) => {
typeMaterials.value = data.type_materials_catalog_labels.sort((a, b) => SPECIMEN_TYPES.indexOf(a.type_type) - SPECIMEN_TYPES.indexOf(b.type_type))
})
}, { immediate: true })
Expand Down
40 changes: 0 additions & 40 deletions src/modules/otus/components/TypeDesignation.vue

This file was deleted.

3 changes: 2 additions & 1 deletion src/modules/otus/constants/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './typeOrder';
export * from './typeOrder'
export * from './rankGroups'
29 changes: 29 additions & 0 deletions src/modules/otus/constants/overviewLayout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { FAMILY_GROUP, GENUS_GROUP, SPECIES_GROUP } from './index.js'
import PanelGallery from '../components/Panel/PanelGallery/Gallery.vue'
import PanelTypeSpecimen from '../components/Panel/PanelTypeSpecimen/PanelTypeSpecimen.vue'
import PanelTypeDesignation from '../components/Panel/PanelTypeDesignation/PanelTypeDesignation.vue'
import PanelCitations from '../components/Panel/PanelCitation/PanelCitation.vue'
import PanelMap from '../components/Panel/PanelMap/PanelMap.vue'
import PanelDescendants from '../components/Panel/PanelDescendants/Descendants.vue'
import PanelContent from '../components/Panel/PanelContent/PanelContent.vue'

export const overviewLayout = {
left: [
{ component: PanelGallery },
{
component: PanelTypeSpecimen,
available: [SPECIES_GROUP]
},
{
component: PanelTypeDesignation,
available: [FAMILY_GROUP, GENUS_GROUP]
},
{ component: PanelCitations }
],

right: [
{ component: PanelMap },
{ component: PanelDescendants },
{ component: PanelContent }
]
}
File renamed without changes.
Loading

0 comments on commit 4818bf2

Please sign in to comment.