Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #225 from turboMaCk/feature/inventory_items_rank
Browse files Browse the repository at this point in the history
inventory items rank attribute
  • Loading branch information
jkleinsc committed Dec 10, 2015
2 parents d39af15 + e202ae9 commit 1c6dc42
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 9 deletions.
21 changes: 21 additions & 0 deletions app/inventory/rank-select/component.js
Original file line number Diff line number Diff line change
@@ -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']));
}
});
7 changes: 7 additions & 0 deletions app/inventory/rank-select/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{em-select
label=label
property=property
content=options
class=class
prompt=prompt
}}
1 change: 1 addition & 0 deletions app/models/inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions app/templates/inventory-basic.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
{{input class="form-control test-item-id" value=model.friendlyId type="text" disabled=true }}
</div>
{{/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}}
<div class="form-group col-sm-2">
<label>Quantity</label>
<p class="form-control-static">{{model.quantity}}</p>
</div>
{{/unless}}

</div>

{{em-text label="Description" property="description" rows=1 }}
<div class="row">
{{em-select label="Type" property="inventoryType"
Expand Down
12 changes: 6 additions & 6 deletions server/config-example.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var config = {
var config = {
couch_db_server: 'localhost',
couch_db_port: '5984',
couch_db_use_ssl: false,
Expand All @@ -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' : '') + '://';
};
Expand All @@ -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;
module.exports = config;
2 changes: 1 addition & 1 deletion server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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); });
};
1 change: 1 addition & 0 deletions tests/acceptance/inventory-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
23 changes: 23 additions & 0 deletions tests/integration/components/inventory/rank-select-test.js
Original file line number Diff line number Diff line change
@@ -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');
});

0 comments on commit 1c6dc42

Please sign in to comment.