Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion bitmapist/cohort/tmpl/form_data.mako
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<link href="https://cdn.jsdelivr.net/npm/tom-select@2.3.1/dist/css/tom-select.default.min.css" rel="stylesheet" />
Comment thread
lukemerrett marked this conversation as resolved.
Outdated
<script src="https://cdn.jsdelivr.net/npm/tom-select@2.3.1/dist/js/tom-select.complete.min.js"></script>
Comment thread
lukemerrett marked this conversation as resolved.
Outdated
Comment thread
lukemerrett marked this conversation as resolved.
Outdated
Comment thread
lukemerrett marked this conversation as resolved.
Outdated

<style>
.cohort_form dd {
display: inline-block;
Expand All @@ -7,6 +10,14 @@
.cohort_form select {
max-width: 150px;
}

/* The event selects are enhanced with Tom Select, which renders its own
searchable control. Give that control a usable width. */
.cohort_form .ts-wrapper {
display: inline-block;
min-width: 200px;
vertical-align: middle;
}
</style>

<form action="${ action_url }" method="GET" class="cohort_form">
Expand Down Expand Up @@ -83,8 +94,20 @@
</dl>
</form>

<script>
// Turn the event dropdowns into searchable selects. With hundreds of
// bitmapist events, scrolling a native <select> is painful; Tom Select
// adds a type-to-filter search box while still submitting the same value.
document.querySelectorAll('.cohort-event-select').forEach(function (el) {
Comment thread
lukemerrett marked this conversation as resolved.
Outdated
new TomSelect(el, {
maxOptions: null, // never truncate the filtered list
Comment thread
lukemerrett marked this conversation as resolved.
Outdated
searchField: ['text', 'value'],
});
});
</script>

<%def name="render_options(select_name, selections, current_selection)">
<select name="${ select_name }">
<select name="${ select_name }" class="cohort-event-select">
%for option in selections:
%if option == '---':
<option value="" disabled="disabled">----</option>
Expand Down
Loading