Species edit refactor

This commit is contained in:
Matthew Dillon 2015-07-06 11:02:41 -08:00
parent cdc825cc6a
commit 45223fd57f
16 changed files with 181 additions and 160 deletions

View file

@ -1,22 +0,0 @@
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');
}
}
});

View file

@ -1,7 +1,57 @@
{{
species-details
species=model
isEditing=isEditing
save="save"
cancel="cancel"
}}
<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-4">
<dl class="span-2">
<dt>Strains</dt>
<dd>
{{#each model.strains as |strain index|}}
{{if index ","}}
{{#link-to 'strains.show' strain.id}}
{{{strain.strainNameMU}}}
{{/link-to}}
{{/each}}
</dd>
</dl>
<dl class="span-2">
<dt>Type Species?</dt>
<dd>
{{if model.typeSpecies 'Yes' 'No'}}
</dd>
</dl>
</div>
{{! ROW 2 }}
<div class="grid-4">
<dl class="span-4">
<dt>Etymology</dt>
<dd>
{{model.etymology}}
</dd>
</dl>
</div>
{{! ROW 3 }}
<div class="grid-4">
<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>
<dl class="span-1"></dl>
</div>
</fieldset>
</div>
</div>