1
0
mirror of https://github.com/Mailu/Mailu.git synced 2024-12-14 10:53:30 +02:00

Fix select2 using webpack-built assets

This commit is contained in:
kaiyou 2019-05-06 19:08:08 +02:00
parent c2a04ab1d4
commit 2d3560b396
6 changed files with 8 additions and 23 deletions

View File

@ -8,11 +8,8 @@
{% call macros.box() %} {% call macros.box() %}
<form class="form" method="post" role="form"> <form class="form" method="post" role="form">
{{ form.hidden_tag() }} {{ form.hidden_tag() }}
{{ macros.form_field(form.admin, id='admin') }} {{ macros.form_field(form.admin, class_='mailselect') }}
{{ macros.form_field(form.submit) }} {{ macros.form_field(form.submit) }}
<script>
$("#admin").select2();
</script>
</form> </form>
{% endcall %} {% endcall %}
{% endblock %} {% endblock %}

View File

@ -14,15 +14,9 @@
{{ form.hidden_tag() }} {{ form.hidden_tag() }}
{{ macros.form_field(form.localpart, append='<span class="input-group-addon">@'+domain.name+'</span>') }} {{ macros.form_field(form.localpart, append='<span class="input-group-addon">@'+domain.name+'</span>') }}
{{ macros.form_field(form.wildcard) }} {{ macros.form_field(form.wildcard) }}
{{ macros.form_field(form.destination, id='destination') }} {{ macros.form_field(form.destination, class_='mailselect') }}
{{ macros.form_field(form.comment) }} {{ macros.form_field(form.comment) }}
{{ macros.form_field(form.submit) }} {{ macros.form_field(form.submit) }}
<script>
$("#destination").select2({
tags: true,
tokenSeparators: [',', ' ']
})
</script>
</form> </form>
{% endcall %} {% endcall %}
{% endblock %} {% endblock %}

View File

@ -31,14 +31,14 @@
</div> </div>
{% endmacro %} {% endmacro %}
{% macro form_individual_field(field, prepend='', append='', label=True) %} {% macro form_individual_field(field, prepend='', append='', label=True, class_="") %}
{% if field.type == "BooleanField" %} {% if field.type == "BooleanField" %}
{{ field(**kwargs) }}<span>&nbsp;&nbsp;</span> {{ field(**kwargs) }}<span>&nbsp;&nbsp;</span>
{{ field.label if label else '' }} {{ field.label if label else '' }}
{% else %} {% else %}
{{ field.label if label else '' }}{{ form_field_errors(field) }} {{ field.label if label else '' }}{{ form_field_errors(field) }}
{% if prepend or append %}<div class="input-group">{% endif %} {% if prepend or append %}<div class="input-group">{% endif %}
{{ prepend|safe }}{{ field(class_="form-control", **kwargs) }}{{ append|safe }} {{ prepend|safe }}{{ field(class_="form-control " + class_, **kwargs) }}{{ append|safe }}
{% if prepend or append %}</div>{% endif %} {% if prepend or append %}</div>{% endif %}
{% endif %} {% endif %}
{% endmacro %} {% endmacro %}

View File

@ -12,11 +12,8 @@
{% call macros.box() %} {% call macros.box() %}
<form class="form" method="post" role="form"> <form class="form" method="post" role="form">
{{ form.hidden_tag() }} {{ form.hidden_tag() }}
{{ macros.form_field(form.manager, id='manager') }} {{ macros.form_field(form.manager, class_='mailselect') }}
{{ macros.form_field(form.submit) }} {{ macros.form_field(form.submit) }}
<script>
$("#manager").select2();
</script>
</form> </form>
{% endcall %} {% endcall %}
{% endblock %} {% endblock %}

View File

@ -25,6 +25,7 @@
"node-sass": "^4.12.0", "node-sass": "^4.12.0",
"popper.js": "^1.15.0", "popper.js": "^1.15.0",
"sass-loader": "^7.1.0", "sass-loader": "^7.1.0",
"select2": "^4.0.7-rc.0",
"style-loader": "^0.23.1", "style-loader": "^0.23.1",
"url-loader": "^1.1.2", "url-loader": "^1.1.2",
"webpack": "^4.30.0", "webpack": "^4.30.0",

View File

@ -16,12 +16,8 @@ module.exports = {
rules: [ rules: [
{ {
test: /\.js$/, test: /\.js$/,
use: { use: ['babel-loader']
loader: "babel-loader",
options: {
presets: ['@babel/preset-env']
}
}
}, },
{ {
test: /\.scss$/, test: /\.scss$/,