Skip to content

Commit

Permalink
#692 Minor changes to genetable filters.
Browse files Browse the repository at this point in the history
  • Loading branch information
lawal-olaotan committed Sep 8, 2023
1 parent b7abe29 commit f46c24f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 32 deletions.
42 changes: 23 additions & 19 deletions client-base/src/main/webapp/html/GeneView/summary-legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,17 @@ let conceptFilter = {
resetFun()
return
}

// NOTE: STILL IN TESTING PHASE
// checks wether filteredData saved from graphDistance and knetscore filter is present
// if not original table data will be used for concept evidence filtering.
let tableData = !this.filtered ? this.table : geneTableFilterMgr.filterByDistanceAndScore(undefined,this.table);





// Select what required, using the helper
var filteredTable = this.table.filter ( row => rowFilterPredicate ( selectedConcepts, row ) )
// Select what required, using the helper
const filteredTable = tableData.filter ( row => rowFilterPredicate ( selectedConcepts, row ) )

if (filteredTable.length > 0){
renderingFun ( filteredTable, this.tableId )
Expand All @@ -85,7 +92,7 @@ let conceptFilter = {
// NEEDS serious review for coherence!
$('#filterMessage').toggleClass('show-block',!displayOn);
$('.num-genes-container').toggleClass('show-block',displayOn);
$('#tablesorter').toggleClass('hide',!displayOn);
$('#geneTableBody').toggleClass('hide',!displayOn);
},
getConceptKeys(){
return this.selectedKeys
Expand Down Expand Up @@ -121,15 +128,14 @@ let geneViewConceptFilter = {
{
conceptFilter.toggleKnetTablesDisplay ( true )

if ( filteredTable && filteredTable.length > 0 ){
geneTableFilterMgr.filterByDistanceAndScore(undefined,filteredTable)
if ( filteredTable.length > 0 ){
genesTableScroller.setTableData (filteredTable);
createGeneTableBody(filteredTable)
}


},
resetTable(){
if(conceptFilter.filtered){
geneTableFilterMgr.filterByDistanceAndScore()
geneTableFilterMgr.filterByDistanceAndScore(undefined,this.tableData);
}else{
document.getElementById("revertGeneView").click();
}
Expand All @@ -139,28 +145,26 @@ let geneViewConceptFilter = {
try{


if ($('#'+this.tableId).css('display') !== 'block') return
if ($('#'+this.tableId).css('display') !== 'block') return

const selectedConcepts = this.getConceptKeys()

if(!selectedConcepts.length){
this.resetTable()
return
}
// Select what required, using the helper
const selectedConcepts = this.getConceptKeys();

// Select what required, using the helper
var filteredTable = tableData.filter ( row => this.rowFilterPred ( selectedConcepts, row ) )

if (filteredTable.length > 0){

genesTableScroller.setTableData (filteredTable);
createGeneTableBody( filteredTable);
return filteredTable

}else{
this.toggleKnetTablesDisplay ( false )
}
}catch(error){
console.error ( "Error while selecting from concept legend", error );
}
}
},

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,16 @@ const geneTableFilterMgr = function() {
}
},
// handles knetscore filtering
filterByDistanceAndScore: function(event = undefined, table = undefined) {
filterByDistanceAndScore: function(event, table) {

// checks if any concept evidence is selected, if not it renders concepts available in the filtered table.
const isConceptActive = $('.evidenceSummaryItem').hasClass("active-legend");

const data = !table ? [...tableData] : [...table]
// sets Tabledata either from table parameter or state saved tableData.
const dataTable = table ? [...table] : [...tableData];

// Checks if evidence concepts are in active states to filter concept evidence
const data = !isConceptActive ? dataTable : geneViewConceptFilter.filterbyData(dataTable);

if(event){
const element = event.target;
Expand Down Expand Up @@ -235,29 +242,34 @@ const geneTableFilterMgr = function() {
}

if(filteredData.length) {
geneTableFilterMgr.renderFilteredTable(filteredData,event);
geneTableFilterMgr.renderFilteredTable(filteredData,event, isConceptActive);
}

geneTableFilterMgr.toggleTableState(filteredData.length);
},
renderFilteredTable(table,event){
renderFilteredTable(table,event,isConceptActive){

// checks if any concept evidence is selected, if not it renders concepts available in the filtered table.
const isConceptActive = $('.evidenceSummaryItem').hasClass("active-legend");
genesTableScroller.setTableData (table);


if(!isConceptActive){
const interactiveSummaryLegend = getInteractiveSummaryLegend(table);
$('#filters').html(interactiveSummaryLegend)
}

// checks if filter function (filterByDistanceAndScore) is called from a click event or
// As a function (as called in summary-legend.js ln 125)

// STILL IN TESTING PHASE
if(event){
geneViewConceptFilter.filterbyData(table);
}else{
genesTableScroller.setTableData (table);
createGeneTableBody(table)
}

}else if(!event && !isConceptActive){
createGeneTableBody(table)
}else{
return data
}

// checks if filter function (filterByDistanceAndScore) is called from a click event or
// As a function (as called in summary-legend.js ln 125)

},
toggleTableState(dataLength){
if(dataLength <= 0)$('#filterMessage').text('Your filter is returning no results');
Expand Down

0 comments on commit f46c24f

Please sign in to comment.