-
-
Save Baukereg/556e18f651a052b25342fd36e49cb34f to your computer and use it in GitHub Desktop.
New Twiddle
This file contains hidden or 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({ | |
| db: Ember.computed('refreshDb', function() { | |
| let dump = window.server.schema.db.dump(); | |
| return JSON.stringify(dump, null, 2); | |
| }), | |
| actions: { | |
| toggleIsShowingDatabase() { | |
| this.toggleProperty('isShowingDatabase'); | |
| }, | |
| refreshDb() { | |
| this.incrementProperty('refreshDb'); | |
| }, | |
| deleteBook(book) { | |
| book.destroyRecord(); | |
| }, | |
| deleteAuthor() { | |
| this.get('model').destroyRecord(); | |
| } | |
| } | |
| }); |
This file contains hidden or 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 Mirage from 'ember-cli-mirage'; | |
| export default function() { | |
| window.server = this; | |
| this.get('authors/:id'); | |
| this.delete('authors/:id'); | |
| this.delete('books/:id'); | |
| this.get('books/:id'); | |
| this.patch('authors/:id'); | |
| }; |
This file contains hidden or 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, belongsTo } from 'ember-cli-mirage'; | |
| export default Model.extend({ | |
| }); |
This file contains hidden or 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
| export default function(server) { | |
| let author = server.create('author', { | |
| name: 'John Steinbeck' | |
| }); | |
| server.create('book', { | |
| title: 'Test Book', | |
| }); | |
| } |
This file contains hidden or 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 { JSONAPISerializer } from 'ember-cli-mirage'; | |
| export default JSONAPISerializer.extend({ | |
| }); |
This file contains hidden or 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: attr() | |
| }); |
This file contains hidden or 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.store.findRecord('author', 1, { | |
| include: 'books' | |
| }); | |
| }, | |
| actions: { | |
| addBook() { | |
| let model = this.get('controller.model'); | |
| console.log('model', model); | |
| this.store.findRecord('book', 1).then((book) => { | |
| console.log('book', book); | |
| let books = model.get('books'); | |
| console.log('books', books); | |
| books.addObject(book); | |
| model.save(); | |
| }); | |
| }, | |
| }, | |
| }); |
This file contains hidden or 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
| body { | |
| margin: 0; | |
| font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
| font-size: 12pt; | |
| } | |
| header { | |
| background: #2e4068; | |
| color: white; | |
| padding: 14px 20px; | |
| } | |
| h1 { | |
| font-size: 12px; | |
| font-weight: bold; | |
| text-shadow: none; | |
| margin: 0 0 2px; | |
| text-transform: uppercase; | |
| opacity: 0.5; | |
| } | |
| h2 { | |
| font-size: 16px; | |
| margin: 0; | |
| } | |
| p { | |
| font-weight: normal; | |
| } | |
| .pa4 { | |
| padding: 20px; | |
| } | |
| .ph4 { | |
| padding-left: 20px; | |
| padding-right: 20px; | |
| } | |
| hr { | |
| border-top: none; | |
| border-bottom: 1px solid #ddd; | |
| } | |
| .panel { | |
| background: whitesmoke; | |
| } | |
| .panel__toggle { | |
| display: block; | |
| text-decoration: none; | |
| padding: 8px; | |
| color: #777; | |
| } | |
| .panel__body { | |
| padding: 8px; | |
| } |
This file contains hidden or 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", | |
| "ENV": { | |
| "ember-cli-mirage": { | |
| "enabled": true | |
| } | |
| }, | |
| "EmberENV": { | |
| "FEATURES": { | |
| "ds-finder-include": true | |
| } | |
| }, | |
| "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.10.0", | |
| "ember-template-compiler": "2.10.0", | |
| "ember-testing": "2.10.0" | |
| }, | |
| "addons": { | |
| "ember-cli-mirage": "0.3.0-beta.4" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment