looshi / Blaze-Haus

Edit blaze templates and css at runtime
6 stars 0 forks source link

Data import #7

Closed looshi closed 9 years ago

looshi commented 9 years ago

Currently all users have access to only two pre-defined databse Collections, 'PeopleCollection' and 'AddressCollection'.

The goal of this ticket is to allow users to import arbitrary JSON that is compatible with a normal mongo import routine, and publish that data if a particular template requests it via a helper.

  1. Editor has a tab Data.js which contains default JSON from PeopleCollection
  2. Users can edit this JSON just as they do with the other files.
  3. Display errors if JSON is invalid
  4. Display error if JSON exceeds max size, TBD, just stub out some arbitrary size for now
looshi commented 9 years ago

Templates no longer need any relation to the Collections. Originally I was planning on having something like Template.dataContext -- which would automatically populate that Template with its dataContext. However that's proving to be pretty difficult and I think for now simplifying to only provide data via helpers will help :)

apendua commented 9 years ago

@looshi Do you think that we could skip the DB roundtrip and just feed a local client collection with the data provided be the user? That's both easier and more safe.

We currently have two editors: one for the template code, the second one for helpers. Why can't we have a third one for JSON array? In practice it means that the user provided data are always stored in the text form and not in a real database.

Does it sound reasonable?

looshi commented 9 years ago

@apendua great idea, let's do it. We can add a field to the Template object https://github.com/looshi/Meteor-Live-Template-Editor/blob/master/collections/TemplateCollection.js name it "data" or whatever seems appropriate. This field will be a string of the JSON data.

If a user makes an edit to the JSON data, the application should update the local Collection. That user will then see the changes to the rendered template.

Currently there should be three editors, CSS, HTML and JS. If you don't see the CSS tab, it's a bug in the layout. So, we can add a fourth tab for the collection JSON data.

thanks

looshi commented 9 years ago

@apendua i'm going to do this one now. if you already started, then just commit a branch, i may be able to merge it, i will probably be doing it the same way.