Giter Club home page Giter Club logo

Comments (6)

e2jk avatar e2jk commented on July 17, 2024

Hi folks, any idea how to perform this?

from ampersand-rest-collection.

aaronmccall avatar aaronmccall commented on July 17, 2024

@e2jk, can you post your model definition and example form data?

from ampersand-rest-collection.

e2jk avatar e2jk commented on July 17, 2024

The model definition: http://pastebin.com/iMkFb3TG

When posting information on the page to create a new record, the following data is posted from the form:

{"abbreviation":"Test Object","objectType":"Interface","description":null,"notes":null,"fromDate":null,"toDate":null,"numberOfRecords":null,"relatedGroup":{"abbreviation":"","name":""},"fromSystem":{"systemName":"","vendorName":"","contactName":"","contactPhone":"","contactEmail":""},"toSystem":{"systemName":"","vendorName":"","contactName":"","contactPhone":"","contactEmail":""},"responsiblePerson":{"firstName":"","lastName":""}}

As you can see, all the data from the children is empty.
Since I'm saving again the model after it has just been created (again, with the same data from the form), a PUT command is issued just after that, which has all the children item populated:

{"id":13,"abbreviation":"Test Object","objectType":"Conversion","description":null,"notes":null,"fromDate":null,"toDate":null,"numberOfRecords":null,"relatedGroup":{"id":2,"abbreviation":"ENC","name":"Afspraak en Opname","objects":[4,5,6,7,8]},"fromSystem":{"id":9,"systemName":"SchedulePlus","vendorName":"","contactName":"","contactPhone":"","contactEmail":"","fromObjects":[]},"toSystem":{"id":11,"systemName":"New EPD","vendorName":"EPD vendor","contactName":"Toto van der Been","contactPhone":"9898989898","contactEmail":"[email protected]","fromObjects":[10],"toObjects":[7]},"responsiblePerson":{"id":5,"firstName":"Rob","lastName":"van Egmond"}}

I've added a debug console log just after submitCallback, and the JS object that is the data variable does have properties named as the children, which are themselves objects that contain the data. Example from this Firefox web tools screenshot:

capture du 2015-07-17 22 38 45

from ampersand-rest-collection.

e2jk avatar e2jk commented on July 17, 2024

This is the text version of the screenshot (with another object I've just created). It's the output of console.log(JSON.stringify(data)); just after submitCallback is called.
You'll notice that the children data are sent themselves as objects (e.g. embedded objects). And as mentioned, when calling model.save with the same data in the success callback of app.objects.create, the model is properly saved (i.e. the issue is not in data, but likely in the way children are saved when calling collection.create whereas model.save works flawlessly):

19:30:17,492 "{"abbreviation":"XXX","objectType":"Conversion","description":"This is a test","notes":"These are notes","fromDate":null,"toDate":null,"numberOfRecords":null,"relatedGroup":{"id":2,"abbreviation":"ENC","name":"Afspraak en Opname","objects":[4,5,6,7,8]},"fromSystem":{"id":2,"systemName":"Radiologix","vendorName":"Radiologix","contactName":"David Seller","contactPhone":"123456789","contactEmail":"[email protected]"},"toSystem":{"id":3,"systemName":"PharmaPill","vendorName":"","contactName":"","contactPhone":"","contactEmail":""},"responsiblePerson":{"id":2,"firstName":"Marcel","lastName":"Eiffel","objects":[3,9,10]}}"1 project-de-brug.nonCached.js:911:1

from ampersand-rest-collection.

e2jk avatar e2jk commented on July 17, 2024

Hi there, any thoughts about this issue?

from ampersand-rest-collection.

pgilad avatar pgilad commented on July 17, 2024

I couldn't understand from your pastepin what you are trying to do. Try to create a minimal example that doesn't work. I sense that you may be mixing between children and collections.

from ampersand-rest-collection.

Related Issues (16)

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.