protected route
This commit is contained in:
parent
72c957f8dc
commit
eb1a8bb6e3
41 changed files with 56 additions and 43 deletions
4
app/pods/protected/about/route.js
Normal file
4
app/pods/protected/about/route.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
import Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin);
|
3
app/pods/protected/about/template.hbs
Normal file
3
app/pods/protected/about/template.hbs
Normal file
|
@ -0,0 +1,3 @@
|
|||
<div class="about">
|
||||
<p>This is some information about hymenobacter.info</p>
|
||||
</div>
|
6
app/pods/protected/characteristics/controller.js
Normal file
6
app/pods/protected/characteristics/controller.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
sortParams: ['characteristicType.characteristicTypeName', 'sortOrder'],
|
||||
sortedCharacteristics: Ember.computed.sort('characteristics', 'sortParams'),
|
||||
});
|
15
app/pods/protected/characteristics/route.js
Normal file
15
app/pods/protected/characteristics/route.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
import Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
model: function() {
|
||||
return Ember.RSVP.hash({
|
||||
characteristicTypes: this.store.findAll('characteristic-type'),
|
||||
characteristics: this.store.findAll('characteristic'),
|
||||
});
|
||||
},
|
||||
|
||||
setupController: function(controller, models) {
|
||||
controller.setProperties(models);
|
||||
},
|
||||
});
|
21
app/pods/protected/characteristics/template.hbs
Normal file
21
app/pods/protected/characteristics/template.hbs
Normal file
|
@ -0,0 +1,21 @@
|
|||
<h2>{{genus-name}} Characteristics</h2>
|
||||
<h3>Total characteristics: {{characteristics.length}}</h3>
|
||||
|
||||
<table class="flakes-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Sort Order</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each sortedCharacteristics as |row|}}
|
||||
<tr>
|
||||
<td>{{row.characteristicName}}</td>
|
||||
<td>{{row.characteristicType.characteristicTypeName}}</td>
|
||||
<td>{{row.sortOrder}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
47
app/pods/protected/compare/controller.js
Normal file
47
app/pods/protected/compare/controller.js
Normal file
|
@ -0,0 +1,47 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
strains: [],
|
||||
dataEmpty: true,
|
||||
|
||||
actions: {
|
||||
search: function(selectedStrains, selectedCharacteristics) {
|
||||
if (Ember.isEmpty(selectedStrains) || Ember.isEmpty(selectedCharacteristics)) {
|
||||
this.set('dataEmpty', true);
|
||||
return false;
|
||||
}
|
||||
|
||||
let data = Ember.A();
|
||||
let strains = [];
|
||||
selectedStrains.forEach((strain) => {
|
||||
let s = this.store.getById('strain', strain);
|
||||
strains.pushObject(s);
|
||||
});
|
||||
this.set('strains', strains);
|
||||
|
||||
this.store.find('measurement', {
|
||||
strain: selectedStrains,
|
||||
characteristic: selectedCharacteristics,
|
||||
}).then((measurements) => {
|
||||
selectedCharacteristics.forEach((characteristic) => {
|
||||
let char = this.store.getById('characteristic', characteristic);
|
||||
let row = {
|
||||
characteristic: char.get('characteristicName'),
|
||||
};
|
||||
selectedStrains.forEach((strain) => {
|
||||
let meas = measurements.filterBy('strain.id', strain)
|
||||
.filterBy('characteristic.id', characteristic);
|
||||
if (!Ember.isEmpty(meas)) {
|
||||
row[strain] = meas[0].get('value');
|
||||
} else {
|
||||
row[strain] = '';
|
||||
}
|
||||
});
|
||||
data.pushObject(row);
|
||||
});
|
||||
this.set('data', data);
|
||||
this.set('dataEmpty', false);
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
11
app/pods/protected/compare/route.js
Normal file
11
app/pods/protected/compare/route.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
resetController: function(controller, isExiting /*, transition*/) {
|
||||
if (isExiting) {
|
||||
controller.set('data', null);
|
||||
controller.set('strains', null);
|
||||
controller.set('dataEmpty', true);
|
||||
}
|
||||
}
|
||||
});
|
41
app/pods/protected/compare/template.hbs
Normal file
41
app/pods/protected/compare/template.hbs
Normal file
|
@ -0,0 +1,41 @@
|
|||
<h2>{{genus-name}} - Compare Strains</h2>
|
||||
|
||||
{{
|
||||
measurement-search-panel
|
||||
search='search'
|
||||
strainLabel='Select one or more strains'
|
||||
charLabel='Select one or more characteristics'
|
||||
}}
|
||||
|
||||
{{#if dataEmpty}}
|
||||
<div class="flakes-message information">
|
||||
Please select one or more strains and one or more characteristics.
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="overflow-div">
|
||||
<table class="flakes-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Characteristic</th>
|
||||
{{#each strains as |strain|}}
|
||||
<th>
|
||||
{{#link-to 'protected.strains.show' strain.id classBinding="data.typeStrain:type-strain"}}
|
||||
{{strain.fullNameMU}}
|
||||
{{/link-to}}
|
||||
</th>
|
||||
{{/each}}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each data as |row|}}
|
||||
<tr>
|
||||
<td>{{row.characteristic}}</td>
|
||||
{{#each strains as |strain|}}
|
||||
<td>{{get-property row strain.id}}</td>
|
||||
{{/each}}
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{/if}}
|
9
app/pods/protected/index/route.js
Normal file
9
app/pods/protected/index/route.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
import Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
beforeModel: function(transition) {
|
||||
this._super(transition);
|
||||
this.transitionTo('protected.compare');
|
||||
}
|
||||
});
|
1
app/pods/protected/index/template.hbs
Normal file
1
app/pods/protected/index/template.hbs
Normal file
|
@ -0,0 +1 @@
|
|||
Welcome
|
50
app/pods/protected/measurements/controller.js
Normal file
50
app/pods/protected/measurements/controller.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
import Ember from 'ember';
|
||||
import ColumnDefinition from 'ember-table/models/column-definition';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
measurements: [],
|
||||
|
||||
measurementsEmpty: function() {
|
||||
return this.get('measurements').length === 0;
|
||||
}.property('measurements'),
|
||||
|
||||
tableColumns: Ember.computed(function() {
|
||||
let strainCol = ColumnDefinition.create({
|
||||
savedWidth: 200,
|
||||
textAlign: 'text-align-left',
|
||||
headerCellName: 'Strain',
|
||||
contentPath: 'strain.fullNameMU',
|
||||
});
|
||||
|
||||
let charCol = ColumnDefinition.create({
|
||||
savedWidth: 200,
|
||||
textAlign: 'text-align-left',
|
||||
headerCellName: 'Characteristic',
|
||||
contentPath: 'characteristic.characteristicName',
|
||||
});
|
||||
|
||||
let valCol = ColumnDefinition.create({
|
||||
savedWidth: 150,
|
||||
textAlign: 'text-align-left',
|
||||
headerCellName: 'Value',
|
||||
contentPath: 'value',
|
||||
});
|
||||
|
||||
return [strainCol, charCol, valCol];
|
||||
}),
|
||||
|
||||
tableContent: Ember.computed('measurements', function() {
|
||||
return this.get('measurements');
|
||||
}),
|
||||
|
||||
actions: {
|
||||
search: function(selectedStrains, selectedCharacteristics) {
|
||||
this.store.find('measurement', {
|
||||
strain: selectedStrains,
|
||||
characteristic: selectedCharacteristics,
|
||||
}).then((measurements)=>{
|
||||
this.set('measurements', measurements);
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
8
app/pods/protected/measurements/route.js
Normal file
8
app/pods/protected/measurements/route.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
import Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
model: function() {
|
||||
return this.store.findAll('measurement');
|
||||
},
|
||||
});
|
21
app/pods/protected/measurements/template.hbs
Normal file
21
app/pods/protected/measurements/template.hbs
Normal file
|
@ -0,0 +1,21 @@
|
|||
<h2>{{genus-name}} Measurements</h2>
|
||||
|
||||
{{measurement-search-panel search='search' strainLabel='All strains' charLabel='All characteristics'}}
|
||||
|
||||
<div class="grid-12 gutter-50">
|
||||
<div class="span-12">
|
||||
<h3>Total matching measurements: {{measurements.length}}</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{#if measurementsEmpty}}
|
||||
<span>No results</span>
|
||||
{{else}}
|
||||
{{
|
||||
ember-table
|
||||
columns=tableColumns
|
||||
content=tableContent
|
||||
columnMode='fluid'
|
||||
hasFooter=false
|
||||
}}
|
||||
{{/if}}
|
9
app/pods/protected/route.js
Normal file
9
app/pods/protected/route.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
import Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
model: function() {
|
||||
let user = this.get('session.secure.currentUser');
|
||||
console.log(user);
|
||||
}
|
||||
});
|
29
app/pods/protected/species/edit/controller.js
Normal file
29
app/pods/protected/species/edit/controller.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
actions: {
|
||||
save: function() {
|
||||
let species = this.get('model');
|
||||
|
||||
if (species.get('isDirty')) {
|
||||
species.save().then((species) => {
|
||||
this.transitionToRoute('species.show', species);
|
||||
}, (err) => {
|
||||
this.get('flashMessages').error(err.responseJSON.error);
|
||||
});
|
||||
} else {
|
||||
this.transitionToRoute('species.show', species);
|
||||
}
|
||||
},
|
||||
|
||||
cancel: function() {
|
||||
let species = this.get('model');
|
||||
|
||||
species.get('errors').clear();
|
||||
species.rollback();
|
||||
|
||||
this.transitionToRoute('species.show', species);
|
||||
},
|
||||
|
||||
},
|
||||
});
|
11
app/pods/protected/species/edit/route.js
Normal file
11
app/pods/protected/species/edit/route.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
import Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
afterModel: function(species) {
|
||||
if (!species.get('canEdit')) {
|
||||
this.transitionTo('species.show', species.get('id'));
|
||||
}
|
||||
},
|
||||
|
||||
});
|
6
app/pods/protected/species/edit/template.hbs
Normal file
6
app/pods/protected/species/edit/template.hbs
Normal file
|
@ -0,0 +1,6 @@
|
|||
{{
|
||||
forms/species-form
|
||||
species=model
|
||||
save="save"
|
||||
cancel="cancel"
|
||||
}}
|
11
app/pods/protected/species/index/controller.js
Normal file
11
app/pods/protected/species/index/controller.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
sortParams: ['speciesName', 'strainCount'],
|
||||
sortedSpecies: Ember.computed.sort('model', 'sortParams'),
|
||||
|
||||
metaData: function() {
|
||||
return Ember.copy(this.store.metadataFor('species'));
|
||||
}.property('model.isLoaded').readOnly(),
|
||||
|
||||
});
|
7
app/pods/protected/species/index/route.js
Normal file
7
app/pods/protected/species/index/route.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
model: function() {
|
||||
return this.store.findAll('species');
|
||||
}
|
||||
});
|
34
app/pods/protected/species/index/template.hbs
Normal file
34
app/pods/protected/species/index/template.hbs
Normal file
|
@ -0,0 +1,34 @@
|
|||
<h2>{{genus-name}} Species</h2>
|
||||
<h3>Total species: {{model.length}}</h3>
|
||||
|
||||
{{add-button label="Add Species" link="protected.species.new" canAdd=metaData.canAdd}}
|
||||
|
||||
<table class="flakes-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Strains</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each sortedSpecies as |species|}}
|
||||
<tr>
|
||||
<td>
|
||||
<em>
|
||||
{{#link-to 'protected.species.show' species}}
|
||||
{{species.speciesName}}
|
||||
{{/link-to}}
|
||||
</em>
|
||||
</td>
|
||||
<td>
|
||||
{{#each species.strains as |strain index|}}
|
||||
{{if index ","}}
|
||||
{{#link-to 'protected.strains.show' strain.id}}
|
||||
{{{strain.strainNameMU}}}
|
||||
{{/link-to}}
|
||||
{{/each}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
25
app/pods/protected/species/new/controller.js
Normal file
25
app/pods/protected/species/new/controller.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
actions: {
|
||||
save: function() {
|
||||
let species = this.get('model');
|
||||
|
||||
if (species.get('isDirty')) {
|
||||
species.save().then((species) => {
|
||||
this.transitionToRoute('species.show', species.get('id'));
|
||||
}, (err) => {
|
||||
this.get('flashMessages').error(err.responseJSON.error);
|
||||
});
|
||||
} else {
|
||||
species.deleteRecord();
|
||||
this.transitionToRoute('species.index');
|
||||
}
|
||||
},
|
||||
|
||||
cancel: function() {
|
||||
this.transitionToRoute('species.index');
|
||||
},
|
||||
|
||||
},
|
||||
});
|
27
app/pods/protected/species/new/route.js
Normal file
27
app/pods/protected/species/new/route.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
import Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
beforeModel: function(transition) {
|
||||
this._super(transition);
|
||||
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();
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
});
|
6
app/pods/protected/species/new/template.hbs
Normal file
6
app/pods/protected/species/new/template.hbs
Normal file
|
@ -0,0 +1,6 @@
|
|||
{{
|
||||
forms/species-form
|
||||
species=model
|
||||
save="save"
|
||||
cancel="cancel"
|
||||
}}
|
9
app/pods/protected/species/show/route.js
Normal file
9
app/pods/protected/species/show/route.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
import Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
model: function(params) {
|
||||
return this.store.findRecord('species', params.species_id, { reload: true });
|
||||
},
|
||||
|
||||
});
|
65
app/pods/protected/species/show/template.hbs
Normal file
65
app/pods/protected/species/show/template.hbs
Normal file
|
@ -0,0 +1,65 @@
|
|||
<div class="grid-1">
|
||||
<div class="span-1">
|
||||
<fieldset class="flakes-information-box {{if isEditing 'is-editing'}}">
|
||||
<legend>
|
||||
Species <em>{{model.speciesName}}</em>
|
||||
</legend>
|
||||
|
||||
{{! ROW 1 }}
|
||||
<div class="grid-2 gutter-20">
|
||||
<dl class="span-1">
|
||||
<dt>Strains</dt>
|
||||
<dd>
|
||||
<ul>
|
||||
{{#each model.strains as |strain index|}}
|
||||
<li>
|
||||
{{#link-to 'protected.strains.show' strain.id}}
|
||||
{{{strain.strainNameMU}}}
|
||||
{{/link-to}}
|
||||
</li>
|
||||
{{/each}}
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="span-1">
|
||||
<dt>Type Species?</dt>
|
||||
<dd>
|
||||
{{if model.typeSpecies 'Yes' 'No'}}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{! ROW 2 }}
|
||||
<div class="grid-1 gutter-20">
|
||||
<dl class="span-1">
|
||||
<dt>Etymology</dt>
|
||||
<dd>
|
||||
{{model.etymology}}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{! ROW 3 }}
|
||||
<div class="grid-3 gutter-20">
|
||||
<dl class="span-1">
|
||||
<dt>Record Created</dt>
|
||||
<dd>{{null-time model.createdAt 'LL'}}</dd>
|
||||
</dl>
|
||||
<dl class="span-1">
|
||||
<dt>Record Updated</dt>
|
||||
<dd>{{null-time model.updatedAt 'LL'}}</dd>
|
||||
</dl>
|
||||
<dl class="span-1">
|
||||
<dt>Record Deleted</dt>
|
||||
<dd>{{null-time model.deletedAt 'LL'}}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
{{#if model.canEdit}}
|
||||
<br>
|
||||
{{#link-to 'protected.species.edit' model class="button-gray smaller"}}
|
||||
Edit
|
||||
{{/link-to}}
|
||||
{{/if}}
|
30
app/pods/protected/strains/edit/controller.js
Normal file
30
app/pods/protected/strains/edit/controller.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
actions: {
|
||||
save: function() {
|
||||
let strain = this.get('strain');
|
||||
|
||||
if (strain.get('isDirty')) {
|
||||
strain.save().then((strain) => {
|
||||
this.transitionToRoute('strains.show', strain);
|
||||
}, (err) => {
|
||||
this.get('flashMessages').error(err.responseJSON.error);
|
||||
});
|
||||
} else {
|
||||
strain.deleteRecord();
|
||||
this.transitionToRoute('strains.show', strain);
|
||||
}
|
||||
},
|
||||
|
||||
cancel: function() {
|
||||
let strain = this.get('strain');
|
||||
|
||||
strain.get('errors').clear();
|
||||
strain.rollback();
|
||||
|
||||
this.transitionToRoute('strains.show', strain);
|
||||
},
|
||||
|
||||
},
|
||||
});
|
22
app/pods/protected/strains/edit/route.js
Normal file
22
app/pods/protected/strains/edit/route.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
import Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
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'), // 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);
|
||||
},
|
||||
|
||||
});
|
7
app/pods/protected/strains/edit/template.hbs
Normal file
7
app/pods/protected/strains/edit/template.hbs
Normal file
|
@ -0,0 +1,7 @@
|
|||
{{
|
||||
forms/strain-form
|
||||
strain=strain
|
||||
species=species
|
||||
save="save"
|
||||
cancel="cancel"
|
||||
}}
|
11
app/pods/protected/strains/index/controller.js
Normal file
11
app/pods/protected/strains/index/controller.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
sortParams: ['fullNameMU', 'totalMeasurements'],
|
||||
sortedStrains: Ember.computed.sort('model', 'sortParams'),
|
||||
|
||||
metaData: function() {
|
||||
return Ember.copy(this.store.metadataFor('strain'));
|
||||
}.property('model.isLoaded').readOnly(),
|
||||
|
||||
});
|
8
app/pods/protected/strains/index/route.js
Normal file
8
app/pods/protected/strains/index/route.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
import Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
model: function() {
|
||||
return this.store.findAll('strain');
|
||||
},
|
||||
});
|
27
app/pods/protected/strains/index/template.hbs
Normal file
27
app/pods/protected/strains/index/template.hbs
Normal file
|
@ -0,0 +1,27 @@
|
|||
<h2>{{genus-name}} Strains</h2>
|
||||
<h3>Total strains: {{model.length}}</h3>
|
||||
|
||||
{{add-button label="Add Strain" link="strains.new" canAdd=metaData.canAdd}}
|
||||
|
||||
<table class="flakes-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Species</th>
|
||||
<th>Total Measurements</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each sortedStrains as |row|}}
|
||||
<tr>
|
||||
<td>
|
||||
{{#link-to 'protected.strains.show' row.id classBinding="data.typeStrain:type-strain"}}
|
||||
{{row.fullNameMU}}
|
||||
{{/link-to}}
|
||||
</td>
|
||||
<td>
|
||||
{{row.totalMeasurements}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
24
app/pods/protected/strains/new/controller.js
Normal file
24
app/pods/protected/strains/new/controller.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
actions: {
|
||||
save: function() {
|
||||
let strain = this.get('strain');
|
||||
|
||||
if (strain.get('isDirty')) {
|
||||
strain.save().then((strain) => {
|
||||
this.transitionToRoute('strains.show', strain);
|
||||
}, (err) => {
|
||||
this.get('flashMessages').error(err.responseJSON.error);
|
||||
});
|
||||
} else {
|
||||
this.transitionToRoute('strains.index');
|
||||
}
|
||||
},
|
||||
|
||||
cancel: function() {
|
||||
this.transitionToRoute('strains.index');
|
||||
},
|
||||
|
||||
},
|
||||
});
|
34
app/pods/protected/strains/new/route.js
Normal file
34
app/pods/protected/strains/new/route.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
import Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
beforeModel: function(transition) {
|
||||
this._super(transition);
|
||||
if (this.get('session.currentUser.role') === 'R') {
|
||||
this.transitionTo('strains.index');
|
||||
}
|
||||
},
|
||||
|
||||
model: function() {
|
||||
return Ember.RSVP.hash({
|
||||
strain: this.store.createRecord('strain'),
|
||||
species: this.store.findAll('species'), // Need for dropdown
|
||||
});
|
||||
},
|
||||
|
||||
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();
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
});
|
7
app/pods/protected/strains/new/template.hbs
Normal file
7
app/pods/protected/strains/new/template.hbs
Normal file
|
@ -0,0 +1,7 @@
|
|||
{{
|
||||
forms/strain-form
|
||||
strain=strain
|
||||
species=species
|
||||
save="save"
|
||||
cancel="cancel"
|
||||
}}
|
9
app/pods/protected/strains/show/route.js
Normal file
9
app/pods/protected/strains/show/route.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
import Ember from 'ember';
|
||||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||
|
||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||
model: function(params) {
|
||||
return this.store.findRecord('strain', params.strain_id, { reload: true });
|
||||
},
|
||||
|
||||
});
|
89
app/pods/protected/strains/show/template.hbs
Normal file
89
app/pods/protected/strains/show/template.hbs
Normal file
|
@ -0,0 +1,89 @@
|
|||
<div class="span-1">
|
||||
<fieldset class="flakes-information-box {{if isEditing 'is-editing'}}">
|
||||
<legend>
|
||||
Strain {{model.strainNameMU}}
|
||||
</legend>
|
||||
|
||||
{{! ROW 1 }}
|
||||
<div class="grid-2 gutter-20">
|
||||
<dl class="span-1">
|
||||
<dt>Species</dt>
|
||||
<dd>
|
||||
{{#link-to 'protected.species.show' model.species.id}}
|
||||
<em>{{model.species.speciesNameMU}}</em>
|
||||
{{/link-to}}
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="span-1">
|
||||
<dt>Type Strain?</dt>
|
||||
<dd>
|
||||
{{if model.typeStrain 'Yes' 'No'}}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{! ROW 2 }}
|
||||
<div class="grid-3 gutter-20">
|
||||
<dl class="span-1">
|
||||
<dt>Accession Numbers</dt>
|
||||
<dd>
|
||||
{{model.accessionNumbers}}
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="span-1">
|
||||
<dt>Genbank</dt>
|
||||
<dd>
|
||||
{{genbank-url genbank=model.genbank}}
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="span-1">
|
||||
<dt>Whole Genome Sequence</dt>
|
||||
<dd>
|
||||
{{model.wholeGenomeSequence}}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{! ROW 3 }}
|
||||
<div class="grid-1 gutter-20">
|
||||
<dl class="span-1">
|
||||
<dt>Isolated From</dt>
|
||||
<dd>
|
||||
{{model.isolatedFrom}}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{! ROW 4 }}
|
||||
<div class="grid-1 gutter-20">
|
||||
<dl class="span-1">
|
||||
<dt>Notes</dt>
|
||||
<dd>
|
||||
{{model.notes}}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{! ROW 5 }}
|
||||
<div class="grid-3 gutter-20">
|
||||
<dl class="span-1">
|
||||
<dt>Record Created</dt>
|
||||
<dd>{{null-time model.createdAt 'LL'}}</dd>
|
||||
</dl>
|
||||
<dl class="span-1">
|
||||
<dt>Record Updated</dt>
|
||||
<dd>{{null-time model.updatedAt 'LL'}}</dd>
|
||||
</dl>
|
||||
<dl class="span-1">
|
||||
<dt>Record Deleted</dt>
|
||||
<dd>{{null-time model.deletedAt 'LL'}}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{#if model.canEdit}}
|
||||
<br>
|
||||
{{#link-to 'protected.species.edit' model class="button-gray smaller"}}
|
||||
Edit
|
||||
{{/link-to}}
|
||||
{{/if}}
|
Reference in a new issue