Skip to content

Commit a30cb0b

Browse files
author
Max Burnette
committed
Clean up search box behavior and update Changelog
1 parent a4cdb48 commit a30cb0b

File tree

4 files changed

+53
-20
lines changed

4 files changed

+53
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ of these changes a reindex of Elasticsearch is required. This can be started by
1414
- API add tags endpoint now returns the added tags.
1515
[CATS-1053](https://opensource.ncsa.illinois.edu/jira/browse/CATS-1053)
1616
- Ability to search by creator name and email address for all resources.
17+
- Ability to filter the files and folders in a dataset when sorting is enabled.
1718

1819
### Fixed
1920
- Ability to delete tags on file page.

app/controllers/Datasets.scala

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -661,17 +661,22 @@ class Datasets @Inject() (
661661
}
662662

663663
val filteredFiles = filter match {
664-
case Some(filt) => files.get(childFiles).found.filter(f => f.filename.contains(filt))
664+
case Some(filt) => files.get(childFiles).found.filter(f => f.filename.toLowerCase.contains(filt.toLowerCase))
665665
case None => files.get(childFiles).found
666666
}
667667

668+
val filteredFolders = filter match {
669+
case Some(filt) => folders.get(childFolders).found.filter(f => f.name.toLowerCase.contains(filt.toLowerCase))
670+
case None => folders.get(childFolders).found
671+
}
672+
668673
val (foldersList: List[Folder], limitFileList: List[File]) =
669674
if (play.Play.application().configuration().getBoolean("sortInMemory")) {
670-
(SortingUtils.sortFolders(childFolders.flatMap(f => folders.get(f)), sortOrder).slice(limit * filepageUpdate, limit * (filepageUpdate + 1)),
671-
SortingUtils.sortFiles(filteredFiles, sortOrder).slice(limit * filepageUpdate - childFolders.length, limit * (filepageUpdate + 1) - childFolders.length))
675+
(SortingUtils.sortFolders(filteredFolders, sortOrder).slice(limit * filepageUpdate, limit * (filepageUpdate + 1)),
676+
SortingUtils.sortFiles(filteredFiles, sortOrder).slice(limit * filepageUpdate - filteredFolders.length, limit * (filepageUpdate + 1) - filteredFolders.length))
672677
} else {
673-
(childFolders.reverse.slice(limit * filepageUpdate, limit * (filepageUpdate + 1)).flatMap(f => folders.get(f)),
674-
childFiles.reverse.slice(limit * filepageUpdate - childFolders.length, limit * (filepageUpdate + 1) - childFolders.length).flatMap(f => files.get(f)))
678+
(folders.get(childFolders.reverse.slice(limit * filepageUpdate, limit * (filepageUpdate + 1))).found,
679+
files.get(childFiles.reverse.slice(limit * filepageUpdate - childFolders.length, limit * (filepageUpdate + 1) - childFolders.length)).found)
675680
}
676681

677682
// Get comment counts per file

app/views/dataset.scala.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,6 @@ <h4>Statistics</h4>
605605

606606
$(function() {
607607
$(window).on('fileDelete hashchange', function() {
608-
609608
getUpdatedFilesAndFolders();
610609
});
611610

app/views/datasets/filesAndFolders.scala.html

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,56 @@
2727
});
2828
});
2929
</script>
30-
3130
<!--label class="sortchoice" for="filename-filter">Filter:-->
32-
<input class="form-horizontal" id="filename-filter" placeholder="Filter filenames..."
33-
value="@filter.getOrElse("")"
34-
onchange="getUpdatedFilesAndFolders()">
31+
<table width=100%"">
32+
<td width="40%">
33+
<div class="input-group">
34+
<!-- TODO: Should the filter value reset when folder level changes? -->
35+
<input type="text" class="form-horizontal form-control" id="filename-filter" placeholder="Search folder and file names..."
36+
value="@filter.getOrElse("")"
37+
onchange="getUpdatedFilesAndFolders()">
38+
<div class="input-group-btn">
39+
<button class="btn btn-default" onclick="getUpdatedFilesAndFolders()">
40+
<span class="glyphicon glyphicon-search"></span></button>
41+
</div>
42+
</div>
43+
</td>
44+
<td width="30%">
45+
<div id="filter-box-value">
46+
&nbsp;
47+
@if(filter.getOrElse("")!="") {
48+
Filtering by <b>@filter.get</b>
49+
}
50+
</div>
51+
</td>
52+
<td width="30%">
53+
<label class="sortchoice" for="js-sort-single">Sort By:
54+
<select class="js-sort-single">
55+
<option value="dateN">Newest</option>
56+
<option value="dateO">Oldest</option>
57+
<option value="titleA">Title (A-Z)</option>
58+
<option value="titleZ">Title (Z-A)</option>
59+
<option value="sizeL">Size (L)</option>
60+
<option value="sizeS">Size (S)</option>
61+
</select>
62+
</td>
63+
</table>
64+
65+
3566

36-
<label class="sortchoice" for="js-sort-single">Sort By:
37-
<select class="js-sort-single">
38-
<option value="dateN">Newest</option>
39-
<option value="dateO">Oldest</option>
40-
<option value="titleA">Title (A-Z)</option>
41-
<option value="titleZ">Title (Z-A)</option>
42-
<option value="sizeL">Size (L)</option>
43-
<option value="sizeS">Size (S)</option>
44-
</select>
4567

4668
</label>
4769
</div>
4870
}
4971

5072
<!-- Show message when the folder is empty -->
51-
<div style="display: none" id="empty-folder-div"><h4>Folder is empty</h4></div>
73+
<div style="display: none" id="empty-folder-div"><h4>
74+
@if(!filter.isEmpty) {
75+
No results found
76+
} else {
77+
Folder is empty
78+
}
79+
</h4></div>
5280
@if(foldersList.size == 0 && fileList.size == 0 ){
5381
<script>$("#empty-folder-div").show();</script>
5482
}

0 commit comments

Comments
 (0)