Skip to content
Permalink
Browse files

Implement Listicle

  • Loading branch information
runspired committed Dec 16, 2019
1 parent 7ffb74c commit 31fded57026b5fa12dbf2f6f7eedcf4d20d505ce
No changes.
@@ -0,0 +1,43 @@
import { all } from 'rsvp';
// import fetch from 'fetch';

function fixUrlForFastboot(url) {
return `http://localhost:4200` + url.substr(1);
}

export default class ApplicationAdapter {
constructor() {
this.currentTransaction = null;
this.transactionPromise = null;
}

request(promise) {
return promise;
if (this.currentTransaction) {
let len = this.currentTransaction.push(promise);
return this.transactionPromise.then(r => r[len - 1]);
}
this.currentTransaction = [promise];
this.transactionPromise = Promise.resolve()
.then(() => {
let transaction = this.currentTransaction;
this.currentTransaction = null;
this.transactionPromise = null;
return all(transaction);
});
return this.transactionPromise.then(r => r[0]);
}
findAll(store, { modelName }) {
return fetch(`./fixtures/${modelName}.json`)
.then(result => result.json());
}

findRecord(store, { modelName }, id) {
const promise = fetch(`./fixtures/${modelName}_${id}.json`)
.then(result => result.json());
return this.request(promise);
}
static create() {
return new this();
}
}
@@ -0,0 +1,8 @@
<item>
<h3>{{@item.text}}</h3>
<ol>
{{#each @item.facets as |facet|}}
<li>{{facet.description}}</li>
{{/each}}
</ol>
</item>
@@ -0,0 +1,9 @@
<list>
<h2>{{@list.title}}</h2>
<h3>Authored By {{@list.author.name}}</h3>
<ul>
{{#each @list.items as |item|}}
<li>{{yield item}}</li>
{{/each}}
</ul>
</list>
No changes.
@@ -0,0 +1,25 @@
import Route from "@ember/routing/route";
import { inject } from '@ember/service';
import { all } from "rsvp";

export default class ListsRoute extends Route {
@inject store;

/*
async model() {
const { store } = this;
let promises = [];
// fetch 50 lists
// each list will have 10 items
// each item will include 3 related items
// for a total of 500 item records + 50 list records + 1500 related items
for (let i = 1; i <= 50; i++) {
promises.push(store.findRecord("list", `list:${i}`));
}
return await all(promises);
}
*/
model() {
return this.store.findAll('list');
}
}
No changes.
@@ -0,0 +1,8 @@
export default class ApplicationSerializer {
normalizeResponse(_, __, payload) {
return payload;
}
static create() {
return new this();
}
}
@@ -0,0 +1,56 @@
html {
font-size: 125%;
background: #e5e5e5;
position: relative;
width: 100%;
height: 100%;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-weight: 300;
}

* {
box-sizing: border-box;
}

list {
font-size: .8rem;
display: block;
position: relative;
width: 32%;
height: 300px;
overflow: scroll;
float: left;
margin: .25rem;
border-radius: 2px;
box-shadow: 2px 2px 0px 0px rgba(0, 0, 0, 0.5);
background: #f5f5f5;
border: 1px solid #d5d5d5;
}

list > h2 {
margin: 0;
padding: .25rem;
font-weight: 500;
width: 100%;
display: block;
font-size: 1.2em;
border-bottom: 1px solid #d0d0d0;
background: #f0f0f0;
}
list > ul {
padding: .25rem;
margin: 0;
list-style: none;
font-size: 1em;
}
item {
font-size: .8rem;
}
item > h3 {
font-size: .8em;
font-weight: 300;
}
item > ul {
font-size: .8em;
font-weight: 100;
}
@@ -1,4 +1 @@
<h2 id="title">Welcome to Ember</h2>

{{outlet}}

{{outlet}}
@@ -0,0 +1,5 @@
{{#each this.model as |list|}}
<List @list={{list}} as |item|>
<Item @item={{item}} />
</List>
{{/each}}

0 comments on commit 31fded5

Please sign in to comment.
You can’t perform that action at this time.