diff --git a/app/models/species.js b/app/models/species.js
index b6d509a..c8746bd 100644
--- a/app/models/species.js
+++ b/app/models/species.js
@@ -16,6 +16,7 @@ export default DS.Model.extend({
updatedBy : DS.attr('number'),
deletedBy : DS.attr('number'),
sortOrder : DS.attr('number'),
+ canEdit : DS.attr('boolean'),
speciesNameMU: function() {
return Ember.String.htmlSafe(`${this.get('speciesName')}`);
diff --git a/app/models/strain.js b/app/models/strain.js
index 49344cf..1f54647 100644
--- a/app/models/strain.js
+++ b/app/models/strain.js
@@ -19,6 +19,7 @@ export default DS.Model.extend({
deletedBy : DS.attr('number'),
totalMeasurements : DS.attr('number'),
sortOrder : DS.attr('number'),
+ canEdit : DS.attr('boolean'),
strainNameMU: function() {
let type = this.get('typeStrain') ? 'T' : '';
diff --git a/app/pods/species/edit/route.js b/app/pods/species/edit/route.js
index b3f843f..6c264c2 100644
--- a/app/pods/species/edit/route.js
+++ b/app/pods/species/edit/route.js
@@ -1,4 +1,11 @@
import Ember from 'ember';
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
-export default Ember.Route.extend(AuthenticatedRouteMixin, {});
+export default Ember.Route.extend(AuthenticatedRouteMixin, {
+ afterModel: function(species) {
+ if (!species.get('canEdit')) {
+ this.transitionTo('species.show', species.get('id'));
+ }
+ },
+
+});
diff --git a/app/pods/species/index/controller.js b/app/pods/species/index/controller.js
index 2714e73..00f9448 100644
--- a/app/pods/species/index/controller.js
+++ b/app/pods/species/index/controller.js
@@ -5,7 +5,7 @@ export default Ember.Controller.extend({
sortedSpecies: Ember.computed.sort('model', 'sortParams'),
metaData: function() {
- return this.store.metadataFor('species');
+ return Ember.copy(this.store.metadataFor('species'));
}.property('model.isLoaded').readOnly(),
});
diff --git a/app/pods/species/show/controller.js b/app/pods/species/show/controller.js
deleted file mode 100644
index 6d9a32a..0000000
--- a/app/pods/species/show/controller.js
+++ /dev/null
@@ -1,14 +0,0 @@
-import Ember from 'ember';
-
-export default Ember.Controller.extend({
- userCanEdit: function() {
- let meta = this.store.metadataFor('species');
- let id = this.get('model.id');
-
- if (meta.canEdit.indexOf( +id ) === -1) {
- return false;
- }
- return true;
- }.property('model.isLoaded').readOnly(),
-
-});
diff --git a/app/pods/species/show/route.js b/app/pods/species/show/route.js
index dcf76cf..da42b03 100644
--- a/app/pods/species/show/route.js
+++ b/app/pods/species/show/route.js
@@ -3,6 +3,7 @@ import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixi
export default Ember.Route.extend(AuthenticatedRouteMixin, {
model: function(params) {
- return this.store.find('species', params.species_id);
- }
+ return this.store.findRecord('species', params.species_id, { reload: true });
+ },
+
});
diff --git a/app/pods/species/show/template.hbs b/app/pods/species/show/template.hbs
index e892234..49a83dc 100644
--- a/app/pods/species/show/template.hbs
+++ b/app/pods/species/show/template.hbs
@@ -6,19 +6,22 @@
{{! ROW 1 }}
-
-
+
+
- Strains
-
- {{#each model.strains as |strain index|}}
- {{if index ","}}
- {{#link-to 'strains.show' strain.id}}
- {{{strain.strainNameMU}}}
- {{/link-to}}
- {{/each}}
+
+ {{#each model.strains as |strain index|}}
+ -
+ {{#link-to 'strains.show' strain.id}}
+ {{{strain.strainNameMU}}}
+ {{/link-to}}
+
+ {{/each}}
+
-
+
- Type Species?
-
{{if model.typeSpecies 'Yes' 'No'}}
@@ -27,8 +30,8 @@
{{! ROW 2 }}
-
-
+
+
- Etymology
-
{{model.etymology}}
@@ -37,7 +40,7 @@
{{! ROW 3 }}
-
+
- Record Created
- {{null-time model.createdAt 'LL'}}
@@ -50,12 +53,11 @@
- Record Deleted
- {{null-time model.deletedAt 'LL'}}
-
-{{#if userCanEdit}}
+{{#if model.canEdit}}
{{#link-to 'species.edit' model class="button-gray smaller"}}
Edit
diff --git a/app/pods/strains/edit/route.js b/app/pods/strains/edit/route.js
index 9400fff..94a7710 100644
--- a/app/pods/strains/edit/route.js
+++ b/app/pods/strains/edit/route.js
@@ -5,10 +5,16 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
model: function(params) {
return Ember.RSVP.hash({
strain: this.store.find('strain', params.strain_id),
- species: this.store.findAll('species'),
+ species: this.store.findAll('species'), // Need for dropdown
});
},
+ afterModel: function(models) {
+ if (!models.strain.get('canEdit')) {
+ this.transitionTo('strains.show', models.strain.get('id'));
+ }
+ },
+
setupController: function(controller, models) {
controller.setProperties(models);
},
diff --git a/app/pods/strains/index/controller.js b/app/pods/strains/index/controller.js
index 17b709b..07954e7 100644
--- a/app/pods/strains/index/controller.js
+++ b/app/pods/strains/index/controller.js
@@ -5,7 +5,7 @@ export default Ember.Controller.extend({
sortedStrains: Ember.computed.sort('model', 'sortParams'),
metaData: function() {
- return this.store.metadataFor('strain');
+ return Ember.copy(this.store.metadataFor('strain'));
}.property('model.isLoaded').readOnly(),
});
diff --git a/app/pods/strains/new/route.js b/app/pods/strains/new/route.js
index 0199071..03b7907 100644
--- a/app/pods/strains/new/route.js
+++ b/app/pods/strains/new/route.js
@@ -5,10 +5,14 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
model: function() {
return Ember.RSVP.hash({
strain: this.store.createRecord('strain'),
- species: this.store.findAll('species'),
+ species: this.store.findAll('species'), // Need for dropdown
});
},
+ afterModel: function(models) {
+ console.log('after model');
+ },
+
setupController: function(controller, models) {
controller.setProperties(models);
},
diff --git a/app/pods/strains/show/controller.js b/app/pods/strains/show/controller.js
deleted file mode 100644
index 2925c60..0000000
--- a/app/pods/strains/show/controller.js
+++ /dev/null
@@ -1,14 +0,0 @@
-import Ember from 'ember';
-
-export default Ember.Controller.extend({
- userCanEdit: function() {
- let meta = this.store.metadataFor('strain');
- let id = this.get('model.id');
-
- if (meta.canEdit.indexOf( +id ) === -1) {
- return false;
- }
- return true;
- }.property('model.isLoaded').readOnly(),
-
-});
diff --git a/app/pods/strains/show/route.js b/app/pods/strains/show/route.js
index bd0b588..4c9634b 100644
--- a/app/pods/strains/show/route.js
+++ b/app/pods/strains/show/route.js
@@ -3,6 +3,7 @@ import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixi
export default Ember.Route.extend(AuthenticatedRouteMixin, {
model: function(params) {
- return this.store.find('strain', params.strain_id);
- }
+ return this.store.findRecord('strain', params.strain_id, { reload: true });
+ },
+
});
diff --git a/app/pods/strains/show/template.hbs b/app/pods/strains/show/template.hbs
index 4605f97..01eb5cf 100644
--- a/app/pods/strains/show/template.hbs
+++ b/app/pods/strains/show/template.hbs
@@ -5,8 +5,8 @@
{{! ROW 1 }}
-
-
+
+
- Species
-
{{#link-to 'species.show' model.species.id}}
@@ -14,7 +14,7 @@
{{/link-to}}
-
+
- Type Strain?
-
{{if model.typeStrain 'Yes' 'No'}}
@@ -23,20 +23,20 @@
{{! ROW 2 }}
-
-
+
+
- Accession Numbers
-
{{model.accessionNumbers}}
-
+
- Genbank
-
{{genbank-url genbank=model.genbank}}
-
+
- Whole Genome Sequence
-
{{model.wholeGenomeSequence}}
@@ -45,8 +45,8 @@
{{! ROW 3 }}
-
-
+
+
- Isolated From
-
{{model.isolatedFrom}}
@@ -55,8 +55,8 @@
{{! ROW 4 }}
-
-
+
+
- Notes
-
{{model.notes}}
@@ -65,7 +65,7 @@
{{! ROW 5 }}
-
+
- Record Created
- {{null-time model.createdAt 'LL'}}
@@ -78,11 +78,10 @@
- Record Deleted
- {{null-time model.deletedAt 'LL'}}
-
-{{#if userCanEdit}}
+{{#if model.canEdit}}
{{#link-to 'species.edit' model class="button-gray smaller"}}
Edit