Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions resources/js/@types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type BrowserConfig = {
perPage?: number
paginationOptions?: number[]
component?: string
isField?: boolean
}

export type Config = {
Expand All @@ -43,6 +44,7 @@ export type Config = {
outdated?: boolean
perPage?: number
paginationOptions?: number[]
isField: boolean
}

export type Entity = {
Expand Down
1 change: 1 addition & 0 deletions resources/js/components/Cards/FieldCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const preview = (file: Entity) => {
perPage: 10,
paginationOptions: undefined,
component: undefined,
isField: true,
})
store.setDisk({
disk: props.field.singleDisk ? 'default' : props.field.value[0].disk,
Expand Down
4 changes: 2 additions & 2 deletions resources/js/components/Modals/PreviewModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,11 @@ const copy = (file: Entity) => {
<PencilSquareIcon class="w-5 h-5" />
</IconButton>

<IconButton ref="buttonRef" @click.self="closePreview" :title="__('NovaFileManager.actions.close')">
<IconButton ref="buttonRef" @click="closePreview" :title="__('NovaFileManager.actions.close')">
<XMarkIcon class="w-5 h-5" />
</IconButton>

<IconButton v-if="isField" variant="success" @click="selectThenConfirm">
<IconButton v-if="isField && !props.readOnly" variant="success" @click="selectThenConfirm">
<CheckIcon class="h-5 w-5" />
</IconButton>
</div>
Expand Down
1 change: 1 addition & 0 deletions resources/js/fields/FormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export default defineComponent({
perPage: this.currentField.perPage ?? 10,
paginationOptions: this.currentField.paginationOptions ?? undefined,
component: this.$inertia?.page?.component,
isField: true,
})
},

Expand Down
7 changes: 4 additions & 3 deletions resources/js/stores/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -805,9 +805,8 @@ const useBrowserStore = defineStore('nova-file-manager/browser', {
perPage,
paginationOptions,
component,
isField,
}: BrowserConfig) {
this.isField = true

this.configure({
initialFiles,
multiple,
Expand All @@ -826,6 +825,7 @@ const useBrowserStore = defineStore('nova-file-manager/browser', {
perPage,
paginationOptions,
component,
isField,
})

this.openModal({ name: BROWSER_MODAL_NAME })
Expand All @@ -849,6 +849,7 @@ const useBrowserStore = defineStore('nova-file-manager/browser', {
perPage,
paginationOptions,
component,
isField = false,
}: BrowserConfig) {
this.multiple = multiple
this.limit = limit
Expand All @@ -868,6 +869,7 @@ const useBrowserStore = defineStore('nova-file-manager/browser', {
this.permissions = permissions
this.disk = undefined
this.component = component
this.isField = isField
},

closeBrowser() {
Expand Down Expand Up @@ -913,7 +915,6 @@ const useBrowserStore = defineStore('nova-file-manager/browser', {
this.clearSelection()

this.limit = undefined
this.isField = false
this.multiple = true
this.singleDisk = singleDisk
this.permissions = permissions
Expand Down
10 changes: 10 additions & 0 deletions src/Http/Requests/BaseRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ public function element(): ?InteractsWithFilesystem
return filter_var($this->fieldMode, FILTER_VALIDATE_BOOL) ? $this->resolveField() : $this->resolveTool();
}

// Override resource() to use $this->resource instead of $this->route('resource')
public function resource()
{
return tap(once(function () {
return Nova::resourceForKey($this->resource);
}), static function ($resource) {
abort_if(\is_null($resource), 404);
});
}

public function resolveField(): ?InteractsWithFilesystem
{
if (!empty($this->wrapper) && $field = FileManager::forWrapper($this->wrapper)) {
Expand Down
Loading