public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
PHP
49%
JavaScript
35%
HTML
9%
CSS
4%
Shell
2%
Python
1%
Lua
0%
Perl
0%
Ruby
0%
SCSS
0%
Create file
Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git
Commit
[Web] fix attribute mapping list
e4284b8e
data/web/js/site/admin.js | 8 ++--
.../admin/tab-config-identity-provider.twig | 50 +++++++++++-----------
2 files changed, 31 insertions(+), 27 deletions(-)
Diff
diff --git a/data/web/js/site/admin.js b/data/web/js/site/admin.js
index b2f8ae1a..d2b206d2 100644
--- a/data/web/js/site/admin.js
+++ b/data/web/js/site/admin.js
@@ -771,7 +771,7 @@ jQuery(function($){
$('.iam_rolemap_add').click(async function(e){
e.preventDefault();
- var parent = $(this).parent().parent();
+ var parent = $('#iam_mapping_list')
$(parent).children().last().clone().appendTo(parent);
var newChild = $(parent).children().last();
$(newChild).find('input').val('');
@@ -784,12 +784,14 @@ jQuery(function($){
$('.iam_rolemap_del').off('click');
$('.iam_rolemap_del').click(async function(e){
e.preventDefault();
- $(this).parent().remove();
+ if ($(this).parent().parent().children().length > 1)
+ $(this).parent().remove();
});
});
$('.iam_rolemap_del').click(async function(e){
e.preventDefault();
- $(this).parent().remove();
+ if ($(this).parent().parent().children().length > 1)
+ $(this).parent().remove();
});
// selecting identity provider
$('#iam_provider').on('change', function(){
diff --git a/data/web/templates/admin/tab-config-identity-provider.twig b/data/web/templates/admin/tab-config-identity-provider.twig
index 1a42d008..a2aff987 100644
--- a/data/web/templates/admin/tab-config-identity-provider.twig
+++ b/data/web/templates/admin/tab-config-identity-provider.twig
@@ -70,32 +70,34 @@
<span class="w-100 ms-2">Template</span>
<button class="btn btn-sm d-block d-sm-inline btn-secondary ms-2 iam_rolemap_add"><i class="bi bi-plus-lg"></i></button>
</div>
- {% for key, role in iam_settings.mappers %}
- <div class="offset-sm-3 col-4 d-flex mb-2">
- <input type="text" class="form-control me-2" name="mappers" value="{{ iam_settings.mappers[key] }}" required>
- <select data-live-search="true" name="templates" class="form-control" title="{{ lang.mailbox.template }}" required>
- {% for mbox_template in mbox_templates %}
- <option{% if mbox_template.template == iam_settings.templates[key] %} selected{% endif %}>
- {{ mbox_template.template }}
- </option>
- {% endfor %}
- </select>
- <button class="iam_rolemap_del btn btn-sm d-block d-sm-inline btn-secondary ms-2"><i class="bi bi-x-lg"></i></button>
- </div>
- {% endfor %}
- {% if not iam_settings.mappers %}
- <div class="offset-sm-3 col-4 d-flex mb-2">
- <input type="text" class="form-control me-2" name="mappers" value="" required>
- <select data-live-search="true" name="templates" class="form-control" title="{{ lang.mailbox.template }}" required>
- {% for mbox_template in mbox_templates %}
- <option>
- {{ mbox_template.template }}
- </option>
+ <div id="iam_mapping_list">
+ {% for key, role in iam_settings.mappers %}
+ <div class="offset-sm-3 col-4 d-flex mb-2">
+ <input type="text" class="form-control me-2" name="mappers" value="{{ iam_settings.mappers[key] }}" required>
+ <select data-live-search="true" name="templates" class="form-control" title="{{ lang.mailbox.template }}" required>
+ {% for mbox_template in mbox_templates %}
+ <option{% if mbox_template.template == iam_settings.templates[key] %} selected{% endif %}>
+ {{ mbox_template.template }}
+ </option>
+ {% endfor %}
+ </select>
+ <button class="iam_rolemap_del btn btn-sm d-block d-sm-inline btn-secondary ms-2"><i class="bi bi-x-lg"></i></button>
+ </div>
{% endfor %}
- </select>
- <button class="iam_rolemap_del btn btn-sm d-block d-sm-inline btn-secondary ms-2"><i class="bi bi-x-lg"></i></button>
+ {% if not iam_settings.mappers %}
+ <div class="offset-sm-3 col-4 d-flex mb-2">
+ <input type="text" class="form-control me-2" name="mappers" value="" required>
+ <select data-live-search="true" name="templates" class="form-control" title="{{ lang.mailbox.template }}" required>
+ {% for mbox_template in mbox_templates %}
+ <option>
+ {{ mbox_template.template }}
+ </option>
+ {% endfor %}
+ </select>
+ <button class="iam_rolemap_del btn btn-sm d-block d-sm-inline btn-secondary ms-2"><i class="bi bi-x-lg"></i></button>
+ </div>
+ {% endif %}
</div>
- {% endif %}
</div>
<div class="row mb-2 mt-4">
<label class="control-label col-sm-3 text-sm-end"></label>