samedi 28 mars 2015

Backbone relation beetween models

I'm working on tool which will be used to create query for elasticsearch, where I have filters which are presented as panels.


I've got a collection of filters, and represtantation in UI, mostly everything works like a charm with pretty default backbone conventions.


I've got problematic situation when some filters need to have another filters in collection, so this makes some kind of relation beetween them. When I remove the main filter, all of the related filters should also be removed.


For example, filter 'type' can have value of 'picture' or 'movie'. When 'movie' option is selected I need also to set 'resolution', which is another filter in my elasticsearch query, but in client-side application is strictly related.


I read a lot about patterns, but Backbone.relational seems to be a bit overkill. I thought about adding references to the main filter ('type') of which another filters depends on it, or maybe create more nested structure which in the end (sending to ES) needs to be flattened out.


Totally don't know which solution is better, hope you guys can help me.


Aucun commentaire:

Enregistrer un commentaire