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

Question : how could we customize files meta-data ? #809

Closed
Aarbel opened this issue May 6, 2018 · 18 comments
Closed

Question : how could we customize files meta-data ? #809

Aarbel opened this issue May 6, 2018 · 18 comments

Comments

@Aarbel
Copy link
Contributor

Aarbel commented May 6, 2018

Hi Uppy Teams

i'm just discovering Uppy, i need to put an other meta-data field in this view, do you think it will be easy to do it using Uppy ?
We can put a Caption, i would like to add a Recipients input (which will be a React Component)

image

Thanks a lot

@arturi
Copy link
Contributor

arturi commented May 7, 2018

Hi! Right now these can only be plain text inputs that you can add via https://uppy.io/docs/dashboard/#metaFields. There were some requests for select support and then completely custom things, like a map location picker. We haven’t decided on the most flexible approach yet, open to suggestions. One of the proposed solutions was to allow rendering completely custom content in place of the meta screen (or just the area where inputs currently are).

@arturi
Copy link
Contributor

arturi commented May 7, 2018

Related #617, #651 and #454

@Aarbel
Copy link
Contributor Author

Aarbel commented May 8, 2018

Thanks Arturi.

Regarding all these issues i think it could be great to add a generic approach that allows to add any kind of field / data with custom UI, it's the right time to do it !

Example of use cases that could be hard to implement each time someone ask you to add it :

  • Select
  • Map
  • Array fields
  • Toggle buttons
  • Textareas
  • etc...

@kvz
Copy link
Member

kvz commented May 8, 2018

Maybe

  • if array of objects: very basic key/value rendering (input + select, and that's it for the coming year?)
  • if string: assume html and render as-is

?

I dislike having multiple ways to do 1 thing. But i think i dislike always leaking a lot of html structure into what could be simple key/value configuration, more.

@cmawhorter
Copy link

@Aarbel
Copy link
Contributor Author

Aarbel commented Aug 30, 2018

@cmawhorter does it allow to put some custom React nodes ?

@Aarbel
Copy link
Contributor Author

Aarbel commented Aug 30, 2018

@arturi did you planned to work on it ?

@kvz
Copy link
Member

kvz commented Aug 30, 2018

Just a friendly note that Artur is on holidays, so it might take a bit before he can respond :)

@Aarbel
Copy link
Contributor Author

Aarbel commented Aug 30, 2018

ok thx @kvz

@goto-bus-stop
Copy link
Contributor

We want to do this but there is no timeline currently.

@Aarbel
Copy link
Contributor Author

Aarbel commented Aug 30, 2018

@goto-bus-stop how could i help ?

@goto-bus-stop
Copy link
Contributor

If you would like to PR it that would be very helpful!

I think, a good way to approach this is to allow the values of the Dashboard's metaFields option to have a render() method that receives a props object (name, id, value onChange handler) and returns a Preact element. Then, we can use that Preact element in place of our default <input type="text">. I imagine it'd be used like this:

uppy.use(Dashboard, {
  /* ..., */
  metaFields: [
    {
      id: 'location',
      name: 'Coordinates',
      render ({ value, onChange }) {
        return <CoordinateSelector
          currentCoordinates={value.split(',')}
          onChange={(coords) => onChange(`${coords[0]},${coords[1]}`)}
        />
      }
    }
  ]
})

The rendering happens here:

renderMetaFields (file) {
const metaFields = this.props.metaFields || []
return metaFields.map((field, i) => {
return <fieldset class="uppy-DashboardFileCard-fieldset">
<label class="uppy-DashboardFileCard-label">{field.name}</label>
<input class="uppy-c-textInput uppy-DashboardFileCard-input"
type="text"
data-name={field.id}
value={file.meta[field.id]}
placeholder={field.placeholder}
onkeyup={this.tempStoreMetaOrSubmit}
onkeydown={this.tempStoreMetaOrSubmit}
onkeypress={this.tempStoreMetaOrSubmit}
ref={(el) => {
if (i === 0) this.firstInput = el
}} /></fieldset>
})
}

Until the user presses "Save changes" in the dashboard, all changes are stored in the FileCard component's this.meta property. I think, if the same would be done for the values gotten from a custom render() function, no additional changes need to be made to save those values to the file's metadata object.

@cmawhorter
Copy link

@Aarbel i'm not too familiar with react, but you can build custom react components to implment your own form elements/behavior. (unrelated to uppy i built a wrapper around tinymce to get a richtext form component). it's ok.

@Aarbel
Copy link
Contributor Author

Aarbel commented Aug 30, 2018

i want to add a token input for each file (to assign people to files). Will be hard to do it around uppy, or maybe in a very unstable way, don't you think ?

@goto-bus-stop
Copy link
Contributor

Putting anything that's not a simple <input type="text"> in the metadata panel is very hard without the changes to Uppy I described above.

@swetapatnaik
Copy link

Are there any updates on this issue, like adding select fields to the metaData form.

@Aarbel
Copy link
Contributor Author

Aarbel commented Dec 10, 2018

Overbooked since August, no chance for me to work on it the next months :/

@kvz
Copy link
Member

kvz commented May 22, 2019

We love this idea, but will probably do it via jsx rendering as was mentioned by Renee and also discussed in #617

Closing this one then!

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

6 participants