This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #225 from turboMaCk/feature/inventory_items_rank
inventory items rank attribute
- Loading branch information
Showing
8 changed files
with
63 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'])); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
tests/integration/components/inventory/rank-select-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); |