mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 09:19:22 +02:00
feat: Settings: password input with hide/show options
This commit is contained in:
parent
19686725dc
commit
4fda4f643b
@ -348,7 +348,7 @@ return [
|
||||
],
|
||||
'database_password' => [
|
||||
'name' => 'Database Password',
|
||||
'type' => 'text',
|
||||
'type' => 'password',
|
||||
'default' => '',
|
||||
'show_if' => [
|
||||
'database_overwrite', '=', 'true'
|
||||
|
@ -247,7 +247,15 @@ class Settings implements \ArrayAccess
|
||||
$min = $max = $step = '';
|
||||
}
|
||||
|
||||
if ($setting['type'] === 'password') {
|
||||
echo '<div class="input-group" id="show-hide-' . $key . '">';
|
||||
}
|
||||
|
||||
echo '<input class="form-control" type="' . $setting['type'] . '" name="settings[' . $key . ']" value="' . ($settingsDb[$key] ?? ($setting['default'] ?? '')) . '" id="' . $key . '"' . $min . $max . $step . '/>';
|
||||
|
||||
if ($setting['type'] === 'password') {
|
||||
echo '<div class="input-group-append input-group-text"><a href=""><i class="fas fa-eye-slash" ></i></a></div></div>';
|
||||
}
|
||||
}
|
||||
|
||||
else if($setting['type'] === 'textarea') {
|
||||
|
@ -109,3 +109,26 @@
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
{% for key, value in settings %}
|
||||
{% if value.type == 'password' %}
|
||||
$(function () {
|
||||
$('#show-hide-{{ key}} a').on('click', function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const $showHideIcon = $('#show-hide-{{ key}} i');
|
||||
const $showHideInput = $('#show-hide-{{ key }} input');
|
||||
if($showHideInput.attr('type') === 'text'){
|
||||
$showHideInput.attr('type', 'password');
|
||||
$showHideIcon.addClass('fa-eye-slash');
|
||||
$showHideIcon.removeClass('fa-eye');
|
||||
}else if($showHideInput.attr("type") === 'password'){
|
||||
$showHideInput.attr('type', 'text');
|
||||
$showHideIcon.removeClass('fa-eye-slash');
|
||||
$showHideIcon.addClass('fa-eye');
|
||||
}
|
||||
});
|
||||
});
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user