Skip to content
Snippets Groups Projects
Commit fa3fb45a authored by Eugen Ciur's avatar Eugen Ciur
Browse files

great links between documents and folders - I love ember

parent c7f17c10
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,7 @@ Router.map(function () {
this.route('contact', { path: '/getting-in-touch' });
this.route('document', { path: '/document/:document_id' });
this.route('folder', { path: '/folder/' });
this.route('folders', { path: '/folders/' });
this.route('folder', { path: '/folder/:folder_id' });
this.route('tags', function () {
......
......@@ -2,17 +2,12 @@ import Route from '@ember/routing/route';
export default class FolderRoute extends Route {
async model(params) {
let url, response, nodes;
let response = await fetch(`/api/folder/${params.folder_id}.json`);
let { data } = await response.json();
if (params.folder_id) {
url = `/api/folder/${params.folder_id}`;
} else {
url = '/api/folder/';
}
response = await fetch(url);
nodes = await response.json();
return { nodes };
return data.map((model) => {
let { id, type, attributes } = model;
return { id, type, ...attributes };
});
}
}
import Route from '@ember/routing/route';
export default class FolderRoute extends Route {
async model(params) {
let response = await fetch(`/api/folder.json`);
let { data } = await response.json();
return data.map((model) => {
let { id, type, attributes } = model;
return { id, type, ...attributes };
});
}
}
{{#each @model as |node|}}
<div>
{{node.attributes.title}}
</div>
{{/each}}
\ No newline at end of file
<h1>Index </h1>
<Nodes @nodes={{@model}} />
<h1>Index </h1>
<Nodes @nodes={{@model}} />
{
"data": [
{
"type": "document",
"id": 4,
"attributes": {
"title": "Contract 1.pdf"
}
},
{
"type": "document",
"id": 5,
"attributes": {
"title": "Contract 2.pdf"
}
}
]
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment