From 8f425ce081b614053bd052f0c8dca0ec46aac175 Mon Sep 17 00:00:00 2001 From: Alexander Graf Date: Fri, 27 Jan 2023 15:28:58 +0100 Subject: [PATCH] Move unit to data-attr and fix defaulting to 1 --- core/admin/assets/assets/app.js | 4 ++-- core/admin/mailu/ui/templates/domain/create.html | 2 +- core/admin/mailu/ui/templates/user/create.html | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/admin/assets/assets/app.js b/core/admin/assets/assets/app.js index a5338878..33f63433 100644 --- a/core/admin/assets/assets/app.js +++ b/core/admin/assets/assets/app.js @@ -86,8 +86,8 @@ $('document').ready(function() { if (value_element.length) { value_element = $(value_element[0]); var infinity = $(this).data('infinity'); - var unit = $(this).attr('unit'); - if (typeof unit === 'undefined' && unit === false) { + var unit = $(this).data('unit'); + if (typeof unit === 'undefined' || unit === false) { unit=1; } $(this).on('input', function() { diff --git a/core/admin/mailu/ui/templates/domain/create.html b/core/admin/mailu/ui/templates/domain/create.html index 5674e52b..4eb7bfc8 100644 --- a/core/admin/mailu/ui/templates/domain/create.html +++ b/core/admin/mailu/ui/templates/domain/create.html @@ -10,7 +10,7 @@ {{ form.hidden_tag() }} {{ macros.form_field(form.name) }} {{ macros.form_fields((form.max_users, form.max_aliases)) }} - {{ macros.form_field(form.max_quota_bytes, unit=10**9, step=50*10**6, max=50*10**9, data_infinity="true", + {{ macros.form_field(form.max_quota_bytes, step=50*10**6, max=50*10**9, data_infinity="true", data_unit=10**9, prepend=' GB') }} {{ macros.form_field(form.signup_enabled) }} {{ macros.form_field(form.comment) }} diff --git a/core/admin/mailu/ui/templates/user/create.html b/core/admin/mailu/ui/templates/user/create.html index ba8904f6..dff78f64 100644 --- a/core/admin/mailu/ui/templates/user/create.html +++ b/core/admin/mailu/ui/templates/user/create.html @@ -21,7 +21,7 @@ {%- endcall %} {%- call macros.card(_("Features and quotas"), theme="success") %} - {{ macros.form_field(form.quota_bytes, unit=10**9, step=50*10**6, max=(max_quota_bytes or domain.max_quota_bytes or 50*10**9), data_infinity="true", + {{ macros.form_field(form.quota_bytes, step=50*10**6, max=(max_quota_bytes or domain.max_quota_bytes or 50*10**9), data_infinity="true", data_unit=10**9, prepend=' GB') }} {{ macros.form_field(form.enable_imap) }} {{ macros.form_field(form.enable_pop) }}