diff --git a/app/inventory/rank-select/component.js b/app/inventory/rank-select/component.js new file mode 100644 index 0000000000..d24d4b26a2 --- /dev/null +++ b/app/inventory/rank-select/component.js @@ -0,0 +1,21 @@ +import Ember from 'ember'; +import SelectValues from 'hospitalrun/utils/select-values'; +import computed from 'ember-computed'; + +export default Ember.Component.extend({ + label: 'Rank', + rankOptions: [], + prompt: ' ', + class: 'col-sm-2 test-inv-rank', + + options: computed('rankOptions', function() { + return SelectValues.selectValues(this.get('rankOptions')); + }), + + init() { + this._super(...arguments); + + // set available options + this.set('rankOptions', Ember.A(['A', 'B', 'C'])); + } +}); diff --git a/app/inventory/rank-select/template.hbs b/app/inventory/rank-select/template.hbs new file mode 100644 index 0000000000..9d7d1a734b --- /dev/null +++ b/app/inventory/rank-select/template.hbs @@ -0,0 +1,7 @@ +{{em-select + label=label + property=property + content=options + class=class + prompt=prompt + }} diff --git a/app/models/inventory.js b/app/models/inventory.js index 4b40236da7..f31cb37461 100644 --- a/app/models/inventory.js +++ b/app/models/inventory.js @@ -26,6 +26,7 @@ export default AbstractModel.extend(LocationName, { price: DS.attr('number'), reorderPoint: DS.attr('number'), distributionUnit: DS.attr('string'), + rank: DS.attr('string'), availableLocations: function() { var locations = this.get('locations').filter(function(location) { diff --git a/app/templates/inventory-basic.hbs b/app/templates/inventory-basic.hbs index cf551b2f3c..d8f1ea1d86 100644 --- a/app/templates/inventory-basic.hbs +++ b/app/templates/inventory-basic.hbs @@ -5,15 +5,16 @@ {{input class="form-control test-item-id" value=model.friendlyId type="text" disabled=true }} {{/unless}} - {{em-input property="name" label="Name" class="required col-sm-8 test-inv-name"}} + {{em-input property="name" label="Name" class="required col-sm-6 test-inv-name"}} + {{inventory/rank-select property="rank"}} {{#unless model.isNew}}

{{model.quantity}}

{{/unless}} - + {{em-text label="Description" property="description" rows=1 }}
{{em-select label="Type" property="inventoryType" diff --git a/server/config-example.js b/server/config-example.js index 4c73e86eb2..67b0cc7ebe 100644 --- a/server/config-example.js +++ b/server/config-example.js @@ -1,4 +1,4 @@ -var config = { +var config = { couch_db_server: 'localhost', couch_db_port: '5984', couch_db_use_ssl: false, @@ -9,17 +9,17 @@ var config = { google_client_secret: 'FOR GOOGLE SSO; GOOGLE CLIENT SECRET GOES HERE', server_port: '3000', server: 'localhost', - use_ssl: false + use_ssl: false }; config.couch_credentials = function() { if (config.couch_admin_user && config.couch_admin_password) { return config.couch_admin_user + ":" + config.couch_admin_password + "@"; - } else { - return ''; + } else { + return ''; } }; - + config.get_protocol = function(is_ssl) { return "http" + (is_ssl ? 's' : '') + '://'; }; @@ -32,4 +32,4 @@ if (config.server_port) { config.couch_db_url = config.get_protocol(config.couch_db_use_ssl) + config.couch_db_server +":"+config.couch_db_port; config.couch_auth_db_url = config.get_protocol(config.couch_db_use_ssl) + config.couch_credentials() + config.couch_db_server + ":"+config.couch_db_port; //config.search_url = 'http://localhost:9200'; ELASTIC SEARCH URL (OPTIONAL) -module.exports = config; \ No newline at end of file +module.exports = config; diff --git a/server/index.js b/server/index.js index fa527201ee..c93f6b0545 100644 --- a/server/index.js +++ b/server/index.js @@ -12,5 +12,5 @@ var globSync = require('glob').sync; var routes = globSync('./routes/**/*.js', { cwd: __dirname }).map(require); module.exports = function(app) { - routes.forEach(function(route) { route(app); }); + routes.forEach(function(route) { route(app); }); }; diff --git a/tests/acceptance/inventory-test.js b/tests/acceptance/inventory-test.js index e58dfb17e9..c9566b96dc 100644 --- a/tests/acceptance/inventory-test.js +++ b/tests/acceptance/inventory-test.js @@ -38,6 +38,7 @@ test('Adding a new inventory item', (assert) => { assert.equal(currentURL(), '/inventory/edit/new'); }); fillIn('.test-inv-name input', 'Biogesic'); + select('.test-inv-rank', 'B'); fillIn('textarea', 'Biogesic nga medisina'); select('.test-inv-type', 'Medication'); fillIn('.test-inv-cross input', '2600'); diff --git a/tests/integration/components/inventory/rank-select-test.js b/tests/integration/components/inventory/rank-select-test.js new file mode 100644 index 0000000000..b309015098 --- /dev/null +++ b/tests/integration/components/inventory/rank-select-test.js @@ -0,0 +1,23 @@ +import { moduleForComponent, test } from 'ember-qunit'; +import hbs from 'htmlbars-inline-precompile'; + +moduleForComponent('inventory/rank-select', 'Integration | Component | inventory/rank select', { + integration: true +}); + +test('it renders correctly', function(assert) { + this.set('value', null); + + this.render(hbs`{{inventory/rank-select + property='value' + prompt='n/a' + }}`); + + // options + const $options = this.$('option'); + assert.equal($options.length, 4, 'Should render 4 options'); + assert.equal($options[0].value, 'null', 'First option value is null (prompt)'); + assert.equal($options[0].innerHTML.trim(), 'n/a', 'First option label is prompt'); + assert.equal($options[1].value, 'A', 'Second option is "A"'); + assert.equal($options[2].value, $options[2].innerHTML.trim(), 'Values are similar as labels'); +});