Skip to content

Instantly share code, notes, and snippets.

@ArnaudValensi
Created June 5, 2018 13:42
Show Gist options
  • Save ArnaudValensi/5e9b9b766c30eb15e884cc228ea3d251 to your computer and use it in GitHub Desktop.
Save ArnaudValensi/5e9b9b766c30eb15e884cc228ea3d251 to your computer and use it in GitHub Desktop.
import Ember from 'ember';
import SmartViewMixin from 'client/mixins/smart-view-mixin';
export default Ember.Component.extend(SmartViewMixin.default, {
router: Ember.inject.service('-routing'),
store: Ember.inject.service(),
actions: {
selectTreatment(patientId) {
const treatmentCollection = this.findCollectionByName('treatment');
const treatmentCollectionId = treatmentCollection[0].get('id');
this.get('router').transitionTo(
'rendering.data.collection.list.viewEdit.summary.index',
[treatmentCollectionId, treatmentCollectionId, patientId]
);
}
},
findCollectionByName(collectionName) {
const collections = this.get('store').peekAll('collection');
return collections.filterBy('name', collectionName);
}
});
{{#each records as |record|}}
<div class="wrapper-card">
<div class="card--title">
<h2>{{record.forest-name}}</h2>
<div class="summary-field patient-field">
<label class="c-form__element">
<strong class="c-form__label--read c-clr-1-2">Patient Count:</strong>
<p class="c-clr-1-4">{{record.forest-patient_count}}</p>
</label>
</div>
{{#each record.forest-patients as |patient|}}
<li>
<a href="#" {{action "selectTreatment" patient.id}}>{{patient.forest-name}}</a>
</li>
{{/each}}
</div>
</div>
{{/each}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment