Skip to content

Commit

Permalink
iva-app: Fix updating url when changing active study #TASK-7216 #TASK…
Browse files Browse the repository at this point in the history
…-7100
  • Loading branch information
jmjuanes committed Nov 26, 2024
1 parent 50b289e commit d507ef4
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions src/sites/iva/iva-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -820,34 +820,26 @@ class IvaApp extends LitElement {
lastStudy: studyFqn
});

// 2. Set the new Hash URL
const hashItems = window.location.hash.replace(/^#/, "").split("/");
// 2. set the new Hash URL
const [hashFragments, hashQuery] = window.location.hash.replace("#", "").split("?");
const hashItems = hashFragments.split("/");
let newHashFragmentUrl = "";

// 2.1. If the hash fragment only contains one or three items, it is a single tool URL
if (hashItems.length === 1 || hashItems.length === 3) {
window.location.hash = `${hashItems[0]}/${this.opencgaSession.project.id}/${this.opencgaSession.study.id}`;
newHashFragmentUrl = `${hashItems[0]}/${this.opencgaSession.project.id}/${this.opencgaSession.study.id}`;
}
// 2.2 if the hash fragment contains two or more than three items, it is an app/tool URL
else if (hashItems.length === 1 || hashItems.length > 3) {

// 2.2 if the hash fragment contains two or four items, it is an app/tool URL
else if (hashItems.length === 2 || hashItems.length === 4) {
// NOTE: if we change current sudy in the interpreter, we must remove the clinical analysis id from the hash fragment
// and redirect to case portal
const tool = hashItems[1] !== "interpreter" ? hashItems[1] : "clinical-analysis-portal";
let newHashFragmentUrl = `${hashItems[0]}/${tool}/${this.opencgaSession.project.id}/${this.opencgaSession.study.id}`;
// add the rest of the items to the hash fragment
if (hashItems.length > 4 && hashItems[1] !== "interpreter") {
for (let i = 4; i < hashItems.length; i++) {
newHashFragmentUrl += "/" + hashItems[i];
}
}
window.location.hash = newHashFragmentUrl;
newHashFragmentUrl = `${hashItems[0]}/${tool}/${this.opencgaSession.project.id}/${this.opencgaSession.study.id}`;
}
// let newHashFragmentUrl = this.tool !== "#interpreter" ? this.tool : "#clinicalAnalysisPortal";
// if (this.opencgaSession?.project) {
// newHashFragmentUrl += "/" + this.opencgaSession.project.id;
// if (this.opencgaSession.study) {
// newHashFragmentUrl += "/" + this.opencgaSession.study.id;
// }
// }
// window.location.hash = newHashFragmentUrl;

// 2.3. reset hash including queries (if any)
window.location.hash = newHashFragmentUrl + (hashQuery ? `?${hashQuery}` : "");

// 3. Reset queries from old studies
this.queries = {};
Expand Down

0 comments on commit d507ef4

Please sign in to comment.