Skip to content

Configuration as method #103

@flauc

Description

@flauc

Because of how configuration for a component get's evaluated when provided as a function we don't currently have a good way to use the documents id.

For example in the below scenario using window.jms.util.docId isn't an option because when a new document is being created this will always have the value "new".

{
  photo: {
      label: 'USERS.FIELDS.PROFILE_PHOTO',
      component: {
        type: 'image',
        configuration: () => {
          const route = `/users/${window.jms.util.docId}`;
          const minPath = window.jms.util.state.role !== 'admin' ? route : `/`;

          return {
            filePrefix: route + '/',
            uploadMethods: [{
              id: 'file-manager',
              label: 'FILE_MANAGER.TITLE',
              component: JSX(<jms-e-file-manager-select/>),
              configuration: {
                hidePath: false,
                hideFolders: false,
                allowUpload: true,
                minPath,
                route,
                filters: [{
                  value: file => file.contentType.startsWith('image/')
                }]
              }
            }]
          }
        }
      }
    },
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions