Begin refactoring strains/show
Will address measurements table later
This commit is contained in:
parent
85d861da27
commit
04486880a0
7 changed files with 139 additions and 117 deletions
|
@ -1,12 +1,9 @@
|
|||
import Ember from 'ember';
|
||||
import DeleteModel from '../../../../mixins/delete-model';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
actions: {
|
||||
delete: function() {
|
||||
this.get('model').destroyRecord().then(() => {
|
||||
this.transitionToRoute('protected.strains.index');
|
||||
});
|
||||
},
|
||||
},
|
||||
const { Controller } = Ember;
|
||||
|
||||
export default Controller.extend(DeleteModel, {
|
||||
// Required for DeleteModel mixin
|
||||
transitionRoute: 'protected.strains.index',
|
||||
});
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
import Ember from 'ember';
|
||||
import ajaxError from '../../../../../utils/ajax-error';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
const { Component } = Ember;
|
||||
|
||||
export default Component.extend({
|
||||
tagName: 'tr',
|
||||
isEditing: false,
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
const { Component } = Ember;
|
||||
|
||||
export default Component.extend({
|
||||
measurementsPresent: function() {
|
||||
return this.get('model.measurements.length') > 0;
|
||||
}.property('model.measurements'),
|
||||
|
|
|
@ -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('strain', params.strain_id, { reload: true });
|
||||
return this.store.findRecord('strain', params.strain_id);
|
||||
},
|
||||
|
||||
});
|
||||
|
|
14
app/pods/protected/strains/show/strain-card/component.js
Normal file
14
app/pods/protected/strains/show/strain-card/component.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
const { Component } = Ember;
|
||||
|
||||
export default Component.extend({
|
||||
strain: null,
|
||||
"on-delete": null,
|
||||
|
||||
actions: {
|
||||
deleteStrain: function() {
|
||||
return this.attrs['on-delete']();
|
||||
},
|
||||
},
|
||||
});
|
105
app/pods/protected/strains/show/strain-card/template.hbs
Normal file
105
app/pods/protected/strains/show/strain-card/template.hbs
Normal file
|
@ -0,0 +1,105 @@
|
|||
<div class="span-1">
|
||||
<fieldset class="flakes-information-box">
|
||||
<legend>
|
||||
{{strain.strainNameMU}}
|
||||
</legend>
|
||||
|
||||
{{! ROW 1 }}
|
||||
<div class="grid-2 gutter-20">
|
||||
<dl class="span-1">
|
||||
<dt>Species</dt>
|
||||
<dd>
|
||||
{{#link-to 'protected.species.show' strain.species.id}}
|
||||
<em>{{strain.species.speciesNameMU}}</em>
|
||||
{{/link-to}}
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="span-1">
|
||||
<dt>Type Strain?</dt>
|
||||
<dd>
|
||||
{{if strain.typeStrain 'Yes' 'No'}}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{! ROW 2 }}
|
||||
<div class="grid-3 gutter-20">
|
||||
<dl class="span-1">
|
||||
<dt>Accession Numbers</dt>
|
||||
<dd>
|
||||
{{strain.accessionNumbers}}
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="span-1">
|
||||
<dt>Genbank</dt>
|
||||
<dd>
|
||||
{{genbank-url genbank=strain.genbank}}
|
||||
</dd>
|
||||
</dl>
|
||||
<dl class="span-1">
|
||||
<dt>Whole Genome Sequence</dt>
|
||||
<dd>
|
||||
{{genbank-url genbank=strain.wholeGenomeSequence}}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{! ROW 3 }}
|
||||
<div class="grid-1 gutter-20">
|
||||
<dl class="span-1">
|
||||
<dt>Isolated From</dt>
|
||||
<dd>
|
||||
{{{strain.isolatedFrom}}}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{! ROW 4 }}
|
||||
<div class="grid-1 gutter-20">
|
||||
<dl class="span-1">
|
||||
<dt>Notes</dt>
|
||||
<dd>
|
||||
{{#if strain.notes}}
|
||||
{{{strain.notes}}}
|
||||
{{else}}
|
||||
No notes.
|
||||
{{/if}}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{! ROW 5 }}
|
||||
<div class="grid-1 gutter-20">
|
||||
<dl class="span-1">
|
||||
<dt>Characteristics</dt>
|
||||
<dd>
|
||||
{{
|
||||
protected/strains/show/measurements-table
|
||||
model=strain
|
||||
canEdit=false
|
||||
canAdd=false
|
||||
}}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{! ROW 6 }}
|
||||
<div class="grid-2 gutter-20">
|
||||
<dl class="span-1">
|
||||
<dt>Record Created</dt>
|
||||
<dd>{{null-time strain.createdAt 'LL'}}</dd>
|
||||
</dl>
|
||||
<dl class="span-1">
|
||||
<dt>Record Updated</dt>
|
||||
<dd>{{null-time strain.updatedAt 'LL'}}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
{{#if strain.canEdit}}
|
||||
<br>
|
||||
{{#link-to 'protected.strains.edit' strain class="button-gray smaller"}}
|
||||
Edit
|
||||
{{/link-to}}
|
||||
{{delete-button delete=(action 'deleteStrain')}}
|
||||
{{/if}}
|
|
@ -1,105 +1,5 @@
|
|||
<div class="span-1">
|
||||
<fieldset class="flakes-information-box">
|
||||
<legend>
|
||||
{{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>
|
||||
{{genbank-url genbank=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>
|
||||
{{#if model.notes}}
|
||||
{{{model.notes}}}
|
||||
{{else}}
|
||||
No notes.
|
||||
{{/if}}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{! ROW 5 }}
|
||||
<div class="grid-1 gutter-20">
|
||||
<dl class="span-1">
|
||||
<dt>Characteristics</dt>
|
||||
<dd>
|
||||
{{
|
||||
protected/strains/show/measurements-table
|
||||
model=model
|
||||
canEdit=false
|
||||
canAdd=false
|
||||
}}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
{{! ROW 6 }}
|
||||
<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>
|
||||
{{#if model.canEdit}}
|
||||
<br>
|
||||
{{#link-to 'protected.strains.edit' model.id class="button-gray smaller"}}
|
||||
Edit
|
||||
{{/link-to}}
|
||||
{{delete-button delete=(action 'delete')}}
|
||||
{{/if}}
|
||||
{{
|
||||
protected/strains/show/strain-card
|
||||
strain=model
|
||||
on-delete=(action 'delete')
|
||||
}}
|
||||
|
|
Reference in a new issue