1 {% macro render_field(field, label=None, label_visible=true, right_url=None, right_label=None, fieldclass=None) -%}
2 <div class="form-group {% if field.errors %}has-error{% endif %} {{ kwargs.pop('class_', '') }}">
3 {% if field.type != 'HiddenField' and label_visible %}
4 {% if not label and label != "" %}{% set label=field.label.text %}{% endif %}
5 {% if label %}<label for="{{ field.id }}">{{ label|safe }}</label>{% endif %}
7 {{ field(class_=fieldclass or 'form-control', **kwargs) }}
9 {% for e in field.errors %}
10 <p class="help-block">{{ e }}</p>
16 {% macro form_scripts() -%}
17 <link href="/static/jquery-ui.min.css" rel="stylesheet" type="text/css">
18 <script src="/static/jquery-ui.min.js"></script>
19 <script src="/static/tagselector.js?v=2"></script>
22 {% macro package_lists() -%}
25 {% for m in mpackages %}
26 {# This is safe as name can only contain `[a-z0-9_]` #}
29 value: "{{ m.name }}",
30 toString: function() { return "{{ m.name }}"; },
35 function escape(unsafe) {
37 .replace(/&/g, "&")
38 .replace(/</g, "<")
39 .replace(/>/g, ">")
40 .replace(/"/g, """)
41 .replace(/'/g, "'");
44 all_packages = meta_packages.slice();
46 {% for p in packages %}
48 id: "{{ p.author.username }}/{{ p.name }}",
49 value: escape({{ p.title | tojson }} + " by " + {{ p.author.display_name | tojson }}),
50 toString: function() { return escape({{ p.title | tojson }} + " by " + {{ p.author.display_name | tojson }} + " only"); },
56 {% macro render_multiselect_field(field, label=None, label_visible=true, right_url=None, right_label=None) -%}
57 <div class="form-group {% if field.errors %}has-error{% endif %} {{ kwargs.pop('class_', '') }}">
58 {% if field.type != 'HiddenField' and label_visible %}
59 {% if not label %}{% set label=field.label.text %}{% endif %}
60 <label for="{{ field.id }}">{{ label|safe }}</label>
62 <div class="multichoice_selector bulletselector form-control">
63 <input type="text" placeholder="Start typing to see suggestions">
64 <div class="clearboth"></div>
66 <div class="invalid-remaining invalid-feedback"></div>
67 {{ field(class_='form-control', **kwargs) }}
69 {% for e in field.errors %}
70 <div class="invalid-feedback">{{ e }}</div>
76 {% macro render_mpackage_field(field, label=None, label_visible=true, right_url=None, right_label=None) -%}
77 <div class="form-group {% if field.errors %}has-error{% endif %} {{ kwargs.pop('class_', '') }}">
78 {% if field.type != 'HiddenField' and label_visible %}
79 {% if not label %}{% set label=field.label.text %}{% endif %}
80 <label for="{{ field.id }}">{{ label|safe }}</label>
82 <div class="metapackage_selector bulletselector form-control">
83 <input type="text" placeholder="Comma-seperated values">
84 <div class="clearboth"></div>
86 {{ field(class_='form-control', **kwargs) }}
87 <div class="invalid-remaining invalid-feedback"></div>
89 {% for e in field.errors %}
90 <p class="help-block">{{ e }}</p>
96 {% macro render_deps_field(field, label=None, label_visible=true, right_url=None, right_label=None) -%}
97 <div class="form-group {% if field.errors %}has-error{% endif %} {{ kwargs.pop('class_', '') }}">
98 {% if field.type != 'HiddenField' and label_visible %}
99 {% if not label %}{% set label=field.label.text %}{% endif %}
100 <label for="{{ field.id }}">{{ label|safe }}</label>
102 <div class="deps_selector bulletselector form-control">
103 <input type="text" placeholder="Comma-seperated values">
104 <div class="clearboth"></div>
106 {{ field(class_='form-control', **kwargs) }}
107 <div class="invalid-remaining invalid-feedback"></div>
108 {% if field.errors %}
109 {% for e in field.errors %}
110 <p class="help-block">{{ e }}</p>
116 {% macro render_checkbox_field(field, label=None) -%}
117 {% if not label %}{% set label=field.label.text %}{% endif %}
118 <div class="checkbox {{ kwargs.pop('class_', '') }}">
120 {{ field(type='checkbox', **kwargs) }} {{ label }}
125 {% macro render_radio_field(field) -%}
126 {% for value, label, checked in field.iter_choices() %}
127 <div class="form-check my-1">
128 <label class="form-check-label">
129 <input class="form-check-input" type="radio" name="{{ field.id }}" id="{{ field.id }}" value="{{ value }}"{% if checked %} checked{% endif %}>
136 {% macro render_toggle_field(field, icons=[]) -%}
137 <div class="btn-group btn-group-toggle" data-toggle="buttons">
138 {% for value, label, checked in field.iter_choices() %}
139 <label class="btn btn-primary{% if checked %} active{% endif %}">
140 {% set icon = icons[value] %}
142 <i class="fas {{ icon }} mr-2"></i>
144 <input type="radio" name="{{ field.id }}" id="{{ field.id }}" value="{{ value }}" autocomplete="off" {% if checked %} checked{% endif %}>
151 {% macro render_submit_field(field, label=None, tabindex=None) -%}
152 {% if not label %}{% set label=field.label.text %}{% endif %}
153 {#<button type="submit" class="form-control btn btn-default btn-primary">{{label}}</button>#}
154 <input type="submit" value="{{label}}" class="btn btn-primary"
155 {% if tabindex %}tabindex="{{ tabindex }}"{% endif %}