mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Make it possible to add multiple files / PDFs to equipment by using Userfields (closes #978)
This commit is contained in:
@@ -1,7 +1,18 @@
|
||||
@php
|
||||
if (!isset($excludeFieldTypes))
|
||||
{
|
||||
$excludeFieldTypes = [];
|
||||
}
|
||||
@endphp
|
||||
|
||||
@if($userfields && count($userfields) > 0)
|
||||
|
||||
@foreach($userfields as $userfield)
|
||||
|
||||
@if(in_array($userfield->type, $excludeFieldTypes))
|
||||
@continue
|
||||
@endif
|
||||
|
||||
@if($userfield->show_as_column_in_tables == 1)
|
||||
@php $userfieldObject = FindObjectInArrayByPropertyValue($userfieldValues, 'name', $userfield->name) @endphp
|
||||
<td>
|
||||
@@ -26,10 +37,10 @@
|
||||
@endphp
|
||||
<a href="{{ $link }}"
|
||||
target="_blank">{{ $title }}</a>
|
||||
@elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_FILE)
|
||||
@elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_FILE && !empty($userfieldObject->value))
|
||||
<a href="{{ $U('/files/userfiles/'. $userfieldObject->value) }}"
|
||||
target="_blank">{{ base64_decode(explode('_', $userfieldObject->value)[1]) }}</a>
|
||||
@elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_IMAGE)
|
||||
@elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_IMAGE && !empty($userfieldObject->value))
|
||||
<a class="show-as-dialog-link"
|
||||
href="{{ $U('/files/userfiles/'. $userfieldObject->value . '?force_serve_as=picture') }}">
|
||||
<img src="{{ $U('/files/userfiles/'. $userfieldObject->value . '?force_serve_as=picture&best_fit_width=32&best_fit_height=32') }}"
|
||||
|
@@ -1,7 +1,18 @@
|
||||
@php
|
||||
if (!isset($excludeFieldTypes))
|
||||
{
|
||||
$excludeFieldTypes = [];
|
||||
}
|
||||
@endphp
|
||||
|
||||
@if($userfields && count($userfields) > 0)
|
||||
|
||||
@foreach($userfields as $userfield)
|
||||
|
||||
@if(in_array($userfield->type, $excludeFieldTypes))
|
||||
@continue
|
||||
@endif
|
||||
|
||||
@if($userfield->show_as_column_in_tables == 1)
|
||||
<th class="allow-grouping">{{ $userfield->caption }}</th>
|
||||
@endif
|
||||
|
@@ -176,7 +176,7 @@
|
||||
<div class="input-group-append">
|
||||
<a href="#"
|
||||
target="_blank"
|
||||
class="input-group-text userfield-file-show d-none"><i class="fas fa-eye"></i></a>
|
||||
class="input-group-text userfield-file-show d-none discrete-link"><i class="fas fa-eye"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -201,7 +201,7 @@
|
||||
</div>
|
||||
<img src=""
|
||||
alt="{{ $userfield->name }}"
|
||||
class="userfield-current-file userfield-file-show d-none lazy mt-1"
|
||||
class="userfield-current-file userfield-file-show d-none lazy mt-1 discrete-link"
|
||||
data-uf-name="{{ $userfield->name }}" />
|
||||
</div>
|
||||
@endif
|
||||
|
@@ -70,7 +70,8 @@
|
||||
<th>{{ $__t('Name') }}</th>
|
||||
|
||||
@include('components.userfields_thead', array(
|
||||
'userfields' => $userfields
|
||||
'userfields' => $userfields,
|
||||
'excludeFieldTypes' => [\Grocy\Services\UserfieldsService::USERFIELD_TYPE_FILE]
|
||||
))
|
||||
|
||||
</tr>
|
||||
@@ -108,7 +109,8 @@
|
||||
|
||||
@include('components.userfields_tbody', array(
|
||||
'userfields' => $userfields,
|
||||
'userfieldValues' => FindAllObjectsInArrayByPropertyValue($userfieldValues, 'object_id', $equipmentItem->id)
|
||||
'userfieldValues' => FindAllObjectsInArrayByPropertyValue($userfieldValues, 'object_id', $equipmentItem->id),
|
||||
'excludeFieldTypes' => [\Grocy\Services\UserfieldsService::USERFIELD_TYPE_FILE]
|
||||
))
|
||||
|
||||
</tr>
|
||||
@@ -129,16 +131,23 @@
|
||||
data-toggle="tab"
|
||||
href="#description-tab">{{ $__t('Notes') }}</a>
|
||||
</li>
|
||||
@foreach($userfields as $userfield)
|
||||
@if($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_FILE)
|
||||
<li class="nav-item">
|
||||
<a class="nav-link"
|
||||
data-toggle="tab"
|
||||
href="#file-userfield-{{$userfield->name}}-tab">{{ $userfield->caption }}</a>
|
||||
</li>
|
||||
@endif
|
||||
@endforeach
|
||||
</ul>
|
||||
<div class="tab-content grocy-tabs">
|
||||
<div class="tab-pane fade show active"
|
||||
id="instruction-manual-tab">
|
||||
<div id="selectedEquipmentInstructionManualCard"
|
||||
class="card">
|
||||
<div class="card selectedEquipmentInstructionManualCard">
|
||||
<div class="card-header card-header-fullscreen">
|
||||
<span class="selected-equipment-name"></span>
|
||||
<a id="selectedEquipmentInstructionManualToggleFullscreenButton"
|
||||
class="btn btn-sm btn-outline-secondary py-0 float-right mr-1"
|
||||
<a class="btn btn-sm btn-outline-secondary py-0 float-right mr-1 selectedEquipmentInstructionManualToggleFullscreenButton"
|
||||
href="#"
|
||||
data-toggle="tooltip"
|
||||
title="{{ $__t('Expand to fullscreen') }}">
|
||||
@@ -163,6 +172,40 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@foreach($userfields as $userfield)
|
||||
@if($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_FILE)
|
||||
<div class="tab-pane fade"
|
||||
id="file-userfield-{{$userfield->name}}-tab">
|
||||
<div class="card selectedEquipmentInstructionManualCard">
|
||||
<div class="card-header card-header-fullscreen">
|
||||
<span class="selected-equipment-name"></span>
|
||||
<a class="btn btn-sm btn-outline-secondary py-0 float-right mr-1 selectedEquipmentInstructionManualToggleFullscreenButton"
|
||||
href="#"
|
||||
data-toggle="tooltip"
|
||||
title="{{ $__t('Expand to fullscreen') }}">
|
||||
<i class="fas fa-expand-arrows-alt"></i>
|
||||
</a>
|
||||
<a id="file-userfield-{{$userfield->name}}-download-button"
|
||||
class="btn btn-sm btn-outline-secondary py-0 float-right mr-1"
|
||||
href="#"
|
||||
target="_blank"
|
||||
data-toggle="tooltip"
|
||||
title="{{ $__t('Download file') }}">
|
||||
<i class="fas fa-file-download"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div class="card-body py-0 px-0">
|
||||
<p id="file-userfield-{{$userfield->name}}-empty-hint"
|
||||
class="text-muted font-italic d-none pt-3 pl-3"></p>
|
||||
<embed id="file-userfield-{{$userfield->name}}-embed"
|
||||
class="embed-responsive embed-responsive-4by3"
|
||||
src=""
|
||||
type="application/pdf">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@endforeach
|
||||
<div class="tab-pane fade"
|
||||
id="description-tab">
|
||||
<div id="selectedEquipmentDescriptionCard"
|
||||
|
Reference in New Issue
Block a user