Pods, pods, everywhere
This commit is contained in:
parent
33f783bc42
commit
e623d52f34
66 changed files with 53 additions and 113 deletions
5
app/pods/species/index/controller.js
Normal file
5
app/pods/species/index/controller.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
import SortableController from '../../../controllers/sortable';
|
||||
|
||||
export default SortableController.extend({
|
||||
sortBy: 'speciesName',
|
||||
});
|
8
app/pods/species/index/route.js
Normal file
8
app/pods/species/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('species');
|
||||
}
|
||||
});
|
37
app/pods/species/index/template.hbs
Normal file
37
app/pods/species/index/template.hbs
Normal file
|
@ -0,0 +1,37 @@
|
|||
<h2>{{genus-name}} Species</h2>
|
||||
<h3>Total species: {{controller.length}}</h3>
|
||||
|
||||
{{#if (can "add species")}}
|
||||
{{! Does nothing ATM }}
|
||||
{{#link-to 'species.new' class="button-gray smaller"}}
|
||||
Add Species
|
||||
{{/link-to}}
|
||||
{{/if}}
|
||||
|
||||
<table class="flakes-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th {{action "setSortBy" "speciesName"}}>Name</th>
|
||||
<th {{action "setSortBy" "totalStrains"}}>Strains</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each species in controller}}
|
||||
<tr>
|
||||
<td>
|
||||
{{#link-to 'species.show' species}}
|
||||
{{species.speciesName}}
|
||||
{{/link-to}}
|
||||
</td>
|
||||
<td>
|
||||
{{#each species.strains as |strain index|}}
|
||||
{{if index ","}}
|
||||
{{#link-to 'strains.show' strain.id}}
|
||||
{{strain.strainName}}
|
||||
{{/link-to}}
|
||||
{{/each}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
21
app/pods/species/new/controller.js
Normal file
21
app/pods/species/new/controller.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
isEditing: true,
|
||||
actions: {
|
||||
save: function() {
|
||||
var species = this.get('model');
|
||||
if (species.get('isDirty')) {
|
||||
species.save();
|
||||
}
|
||||
this.transitionToRoute('species.index');
|
||||
},
|
||||
cancel: function() {
|
||||
var species = this.get('model');
|
||||
if (species.get('isNew')) {
|
||||
species.deleteRecord();
|
||||
}
|
||||
this.transitionToRoute('species.index');
|
||||
}
|
||||
}
|
||||
});
|
12
app/pods/species/new/route.js
Normal file
12
app/pods/species/new/route.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
model: function() {
|
||||
return this.store.createRecord('species');
|
||||
},
|
||||
actions: {
|
||||
cancelSpecies: function() {
|
||||
this.transitionTo('species.index');
|
||||
}
|
||||
}
|
||||
});
|
7
app/pods/species/new/template.hbs
Normal file
7
app/pods/species/new/template.hbs
Normal file
|
@ -0,0 +1,7 @@
|
|||
{{
|
||||
species-details
|
||||
species=model
|
||||
isEditing=true
|
||||
save="save"
|
||||
cancel="cancel"
|
||||
}}
|
22
app/pods/species/show/controller.js
Normal file
22
app/pods/species/show/controller.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
isEditing: false,
|
||||
actions: {
|
||||
save: function() {
|
||||
var species = this.get('model');
|
||||
if (species.get('isDirty')) {
|
||||
species.save();
|
||||
}
|
||||
this.toggleProperty('isEditing');
|
||||
},
|
||||
cancel: function() {
|
||||
if (this.get('isEditing')) {
|
||||
var species = this.get('model');
|
||||
species.get('errors').clear();
|
||||
species.rollback();
|
||||
}
|
||||
this.toggleProperty('isEditing');
|
||||
}
|
||||
}
|
||||
});
|
4
app/pods/species/show/route.js
Normal file
4
app/pods/species/show/route.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
});
|
7
app/pods/species/show/template.hbs
Normal file
7
app/pods/species/show/template.hbs
Normal file
|
@ -0,0 +1,7 @@
|
|||
{{
|
||||
species-details
|
||||
species=model
|
||||
isEditing=isEditing
|
||||
save="save"
|
||||
cancel="cancel"
|
||||
}}
|
Reference in a new issue