Skip to content

Commit

Permalink
Merge pull request #60 from awcodes/port-methods
Browse files Browse the repository at this point in the history
Chore: Port methods and revert to normal field extension
  • Loading branch information
awcodes authored Dec 13, 2022
2 parents 0c6ab6c + 123ad6d commit 2145988
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 74 deletions.
1 change: 1 addition & 0 deletions .idea/filament-curator.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions resources/views/components/media-action.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
:state-path="$statePath"
:modal-id="$modalId"
:directory="$directory"
:preserve-filenames="$preserveFilenames"
:should-preserve-filenames="$shouldPreserveFilenames"
:max-width="$maxWidth"
:min-size="$minSize"
:max-size="$maxSize"
:rules="$rules"
:accepted-file-types="$acceptedFileTypes"
:disk="$disk"
:disk-name="$diskName"
:visibility="$visibility"
:image-crop-aspect-ratio="$imageCropAspectRatio"
:image-resize-target-width="$imageResizeTargetWidth"
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/media-picker.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class="w-full filament-curator-media-picker"
>

@if (!$currentItem)
@if (! $currentItem)
<div>
<x-filament::button type="button"
color="{{ $getColor() }}"
Expand Down
42 changes: 23 additions & 19 deletions src/Actions/MediaPickerAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

namespace FilamentCurator\Actions;

use Closure;
use Filament\Forms\Components\Actions\Action;
use FilamentCurator\Forms\Components\MediaPicker;
use Illuminate\Contracts\Support\Htmlable;
use Illuminate\View\View;

class MediaPickerAction extends Action
Expand All @@ -18,27 +20,29 @@ protected function setUp(): void
{
parent::setUp();

$this->modalWidth('screen');
$this->modalWidth = 'screen';

$this->modalActions([]);

$this->modalHeading(__('filament-curator::media-picker-modal.heading'));

$this->modalActions(fn () => []);

$this->modalContent(fn(MediaPicker $component): View => view('filament-curator::components.media-action', [
'statePath' => $component->getStatePath(),
'modalId' => $component->getLivewire()->id . '-form-component-action',
'directory' => $component->getDirectory(),
'preserveFilenames' => $component->shouldPreserveFilenames(),
'maxWidth' => $component->getMaxWidth(),
'minSize' => $component->getMinSize(),
'maxSize' => $component->getMaxSize(),
'rules' => $component->getValidationRules(),
'acceptedFileTypes' => $component->getAcceptedFileTypes(),
'disk' => $component->getDiskName(),
'visibility' => $component->getVisibility(),
'imageCropAspectRatio' => $component->getImageCropAspectRatio(),
'imageResizeTargetWidth' => $component->getImageResizeTargetWidth(),
'imageResizeTargetHeight' => $component->getImageResizeTargetHeight(),
]));
$this->modalContent(static function(MediaPicker $component): View {
return view('filament-curator::components.media-action', [
'statePath' => $component->getStatePath(),
'modalId' => $component->getLivewire()->id . '-form-component-action',
'directory' => $component->getDirectory(),
'shouldPreserveFilenames' => $component->shouldPreserveFilenames(),
'maxWidth' => $component->getMaxWidth(),
'minSize' => $component->getMinSize(),
'maxSize' => $component->getMaxSize(),
'rules' => $component->getValidationRules(),
'acceptedFileTypes' => $component->getAcceptedFileTypes(),
'diskName' => $component->getDiskName(),
'visibility' => $component->getVisibility(),
'imageCropAspectRatio' => $component->getImageCropAspectRatio(),
'imageResizeTargetWidth' => $component->getImageResizeTargetWidth(),
'imageResizeTargetHeight' => $component->getImageResizeTargetHeight(),
]);
});
}
}
8 changes: 4 additions & 4 deletions src/Forms/Components/Curator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Curator extends Component implements HasForms

public $directory;

public $preserveFilenames;
public $shouldPreserveFilenames;

public $maxWidth;

Expand All @@ -45,7 +45,7 @@ class Curator extends Component implements HasForms

public $acceptedFileTypes = [];

public $disk;
public $diskName;

public $visibility;

Expand Down Expand Up @@ -74,13 +74,13 @@ protected function getAddMediaFormSchema(): array
->required()
->multiple()
->label(__('filament-curator::media-form.labels.file'))
->preserveFilenames($this->preserveFilenames)
->preserveFilenames($this->shouldPreserveFilenames)
->maxWidth($this->maxWidth)
->minSize($this->minSize)
->maxSize($this->maxSize)
->rules($this->validationRules)
->acceptedFileTypes($this->acceptedFileTypes)
->disk($this->disk)
->disk($this->diskName)
->visibility($this->visibility)
->directory($this->directory)
->imageCropAspectRatio($this->imageCropAspectRatio)
Expand Down
Loading

0 comments on commit 2145988

Please sign in to comment.