diff --git a/assets/app_component_dataset.js b/assets/app_component_dataset.js index f889027d..082b3831 100644 --- a/assets/app_component_dataset.js +++ b/assets/app_component_dataset.js @@ -274,7 +274,8 @@ const datasetView = () => }, methods: { newTabActivated(newTabIndex, prevTabIndex, bvEvent) { - if (newTabIndex == 1) { + var tabs = this.selectedDataset.available_tabs + if (tabs[newTabIndex] == 'content') { this.getFiles() } }, @@ -398,7 +399,7 @@ const datasetView = () => router.push(current_route_info) } else { this.clearFilters(); - this.tabIndex = 0; + this.tabIndex = this.getDefaultTabIdx(); } } else { if (this.currentIsHome()) { @@ -406,7 +407,7 @@ const datasetView = () => router.push(current_route_info) } else { this.clearFilters(); - this.tabIndex = 0; + this.tabIndex = this.getDefaultTabIdx(); } } else { router.push({ name: "home" }); @@ -545,28 +546,37 @@ const datasetView = () => } } }, - setCorrectTab(tab_param) { + setCorrectTab(tab_param, available_tabs, default_tab) { // the set of available tabs have been updated in component - // data in either created() or beforeRouteUpdate() - var tabs = this.$root.selectedDataset.available_tabs.map(v => v.toLowerCase()); - // If no tab parameter is supplied via the router, set to first tab + // data in either created() or beforeRouteUpdate() and have been passed + // as the second argument + default_tab = default_tab ? default_tab : "content" + var idx = available_tabs.indexOf(default_tab.toLowerCase()) + var default_tab_idx = idx >= 0 ? idx : 0 + + // If no tab parameter is supplied via the router, set to default tab if (!tab_param) { - this.tabIndex = 0 + this.tabIndex = default_tab_idx; } // If a tab parameter is supplied via the router, navigate to that tab if - // part of available tabs, otherwise first tab + // part of available tabs, otherwise default tab else { selectTab = tabs.indexOf(tab_param.toLowerCase()) if (selectTab >= 0) { this.tabIndex = selectTab; } else { - this.tabIndex = 0; + this.tabIndex = default_tab_idx; } } - } + }, + getDefaultTabIdx() { + var default_tab = this.selectedDataset.config?.dataset_options?.default_tab + default_tab = default_tab ? default_tab : "content" + var idx = this.selectedDataset.available_tabs.indexOf(default_tab.toLowerCase()) + return idx >= 0 ? idx : 0 + }, }, async beforeRouteUpdate(to, from, next) { - this.tabIndex = 0; this.subdatasets_ready = false; this.dataset_ready = false; @@ -677,7 +687,7 @@ const datasetView = () => // Now list all tabs and set the correct one // order in DOM: subdatasets, content, publications, funding, provenance, sDs = this.$root.selectedDataset - available_tabs = ['subdatasets', 'content'] + available_tabs = ['content', 'subdatasets'] standard_tabs = ['publications', 'funding', 'provenance'] // add available standard tabs for (var t=0; t available_tabs.push(sDs.additional_display[t].name) } } - // finally set the root data and then set the correct tab - this.$root.selectedDataset.available_tabs = available_tabs + // set the root data for available tabs + available_tabs_lower = available_tabs + this.$root.selectedDataset.available_tabs = available_tabs_lower + // Now get dataset config if it exists + dataset_config_path = metadata_dir + "/" + sDs.dataset_id + "/" + sDs.dataset_version + "/config.json"; + configresponse = await fetch(dataset_config_path); + if (configresponse.status == 404) { + this.$root.selectedDataset.config = {}; + } else { + configtext = await configresponse.text(); + config = JSON.parse(configtext); + this.$root.selectedDataset.config = config; + } + // Set the correct tab to be rendered this.setCorrectTab( to.params.tab_name, + available_tabs_lower, + this.$root.selectedDataset.config?.dataset_options?.default_tab ) // if navigated to using vue router (i.e. internal to the app), show the back button if (this.currentIsHome()) { @@ -798,9 +822,9 @@ const datasetView = () => this.$root.selectedDataset.has_files = false; } // Now list all tabs and set the correct one - // order in DOM: subdatasets, content, publications, funding, provenance, + // order in DOM: content, subdatasets, publications, funding, provenance, sDs = this.$root.selectedDataset - available_tabs = ['subdatasets', 'content'] + available_tabs = ['content', 'subdatasets'] standard_tabs = ['publications', 'funding', 'provenance'] // add available standard tabs for (var t=0; t available_tabs.push(sDs.additional_display[t].name) } } - // finally set the root data and then set the correct tab - this.$root.selectedDataset.available_tabs = available_tabs + available_tabs_lower = available_tabs + // set the root data for available tabs + this.$root.selectedDataset.available_tabs = available_tabs_lower + // Now get dataset config if it exists + dataset_config_path = metadata_dir + "/" + sDs.dataset_id + "/" + sDs.dataset_version + "/config.json"; + configresponse = await fetch(dataset_config_path); + if (configresponse.status == 404) { + this.$root.selectedDataset.config = {}; + } else { + configtext = await configresponse.text(); + config = JSON.parse(configtext); + this.$root.selectedDataset.config = config; + } + // Set the correct tab to be rendered this.setCorrectTab( this.$route.params.tab_name, + available_tabs_lower, + this.$root.selectedDataset.config?.dataset_options?.default_tab ) }, mounted() { diff --git a/metadata/deabeb9b-7a37-4062-a1e0-8fcef7909609/6d7fb68264f9b9951ae141fc830712a8744e3293/config.json b/metadata/deabeb9b-7a37-4062-a1e0-8fcef7909609/6d7fb68264f9b9951ae141fc830712a8744e3293/config.json new file mode 100644 index 00000000..d8e313ce --- /dev/null +++ b/metadata/deabeb9b-7a37-4062-a1e0-8fcef7909609/6d7fb68264f9b9951ae141fc830712a8744e3293/config.json @@ -0,0 +1,47 @@ +{ + "catalog_name": "DataCat", + "link_color": "#fba304", + "link_hover_color": "#af7714", + "social_links": { + "about": null, + "documentation": "https://docs.datalad.org/projects/catalog/en/latest/", + "github": "https://github.com/datalad/datalad-catalog", + "mastodon": "https://fosstodon.org/@datalad", + "x": "https://x.com/datalad" + }, + "dataset_options": { + "include_metadata_export": true, + "default_tab": "subdatasets" + }, + "property_sources": { + "dataset": { + "authors": { + "rule": "merge", + "source": [ + "metalad_studyminimeta" + ] + }, + "description": { + "rule": "priority", + "source": [ + "metalad_studyminimeta", + "bids_dataset" + ] + }, + "keywords": { + "rule": "merge", + "source": "any" + }, + "additional_display": { + "rule": "merge", + "source": [] + }, + "top_display": { + "rule": "merge", + "source": [] + } + }, + "file": { + } + } +} \ No newline at end of file diff --git a/templates/dataset-template.html b/templates/dataset-template.html index c6d3c254..92a5ec1f 100644 --- a/templates/dataset-template.html +++ b/templates/dataset-template.html @@ -156,6 +156,41 @@

Cite dataset

+ + + + + There is no content available for the current dataset + + +
    + +
+
+
+ + + +
+ +
+ +
+
+