dimanche 28 novembre 2021

Find-by with multiple attribute in Ember.js Octane

I have a route with RSVP that load several models (categories with items, treatments, prices) which return in JsON API Forrmat and want to show them in a table:

Item Name Treatment Name 1 Treatment Name N
Category 1
Item 1 in Cat 1 Price item 1 in Cat 1 for Treatment 1 Setup Price
Item 2 in Cat 1 Setup Price Price item 2 in Cat 1 for Treatment N
Category 2
Item 1 in Cat 2 Price item 1 in Cat 2 for Treatment 1 Price item 1 in Cat 2 for Treatment N

Setup Price only show if there isn't any price found, so the user can setup the price for the item in that treatment

I already can iterate the categories, items and treatment; but still do not know how to configure to show the correct price.

How can I find the correct prices by 2 attributes? I tried using find-by helper in the template:


  

, but it seems it only support 1 attributes.

Well, if in SQL it would be something like:

select * from prices where item.id = [currentItemId] and treatment.id = [currentTreatmentId]

but I want it to search in the already loaded price model...

Any help ? thank you...




Aucun commentaire:

Enregistrer un commentaire