Pods, pods, everywhere
This commit is contained in:
parent
33f783bc42
commit
e623d52f34
66 changed files with 53 additions and 113 deletions
8
app/pods/strains/index/route.js
Normal file
8
app/pods/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');
|
||||
}
|
||||
});
|
30
app/pods/strains/index/template.hbs
Normal file
30
app/pods/strains/index/template.hbs
Normal file
|
@ -0,0 +1,30 @@
|
|||
<h2>{{genus-name}} Strains</h2>
|
||||
<h3>Total strains: {{controller.length}}</h3>
|
||||
|
||||
{{#if (can "add strain")}}
|
||||
{{! Does nothing ATM }}
|
||||
{{#link-to 'strains.new' class="button-gray smaller"}}
|
||||
Add Strain
|
||||
{{/link-to}}
|
||||
{{/if}}
|
||||
|
||||
<table class="flakes-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th {{action "setSortBy" "fullName"}}>Name</th>
|
||||
<th {{action "setSortBy" "totalMeasurements"}}>Total Measurements</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each strain in controller}}
|
||||
<tr>
|
||||
<td>
|
||||
{{#link-to 'strains.show' strain.id}}
|
||||
{{scientific-name strain=strain}}
|
||||
{{/link-to}}
|
||||
</td>
|
||||
<td>{{strain.totalMeasurements}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
21
app/pods/strains/new/controller.js
Normal file
21
app/pods/strains/new/controller.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
isEditing: true,
|
||||
actions: {
|
||||
save: function() {
|
||||
var strain = this.get('strain');
|
||||
if (strain.get('isDirty')) {
|
||||
strain.save();
|
||||
}
|
||||
this.transitionToRoute('strains.index');
|
||||
},
|
||||
cancel: function() {
|
||||
var strain = this.get('strain');
|
||||
if (strain.get('isNew')) {
|
||||
strain.deleteRecord();
|
||||
}
|
||||
this.transitionToRoute('strains.index');
|
||||
}
|
||||
}
|
||||
});
|
13
app/pods/strains/new/route.js
Normal file
13
app/pods/strains/new/route.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
model: function() {
|
||||
return Ember.RSVP.hash({
|
||||
strain: this.store.createRecord('strain'),
|
||||
species: this.store.findAll('species')
|
||||
});
|
||||
},
|
||||
setupController: function(controller, models) {
|
||||
controller.setProperties(models);
|
||||
},
|
||||
});
|
8
app/pods/strains/new/template.hbs
Normal file
8
app/pods/strains/new/template.hbs
Normal file
|
@ -0,0 +1,8 @@
|
|||
{{
|
||||
strain-details
|
||||
strain=strain
|
||||
species=species
|
||||
isEditing=true
|
||||
save="save"
|
||||
cancel="cancel"
|
||||
}}
|
19
app/pods/strains/show/controller.js
Normal file
19
app/pods/strains/show/controller.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
isEditing: false,
|
||||
actions: {
|
||||
save: function() {
|
||||
var strain = this.get('strain');
|
||||
if (strain.get('isDirty')) {
|
||||
strain.save();
|
||||
}
|
||||
this.toggleProperty('isEditing');
|
||||
},
|
||||
cancel: function() {
|
||||
this.get('strain').get('errors').clear();
|
||||
this.get('strain').rollback();
|
||||
this.toggleProperty('isEditing');
|
||||
}
|
||||
}
|
||||
});
|
13
app/pods/strains/show/route.js
Normal file
13
app/pods/strains/show/route.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
model: function(params) {
|
||||
return Ember.RSVP.hash({
|
||||
strain: this.store.find('strain', params.strain_id),
|
||||
species: this.store.findAll('species')
|
||||
});
|
||||
},
|
||||
setupController: function(controller, models) {
|
||||
controller.setProperties(models);
|
||||
},
|
||||
});
|
8
app/pods/strains/show/template.hbs
Normal file
8
app/pods/strains/show/template.hbs
Normal file
|
@ -0,0 +1,8 @@
|
|||
{{
|
||||
strain-details
|
||||
strain=strain
|
||||
species=species
|
||||
isEditing=isEditing
|
||||
save="save"
|
||||
cancel="cancel"
|
||||
}}
|
Reference in a new issue