diff --git a/src/webcomponents/clinical/clinical-analysis-view.js b/src/webcomponents/clinical/clinical-analysis-view.js index 2d71abade..963297a35 100644 --- a/src/webcomponents/clinical/clinical-analysis-view.js +++ b/src/webcomponents/clinical/clinical-analysis-view.js @@ -296,7 +296,7 @@ export default class ClinicalAnalysisView extends LitElement { display: { template: "${priority.id}", className: { - "priority.id": (id, data) => this.#priorityFormatter(id, data), + "priority.id": (id, data) => `badge ${this.#priorityFormatter(id, data)}`, }, } }, diff --git a/src/webcomponents/clinical/interpretation/clinical-interpretation-summary.js b/src/webcomponents/clinical/interpretation/clinical-interpretation-summary.js index 3885b6c48..454d02ea3 100644 --- a/src/webcomponents/clinical/interpretation/clinical-interpretation-summary.js +++ b/src/webcomponents/clinical/interpretation/clinical-interpretation-summary.js @@ -22,7 +22,7 @@ export default class ClinicalInterpretationSummary extends LitElement { constructor() { super(); - this._init(); + this.#init(); } createRenderRoot() { @@ -40,10 +40,20 @@ export default class ClinicalInterpretationSummary extends LitElement { opencgaSession: { type: Object }, + displayConfig: { + type: Object, + }, }; } - _init() { + #init() { + this.displayConfigDefault = { + titleVisible: false, + titleWidth: 3, + defaultLayout: "horizontal", + style: "background-color:#f3f3f3;border-left: 4px solid #0c2f4c;padding:16px", + buttonsVisible: false, + }; this._config = this.getDefaultConfig(); } @@ -51,12 +61,20 @@ export default class ClinicalInterpretationSummary extends LitElement { if (changedProperties.has("interpretationId")) { this.interpretationIdObserver(); } + + if (changedProperties.has("displayConfig")) { + this._config = this.getDefaultConfig(); + } + super.update(changedProperties); } interpretationIdObserver() { if (this.opencgaSession && this.interpretationId) { - this.opencgaSession.opencgaClient.clinical().infoInterpretation(this.interpretationId, {study: this.opencgaSession.study.fqn}) + this.opencgaSession.opencgaClient.clinical() + .infoInterpretation(this.interpretationId, { + study: this.opencgaSession.study.fqn, + }) .then(response => { this.interpretation = response.responses[0].results[0]; }) @@ -107,11 +125,8 @@ export default class ClinicalInterpretationSummary extends LitElement { title: "Case Interpretation Summary", icon: "fas fa-user-md", display: { - titleVisible: false, - titleWidth: 3, - defaultLayout: "horizontal", - style: "background-color:#f3f3f3;border-left: 4px solid #0c2f4c;padding:16px", - buttonsVisible: false, + ...this.displayConfigDefault, + ...(this.displayConfig || {}), }, sections: [ { diff --git a/src/webcomponents/variant/variant-cohort-stats.js b/src/webcomponents/variant/variant-cohort-stats.js index 44283a0b2..10e5ef537 100644 --- a/src/webcomponents/variant/variant-cohort-stats.js +++ b/src/webcomponents/variant/variant-cohort-stats.js @@ -15,7 +15,6 @@ */ import {LitElement, html} from "lit"; -import UtilsNew from "../../core/utils-new.js"; import "./variant-cohort-stats-grid.js"; export default class VariantCohortStats extends LitElement { @@ -23,7 +22,7 @@ export default class VariantCohortStats extends LitElement { constructor() { super(); - this._init(); + this.#init(); } createRenderRoot() { @@ -50,12 +49,16 @@ export default class VariantCohortStats extends LitElement { }; } - _init() { - this._prefix = UtilsNew.randomString(8); + #init() { this.active = false; + this.studyNames = {}; } update(changedProperties) { + if (changedProperties.has("opencgaSession")) { + this.opencgaSessionObserver(); + } + if (changedProperties.has("variantId") || changedProperties.has("active")) { this.variantIdObserver(); } @@ -63,46 +66,60 @@ export default class VariantCohortStats extends LitElement { super.update(changedProperties); } + opencgaSessionObserver() { + this.studyNames = {}; + if (this.opencgaSession?.project?.studies) { + this.opencgaSession.project.studies.forEach(study => { + this.studyNames[study.id] = study.name; + this.studyNames[study.fqn] = study.name; + }); + } + } + variantIdObserver() { if (this.variantId && this.variantId.split(":").length > 2 && this.active) { - const params = { - id: this.variantId, - study: this.opencgaSession.study.fqn, - includeStudy: "all", - exclude: "annotation,studies.files,studies.samples,studies.scores,studies.issues", - useSearchIndex: "no" - }; - this.opencgaSession.opencgaClient.variants().query(params) + this.opencgaSession.opencgaClient.variants() + .query({ + id: this.variantId, + study: this.opencgaSession.study.fqn, + includeStudy: "all", + exclude: "annotation,studies.files,studies.samples,studies.scores,studies.issues", + useSearchIndex: "no", + }) .then(response => { if (response.responses[0].results[0]) { this.variant = response.responses[0].results[0]; this.requestUpdate(); } }) - .catch(function(reason) { - console.error(reason); + .catch(error => { + console.error(error); }); } } render() { - let studyNames = {}; - for (let study of this.opencgaSession.project.studies) { - studyNames[study.id] = study.name; - studyNames[study.fqn] = study.name; + if (!this.variant || !(this.variant?.studies?.length > 0)) { + return html` +