From e4f01246c230730aeb59e79e38c8ac1251af9c46 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Thu, 11 Jun 2015 13:45:10 -0800 Subject: [PATCH] Genbank URL --- app/pods/components/genbank-url/component.js | 10 ++++++++++ app/pods/components/genbank-url/template.hbs | 1 + .../components/strain-details/template.hbs | 2 +- .../components/genbank-url/component-test.js | 19 +++++++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 app/pods/components/genbank-url/component.js create mode 100644 app/pods/components/genbank-url/template.hbs create mode 100644 tests/unit/pods/components/genbank-url/component-test.js diff --git a/app/pods/components/genbank-url/component.js b/app/pods/components/genbank-url/component.js new file mode 100644 index 0000000..7731a82 --- /dev/null +++ b/app/pods/components/genbank-url/component.js @@ -0,0 +1,10 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + tagName: 'a', + attributeBindings: ['href', 'target'], + href: function() { + return 'http://www.ncbi.nlm.nih.gov/nucleotide/' + this.get('genbank'); + }.property(), + target: '_blank', +}); diff --git a/app/pods/components/genbank-url/template.hbs b/app/pods/components/genbank-url/template.hbs new file mode 100644 index 0000000..acfd87b --- /dev/null +++ b/app/pods/components/genbank-url/template.hbs @@ -0,0 +1 @@ +{{genbank}} diff --git a/app/pods/components/strain-details/template.hbs b/app/pods/components/strain-details/template.hbs index bb9512a..c49d5f4 100644 --- a/app/pods/components/strain-details/template.hbs +++ b/app/pods/components/strain-details/template.hbs @@ -61,7 +61,7 @@ {{#if isEditing}} {{input value=strain.genbank}} {{else}} - {{strain.genbank}} + {{genbank-url genbank=strain.genbank}} {{/if}} {{display-errors a=strain.errors.genbank}} diff --git a/tests/unit/pods/components/genbank-url/component-test.js b/tests/unit/pods/components/genbank-url/component-test.js new file mode 100644 index 0000000..753b583 --- /dev/null +++ b/tests/unit/pods/components/genbank-url/component-test.js @@ -0,0 +1,19 @@ +import { moduleForComponent, test } from 'ember-qunit'; + +moduleForComponent('genbank-url', 'Unit | Component | genbank url', { + // Specify the other units that are required for this test + // needs: ['component:foo', 'helper:bar'], + unit: true +}); + +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'); +});