View logic in DS Models?

Hi everybody,

I fear I already know the answer to this but I thought I’d put it out there.

I have some DS.Models that are displayed on one side as RowComponent in a TableComponent and in as MarkerComponent in a MapComponent on the other.

When the User selects a RowComponent, the MarkerComponent of the same Record should be aware of it and vice versa.

I am flirting with the idea of adding isSelected: DS.attr('boolean') to my Models and observing it.

//  RowComponent
click(){
     // set a select styling
     this.get('record').set('isSelected',  true);
}

// in MarkerComponent
listenForDistantSelect: function(){
   // set a select styling
}.observes('record.isSelected')

It’s not really business logic, which as I understand should be reserved to Routes and EmberData stuff. Would you say this is something that should really handled at the View level or has anyone done somthing similar?

I think your instinct here (that this should be view level logic) is correct. I would not add view-related properties to the model. This should be done at the controller or component level to maintain good design patterns. I would say probably whatever “owns” both the map and table components.

1 Like