diff --git a/app/components/strains/strain-details.js b/app/components/strains/strain-details.js new file mode 100644 index 0000000..a25aead --- /dev/null +++ b/app/components/strains/strain-details.js @@ -0,0 +1,15 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + classNames: ['grid-1'], + isEditing: false, + actions: { + editStrain: function() { + this.get('strain').get('errors').clear(); + this.toggleProperty('isEditing'); + }, + saveStrain: function() { + this.get('strain').save().then(this.toggleProperty('isEditing')); + } + } +}); diff --git a/app/controllers/strains/show.js b/app/controllers/strains/show.js deleted file mode 100644 index 125549e..0000000 --- a/app/controllers/strains/show.js +++ /dev/null @@ -1,14 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Controller.extend({ - isEditing: false, - actions: { - editStrain: function() { - this.get('model').get("errors").clear(); - this.toggleProperty('isEditing'); - }, - saveStrain: function() { - this.get('model').save().then(this.toggleProperty('isEditing')); - } - } -}); diff --git a/app/templates/components/strains/strain-details.hbs b/app/templates/components/strains/strain-details.hbs new file mode 100644 index 0000000..702fa1f --- /dev/null +++ b/app/templates/components/strains/strain-details.hbs @@ -0,0 +1,121 @@ +
+
+ + Strain + {{#if isEditing}} + {{input value=strain.strainName}} + {{else}} + {{strain.strainName}} + {{/if}} + {{display-errors a=strain.errors.strainName}} + + + {{! ROW 1 }} +
+
+
Species
+
{{strain.speciesName}}
+
+
+
Type Strain?
+
+ {{#if isEditing}} + {{input type="checkbox" checked=strain.typeStrain}} + {{/if}} + {{if strain.typeStrain 'Yes' 'No'}} + {{display-errors a=strain.errors.typeStrain}} +
+
+
+ + {{! ROW 2 }} +
+
+
Accession Numbers
+
+ {{#if isEditing}} + {{input value=strain.accessionNumbers}} + {{else}} + {{strain.accessionNumbers}} + {{/if}} + {{display-errors a=strain.errors.accessionNumbers}} +
+
+
+
Genbank
+
+ {{#if isEditing}} + {{input value=strain.genbank}} + {{else}} + {{strain.genbank}} + {{/if}} + {{display-errors a=strain.errors.genbank}} +
+
+
+ + {{! ROW 3 }} +
+
+
Isolated From
+
+ {{#if isEditing}} + {{textarea value=strain.isolatedFrom cols="70" rows="3"}} + {{else}} + {{strain.isolatedFrom}} + {{/if}} + {{display-errors a=strain.errors.isolatedFrom}} +
+
+
+ + {{! ROW 4 }} +
+
+
Notes
+
+ {{#if isEditing}} + {{textarea value=strain.notes cols="70" rows="3"}} + {{else}} + {{strain.notes}} + {{/if}} + {{display-errors a=strain.errors.notes}} +
+
+
+ + {{! ROW 5 }} +
+
+
Record Created
+
{{null-time strain.createdAt 'LL'}}
+
+
+
Record Updated
+
{{null-time strain.updatedAt 'LL'}}
+
+
+
Record Deleted
+
{{null-time strain.deletedAt 'LL'}}
+
+
+
+ + {{! ROW 6 }} + {{#if (can "edit strain" strain)}} +
+
+ {{! Does nothing ATM }} + + {{#if isEditing}}Cancel{{else}}Edit{{/if}} + + {{#if isEditing}} + + Save + + {{/if}} +
+
+ {{/if}} +
+
diff --git a/app/templates/strains/show.hbs b/app/templates/strains/show.hbs index cc0393a..dbeeba2 100644 --- a/app/templates/strains/show.hbs +++ b/app/templates/strains/show.hbs @@ -1,126 +1,4 @@ -
-
-
- - Strain - {{#if isEditing}} - {{input value=model.strainName}} - {{else}} - {{model.strainName}} - {{/if}} - {{display-errors a=model.errors.strainName}} - - - {{! ROW 1 }} -
-
-
Species
-
{{model.speciesName}}
-
-
-
Type Strain?
-
- {{#if isEditing}} - {{input type="checkbox" checked=model.typeStrain}} - {{/if}} - {{if model.typeStrain 'Yes' 'No'}} - {{display-errors a=model.errors.typeStrain}} -
-
-
- - {{! ROW 2 }} -
-
-
Accession Numbers
-
- {{#if isEditing}} - {{input value=model.accessionNumbers}} - {{else}} - {{model.accessionNumbers}} - {{/if}} - {{display-errors a=model.errors.accessionNumbers}} -
-
-
-
Genbank
-
- {{#if isEditing}} - {{input value=model.genbank}} - {{else}} - {{model.genbank}} - {{/if}} - {{display-errors a=model.errors.genbank}} -
-
-
- - {{! ROW 3 }} -
-
-
Isolated From
-
- {{#if isEditing}} - {{textarea value=model.isolatedFrom cols="70" rows="3"}} - {{else}} - {{model.isolatedFrom}} - {{/if}} - {{display-errors a=model.errors.isolatedFrom}} -
-
-
- - {{! ROW 4 }} -
-
-
Notes
-
- {{#if isEditing}} - {{textarea value=model.notes cols="70" rows="3"}} - {{else}} - {{model.notes}} - {{/if}} - {{display-errors a=model.errors.notes}} -
-
-
- - {{! ROW 5 }} -
-
-
Record Created
-
{{null-time model.createdAt 'LL'}}
-
-
-
Record Updated
-
{{null-time model.updatedAt 'LL'}}
-
-
-
Record Deleted
-
{{null-time model.deletedAt 'LL'}}
-
-
-
- - {{! ROW 6 }} - {{#if (can "edit strain" model)}} -
-
- {{! Does nothing ATM }} - - {{#if isEditing}}Cancel{{else}}Edit{{/if}} - - {{#if isEditing}} - - Save - - {{/if}} -
-
- {{/if}} -
-
-
+{{strains/strain-details strain=model}}
{{outlet}} diff --git a/tests/unit/components/strains/strain-details-test.js b/tests/unit/components/strains/strain-details-test.js new file mode 100644 index 0000000..a52c33c --- /dev/null +++ b/tests/unit/components/strains/strain-details-test.js @@ -0,0 +1,21 @@ +import { + moduleForComponent, + test +} from 'ember-qunit'; + +moduleForComponent('strains/strain-details', { + // Specify the other units that are required for this test + // needs: ['component:foo', 'helper:bar'] +}); + +test('it renders', function(assert) { + assert.expect(2); + + // Creates the component instance + var component = this.subject(); + assert.equal(component._state, 'preRender'); + + // Renders the component to the page + this.render(); + assert.equal(component._state, 'inDOM'); +}); diff --git a/tests/unit/controllers/strains/show-test.js b/tests/unit/controllers/strains/show-test.js deleted file mode 100644 index 9808fa5..0000000 --- a/tests/unit/controllers/strains/show-test.js +++ /dev/null @@ -1,15 +0,0 @@ -import { - moduleFor, - test -} from 'ember-qunit'; - -moduleFor('controller:strains/show', { - // Specify the other units that are required for this test. - // needs: ['controller:foo'] -}); - -// Replace this with your real tests. -test('it exists', function(assert) { - var controller = this.subject(); - assert.ok(controller); -});