Skip to content

Commit

Permalink
Merge pull request #301 from datalad/bring-back-the-dead
Browse files Browse the repository at this point in the history
ENH+BF: Bring back the dead
  • Loading branch information
jsheunis authored Apr 19, 2023
2 parents a0e5384 + 41b0688 commit 84ffaa7
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 87 deletions.
159 changes: 73 additions & 86 deletions datalad_catalog/catalog/assets/app_component_dataset.js
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,46 @@ const datasetView = () =>
}
}
},
tabsChanged(currentTabs, previousTabs) {
this.setCorrectTab(
this.$root.selectedDataset.has_subdatasets,
this.$root.selectedDataset.has_files
)
},
setCorrectTab(has_subdatasets, has_files) {
// now set the correct tab:
var tabs = this.$refs['alltabs'].$children.filter(
child => typeof child.$vnode.key === 'string' || child.$vnode.key instanceof String
).map(child => child.$vnode.key)
var tab_param = this.$route.params.tab_name;
if (!tab_param) {
if (has_subdatasets) {
this.tabIndex = 0;
}
else {
if (has_files) {
this.tabIndex = 1;
}
else {
if (tabs.length > 2) {
this.tabIndex = 2;
} else {
this.tabIndex = 0;
}
}
}
}
else {
selectTab = tabs.indexOf(tab_param)
if (selectTab >= 0) {
this.tabIndex = selectTab;
} else {
this.tabIndex = 0;
}
}
}
},
async beforeRouteUpdate(to, from, next) {
var has_subdatasets, has_files
console.log('\n---BEFORE ROUTE UPDATE---\n')
console.log(to.params.tab_name)
console.log('\n---BEFORE ROUTE UPDATE---\n')
this.tabIndex = 0;
this.subdatasets_ready = false;
this.dataset_ready = false;
Expand Down Expand Up @@ -572,62 +606,37 @@ const datasetView = () =>
this.$root.selectedDataset.subdatasets_available_count = subdatasets_available.length
this.$root.selectedDataset.subdatasets_unavailable_count = subdatasets_unavailable.length
this.subdatasets_ready = true;
has_subdatasets = true;
this.$root.selectedDataset.has_subdatasets = true;
} else {
this.$root.selectedDataset.subdatasets = [];
this.$root.selectedDataset.subdatasets_count = 0
this.$root.selectedDataset.subdatasets_available_count = 0
this.$root.selectedDataset.subdatasets_unavailable_count = 0
this.subdatasets_ready = true;
has_subdatasets = false;
// Now check file content
this.files_ready = false;
this.$root.selectedDataset.tree = this.$root.selectedDataset["children"];
this.files_ready = true;
if (
this.$root.selectedDataset.hasOwnProperty("tree") &&
this.$root.selectedDataset.tree instanceof Array &&
this.$root.selectedDataset.tree.length > 0
) {
has_files = true;
}
else {
has_files = false;
}
this.$root.selectedDataset.has_subdatasets = false;
}
// now set the correct tab:
var tab_param = this.$route.params.tab_name;
if (!tab_param) {
if (has_subdatasets) {
this.tabIndex = 0;
}
else {
if (has_files) {
this.tabIndex = 1;
}
else {
this.tabIndex = 2;
}
}
// Now check file content
this.files_ready = false;
this.$root.selectedDataset.tree = this.$root.selectedDataset["children"];
this.files_ready = true;
if (
this.$root.selectedDataset.hasOwnProperty("tree") &&
this.$root.selectedDataset.tree instanceof Array &&
this.$root.selectedDataset.tree.length > 0
) {
this.$root.selectedDataset.has_files = true;
}
else {
tabs = this.$refs['alltabs'].$children.filter(
child => typeof child.$vnode.key === 'string' || child.$vnode.key instanceof String
).map(child => child.$vnode.key)
selectTab = tabs.indexOf(tab_param)
if (selectTab >= 0) {
this.tabIndex = selectTab;
} else {
this.tabIndex = 0;
}
this.$root.selectedDataset.has_files = false;
}
// now set the correct tab:
this.setCorrectTab(
this.$root.selectedDataset.has_subdatasets,
this.$root.selectedDataset.has_files
)
next();
},
async created() {
var has_subdatasets, has_files
console.log('\n---CREATED---\n')
console.log(this.$route.params.tab_name)
console.log('\n---CREATED---\n')
file = getFilePath(
this.$route.params.dataset_id,
this.$route.params.dataset_version,
Expand Down Expand Up @@ -685,55 +694,33 @@ const datasetView = () =>
this.$root.selectedDataset.subdatasets_available_count = subdatasets_available.length
this.$root.selectedDataset.subdatasets_unavailable_count = subdatasets_unavailable.length
this.subdatasets_ready = true;
has_subdatasets = true;
this.$root.selectedDataset.has_subdatasets = true;
} else {
this.$root.selectedDataset.subdatasets = [];
this.$root.selectedDataset.subdatasets_count = 0
this.$root.selectedDataset.subdatasets_available_count = 0
this.$root.selectedDataset.subdatasets_unavailable_count = 0
this.subdatasets_ready = true;
has_subdatasets = false;
// Now check file content
this.files_ready = false;
this.$root.selectedDataset.tree = this.$root.selectedDataset["children"];
this.files_ready = true;
if (
this.$root.selectedDataset.hasOwnProperty("tree") &&
this.$root.selectedDataset.tree instanceof Array &&
this.$root.selectedDataset.tree.length > 0
) {
has_files = true;
}
else {
has_files = false;
}
this.$root.selectedDataset.has_subdatasets = false;
}
// now set the correct tab:
var tab_param = this.$route.params.tab_name;
if (!tab_param) {
if (has_subdatasets) {
this.tabIndex = 0;
}
else {
if (has_files) {
this.tabIndex = 1;
}
else {
this.tabIndex = 2;
}
}
// Now check file content
this.files_ready = false;
this.$root.selectedDataset.tree = this.$root.selectedDataset["children"];
this.files_ready = true;
if (
this.$root.selectedDataset.hasOwnProperty("tree") &&
this.$root.selectedDataset.tree instanceof Array &&
this.$root.selectedDataset.tree.length > 0
) {
this.$root.selectedDataset.has_files = true;
}
else {
tabs = this.$refs['alltabs'].$children.filter(
child => typeof child.$vnode.key === 'string' || child.$vnode.key instanceof String
).map(child => child.$vnode.key)
selectTab = tabs.indexOf(tab_param)
if (selectTab >= 0) {
this.tabIndex = selectTab;
} else {
this.tabIndex = 0;
}
this.$root.selectedDataset.has_files = false;
}
this.setCorrectTab(
this.$root.selectedDataset.has_subdatasets,
this.$root.selectedDataset.has_files
)
},
mounted() {
this.tag_options_filtered = this.tag_options;
Expand Down
2 changes: 1 addition & 1 deletion datalad_catalog/catalog/templates/dataset-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ <h3>Cite dataset</h3>
</div>
</span>
<span v-else>
<span v-if="!sortedSubdatasets || !sortedSubdatasets.length"><em>There are no subdatasets listed for the current dataset</em></span>
<span v-if="!subdatasets || !subdatasets.length"><em>There are no subdatasets listed for the current dataset</em></span>
<span v-else>
<b-form>
<b-row>
Expand Down

0 comments on commit 84ffaa7

Please sign in to comment.