From 43bc7645f2d2db853063c57f464b7aba7ef0b1e8 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Tue, 20 Oct 2015 10:07:29 -0700 Subject: [PATCH] Replace calls to store for metaData with user CP Fixes #25. --- app/models/user.js | 10 ++++++++++ app/pods/protected/characteristics/index/route.js | 4 +++- app/pods/protected/species/edit/route.js | 4 +++- app/pods/protected/species/index/route.js | 4 +++- app/pods/protected/strains/edit/route.js | 4 +++- app/pods/protected/strains/index/route.js | 4 +++- 6 files changed, 25 insertions(+), 5 deletions(-) diff --git a/app/models/user.js b/app/models/user.js index c6a5dac..198f451 100644 --- a/app/models/user.js +++ b/app/models/user.js @@ -1,3 +1,4 @@ +import Ember from 'ember'; import DS from 'ember-data'; export default DS.Model.extend({ @@ -33,4 +34,13 @@ export default DS.Model.extend({ return 'Error'; } }.property('role'), + + canWrite: Ember.computed('role', function() { + return this.get('role') !== 'R'; + }), + + metaData: Ember.computed('canWrite', function() { + return { 'canAdd': this.get('canWrite') }; + }), + }); diff --git a/app/pods/protected/characteristics/index/route.js b/app/pods/protected/characteristics/index/route.js index 83aa3ef..a68c605 100644 --- a/app/pods/protected/characteristics/index/route.js +++ b/app/pods/protected/characteristics/index/route.js @@ -7,7 +7,9 @@ export default Ember.Route.extend({ setupController: function(controller, model) { controller.set('model', model); - controller.set('metaData', this.store.metadataFor('characteristic')); + this.get('session.currentUser').then((user) => { + controller.set('metaData', user.get('metaData')); + }); }, }); diff --git a/app/pods/protected/species/edit/route.js b/app/pods/protected/species/edit/route.js index e9e9076..3da73d9 100644 --- a/app/pods/protected/species/edit/route.js +++ b/app/pods/protected/species/edit/route.js @@ -18,7 +18,9 @@ export default Ember.Route.extend({ setupController: function(controller, model) { controller.set('model', model); - controller.set('metaData', this.store.metadataFor('species')); + this.get('session.currentUser').then((user) => { + controller.set('metaData', user.get('metaData')); + }); }, }); diff --git a/app/pods/protected/species/index/route.js b/app/pods/protected/species/index/route.js index 755edff..fdb9293 100644 --- a/app/pods/protected/species/index/route.js +++ b/app/pods/protected/species/index/route.js @@ -7,7 +7,9 @@ export default Ember.Route.extend({ setupController: function(controller, model) { controller.set('model', model); - controller.set('metaData', this.store.metadataFor('species')); + this.get('session.currentUser').then((user) => { + controller.set('metaData', user.get('metaData')); + }); }, }); diff --git a/app/pods/protected/strains/edit/route.js b/app/pods/protected/strains/edit/route.js index 328d89d..90ae097 100644 --- a/app/pods/protected/strains/edit/route.js +++ b/app/pods/protected/strains/edit/route.js @@ -26,7 +26,9 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, { setupController: function(controller, models) { controller.setProperties(models); - controller.set('metaData', this.store.metadataFor('strain')); + this.get('session.currentUser').then((user) => { + controller.set('metaData', user.get('metaData')); + }); }, }); diff --git a/app/pods/protected/strains/index/route.js b/app/pods/protected/strains/index/route.js index 14b7a5c..89b5e40 100644 --- a/app/pods/protected/strains/index/route.js +++ b/app/pods/protected/strains/index/route.js @@ -7,7 +7,9 @@ export default Ember.Route.extend({ setupController: function(controller, model) { controller.set('model', model); - controller.set('metaData', this.store.metadataFor('strain')); + this.get('session.currentUser').then((user) => { + controller.set('metaData', user.get('metaData')); + }); }, });