Skip to content

Commit

Permalink
Merge pull request #77 from BBS-Lab/develop
Browse files Browse the repository at this point in the history
fix(flexible): fix flexible support
  • Loading branch information
mikaelpopowicz authored Sep 9, 2022
2 parents e03f3af + df4534e commit 03f6b08
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dist/js/tool.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions resources/js/fields/FormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ export default {
initialFiles: this.value,
multiple: this.field.multiple ?? false,
limit: this.field.limit ?? null,
resource: this.resourceName,
resourceId: this.resourceId,
resource: this.resourceName ?? null,
resourceId: this.resourceId ?? null,
attribute: this.flexibleGroup.length ? this.field.sortableUriKey : this.field.attribute,
customDisk: this.field.customDisk,
permissions: this.field.permissions,
customDisk: this.field.customDisk ?? false,
permissions: this.field.permissions ?? {},
flexibleGroup: this.flexibleGroup,
callback: selection => {
this.value = selection.map(f => this.mapEntity(f))
Expand Down
4 changes: 3 additions & 1 deletion resources/js/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const buildPayload = (state, params) => {
...params,
attribute: state.attribute,
resource: state.resource,
resourceId: state.resourceId,
...(state.resourceId && {
resourceId: state.resourceId,
}),
fieldMode: state.isFieldMode ? 1 : 0,
...(!state.customDisk && {
disk: state.disk,
Expand Down
5 changes: 5 additions & 0 deletions src/FileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use JsonException;
use Laravel\Nova\Fields\Field;
use Laravel\Nova\Http\Requests\NovaRequest;
use stdClass;

class FileManager extends Field implements InteractsWithFilesystem
{
Expand Down Expand Up @@ -113,6 +114,10 @@ protected function resolveAttribute($resource, $attribute = null): ?array
$value = collect([$value]);
}

if ($value instanceof stdClass) {
$value = (array) $value;
}

if (is_array($value)) {
if ($this->multiple) {
$value = collect($value)->map(fn (array $asset) => new Asset(...$asset));
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Requests/BaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function element(): ?InteractsWithFilesystem

public function resolveField(): ?InteractsWithFilesystem
{
$resource = $this->resourceId ? $this->findResourceOrFail() : $this->newResource();
$resource = !(empty($this->resourceId)) ? $this->findResourceOrFail() : $this->newResource();

$fields = $this->has('flexible')
? $this->flexibleAvailableFields($resource)
Expand Down

0 comments on commit 03f6b08

Please sign in to comment.