Skip to content

Instantly share code, notes, and snippets.

@mfeckie
Last active August 26, 2020 08:19
Show Gist options
  • Save mfeckie/eb2eb8ea1582b29bf8c428da0d2269bc to your computer and use it in GitHub Desktop.
Save mfeckie/eb2eb8ea1582b29bf8c428da0d2269bc to your computer and use it in GitHub Desktop.
Patient Explorer
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
}
import EmberRouter from '@ember/routing/router';
import config from './config/environment';
const Router = EmberRouter.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('patients', function() {
this.route('edit', { path: '/patients/:id' });
});
});
export default Router;
import Route from '@ember/routing/route';
export default Route.extend({
model(params) {
const patient = [
{name: 'Dave', id: "1"},
{name: 'Martha', id: "2"},
{name: 'Mabel', id: "3"},
].findBy('id', params.id);
return patient;
}
});
import Route from '@ember/routing/route';
export default Route.extend({
model() {
return [
{name: 'Dave', id: 1},
{name: 'Martha', id: 2},
{name: 'Mabel', id: 3},
]
}
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
a.active {
color: green;
}
<h1>Anatomy of Ember</h1>
<nav><LinkTo @route='patients'>Patients</LinkTo></nav>
<div class="page-content">
{{outlet}}
</div>
<h2>Details For {{this.model.name}}</h2>
<p>Patient ID: {{this.model.id}}</p>
<h2>Top level patients</h2>
<ul>
{{#each this.model as |patient| }}
<li>Patient: {{patient.name}} <LinkTo @route="patients.edit" @model={{patient.id}}>View</LinkTo></li>
{{/each}}
</ul>
<div class="details">
{{outlet}}
</div>
{
"version": "0.17.1",
"EmberENV": {
"FEATURES": {},
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false,
"_APPLICATION_TEMPLATE_WRAPPER": true,
"_JQUERY_INTEGRATION": true
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js",
"ember": "3.18.1",
"ember-template-compiler": "3.18.1",
"ember-testing": "3.18.1"
},
"addons": {
"@glimmer/component": "1.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment