mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Refactor out common code for 'custom fields view' partial
This commit is contained in:
parent
48fd6f3f26
commit
873d260f55
|
@ -11,7 +11,7 @@ use Illuminate\Support\Facades\Gate;
|
|||
*
|
||||
* The 'present' method is designed for when you're trying to generate fieldlists for use in Bootstrap tables
|
||||
* - typically the 'dataTableLayout' method
|
||||
*
|
||||
*
|
||||
*********************/
|
||||
class CustomFieldHelper {
|
||||
|
||||
|
|
|
@ -418,63 +418,8 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
@if (($asset->model) && ($asset->model->fieldset))
|
||||
@foreach($asset->model->fieldset->fields as $field)
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<strong>
|
||||
{{ $field->name }}
|
||||
</strong>
|
||||
</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') }}" onclick="showHideEncValue(this)" id="text-{{ $field->id }}"></i>
|
||||
@endif
|
||||
|
||||
@if ($field->isFieldDecryptable($asset->{$field->db_column_name()} ))
|
||||
@can('assets.view.encrypted_custom_fields')
|
||||
@php
|
||||
$fieldSize=strlen(Helper::gracefulDecrypt($field, $asset->{$field->db_column_name()}))
|
||||
@endphp
|
||||
@if ($fieldSize>0)
|
||||
<span id="text-{{ $field->id }}-to-hide">{{ str_repeat('*', $fieldSize) }}</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()}!=''))
|
||||
{{ \App\Helpers\Helper::gracefulDecrypt($field, \App\Helpers\Helper::getFormattedDateObject($asset->{$field->db_column_name()}, 'date', false)) }}
|
||||
@else
|
||||
{{ Helper::gracefulDecrypt($field, $asset->{$field->db_column_name()}) }}
|
||||
@endif
|
||||
</span>
|
||||
<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>
|
||||
@endif
|
||||
@else
|
||||
{{ strtoupper(trans('admin/custom_fields/general.encrypted')) }}
|
||||
@endcan
|
||||
|
||||
@else
|
||||
@if (($field->format=='BOOLEAN') && ($asset->{$field->db_column_name()}!=''))
|
||||
{!! ($asset->{$field->db_column_name()} == 1) ? "<span class='fas fa-check-circle' style='color:green' />" : "<span class='fas fa-times-circle' style='color:red' />" !!}
|
||||
@elseif (($field->format=='URL') && ($asset->{$field->db_column_name()}!=''))
|
||||
<a href="{{ $asset->{$field->db_column_name()} }}" target="_new">{{ $asset->{$field->db_column_name()} }}</a>
|
||||
@elseif (($field->format=='DATE') && ($asset->{$field->db_column_name()}!=''))
|
||||
{{ \App\Helpers\Helper::getFormattedDateObject($asset->{$field->db_column_name()}, 'date', false) }}
|
||||
@else
|
||||
{!! nl2br(e($asset->{$field->db_column_name()})) !!}
|
||||
@endif
|
||||
|
||||
@endif
|
||||
|
||||
@if ($asset->{$field->db_column_name()}=='')
|
||||
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
@endif
|
||||
@include('partials.custom-fields-view', ['item' => $asset,'width' => 2])
|
||||
|
||||
|
||||
@if ($asset->purchase_date)
|
||||
|
|
47
resources/views/partials/custom-fields-view.blade.php
Normal file
47
resources/views/partials/custom-fields-view.blade.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
{{-- FIXME - this doesn't work for Assets (crap!) --}}
|
||||
@if ($item->getFieldset())
|
||||
@foreach($item->getFieldset()->fields as $field)
|
||||
<div class="row">
|
||||
<div class="col-md-{{ $width }}">
|
||||
<strong>
|
||||
{{ $field->name }}
|
||||
</strong>
|
||||
</div>
|
||||
<div class="col-md-{{ 12 - $width }}{{ (($field->format=='URL') && ($item->{$field->db_column_name()}!='')) ? ' ellipsis': '' }}">
|
||||
@if ($field->field_encrypted=='1')
|
||||
<i class="fas fa-lock" data-tooltip="true" data-placement="top" title="{{ trans('admin/custom_fields/general.value_encrypted') }}"></i>
|
||||
@endif
|
||||
|
||||
@if ($field->isFieldDecryptable($item->{$field->db_column_name()} ))
|
||||
@can('assets.view.encrypted_custom_fields')
|
||||
@if (($field->format=='URL') && ($item->{$field->db_column_name()}!=''))
|
||||
<a href="{{ Helper::gracefulDecrypt($field, $item->{$field->db_column_name()}) }}" target="_new">{{ Helper::gracefulDecrypt($field, $item->{$field->db_column_name()}) }}</a>
|
||||
@elseif (($field->format=='DATE') && ($item->{$field->db_column_name()}!=''))
|
||||
{{ \App\Helpers\Helper::gracefulDecrypt($field, \App\Helpers\Helper::getFormattedDateObject($item->{$field->db_column_name()}, 'date', false)) }}
|
||||
@else
|
||||
{{ Helper::gracefulDecrypt($field, $item->{$field->db_column_name()}) }}
|
||||
@endif
|
||||
@else
|
||||
{{ strtoupper(trans('admin/custom_fields/general.encrypted')) }}
|
||||
@endcan
|
||||
|
||||
@else
|
||||
@if (($field->format=='BOOLEAN') && ($item->{$field->db_column_name()}!=''))
|
||||
{!! ($item->{$field->db_column_name()} == 1) ? "<span class='fas fa-check-circle' style='color:green' />" : "<span class='fas fa-times-circle' style='color:red' />" !!}
|
||||
@elseif (($field->format=='URL') && ($item->{$field->db_column_name()}!=''))
|
||||
<a href="{{ $item->{$field->db_column_name()} }}" target="_new">{{ $item->{$field->db_column_name()} }}</a>
|
||||
@elseif (($field->format=='DATE') && ($item->{$field->db_column_name()}!=''))
|
||||
{{ \App\Helpers\Helper::getFormattedDateObject($item->{$field->db_column_name()}, 'date', false) }}
|
||||
@else
|
||||
{!! nl2br(e($item->{$field->db_column_name()})) !!}
|
||||
@endif
|
||||
|
||||
@endif
|
||||
|
||||
@if ($item->{$field->db_column_name()}=='')
|
||||
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
@endif
|
|
@ -728,6 +728,7 @@
|
|||
@endforeach
|
||||
@endif
|
||||
{{-- FIXME <end> copypasta from hardware/view.blade.php --}}
|
||||
@include('partials.custom-fields-view',['item' => $user,'width' => 3])
|
||||
|
||||
</div> <!--/end striped container-->
|
||||
</div> <!-- end col-md-9 -->
|
||||
|
|
Loading…
Reference in a new issue