Skip to content

Commit

Permalink
Merge pull request #209 from oneduo/208-file-manager-field-does-not-l…
Browse files Browse the repository at this point in the history
…oad-with-fieldsforupdate

Adds fieldsForCreate and fieldsForUpdate support
  • Loading branch information
mikaelpopowicz authored Mar 27, 2023
2 parents 981bc88 + 28e603e commit d945527
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
18 changes: 9 additions & 9 deletions dist/js/tool.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions resources/js/@types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export type BrowserConfig = {
usePintura: boolean
pinturaOptions?: PinturaOptions
cropperOptions?: CropperOptions
component?: string
}

export type Config = {
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 @@ -108,6 +108,7 @@ export default defineComponent({
usePintura: this.currentField.usePintura ?? false,
pinturaOptions: this.currentField.pinturaOptions ?? {},
cropperOptions: this.currentField.cropperOptions ?? {},
component: this.$inertia?.page?.component,
})
},
Expand Down
24 changes: 23 additions & 1 deletion resources/js/stores/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
Breadcrumb,
BrowserConfig,
Config,
CropperOptions,
Entity,
ErrorsBag,
Folder,
Expand All @@ -11,7 +12,6 @@ import {
QueueEntry,
QueueEntryStatus,
View,
CropperOptions,
} from '__types__'
import { AxiosResponse } from 'axios'
import range from 'lodash/range'
Expand Down Expand Up @@ -76,6 +76,7 @@ interface State {
usePintura: boolean
pinturaOptions?: PinturaOptions
cropperOptions?: CropperOptions
component?: string
}

const useBrowserStore = defineStore('nova-file-manager/browser', {
Expand Down Expand Up @@ -713,6 +714,25 @@ const useBrowserStore = defineStore('nova-file-manager/browser', {
fieldMode: this.isField,
}

if (this.component?.length && ['Nova.Create', 'Nova.Update'].includes(this.component)) {
let editMode

switch (this.component) {
case 'Nova.Create':
editMode = 'create'
break
case 'Nova.Update':
editMode = 'update'
break
}

data = {
...data,
editing: true,
editMode,
}
}

if (this.wrapper?.length) {
data = {
...data,
Expand Down Expand Up @@ -765,6 +785,7 @@ const useBrowserStore = defineStore('nova-file-manager/browser', {
usePintura,
pinturaOptions,
cropperOptions,
component,
}: BrowserConfig) {
this.isField = true
this.multiple = multiple
Expand All @@ -782,6 +803,7 @@ const useBrowserStore = defineStore('nova-file-manager/browser', {
this.error = undefined
this.permissions = permissions
this.disk = undefined
this.component = component

this.openModal({ name: BROWSER_MODAL_NAME })
this.setSelection({ files: [...initialFiles] })
Expand Down

0 comments on commit d945527

Please sign in to comment.