Last active
November 5, 2015 15:23
-
-
Save felixkiss/9857fd830a837866f641 to your computer and use it in GitHub Desktop.
ember-filter-async-relationship
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({ | |
appName:'Ember 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.Model.extend({ | |
order: DS.attr('number'), | |
tab: DS.belongsTo('custom-field-tab', {async: true}) | |
}); |
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.Model.extend({ | |
slug: DS.attr('string'), | |
label: DS.attr('string'), | |
icon: DS.attr('string'), | |
order: DS.attr('number') | |
}); |
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.Model.extend({ | |
label: DS.attr('string'), | |
positions: DS.hasMany('custom-field-position', {async: false}) | |
}); |
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.Model.extend({ | |
value: DS.attr('string'), | |
field: DS.belongsTo('custom-field', {async: false}) | |
}); |
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'; | |
const User = DS.Model.extend({ | |
username: DS.attr('string'), | |
customFields: DS.hasMany('user-custom-field', {async: false}), | |
indexFields: function() { | |
return this._filterByTab(1); | |
}.property('customFields.[]'), | |
contactFields: function() { | |
return this._filterByTab(2); | |
}.property('customFields.[]'), | |
_filterByTab: function(tab) { | |
return this.get('customFields').filter(function(field) { | |
var position = field.get('field.positions').findBy('tab.id', '' + tab); | |
if (! position) { | |
return false; | |
} | |
field.order = position.get('order'); | |
return true; | |
}).sortBy('order'); | |
} | |
}); | |
return User; |
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: function() { | |
return this.store.find('user', 1); | |
} | |
}); |
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.4.16", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.1.0", | |
"ember-data": "2.1.0", | |
"ember-template-compiler": "2.1.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment