Coder Social home page Coder Social logo

Comments (6)

Odonno avatar Odonno commented on May 10, 2024 1

That's a clever idea. react-admin already use Confirm modal to check for validation (like deletion). We should investigate on this to reuse their component.

Also, your idea gave some idea about new properties: overwrite and confirm. The confirm is a boolean to indicate if the modal should be opened. If confirm=false and overwrite is set, we should bypass the modal process to automatically execute the update/create.

That could be really good. The last thing that we should handle is when a user wants to import both new and updated data... Not sure how we can do that, because we cannot predict what user will put in the csv file.

from react-admin-import-csv.

benwinding avatar benwinding commented on May 10, 2024

Hey @Odonno,

I just want to first say thank you for sharing your code initially, it's been a big help in understanding react, redux and react-admin.

I suppose that all console.log should be forbidden, right?

Yes, or at least a configuration flag.

I used to dispatch an action crudUpdateMany in order to save that in the redux store and then it will trigger an UPDATE_MANY event to the according data provider. You, otherwise, you use directly the data provider for each item. I am not sure what is the best use of this ATM. Otherwise, I can see there is 2 kind of operations:

I'm not 100% sure, but according to the API, the UPDATE_MANY action updates a lot of ids with one row of common data. We need to update many ids with unique rows of data, so this probably isn't going to work. I may be mistaken though...

image

It can be a little tricky but I believe we should allow the developer to choose the action to execute in those cases, don't you think? Like adding a new prop.

Also, we manage papaparse props ourselves. That could be interesting to set default props and then let the developers override the props based on their own needs. Maybe by reusing the same standard of react-admin. They use an exporter prop, we could have an importer prop.

I like both of these ideas.

Cheers,
Ben

from react-admin-import-csv.

Odonno avatar Odonno commented on May 10, 2024

Hum, you are right, it seems that UPDATE_MANY is to update multiple objects using the same payload/properties. So, multiple UPDATE may be more suitable.

I also see you use hooks instead of the crudUpdate dispatched action. Seems to be a better way than I did. So, the last thing is to know to identify whether to create or to update. Not sure how to do that.

from react-admin-import-csv.

benwinding avatar benwinding commented on May 10, 2024

I also see you use hooks instead of the crudUpdate dispatched action. Seems to be a better way than I did.

This was a huge learning process for me, I tried using effects and dispatches by kept getting "the invalid hook call warning". So after a lot of trial and error, this was the only thing that react allowed me to do.

... the last thing is to know to identify whether to create or to update. Not sure how to do that.

Maybe we could launch a Material-ui Dialog and ask the question to the user? (I think material-ui is included in react-admin anyway) Something like the following perhaps?

image

from react-admin-import-csv.

Odonno avatar Odonno commented on May 10, 2024

I suppose we can start like that with overwrite and confirm props. If someone has an idea in the future for improvements, we will check at that time.

What do you think?

from react-admin-import-csv.

benwinding avatar benwinding commented on May 10, 2024

Hey @Odonno,

I've made some recent updates and included a demo here. Let me know what you think.

If you'd like to add some additional features or fix something, please have a look at the development notes at the bottom of the README, and submit a PR.

Cheers for your help,
Ben

from react-admin-import-csv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.