From ae7f3bdafaa01c5492ee51fc22729d397d531b67 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Tue, 7 Jul 2015 09:56:49 -0800 Subject: [PATCH] Test-drive metadata --- app/pods/components/add-button/component.js | 9 --------- app/pods/species/index/controller.js | 5 +++++ app/pods/species/index/template.hbs | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) delete mode 100644 app/pods/components/add-button/component.js diff --git a/app/pods/components/add-button/component.js b/app/pods/components/add-button/component.js deleted file mode 100644 index 8075297..0000000 --- a/app/pods/components/add-button/component.js +++ /dev/null @@ -1,9 +0,0 @@ -import Ember from 'ember'; -import userCanAdd from '../../../utils/user-can-add'; - -export default Ember.Component.extend({ - canAdd: function() { - let user_role = this.get('session.currentUser.role'); - return userCanAdd(user_role); - }.property('session.currentUser.role').readOnly(), -}); diff --git a/app/pods/species/index/controller.js b/app/pods/species/index/controller.js index a28a11f..82a022e 100644 --- a/app/pods/species/index/controller.js +++ b/app/pods/species/index/controller.js @@ -3,4 +3,9 @@ import Ember from 'ember'; export default Ember.Controller.extend({ sortParams: ['speciesName', 'strainCount'], sortedSpecies: Ember.computed.sort('species', 'sortParams'), + + metaData: function() { + return this.store.metadataFor('species'); + }.property('model.isLoaded').readOnly(), + }); diff --git a/app/pods/species/index/template.hbs b/app/pods/species/index/template.hbs index 12cd6d8..4f34a27 100644 --- a/app/pods/species/index/template.hbs +++ b/app/pods/species/index/template.hbs @@ -1,7 +1,7 @@

{{genus-name}} Species

Total species: {{species.length}}

-{{add-button label="Add Species" link="species.new"}} +{{add-button label="Add Species" link="species.new" canAdd=metaData.canAdd}}