mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 17:29:21 +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' => [
|
'database_password' => [
|
||||||
'name' => 'Database Password',
|
'name' => 'Database Password',
|
||||||
'type' => 'text',
|
'type' => 'password',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'show_if' => [
|
'show_if' => [
|
||||||
'database_overwrite', '=', 'true'
|
'database_overwrite', '=', 'true'
|
||||||
|
@ -247,7 +247,15 @@ class Settings implements \ArrayAccess
|
|||||||
$min = $max = $step = '';
|
$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 . '/>';
|
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') {
|
else if($setting['type'] === 'textarea') {
|
||||||
|
@ -109,3 +109,26 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</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