Skip to content

Commit

Permalink
Merge pull request #199 from ufal/minor-ui-fixes
Browse files Browse the repository at this point in the history
Minor UI fixes
  • Loading branch information
kasnerz authored Jan 30, 2025
2 parents b7ffc34 + b80d465 commit aebff0e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 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
4 changes: 2 additions & 2 deletions factgenie/templates/pages/crowdsourcing_new.html
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ <h3>New crowdsourcing campaign</h3>
<div class="accordion mt-3" id="advancedAccordion">
<div class="accordion-item">
<h2 class="accordion-header" id="headingAdvanced">
<button class="accordion-button collapsed" type="button" data-bs-toggle="collapse"
<button class="accordion-button" type="button" data-bs-toggle="collapse"
data-bs-target="#collapseAdvanced" aria-expanded="false" aria-controls="collapseAdvanced">
Example-level inputs
</button>
</h2>
<div id="collapseAdvanced" class="accordion-collapse collapse" aria-labelledby="headingAdvanced"
<div id="collapseAdvanced" class="accordion-collapse collapse show" aria-labelledby="headingAdvanced"
data-bs-parent="#advancedAccordion">
<div class="accordion-body">
<div class="row mb-3 align-items-center">
Expand Down
8 changes: 8 additions & 0 deletions factgenie/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,14 @@ def get_output_index(app, force_reload=True):
elif app.db["output_index"] is None:
app.db["output_index"] = pd.DataFrame(columns=cols)

# Hotfix to prevent duplicate outputs after some updates
# Probably a caching issue, should be fixed more properly
app.db["output_index"] = (
app.db["output_index"]
.drop_duplicates(subset=["dataset", "split", "setup_id", "example_idx"], keep="last")
.reset_index(drop=True)
)

return app.db["output_index"]


Expand Down

0 comments on commit aebff0e

Please sign in to comment.