Skip to content

Commit

Permalink
Merge pull request #394 from datalad/home-navigation
Browse files Browse the repository at this point in the history
ENH: Updates functioning of catalog home button
  • Loading branch information
jsheunis authored Oct 23, 2023
2 parents 75097bc + e95b924 commit 65ca5d2
Showing 1 changed file with 47 additions and 3 deletions.
50 changes: 47 additions & 3 deletions datalad_catalog/catalog/assets/app_component_dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,52 @@ const datasetView = () =>
}
},
gotoHome() {
router.push({ name: "home" });
// if there is NO home page set:
// - if there is a tab name in the URL, navigate to current
// - else: don't navigate, only "reset"
// if there IS a home page set:
// - if the current page IS the home page:
// - if there is a tab name in the URL, navigate to current
// - else: don't navigate, only "reset"
// - if the current page is NOT the home page, navigate to home
// reset: clear filters and set tab index = 0
const current_route_info = {
name: "dataset",
params: {
dataset_id: this.selectedDataset.dataset_id,
dataset_version: this.selectedDataset.dataset_version,
},
}
if (!this.catalogHasHome()) {
if (this.$route.params.tab_name) {
router.push(current_route_info)
} else {
this.clearFilters();
this.tabIndex = 0;
}
} else {
if (this.currentIsHome()) {
if (this.$route.params.tab_name) {
router.push(current_route_info)
} else {
this.clearFilters();
this.tabIndex = 0;
}
} else {
router.push({ name: "home" });
}
}
},
catalogHasHome() {
if (this.$root.home_dataset_id && this.$root.home_dataset_version) {
return true
} else {
return false
}
},
currentIsHome() {
return ((this.$root.home_dataset_id == this.$root.selectedDataset.dataset_id) &&
(this.$root.home_dataset_version == this.$root.selectedDataset.dataset_version))
},
getDateFromUTCseconds(utcSeconds) {
// TODO: consider moving this functionality to generator tool
Expand Down Expand Up @@ -652,8 +697,7 @@ const datasetView = () =>
to.params.tab_name,
)
// if navigated to using vue router (i.e. internal to the app), show the back button
if ((this.$root.home_dataset_id == this.$root.selectedDataset.dataset_id) &&
(this.$root.home_dataset_version == this.$root.selectedDataset.dataset_version)) {
if (this.currentIsHome()) {
this.$root.selectedDataset.show_backbutton = false
} else {
this.$root.selectedDataset.show_backbutton = true
Expand Down

0 comments on commit 65ca5d2

Please sign in to comment.