mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Merge pull request #14406 from mauro-miatello/develop
Hide/Show ecnrypted values when click on the lock icon
This commit is contained in:
commit
0e2aaebda4
|
@ -410,12 +410,13 @@
|
|||
</div>
|
||||
<div class="col-md-6{{ (($field->format=='URL') && ($asset->{$field->db_column_name()}!='')) ? ' ellipsis': '' }}">
|
||||
@if (($field->field_encrypted=='1') && ($asset->{$field->db_column_name()}!=''))
|
||||
<i class="fas fa-lock" data-tooltip="true" data-placement="top" title="{{ trans('admin/custom_fields/general.value_encrypted') }}"></i>
|
||||
<i class="fas fa-lock" data-tooltip="true" data-placement="top" title="{{ trans('admin/custom_fields/general.value_encrypted') }}" onclick="showHideEncValue(this)" id="text-{{ $field->id }}"></i>
|
||||
@endif
|
||||
|
||||
@if ($field->isFieldDecryptable($asset->{$field->db_column_name()} ))
|
||||
@can('assets.view.encrypted_custom_fields')
|
||||
<span class="js-copy-{{ $field->id }}">
|
||||
<span id="text-{{ $field->id }}-to-hide">********</span>
|
||||
<span class="js-copy-{{ $field->id }}" id="text-{{ $field->id }}-to-show" style="font-size: 0px;">
|
||||
@if (($field->format=='URL') && ($asset->{$field->db_column_name()}!=''))
|
||||
<a href="{{ Helper::gracefulDecrypt($field, $asset->{$field->db_column_name()}) }}" target="_new">{{ Helper::gracefulDecrypt($field, $asset->{$field->db_column_name()}) }}</a>
|
||||
@elseif (($field->format=='DATE') && ($asset->{$field->db_column_name()}!=''))
|
||||
|
@ -427,7 +428,7 @@
|
|||
<i class="fa-regular fa-clipboard js-copy-link" data-clipboard-target=".js-copy-{{ $field->id }}" aria-hidden="true" data-tooltip="true" data-placement="top" title="{{ trans('general.copy_to_clipboard') }}">
|
||||
<span class="sr-only">{{ trans('general.copy_to_clipboard') }}</span>
|
||||
</i>
|
||||
@else
|
||||
@else
|
||||
{{ strtoupper(trans('admin/custom_fields/general.encrypted')) }}
|
||||
@endcan
|
||||
|
||||
|
|
|
@ -964,8 +964,7 @@
|
|||
var clickedElement = $(e.trigger);
|
||||
// Get the target element selector from data attribute
|
||||
var targetSelector = clickedElement.data('data-clipboard-target');
|
||||
// Find the target element
|
||||
var targetEl = $(targetSelector);
|
||||
// Show the alert that the content was copied
|
||||
clickedElement.tooltip('hide').attr('data-original-title', '{{ trans('general.copied') }}').tooltip('show');
|
||||
});
|
||||
|
||||
|
@ -979,6 +978,23 @@
|
|||
});
|
||||
|
||||
|
||||
function showHideEncValue(e) {
|
||||
// Use element id to find the text element to hide / show
|
||||
var targetElement = e.id+"-to-show";
|
||||
var hiddenElement = e.id+"-to-hide";
|
||||
if($(e).hasClass('fa-lock')) {
|
||||
$(e).removeClass('fa-lock').addClass('fa-unlock');
|
||||
// Show the encrypted custom value and hide the element with asterisks
|
||||
document.getElementById(targetElement).style.fontSize = "100%";
|
||||
document.getElementById(hiddenElement).style.display = "none";
|
||||
} else {
|
||||
$(e).removeClass('fa-unlock').addClass('fa-lock');
|
||||
// ClipboardJS can't copy display:none elements so use a trick to hide the value
|
||||
document.getElementById(targetElement).style.fontSize = "0px";
|
||||
document.getElementById(hiddenElement).style.display = "";
|
||||
}
|
||||
}
|
||||
|
||||
$(function () {
|
||||
|
||||
// Invoke Bootstrap 3's tooltip
|
||||
|
|
Loading…
Reference in a new issue