Fossil SCM
make quickfilter work correctly with multirow reports
Commit
a42c48797cf44588fa53a6c983a8921eb0f9df0d6b31f12225d3aa122fee054a
Parent
6280151831c0c0a…
2 files changed
+15
-2
+2
-1
+15
-2
| --- src/quickfilter.js | ||
| +++ src/quickfilter.js | ||
| @@ -16,20 +16,26 @@ | ||
| 16 | 16 | }); |
| 17 | 17 | |
| 18 | 18 | quickfilter.addEventListener('input', function(){ |
| 19 | 19 | const filterrows = document.querySelectorAll('.filterable tbody tr'); |
| 20 | 20 | const filter = quickfilter.value.toLowerCase().trim(); |
| 21 | + let group = null; | |
| 22 | + let groupmatched = false; | |
| 21 | 23 | for(row of filterrows){ |
| 22 | 24 | const orig = row.innerHTML; |
| 23 | 25 | const cleaned = orig.replaceAll("<mark>", "").replaceAll("</mark>", ""); |
| 24 | 26 | if(filter===''){ |
| 25 | 27 | row.innerHTML = cleaned; |
| 26 | 28 | row.style.display = 'table-row'; |
| 27 | 29 | continue; |
| 30 | + } | |
| 31 | + if (row.classList.contains("separator")){ | |
| 32 | + group = []; | |
| 33 | + groupmatched = false; | |
| 28 | 34 | } |
| 29 | 35 | let ind = cleaned.toLowerCase().lastIndexOf(filter); |
| 30 | - if(ind<0){ | |
| 36 | + if(ind<0 && !groupmatched){ | |
| 31 | 37 | row.innerHTML = cleaned; |
| 32 | 38 | row.style.display = 'none'; |
| 33 | 39 | } |
| 34 | 40 | let marked = cleaned; |
| 35 | 41 | do{ |
| @@ -39,9 +45,16 @@ | ||
| 39 | 45 | marked.substring(ind, ind+filter.length)+'</mark>'+ |
| 40 | 46 | marked.substring(ind+filter.length); |
| 41 | 47 | } |
| 42 | 48 | ind = cleaned.toLowerCase().lastIndexOf(filter,ind-1); |
| 43 | 49 | }while(ind>=0); |
| 44 | - row.style.display = (marked===cleaned) ? 'none' : 'table-row'; | |
| 50 | + row.style.display = | |
| 51 | + (marked===cleaned && !groupmatched) ? 'none' : 'table-row'; | |
| 45 | 52 | row.innerHTML = marked; |
| 53 | + if (marked!=cleaned && group){ | |
| 54 | + if (!groupmatched) | |
| 55 | + for (grouprow of group) grouprow.style.display = 'table-row'; | |
| 56 | + groupmatched = true; | |
| 57 | + } | |
| 58 | + if (group) group.push(row); | |
| 46 | 59 | }; |
| 47 | 60 | }); |
| 48 | 61 |
| --- src/quickfilter.js | |
| +++ src/quickfilter.js | |
| @@ -16,20 +16,26 @@ | |
| 16 | }); |
| 17 | |
| 18 | quickfilter.addEventListener('input', function(){ |
| 19 | const filterrows = document.querySelectorAll('.filterable tbody tr'); |
| 20 | const filter = quickfilter.value.toLowerCase().trim(); |
| 21 | for(row of filterrows){ |
| 22 | const orig = row.innerHTML; |
| 23 | const cleaned = orig.replaceAll("<mark>", "").replaceAll("</mark>", ""); |
| 24 | if(filter===''){ |
| 25 | row.innerHTML = cleaned; |
| 26 | row.style.display = 'table-row'; |
| 27 | continue; |
| 28 | } |
| 29 | let ind = cleaned.toLowerCase().lastIndexOf(filter); |
| 30 | if(ind<0){ |
| 31 | row.innerHTML = cleaned; |
| 32 | row.style.display = 'none'; |
| 33 | } |
| 34 | let marked = cleaned; |
| 35 | do{ |
| @@ -39,9 +45,16 @@ | |
| 39 | marked.substring(ind, ind+filter.length)+'</mark>'+ |
| 40 | marked.substring(ind+filter.length); |
| 41 | } |
| 42 | ind = cleaned.toLowerCase().lastIndexOf(filter,ind-1); |
| 43 | }while(ind>=0); |
| 44 | row.style.display = (marked===cleaned) ? 'none' : 'table-row'; |
| 45 | row.innerHTML = marked; |
| 46 | }; |
| 47 | }); |
| 48 |
| --- src/quickfilter.js | |
| +++ src/quickfilter.js | |
| @@ -16,20 +16,26 @@ | |
| 16 | }); |
| 17 | |
| 18 | quickfilter.addEventListener('input', function(){ |
| 19 | const filterrows = document.querySelectorAll('.filterable tbody tr'); |
| 20 | const filter = quickfilter.value.toLowerCase().trim(); |
| 21 | let group = null; |
| 22 | let groupmatched = false; |
| 23 | for(row of filterrows){ |
| 24 | const orig = row.innerHTML; |
| 25 | const cleaned = orig.replaceAll("<mark>", "").replaceAll("</mark>", ""); |
| 26 | if(filter===''){ |
| 27 | row.innerHTML = cleaned; |
| 28 | row.style.display = 'table-row'; |
| 29 | continue; |
| 30 | } |
| 31 | if (row.classList.contains("separator")){ |
| 32 | group = []; |
| 33 | groupmatched = false; |
| 34 | } |
| 35 | let ind = cleaned.toLowerCase().lastIndexOf(filter); |
| 36 | if(ind<0 && !groupmatched){ |
| 37 | row.innerHTML = cleaned; |
| 38 | row.style.display = 'none'; |
| 39 | } |
| 40 | let marked = cleaned; |
| 41 | do{ |
| @@ -39,9 +45,16 @@ | |
| 45 | marked.substring(ind, ind+filter.length)+'</mark>'+ |
| 46 | marked.substring(ind+filter.length); |
| 47 | } |
| 48 | ind = cleaned.toLowerCase().lastIndexOf(filter,ind-1); |
| 49 | }while(ind>=0); |
| 50 | row.style.display = |
| 51 | (marked===cleaned && !groupmatched) ? 'none' : 'table-row'; |
| 52 | row.innerHTML = marked; |
| 53 | if (marked!=cleaned && group){ |
| 54 | if (!groupmatched) |
| 55 | for (grouprow of group) grouprow.style.display = 'table-row'; |
| 56 | groupmatched = true; |
| 57 | } |
| 58 | if (group) group.push(row); |
| 59 | }; |
| 60 | }); |
| 61 |
+2
-1
| --- src/report.c | ||
| +++ src/report.c | ||
| @@ -903,11 +903,12 @@ | ||
| 903 | 903 | |
| 904 | 904 | /* Output the separator above each entry in a table which has multiple lines |
| 905 | 905 | ** per database entry. |
| 906 | 906 | */ |
| 907 | 907 | if( pState->iNewRow>=0 ){ |
| 908 | - @ <tr><td colspan="%d(pState->nCol)" style="padding:0px"> | |
| 908 | + @ <tr class="separator"><td colspan="%d(pState->nCol)" | |
| 909 | + @ style="padding:0px"> | |
| 909 | 910 | @ <hr style="margin:0px"></td></tr> |
| 910 | 911 | } |
| 911 | 912 | |
| 912 | 913 | /* Output the data for this entry from the database |
| 913 | 914 | */ |
| 914 | 915 |
| --- src/report.c | |
| +++ src/report.c | |
| @@ -903,11 +903,12 @@ | |
| 903 | |
| 904 | /* Output the separator above each entry in a table which has multiple lines |
| 905 | ** per database entry. |
| 906 | */ |
| 907 | if( pState->iNewRow>=0 ){ |
| 908 | @ <tr><td colspan="%d(pState->nCol)" style="padding:0px"> |
| 909 | @ <hr style="margin:0px"></td></tr> |
| 910 | } |
| 911 | |
| 912 | /* Output the data for this entry from the database |
| 913 | */ |
| 914 |
| --- src/report.c | |
| +++ src/report.c | |
| @@ -903,11 +903,12 @@ | |
| 903 | |
| 904 | /* Output the separator above each entry in a table which has multiple lines |
| 905 | ** per database entry. |
| 906 | */ |
| 907 | if( pState->iNewRow>=0 ){ |
| 908 | @ <tr class="separator"><td colspan="%d(pState->nCol)" |
| 909 | @ style="padding:0px"> |
| 910 | @ <hr style="margin:0px"></td></tr> |
| 911 | } |
| 912 | |
| 913 | /* Output the data for this entry from the database |
| 914 | */ |
| 915 |