-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move column selector from form to table
This commit changes the way the `column_selector` is set up. Up until now, it was a simple select input, that could only be used in conjunction with an existing form. That meant, that the colums selector had to be places at a position away from the actual table. Now the column selector is its own form, therefore it can be places whereever we want it. Also it is not a templatetag anymore, but a simple partial template that has to be included with {% include ... %}. The downside is, that we might now have multiple forms sending get parameters - this is where the new "form_get_hidden.html" template comes in. It adds existing get parameters to hidden fields in the form, that way multiple forms don't get in each others way. Closes: #173
- Loading branch information
Showing
5 changed files
with
46 additions
and
35 deletions.
There are no files selected for viewing
17 changes: 0 additions & 17 deletions
17
apis_core/apis_metainfo/templates/apis_metainfo/tags/column_selector.html
This file was deleted.
Oops, something went wrong.
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
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,20 @@ | ||
{% if togglable_columns %} | ||
<form class="form-inline float-right"> | ||
<select class="selectpicker" | ||
multiple | ||
data-selected-text-format="count > 2" | ||
name="columns" | ||
id="column_selector"> | ||
{% for col in togglable_columns %}<option value="{{ col }}">{{ col|title }}</option>{% endfor %} | ||
</select> | ||
{% include "partials/form_get_hidden.html" with request=request exclude_fields="columns" %} | ||
<button type="submit" class="form-control">Show</button> | ||
<script> | ||
$('#column_selector').on('loaded.bs.select', function (e) { | ||
var url = new URL(window.location.href); | ||
var columns = url.searchParams.getAll("columns"); | ||
$('#column_selector').selectpicker('val', columns); | ||
}); | ||
</script> | ||
</form> | ||
{% endif %} |
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,11 @@ | ||
{# this template is meant to be used in forms #} | ||
{# it add exisiting GET parameters to the form as hidden input fields #} | ||
{# it requires the request as argument `request` as well as an `exclude_fields` list #} | ||
{# this should be the list of fields of the form itself #} | ||
{% for field, values in request.GET.lists %} | ||
|
||
{% if field not in exclude_fields %} | ||
{% for value in values %}<input type="hidden" name="{{ field }}" value="{{ value }}" />{% endfor %} | ||
{% endif %} | ||
|
||
{% endfor %} |