Limit species and strain new access
This commit is contained in:
parent
58779a4a7d
commit
bb2386807c
4 changed files with 34 additions and 16 deletions
|
@ -18,12 +18,6 @@ export default Ember.Controller.extend({
|
|||
},
|
||||
|
||||
cancel: function() {
|
||||
let species = this.get('model');
|
||||
|
||||
if (species.get('isNew')) {
|
||||
species.deleteRecord();
|
||||
}
|
||||
|
||||
this.transitionToRoute('species.index');
|
||||
},
|
||||
|
||||
|
|
|
@ -2,8 +2,25 @@ import Ember from 'ember';
|
|||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
beforeModel: function() {
|
||||
if (this.get('session.currentUser.role') === 'R') {
|
||||
this.transitionTo('species.index');
|
||||
}
|
||||
},
|
||||
|
||||
model: function() {
|
||||
return this.store.createRecord('species');
|
||||
},
|
||||
|
||||
actions: {
|
||||
willTransition: function(transition) {
|
||||
let controller = this.get('controller');
|
||||
let species = controller.get('model');
|
||||
|
||||
if (species.get('isNew')) {
|
||||
species.deleteRecord();
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
|
|
@ -17,12 +17,6 @@ export default Ember.Controller.extend({
|
|||
},
|
||||
|
||||
cancel: function() {
|
||||
let strain = this.get('strain');
|
||||
|
||||
if (strain.get('isNew')) {
|
||||
strain.deleteRecord();
|
||||
}
|
||||
|
||||
this.transitionToRoute('strains.index');
|
||||
},
|
||||
|
||||
|
|
|
@ -2,6 +2,12 @@ import Ember from 'ember';
|
|||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
beforeModel: function() {
|
||||
if (this.get('session.currentUser.role') === 'R') {
|
||||
this.transitionTo('strains.index');
|
||||
}
|
||||
},
|
||||
|
||||
model: function() {
|
||||
return Ember.RSVP.hash({
|
||||
strain: this.store.createRecord('strain'),
|
||||
|
@ -9,12 +15,19 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
|||
});
|
||||
},
|
||||
|
||||
afterModel: function(models) {
|
||||
console.log('after model');
|
||||
},
|
||||
|
||||
setupController: function(controller, models) {
|
||||
controller.setProperties(models);
|
||||
},
|
||||
|
||||
actions: {
|
||||
willTransition: function(transition) {
|
||||
let controller = this.get('controller');
|
||||
let strain = controller.get('strain');
|
||||
|
||||
if (strain.get('isNew')) {
|
||||
strain.deleteRecord();
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
|
Reference in a new issue