Refactor species/show
This commit is contained in:
parent
2b2489a35a
commit
d1e3d05db2
8 changed files with 106 additions and 69 deletions
|
@ -1,6 +1,8 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
const { Controller } = Ember;
|
||||
|
||||
export default Controller.extend({
|
||||
actions: {
|
||||
delete: function() {
|
||||
this.get('model').destroyRecord().then(() => {
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
const { Route } = Ember;
|
||||
|
||||
export default Route.extend({
|
||||
model: function(params) {
|
||||
return this.store.findRecord('species', params.species_id, { reload: true });
|
||||
return this.store.findRecord('species', params.species_id);
|
||||
},
|
||||
|
||||
});
|
||||
|
|
14
app/pods/protected/species/show/species-card/component.js
Normal file
14
app/pods/protected/species/show/species-card/component.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
const { Component } = Ember;
|
||||
|
||||
export default Component.extend({
|
||||
species: null,
|
||||
"on-delete": null,
|
||||
|
||||
actions: {
|
||||
deleteSpecies: function() {
|
||||
return this.attrs['on-delete']();
|
||||
},
|
||||
},
|
||||
});
|
62
app/pods/protected/species/show/species-card/template.hbs
Normal file
62
app/pods/protected/species/show/species-card/template.hbs
Normal file
|
@ -0,0 +1,62 @@
|
|||
<div class="grid-1">
|
||||
<div class="span-1">
|
||||
<fieldset class="flakes-information-box">
|
||||
<legend>
|
||||
Species <em>{{species.speciesName}}</em>
|
||||
</legend>
|
||||
|
||||
{{! ROW 1 }}
|
||||
<div class="grid-2 gutter-20">
|
||||
<dl class="span-1">
|
||||
<dt>Strains</dt>
|
||||
<dd>
|
||||
<ul>
|
||||
{{#each species.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 species.typeSpecies 'Yes' 'No'}}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{! ROW 2 }}
|
||||
<div class="grid-1 gutter-20">
|
||||
<dl class="span-1">
|
||||
<dt>Etymology</dt>
|
||||
<dd>
|
||||
{{{species.etymology}}}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{! ROW 3 }}
|
||||
<div class="grid-2 gutter-20">
|
||||
<dl class="span-1">
|
||||
<dt>Record Created</dt>
|
||||
<dd>{{null-time species.createdAt 'LL'}}</dd>
|
||||
</dl>
|
||||
<dl class="span-1">
|
||||
<dt>Record Updated</dt>
|
||||
<dd>{{null-time species.updatedAt 'LL'}}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
{{#if species.canEdit}}
|
||||
<br>
|
||||
{{#link-to 'protected.species.edit' species class="button-gray smaller"}}
|
||||
Edit
|
||||
{{/link-to}}
|
||||
{{delete-button delete=(action 'deleteSpecies')}}
|
||||
{{/if}}
|
|
@ -1,62 +1,5 @@
|
|||
<div class="grid-1">
|
||||
<div class="span-1">
|
||||
<fieldset class="flakes-information-box">
|
||||
<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-2 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>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
{{#if model.canEdit}}
|
||||
<br>
|
||||
{{#link-to 'protected.species.edit' model class="button-gray smaller"}}
|
||||
Edit
|
||||
{{/link-to}}
|
||||
{{delete-button delete=(action 'delete')}}
|
||||
{{/if}}
|
||||
{{
|
||||
protected/species/show/species-card
|
||||
species=model
|
||||
on-delete=(action 'delete')
|
||||
}}
|
||||
|
|
Reference in a new issue