Skip to content

Commit

Permalink
Fix display of Owner filter when they have No figures in group
Browse files Browse the repository at this point in the history
  • Loading branch information
will-moore committed Dec 3, 2024
1 parent c7e2e7b commit 967588c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,7 @@ <h5 class="modal-title">Open</h5>
</form>
</th>
<th>
Group:
Group:<br>
<div class="btn-group" title="Filter files by group">
<button
style="max-width: 120px; overflow: hidden;"
Expand All @@ -1102,7 +1102,7 @@ <h5 class="modal-title">Open</h5>
</div>
</th>
<th>
Owner:
Owner:<br>
<div class="btn-group" title="Filter files by owner">
<button
style="max-width: 120px; overflow: hidden;"
Expand Down
6 changes: 4 additions & 2 deletions src/js/views/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ export var FileListView = Backbone.View.extend({
self.$tbody.prepend(e);
});
var owners = this.model.pluck("owner");
// Lookup owner by ID "before" filtering, in case the chosen owner is filtered out
let owner = owners.find(o => o.id == filter.owner);
let ownerName = owner ? `${owner.firstName} ${owner.lastName}`: "Show All";

if (filter.group) {
let ownerIds = this.model.models.filter(f => f.get('group').id == filter.group).map(f => f.get('owner').id);
owners = owners.filter(o => ownerIds.includes(o.id));
Expand Down Expand Up @@ -284,8 +288,6 @@ export var FileListView = Backbone.View.extend({
</a></li>`;
});
$("#owner-menu").html(ownersHtml);
let owner = owners.find(o => o.id == filter.owner);
let ownerName = owner ? `${owner.firstName} ${owner.lastName}`: "Show All";
$("#selected_owner").html(ownerName);

// render groups chooser
Expand Down

0 comments on commit 967588c

Please sign in to comment.