Skip to content

Commit

Permalink
Merge pull request #992 from opencb/TASK-6866
Browse files Browse the repository at this point in the history
TASK-6866 - Issue in genotype filter dropdown in Samples-detail-tab in Variant Browser and Sample Variant Browser
  • Loading branch information
jmjuanes authored Nov 4, 2024
2 parents a023943 + e11788d commit a27300d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
3 changes: 1 addition & 2 deletions src/webcomponents/commons/forms/select-field-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ export default class SelectFieldFilter extends LitElement {
.select-field-filter .select2-results__options {
max-height: 600px !important;
}
.select-field-filter .select2-results__option--selected {
background-color: #fff !important;
color: #000 !important;
Expand All @@ -379,7 +378,7 @@ export default class SelectFieldFilter extends LitElement {
render() {
return html`
${this.renderStyle()}
<div class="input-group mb-1 select-field-filter">
<div class="input-group select-field-filter">
<select
class="form-select"
id="${this._prefix}"
Expand Down
52 changes: 26 additions & 26 deletions src/webcomponents/variant/variant-samples.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,8 @@ export default class VariantSamples extends LitElement {
this.gridCommons = new GridCommons(this.gridId, this, this.config);

// Nacho: to be more consistent with the rest of the application we are NOT selecting all genotypes by default
this.genotypeFilter = "";
this.selectedGenotypes = "";
// const selectedGenotypesArray = [];
// for (const genotype of this.config.genotypes) {
// if (genotype.fields) {
// selectedGenotypesArray.push(genotype.fields.filter(gt => gt.id).map(gt => gt.id).join(","));
// }
// }
// this.selectedGenotypes = selectedGenotypesArray.join(",");
}

updated(changedProperties) {
Expand Down Expand Up @@ -421,12 +415,15 @@ export default class VariantSamples extends LitElement {
}

onSelectFilterChange(e) {
this._genotypeFilter = e.detail?.value;
this.selectedGenotypes = e.detail?.value;
this.requestUpdate();
}

onSearch() {
this.genotypeFilter = this._genotypeFilter;
this.renderTable();
if (this.selectedGenotypes !== this.genotypeFilter) {
this.genotypeFilter = this.selectedGenotypes;
this.renderTable();
}
}

render() {
Expand All @@ -439,34 +436,37 @@ export default class VariantSamples extends LitElement {
<div>
${this.numSamples !== this.numUserTotalSamples ? html`
<div class="alert alert-warning">
<i class="fas fa-3x fa-exclamation-circle align-middle"></i>
<i class="fas fa-exclamation-circle me-1"></i>
Number of samples found is <span style="font-weight: bold">${this.numSamples}</span>
${this.approximateCount === true ? html` (<i>please note this is an estimated number</i>)` : ""}, and
your user account has permission to view <span style="font-weight: bold">${this.numUserTotalSamples} samples</span>.
Note that you might not have permission to view all samples for any variant.
</div>
` : nothing}
${this.selectedGenotypes !== this.genotypeFilter ? html`
<div class="alert alert-warning">
<i class="fas fa-exclamation-triangle align-middle me-1"></i>
<span>The selected genotypes have been updated. Please click the <b>Search</b> button to refresh the table with the updated results.</span>
</div>
` : nothing}
<div class="row" style="margin-top: 20px">
<div class="col-md-12">
<div class="col-md-4"><label>Select Genotypes:</label></div>
</div>
<div class="col-md-12">
<div class="col-md-4">
<div class="input-group">
<select-field-filter
.data="${this.config.genotypes}"
.value="${this.selectedGenotypes}"
.selectedTextFormat="${"count > 3"}"
.config="${{multiple: true}}"
@filterChange="${this.onSelectFilterChange}">
</select-field-filter>
<span class="input-group-btn">
<button class="btn btn-default" type="button" @click="${this.onSearch}">
<i class="fas fa-search"></i> Search
</button>
</span>
</div>
<div class="d-flex gap-1">
<select-field-filter
.data="${this.config.genotypes}"
.value="${this.selectedGenotypes}"
.selectedTextFormat="${"count > 3"}"
.config="${{multiple: true}}"
@filterChange="${this.onSelectFilterChange}">
</select-field-filter>
<button class="btn btn-light" type="button" @click="${this.onSearch}">
<i class="fas fa-search me-1"></i> Search
</button>
</div>
</div>
</div>
Expand Down

0 comments on commit a27300d

Please sign in to comment.