Skip to content

Commit

Permalink
Merge branch 'release-2.8.x' into TASK-4547
Browse files Browse the repository at this point in the history
  • Loading branch information
jmjuanes authored Jul 25, 2023
2 parents e61d85a + eb0849d commit bebc79d
Show file tree
Hide file tree
Showing 13 changed files with 142 additions and 61 deletions.
45 changes: 37 additions & 8 deletions src/webcomponents/clinical/clinical-analysis-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default class ClinicalAnalysisUpdate extends LitElement {
#init() {
this.clinicalAnalysis = {};
this.clinicalAnalysisId = "";
this.buttonsDisabled = false;

this.displayConfig = {
titleWidth: 3,
Expand Down Expand Up @@ -89,11 +90,15 @@ export default class ClinicalAnalysisUpdate extends LitElement {
this.disordersAllowedValues = (this.clinicalAnalysis?.proband?.disorders?.length > 0) ?
this.clinicalAnalysis?.proband?.disorders?.map(disorder => disorder.id) :
[];

// Initialize the state of the submit and discard buttons
this.buttonsDisabled = !!this.clinicalAnalysis?.locked;
this._config = this.getDefaultConfig();
}

clinicalAnalysisIdObserver(e) {
this.clinicalAnalysis = e.detail.value;
/*
/*
// Fixme: discuss what to do with:
// (a) the custom event received.
// (b) event.status error and message (notified to the user in opencga-update catch)
Expand All @@ -104,13 +109,33 @@ export default class ClinicalAnalysisUpdate extends LitElement {
e.detail.value,
e.detail,
null);
*/
*/
// Initialize the state of the submit and discard buttons
this.buttonsDisabled = !!this.clinicalAnalysis?.locked;
this._config = this.getDefaultConfig();
this.requestUpdate();
}

opencgaSessionObserver() {
this.users = OpencgaCatalogUtils.getUsers(this.opencgaSession.study);
}

onComponentFieldChange(e) {
if (e.detail.param === "locked") {
if (this.clinicalAnalysis?.locked) {
this.buttonsDisabled = e.detail.value;
}
this._config = this.getDefaultConfig();
this.requestUpdate();
}
}

onComponentClear() {
this.buttonsDisabled = !!this.clinicalAnalysis?.locked;
this._config = this.getDefaultConfig();
this.requestUpdate();
}

render() {
return html`
<opencga-update
Expand All @@ -119,7 +144,9 @@ export default class ClinicalAnalysisUpdate extends LitElement {
.componentId="${this.clinicalAnalysisId}"
.opencgaSession="${this.opencgaSession}"
.config="${this._config}"
@componentIdObserver="${this.clinicalAnalysisIdObserver}">
@componentIdObserver="${this.clinicalAnalysisIdObserver}"
@componentFieldChange="${this.onComponentFieldChange}"
@componentClear="${this.onComponentClear}">
</opencga-update>
`;
}
Expand All @@ -129,7 +156,11 @@ export default class ClinicalAnalysisUpdate extends LitElement {
id: "clinical-analysis", // Fixme: clinical-analysis-update.js?
title: "Case Editor", // Fixme: Clinical Analysis update?
icon: "fas fa-user-md", // Fixme: to overwrite?
display: this.displayConfig,
display: {
...this.displayConfig,
buttonOkDisabled: this.buttonsDisabled,
buttonClearDisabled: this.buttonsDisabled,
},
sections: [
{
id: "summary",
Expand Down Expand Up @@ -320,12 +351,10 @@ export default class ClinicalAnalysisUpdate extends LitElement {
display: {
render: (panels, dataFormFilterChange, updateParams, clinicalAnalysis) => {
const handlePanelsFilterChange = e => {
// eslint-disable-next-line no-param-reassign
e.detail.value = e.detail.value
?.split(",")
const panels = (e.detail.value?.split(",") || [])
.filter(panelId => panelId)
.map(panelId => ({id: panelId}));
dataFormFilterChange(e.detail.value);
dataFormFilterChange(panels);
};
return html`
<disease-panel-filter
Expand Down
12 changes: 9 additions & 3 deletions src/webcomponents/clinical/clinical-analysis-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,16 @@ export default class ClinicalAnalysisView extends LitElement {
{
title: "Collection Method",
field: "collection.method",
defaultValue: "-",
display: {
defaultValue: "-",
},
},
{
title: "Preparation Method",
field: "processing.preparationMethod",
defaultValue: "-",
display: {
defaultValue: "-",
},
},
{
title: "Somatic",
Expand All @@ -427,7 +431,9 @@ export default class ClinicalAnalysisView extends LitElement {
{
title: "Status",
field: "status.name",
defaultValue: "-",
display: {
defaultValue: "-",
},
},
],
defaultValue: "No sample found",
Expand Down
8 changes: 5 additions & 3 deletions src/webcomponents/cohort/cohort-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,13 @@ export default class CohortView extends LitElement {
title: "Annotation sets",
field: "annotationSets",
type: "custom",
defaultValue: "N/A",
display: {
render: field => html`
<annotation-set-view
.annotationSets="${field}">
</annotation-set-view>
`,
defaultValue: "N/A",
},
},
],
Expand All @@ -246,15 +246,17 @@ export default class CohortView extends LitElement {
{
title: "Somatic",
field: "somatic",
defaultValue: "false",
display: {
defaultValue: "false",
},
},
{
title: "Phenotypes",
field: "phenotypes",
type: "custom",
defaultValue: "-",
display: {
render: data => data?.length ? html`${data.map(d => d.id).join(", ")}` : "-",
defaultValue: "-",
},
},
],
Expand Down
42 changes: 23 additions & 19 deletions src/webcomponents/commons/analysis/analysis-utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {html} from "lit";
import NotificationUtils from "../utils/notification-utils";
import UtilsNew from "../../../core/utils-new";
import "../../commons/filters/feature-filter.js";
import "../filters/feature-filter.js";
import "../filters/disease-panel-filter.js";

export default class AnalysisUtils {

Expand Down Expand Up @@ -78,30 +79,33 @@ export default class AnalysisUtils {
type: "custom",
display: {
visible: !ignoreList?.includes("ct"),
render: (ct, dataFormFilterChange) => {
return html`
<consequence-type-select-filter
.ct="${ct}"
.config="${CONSEQUENCE_TYPES}"
@filterChange="${e => dataFormFilterChange(e.detail.value)}">
</consequence-type-select-filter>
`;
}
render: (ct, dataFormFilterChange) => html`
<consequence-type-select-filter
.ct="${ct}"
.config="${CONSEQUENCE_TYPES}"
@filterChange="${e => dataFormFilterChange(e.detail.value)}">
</consequence-type-select-filter>
`,
}
},
{
title: "Disease Panel",
field: prefix + "panel",
type: "select",
allowedValues: opencgaSession?.study?.panels?.map(panel => (
{
id: panel.id,
name: `${panel.name}
${panel.source ? ` - ${panel.source.author || ""} ${panel.source.project} ${panel.source.version ? "v" + panel.source.version : ""}` : ""}
${panel.stats ? ` (${panel.stats.numberOfGenes} genes, ${panel.stats.numberOfRegions} regions)` : ""}`}
)) || [],
type: "custom",
display: {
visible: !ignoreList?.includes("panel")
visible: !ignoreList?.includes("panel"),
render: (panel, dataFormFilterChange, updateParams) => html`
<disease-panel-filter
.opencgaSession="${opencgaSession}"
.diseasePanels="${opencgaSession.study?.panels || []}"
.panel="${panel}"
.showExtendedFilters="${false}"
.showSelectedPanels="${false}"
.multiple="${false}"
.classes="${updateParams?.panels ? "selection-updated" : ""}"
@filterChange="${e => dataFormFilterChange(e.detail.value)}">
</disease-panel-filter>
`,
},
},
];
Expand Down
45 changes: 37 additions & 8 deletions src/webcomponents/commons/forms/data-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,14 @@ export default class DataForm extends LitElement {
const helpMessage = this._getHelpMessage(element);
const helpMode = this._getHelpMode(element);

if (error) {
return html `
<span class="${error.className}">
${error.message || "Error"}
</span>
`;
}

return html`
<div class="${hasErrorMessages ? "has-error" : nothing}">
<div data-testid="${this.config.test?.active ? `${this.config.test.prefix || "test"}-${element.field}` : nothing}">
Expand Down Expand Up @@ -944,15 +952,23 @@ export default class DataForm extends LitElement {
// Check values
if (!array || !array.length) {
const message = this._getDefaultValue(element);
return this._createElementTemplate(element, null, null, {message: message, className: "text-danger"});
return this._createElementTemplate(element, null, null, {
message: message,
});
}
if (!Array.isArray(array)) {
const message = `Field '${element.field}' is not an array`;
return this._createElementTemplate(element, null, null, {message: message, classname: "text-danger"});
return this._createElementTemplate(element, null, null, {
message: message,
classname: "text-danger"
});
}
if (contentLayout !== "horizontal" && contentLayout !== "vertical" && contentLayout !== "bullets") {
const message = "Content layout must be 'horizontal', 'vertical' or 'bullets'";
return this._createElementTemplate(element, null, null, {message: message, className: "text-danger"});
return this._createElementTemplate(element, null, null, {
message: message,
className: "text-danger"
});
}

// Apply the template to all Array elements and store them in 'values'
Expand Down Expand Up @@ -1022,7 +1038,7 @@ export default class DataForm extends LitElement {
const message = errorMessage ?? `Type 'table' requires a valid array field: ${element.field} not found`;
return this._createElementTemplate(element, null, null, {
message: message,
className: errorClassName
className: errorClassName,
});
}
if (!Array.isArray(array)) {
Expand Down Expand Up @@ -1138,7 +1154,11 @@ export default class DataForm extends LitElement {
return this._createElementTemplate(element, null, content);
} else {
const message = this._getErrorMessage(element);
return this._createElementTemplate(element, null, null, {message: message});
const errorClassName = element.display?.errorClassName ?? element.display?.errorClasses ?? "text-danger";
return this._createElementTemplate(element, null, null, {
message: message,
className: errorClassName,
});
}
}

Expand Down Expand Up @@ -1173,10 +1193,11 @@ export default class DataForm extends LitElement {
_createTreeElement(element) {
const json = this.getValue(element.field, this.data, this._getDefaultValue(element));
if (typeof element.display.apply !== "function") {
const errorClassName = element.display?.errorClassName ?? element.display?.errorClasses ?? "text-danger";
const message = "apply() function that provides a 'text' property is mandatory in Tree-Viewer elements";
return this._createElementTemplate(element, null, null, {
message: message,
classError: "text-danger"
classError: errorClassName,
});
} else {
if (Array.isArray(json)) {
Expand All @@ -1201,7 +1222,11 @@ export default class DataForm extends LitElement {
return this._createElementTemplate(element, null, content);
} else {
const message = "Unexpected JSON format";
return this._createElementTemplate(element, null, null, {message: message, classError: "text-danger"});
const errorClassName = element.display?.errorClassName ?? element.display?.errorClasses ?? "text-danger";
return this._createElementTemplate(element, null, null, {
message: message,
classError: errorClassName,
});
}
}
}
Expand Down Expand Up @@ -1230,7 +1255,11 @@ export default class DataForm extends LitElement {
return this._createElementTemplate(element, data, content);
} else {
const message = this._getErrorMessage(element);
return this._createElementTemplate(element, null, null, {message: message});
const errorClassName = element.display?.errorClassName ?? element.display?.errorClasses ?? "text-danger";
return this._createElementTemplate(element, null, null, {
message: message,
classError: errorClassName,
});
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/webcomponents/commons/opencga-update.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,12 @@ export default class OpencgaUpdate extends LitElement {
e.detail.value,
e.detail.action);

// Notify to parent components in case the want to perform any other action, fir instance, get the gene info in the disease panels.
LitUtils.dispatchCustomEvent(this, "componentFieldChange", e.detail.value, {component: this._component, action: e.detail.action}, null);
// Notify to parent components in case the want to perform any other action, for instance, get the gene info in the disease panels.
LitUtils.dispatchCustomEvent(this, "componentFieldChange", e.detail.value, {
component: this._component,
action: e.detail.action,
param: param,
});
this.requestUpdate();
}

Expand All @@ -354,6 +358,10 @@ export default class OpencgaUpdate extends LitElement {
ok: () => {
this.initOriginalObjects();
this.requestUpdate();
// We need to dispatch a component clear event
LitUtils.dispatchCustomEvent(this, "componentClear", null, {
component: this._component,
});
},
});
}
Expand Down
10 changes: 7 additions & 3 deletions src/webcomponents/family/family-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,16 @@ export default class FamilyView extends LitElement {
{
title: "Father ID",
field: "father.id",
defaultValue: "-"
display: {
defaultValue: "-",
},
},
{
title: "Mother ID",
field: "mother.id",
defaultValue: "-"
display: {
defaultValue: "-",
},
},
{
title: "Disorders",
Expand All @@ -337,9 +341,9 @@ export default class FamilyView extends LitElement {
title: "Phenotypes",
field: "phenotypes",
type: "custom",
defaultValue: "-",
display: {
render: data => data?.length ? html`${data.map(d => d.id).join(", ")}` : "-",
defaultValue: "-",
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion src/webcomponents/file/file-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export default class OpencgaFileGrid extends LitElement {
limit: params.data.limit,
skip: params.data.offset || 0,
count: !this.table.bootstrapTable("getOptions").pageNumber || this.table.bootstrapTable("getOptions").pageNumber === 1,
include: "id,name,path,uuid,samples,status,format,bioformat,size,creationDate,modificationDate,internal",
include: "id,name,path,uuid,sampleIds,status,format,bioformat,size,creationDate,modificationDate,internal",
...this.query
};
// When searching by directory we must also show directories
Expand Down
Loading

0 comments on commit bebc79d

Please sign in to comment.