samedi 21 janvier 2017

Extending model without persisting to datastore

The below shows Ember files from an application that lists employee names from a Mirage data store.

What I need to do is add a property 'present' to the model outside of the datastore. The idea is that the employee will click their name on the list to toggle whether they are present or not.

What I don't know is how or where to apply this functionality.

Any advice is welcome.

Mirage Scenario

export default function(server) {
  server.create('employee', {
    firstname: "John",
    lastname: "Doe"
  });
  server.create('employee', {
    firstname: "Joe",
    lastname: "Bloggs"
  });
}

Route

export default Ember.Route.extend({
  model() {
    return this.store.findAll('employee');
  }
});

Model

export default DS.Model.extend({
  firstname: DS.attr('string'),
  lastname: DS.attr('string')
});

Template

<ul>
  
      <li> </li>
  
</ul>




Aucun commentaire:

Enregistrer un commentaire