MetaData mixin

This commit is contained in:
Matthew Dillon 2015-11-05 12:40:10 -07:00
parent 6924dba26e
commit e6c6cac212
3 changed files with 20 additions and 21 deletions

View file

@ -0,0 +1,14 @@
import Ember from 'ember';
const { Mixin, inject: { service }} = Ember;
export default Mixin.create({
currentUser: service('session-account'),
metaData: null,
setupMetaDataOnInit: Ember.on('init', function() {
this.get('currentUser.account').then((user) => {
this.set('metaData', user.get('metaData'));
});
}),
});

View file

@ -1,19 +1,11 @@
import Ember from 'ember';
import SetupMetaData from '../../../../../mixins/setup-metadata';
const { Component, inject: { service }} = Ember;
const { Component } = Ember;
export default Component.extend({
currentUser: service('session-account'),
metaData: null,
export default Component.extend(SetupMetaData, {
species: null,
setupMetaDataOnInit: Ember.on('init', function() {
this.get('currentUser.account').then((user) => {
this.set('metaData', user.get('metaData'));
});
}),
sortParams: ['speciesName', 'strainCount'],
sortedSpecies: Ember.computed.sort('species', 'sortParams'),

View file

@ -1,10 +1,9 @@
import Ember from 'ember';
import SetupMetaData from '../../../../mixins/setup-metadata';
const { Component, inject: { service } } = Ember;
export default Component.extend({
currentUser: service('session-account'),
const { Component } = Ember;
export default Component.extend(SetupMetaData, {
// Read-only attributes
species: null,
isNew: null,
@ -31,12 +30,6 @@ export default Component.extend({
this.set('isNew', this.get('species.isNew'));
}),
setupMetaDataOnInit: Ember.on('init', function() {
this.get('currentUser.account').then((user) => {
this.set('metaData', user.get('metaData'));
});
}),
updateField: function(property, value) {
this.set(property, value);
// Manually compare against passed in value