Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve flatmap card issue in gallery #102

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 21 additions & 11 deletions components/ImagesGallery/ImagesGallery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,32 @@ const getThumbnailData = async (datasetDoi, datasetId, datasetVersion, datasetFa
}
}

// Add flatmaps that match the anatomy and taxonomy to the gallery
// Default species flatmap
let speciesData = {
taxo,
id: datasetId,
version: datasetVersion,
species: species
}
// Add uberonid and organ to the default flatmap if match the anatomy and taxonomy
scicrunchData.organs.forEach(organ => {
if (foundAnatomy.includes(organ.curie)){
if (foundAnatomy.includes(organ.curie)) {
let organData = {
taxo,
...speciesData,
uberonid: organ.curie,
organ: organ.name,
id: datasetId,
version: datasetVersion,
species: species
}
flatmapData.push(organData)
}
})
//Only create a flatmaps field if flatmapData is not empty
if (flatmapData.length > 0)
scicrunchData['flatmaps'] = flatmapData
// Use the default species flatmap when the anatomy and taxonomy not match
if (flatmapData.length === 0) {
flatmapData.push(speciesData)
}
scicrunchData['flatmaps'] = flatmapData
} else {
// Use the rat flatmap when no entity on the anatomical structure as generic flatmap
scicrunchData['flatmaps'] = [{ taxo: Uberons.species['rat'] }]
}
}
} catch (e) {
Expand Down Expand Up @@ -402,13 +411,14 @@ export default {
title = `View ${f.organ}`
}

let linkUrl = `${baseRoute}maps?type=flatmap&dataset_version=${datasetVersion}&dataset_id=${datasetId}&taxo=${f.taxo}&uberonid=${f.uberonid}`
let linkUrl = `${baseRoute}maps?type=flatmap&dataset_version=${datasetVersion}&dataset_id=${datasetId}&taxo=${f.taxo}`
if (f.uberonid) linkUrl = linkUrl + `&uberonid=${f.uberonid}`
if (f.species) linkUrl = linkUrl + `&for_species=${f.species}`
const item = {
id: f.uberonid,
title: title,
type: `${this.capitalize(
f.species ? f.species : 'rat'
f.species && f.species === flatmaps.speciesMap[f.taxo] ? f.species : 'generic'
)} flatmap`,
thumbnail: null,
link: linkUrl
Expand Down
7 changes: 6 additions & 1 deletion pages/apps/maps/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,12 @@ const checkSpecies = (route, organ, organ_name, taxo, for_species) => {
} else if (route.query.fid) {
successMessage = "A flatmap's unique id is provided, a legacy map may be displayed instead."
} else {
failMessage = `Sorry! Species information cannot be found. The ${organ} of a rat has been shown instead.`
failMessage = 'Sorry! Species information cannot be found. '
if (organ) {
failMessage += `The ${organ} of a rat has been shown instead.`
} else {
failMessage += 'A generic rat flatmap has been shown instead.'
}
}
return { successMessage, failMessage }
}
Expand Down