-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ReferenceOnListView): load last added bibsononmy title in form
This commit adds a small javascript snipplet to the `reference_list.html` template which autofills the bibsonomy forms `bibs_url` field with the data from the last added bibsonomy.
- Loading branch information
Showing
3 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
apis_bibsonomy/templates/apis_bibsonomy/partials/autofill_bibsonomy.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{% comment %} | ||
iterate through the `last_bibsonomy_reference` that is set in | ||
the session and use it to fill out the `bibs_url` form field | ||
{% endcomment %} | ||
<script> | ||
function autoFillBibsonomyForm() { | ||
{% spaceless %} | ||
{% for field, value in request.session.last_bibsonomy_reference.items %} | ||
{% if field == "bibs_url" %} | ||
var newOption = new Option("{{ request.session.last_bibsonomy_reference_title }}", "{{ value }}", true, true); | ||
$('select.listselect2').each(function() { | ||
$(this).append(newOption).trigger("change"); | ||
}); | ||
{% endif %} | ||
{% endfor %} | ||
{% endspaceless %} | ||
} | ||
document.body.onload = autoFillBibsonomyForm(); | ||
htmx.on("htmx:afterSettle", function(evt) { | ||
autoFillBibsonomyForm(); | ||
}); | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters