diff --git a/client-base/src/main/webapp/html/GeneView/summary-legend.js b/client-base/src/main/webapp/html/GeneView/summary-legend.js index f8fdff986..f9f7d5bbc 100644 --- a/client-base/src/main/webapp/html/GeneView/summary-legend.js +++ b/client-base/src/main/webapp/html/GeneView/summary-legend.js @@ -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 ) @@ -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 @@ -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(); } @@ -139,20 +145,17 @@ 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 ) @@ -160,7 +163,8 @@ let geneViewConceptFilter = { }catch(error){ console.error ( "Error while selecting from concept legend", error ); } - } + }, + } /** diff --git a/client-base/src/main/webapp/html/javascript/genes-table-filtering.js b/client-base/src/main/webapp/html/javascript/genes-table-filtering.js index 7b748e447..e08b13ba2 100644 --- a/client-base/src/main/webapp/html/javascript/genes-table-filtering.js +++ b/client-base/src/main/webapp/html/javascript/genes-table-filtering.js @@ -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; @@ -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');