Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding hooks #61

Open
jankapunkt opened this issue Apr 12, 2022 · 1 comment
Open

Adding hooks #61

jankapunkt opened this issue Apr 12, 2022 · 1 comment

Comments

@jankapunkt
Copy link
Collaborator

I have a suggestion:

I am still using this and I came to some limits I'd like to solve with some hooks:

picture: {
  type: String,
  autoform: {
    afFieldInput: {
      type: 'fileUpload',
      collection: 'Images',
      hooks: {
        onProgress: () => {}, // while in progress
        onComplete: () => {}, // progress === 100%
        onError: err => {}, // there was an upload error
        onRemove: fileId => {}, // user wants to delete the uploaded file
        onRemoved: () => {}, // the file has been removed
      }
    }
  }
}

The reasons are simple:

  • disable form submit/cancel until file has been uploaded
  • let users remove their uploaded file by using a custom Meteor method (because the default remove is disabled)
  • custom way of communicating upload errors to the user
@jankapunkt
Copy link
Collaborator Author

Even easier would be to just pass the Upload context from insert:

picture: {
  type: String,
  autoform: {
    afFieldInput: {
      type: 'fileUpload',
      collection: 'Images',
      hooks: {
        onUpload: (file, uploadCtx) => {}, // hook into upload ctx
        onRemove: fileId => {}, // user wants to delete the uploaded file
      }
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants