Created
December 26, 2016 21:45
-
-
Save zolo2hin/fdb92b163008e4f280287353cb32089b to your computer and use it in GitHub Desktop.
New Twiddle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import DS from 'ember-data'; | |
export default DS.JSONAPIAdapter.extend({ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
datasource: Ember.A(), | |
tagName: 'ul', | |
itemTag: 'li', | |
itemClass: 'item', | |
itemOpenedClass: 'item--open', | |
parent: null, | |
childItems: Ember.A(), | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
const eq = (params) => params[0] == params[1]; | |
export default Ember.Helper.helper(eq); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
import { belongsTo, hasMany } from "ember-data/relationships"; | |
export default Model.extend({ | |
title: DS.attr('string'), | |
parent: DS.belongsTo('category', {inverse: 'children'}), | |
children: DS.hasMany('category', {inverse: 'parent'}) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('main', { path: '/' }); | |
}); | |
export default Router; | |
$.mockjax({ | |
url: '/categories', | |
type: 'GET', | |
status: '200', | |
dataType: 'json', | |
responseText: { | |
"data": [ | |
{ | |
"type": "categories", | |
"id": 1, | |
"attributes": { | |
"title": "Category 1", | |
}, | |
"relationships": [] | |
}, | |
{ | |
"type": "categories", | |
"id": 2, | |
"attributes": { | |
"title": "Category 2" | |
}, | |
"relationships": { | |
"parent": { | |
"data": { | |
"type": "categories", | |
"id": 1 | |
} | |
} | |
} | |
}, | |
{ | |
"type": "categories", | |
"id": 3, | |
"attributes": { | |
"title": "Category 3" | |
}, | |
"relationships": { | |
"parent": { | |
"data": { | |
"type": "categories", | |
"id": 2 | |
} | |
} | |
} | |
} | |
] | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model() { | |
return this.get('store').findAll('category'); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.10.7", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.10.0", | |
"ember-data": "2.3.3", | |
"ember-template-compiler": "2.10.0", | |
"ember-testing": "2.10.0", | |
"jquery-mockjax": "https://cdnjs.cloudflare.com/ajax/libs/jquery-mockjax/1.6.2/jquery.mockjax.js" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment