From 7d40b7a32a73737a9a87f9f3d78f23f05514c75c Mon Sep 17 00:00:00 2001 From: LT Date: Thu, 15 Dec 2022 21:05:54 +0300 Subject: [PATCH] fixed hasOne/hasMany Image/File --- resources/views/fields/file.blade.php | 101 +++++++++++++----- resources/views/fields/image.blade.php | 91 +++++++++++----- resources/views/fields/shared/file.blade.php | 19 ++-- .../views/fields/shared/full-fields.blade.php | 40 +++---- .../fields/shared/table-fields.blade.php | 34 +++--- resources/views/shared/icons/clip.blade.php | 6 ++ src/Fields/File.php | 4 +- src/Fields/HasMany.php | 8 +- src/Fields/HasOne.php | 4 +- src/Fields/Image.php | 4 +- src/Traits/Fields/FileTrait.php | 64 +++++++++-- 11 files changed, 263 insertions(+), 112 deletions(-) create mode 100644 resources/views/shared/icons/clip.blade.php diff --git a/resources/views/fields/file.blade.php b/resources/views/fields/file.blade.php index 9a102d923..f37fabf10 100644 --- a/resources/views/fields/file.blade.php +++ b/resources/views/fields/file.blade.php @@ -2,28 +2,82 @@ @if($field->formViewValue($item)) @if($field->isMultiple())
-
- @foreach($field->formViewValue($item) as $index => $file) -
- - - @include('moonshine::fields.shared.file', [ - 'index' => $index+1, - 'canDownload' => $field->canDownload(), - 'value' => $file, - 'field' => $field, - ]) - - @if($field->isRemovable()) -
- - {{ trans('moonshine::ui.delete') }} - + @if($field->attributes()->has('x-model')) +
+ +
+ @else +
+ @foreach($field->formViewValue($item) as $index => $file) +
+ + + + @include('moonshine::fields.shared.file', [ + 'index' => $index+1, + 'canDownload' => $field->canDownload(), + 'value' => $file, + 'field' => $field, + ]) + + @if($field->isRemovable()) + + @endif +
+ @endforeach +
+ @endif
@else @include('moonshine::fields.shared.file', [ @@ -35,8 +89,7 @@ @endif @include("moonshine::fields.input", [ - 'field' => $field, - 'item' => $item + "field" => $field, + "item" => $item ])
- diff --git a/resources/views/fields/image.blade.php b/resources/views/fields/image.blade.php index 2582021fe..050df14d1 100644 --- a/resources/views/fields/image.blade.php +++ b/resources/views/fields/image.blade.php @@ -2,37 +2,80 @@ @if($field->formViewValue($item)) @if($field->isMultiple())
-
- @foreach($field->formViewValue($item) as $index => $file) -
- + @if($field->attributes()->has('x-model')) +
+ +
+ @else +
+ @foreach($field->formViewValue($item) as $index => $file) +
+ + + + + + @if($field->isRemovable()) + + @endif +
+ @endforeach +
+ @endif
@else -
+
attributes()->has('x-model')) + x-data="{imageValue: {{ $field->attributes()->get('x-model', '') }}}" + @else + x-data="{imageValue: ''}" + @endif + + class="max-w-sm rounded overflow-hidden shadow-lg my-2" + > attributes()->has('x-model')) - :src="({{ $field->attributes()->get('x-model') }}) ? ('{{ Storage::url('') }}' + {{ $field->attributes()->get('x-model') }}) : ''" + :src="imageValue ? ('{{ Storage::url('') }}') + imageValue : ''" @else @click.stop="$dispatch('img-modal', {imgModal: true, imgModalSrc: '{{ Storage::url($field->formViewValue($item)) }}' })" src="{{ Storage::url($field->formViewValue($item)) }}" diff --git a/resources/views/fields/shared/file.blade.php b/resources/views/fields/shared/file.blade.php index 201232804..95f1ed09b 100644 --- a/resources/views/fields/shared/file.blade.php +++ b/resources/views/fields/shared/file.blade.php @@ -1,11 +1,14 @@ -