Last active
July 7, 2019 01:12
-
-
Save HenryVonfire/8460f197cd852750f5c7fdcede175c68 to your computer and use it in GitHub Desktop.
SO example
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({ | |
appName: 'Ember 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 Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
import { belongsTo, hasMany } from "ember-data/relationships"; | |
export default Model.extend({ | |
transferOrigins:hasMany('transfer', { inverse: 'storeOrigin' }), | |
transferDestinations:hasMany('transfer', { inverse: 'storeDestination' }), | |
storeNo:attr('string'), | |
storeState:attr('string'), | |
storeCity:attr('string') | |
}); |
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({ | |
storeOrigin:belongsTo('storehouse'), | |
storeDestination:belongsTo('storehouse'), | |
fromStoreId:attr('string'), | |
toStoreId:attr('string'), | |
transferNotes:attr('string') | |
}); |
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({ | |
beforeModel(){ | |
let store1 = this.store.createRecord('storehouse',{ | |
id:'1', | |
storeNo:'me1', | |
storeState: 'me', | |
storeCity: 'Bangor' | |
}); | |
let store2 = this.store.createRecord('storehouse',{ | |
id:'2', | |
storeNo:'tx1', | |
storeState: 'tx', | |
storeCity: 'Dallas' | |
}); | |
let transfer1 = this.store.createRecord('transfer',{ | |
id:'1' | |
}); | |
transfer1.set('storeOrigin',store1); | |
transfer1.set('fromStoreId',store1.id); | |
transfer1.set('storeDestination',store2); | |
transfer1.set('toStoreId',store2.id); | |
transfer1.set('transferNotes','transfer to 2'); | |
}, | |
model(){ | |
return this.store.peekRecord('transfer','1'); | |
} | |
}); |
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.8.1", | |
"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.5.1", | |
"ember-data": "2.5.2", | |
"ember-template-compiler": "2.5.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment