Skip to content

Commit

Permalink
Sort annotator ids in browse view
Browse files Browse the repository at this point in the history
  • Loading branch information
kasnerz committed Jan 30, 2025
1 parent 0bc488e commit 4d0bf02
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions factgenie/static/js/browse.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,15 @@ function createOutputBoxes(generated_outputs, highlight_setup_id) {
annIds.set(ann_id, { "campaign_id": campaign_id, "annotator_group": annotator_group });
});
});

const selectBox = $("#annotations-select");
// clear the selectbox
selectBox.empty();

const sortedAnnIds = Array.from(annIds.keys()).sort();

// add an option for each campaign id
for (const [ann_id, { campaign_id, annotator_group }] of annIds) {
for (const ann_id of sortedAnnIds) {
const button = $(`<button type="button" class="btn btn-sm btn-primary btn-ann-select" data-ann="${ann_id}">${ann_id}</button>`);
button.on('click', function () {
$(this).toggleClass('active');
Expand All @@ -124,7 +127,8 @@ function createOutputBoxes(generated_outputs, highlight_setup_id) {
card = createOutputBox(plain_output, null, "original", output.setup_id);
card.appendTo(groupDiv);

for (const [annId, { campaign_id, annotator_group }] of annIds) {
for (const annId of sortedAnnIds) {
const { campaign_id, annotator_group } = annIds.get(annId);
annotations = output.annotations.filter(a => a.campaign_id == campaign_id && a.annotator_group == annotator_group)[0];

const annotated_output = getAnnotatedOutput(output, annId, annotations);
Expand Down
2 changes: 1 addition & 1 deletion factgenie/templates/pages/browse.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
<div id='setuparea' style="display: none">
<div class="mb-1 d-flex align-items-center justify-content-between">
<small class="text-muted">
<i class="fa fa-pencil"></i> Annotations (click to show)
<i class="fa fa-pencil"></i> Annotations
</small>
<!-- <div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="badgesSwitch">
Expand Down

0 comments on commit 4d0bf02

Please sign in to comment.