MetaData mixin
This commit is contained in:
parent
6924dba26e
commit
e6c6cac212
3 changed files with 20 additions and 21 deletions
14
app/mixins/setup-metadata.js
Normal file
14
app/mixins/setup-metadata.js
Normal 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'));
|
||||
});
|
||||
}),
|
||||
});
|
|
@ -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'),
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in a new issue