aboutsummaryrefslogtreecommitdiff
path: root/app/templates/macros/forms.html
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2018-05-25 16:53:25 +0100
committerrubenwardy <rw@rubenwardy.com>2018-05-25 16:53:25 +0100
commit211ed7c6fd223f293f5065b05127b95496b52cca (patch)
tree27c722b7ebdfb019a894e81f2fe7fe778cb85ab4 /app/templates/macros/forms.html
parentebd99165e9473e4b0f93574c3d0aa9a5c8090841 (diff)
downloadcheatdb-211ed7c6fd223f293f5065b05127b95496b52cca.tar.xz
Add fancy multichoice selector
Fixes #47
Diffstat (limited to 'app/templates/macros/forms.html')
-rw-r--r--app/templates/macros/forms.html88
1 files changed, 57 insertions, 31 deletions
diff --git a/app/templates/macros/forms.html b/app/templates/macros/forms.html
index a2b75a7..b23711a 100644
--- a/app/templates/macros/forms.html
+++ b/app/templates/macros/forms.html
@@ -1,42 +1,68 @@
{% macro render_field(field, label=None, label_visible=true, right_url=None, right_label=None) -%}
- <div class="form-group {% if field.errors %}has-error{% endif %} {{ kwargs.pop('class_', '') }}">
- {% if field.type != 'HiddenField' and label_visible %}
- {% if not label %}{% set label=field.label.text %}{% endif %}
- <label for="{{ field.id }}" class="control-label">{{ label|safe }}</label>
- {% endif %}
- {{ field(class_='form-control', **kwargs) }}
- {% if field.errors %}
- {% for e in field.errors %}
- <p class="help-block">{{ e }}</p>
- {% endfor %}
- {% endif %}
- </div>
+ <div class="form-group {% if field.errors %}has-error{% endif %} {{ kwargs.pop('class_', '') }}">
+ {% if field.type != 'HiddenField' and label_visible %}
+ {% if not label %}{% set label=field.label.text %}{% endif %}
+ <label for="{{ field.id }}" class="control-label">{{ label|safe }}</label>
+ {% endif %}
+ {{ field(class_='form-control', **kwargs) }}
+ {% if field.errors %}
+ {% for e in field.errors %}
+ <p class="help-block">{{ e }}</p>
+ {% endfor %}
+ {% endif %}
+ </div>
{%- endmacro %}
+{% macro form_includes() -%}
+ <link href="/static/jquery-ui.min.css" rel="stylesheet" type="text/css">
+ <script src="/static/jquery.min.js"></script>
+ <script src="/static/jquery-ui.min.js"></script>
+ <script src="/static/tagselector.js"></script>
+{% endmacro %}
+
+{% macro render_multiselect_field(field, label=None, label_visible=true, right_url=None, right_label=None) -%}
+ <div class="form-group {% if field.errors %}has-error{% endif %} {{ kwargs.pop('class_', '') }}">
+ {% if field.type != 'HiddenField' and label_visible %}
+ {% if not label %}{% set label=field.label.text %}{% endif %}
+ <label for="{{ field.id }}" class="control-label">{{ label|safe }}</label>
+ {% endif %}
+ <div class="multichoice_selector">
+ <input type="text" placeholder="Start typing to see suggestions">
+ <div class="clearboth"></div>
+ </div>
+ {{ field(class_='form-control', **kwargs) }}
+ {% if field.errors %}
+ {% for e in field.errors %}
+ <p class="help-block">{{ e }}</p>
+ {% endfor %}
+ {% endif %}
+ </div>
+{% endmacro %}
+
{% macro render_checkbox_field(field, label=None) -%}
- {% if not label %}{% set label=field.label.text %}{% endif %}
- <div class="checkbox">
- <label>
- {{ field(type='checkbox', **kwargs) }} {{ label }}
- </label>
- </div>
+ {% if not label %}{% set label=field.label.text %}{% endif %}
+ <div class="checkbox">
+ <label>
+ {{ field(type='checkbox', **kwargs) }} {{ label }}
+ </label>
+ </div>
{%- endmacro %}
{% macro render_radio_field(field) -%}
- {% for value, label, checked in field.iter_choices() %}
- <div class="radio">
- <label>
- <input type="radio" name="{{ field.id }}" id="{{ field.id }}" value="{{ value }}"{% if checked %} checked{% endif %}>
- {{ label }}
- </label>
- </div>
- {% endfor %}
+ {% for value, label, checked in field.iter_choices() %}
+ <div class="radio">
+ <label>
+ <input type="radio" name="{{ field.id }}" id="{{ field.id }}" value="{{ value }}"{% if checked %} checked{% endif %}>
+ {{ label }}
+ </label>
+ </div>
+ {% endfor %}
{%- endmacro %}
{% macro render_submit_field(field, label=None, tabindex=None) -%}
- {% if not label %}{% set label=field.label.text %}{% endif %}
- {#<button type="submit" class="form-control btn btn-default btn-primary">{{label}}</button>#}
- <input type="submit" value="{{label}}"
- {% if tabindex %}tabindex="{{ tabindex }}"{% endif %}
- >
+ {% if not label %}{% set label=field.label.text %}{% endif %}
+ {#<button type="submit" class="form-control btn btn-default btn-primary">{{label}}</button>#}
+ <input type="submit" value="{{label}}"
+ {% if tabindex %}tabindex="{{ tabindex }}"{% endif %}
+ >
{%- endmacro %}