-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
inventory items rank attribut #225
inventory items rank attribut #225
Conversation
@@ -0,0 +1,16 @@ | |||
import Ember from 'ember'; | |||
import SelectValues from 'hospitalrun/utils/select-values'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've used this util to generate options collection.
I see you are using mixins for defining available options / enums for select. My implementation is using wrapper component. I chose this because I want to do it in more component-centric way since there is no need to allow controllers access this options. I'm opened to discussion on this decision. |
|
||
export default Ember.Component.extend({ | ||
label: 'Rank', | ||
rankOptions: ['A', 'B', 'C'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets put this in init or a CP, putting complex values on the prototype is likely to cause grief.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actual options (Array of Objects) is defined via CP in here. I can define setter for this in init()
if you like to.
bf5f068
to
6edc204
Compare
@turboMaCk the screenshots look great. I'll review w/ @jkleinsc tomorrow and either accept the PR or get you feedback. Thanks for hopping right in. |
|
||
export default Ember.Component.extend({ | ||
label: 'Rank', | ||
rankOptions: [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks like instance state, it should likely be instantiated in the initializer, or as a CP.
Placing instance state of the prototype can often lead to unexpected behavior and leaks).
If you want the slot on the prototype for documentation, let my suggestion making the value undefined or null. Alliteratively it could be a CP, which insures the per instance state.
rankOptions: Ember.computed(function() {
return ['A', 'B', 'C'];
});
In ES7 we will get property initializers, which make this nicer and less confusing.
class Foo {
rankOptions = ['A', 'B', 'C']; // re-rerun for each instantiation, and set to `this`
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imho setting this in initializer is little bit over-kill and made code confusing. Setting this to undefined/null by default do not specify type (maybe it will be better to remove this and keep only setter in init). The only reason I kept this is to let everyone know that this property will be and it should be Array
. Computed property seems to be best solution but I'm not sure if there is no any reasonable overhead (since this type implements little bit more than we actually need). ES7 solution seems to be best for me, but I'm not sure, if it's compatible.
I can remove this completely (but for me it makes sense to have defined all props that instance has on one place) and keep the setter in init()
or make CP (if it is not too much expensive)
I do not know as much about ember-metal
as you so let me know your suggestions on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW... this discussion is still actual even github hides this.
@turboMaCk thanks for your work here. Some design feedback: These labels should use colors from the existing color palette here. Although I looked through the code and it appears you're adding classes, but not defining colors anywhere? Now I'm wondering where those colors are coming from... As for the edit screen, the only thing that concerns me is the Purchases table heading looks really crammed. It would be great to either reduce the label copy a bit (i.e. drop words where appropriate, like "Date" when date is obvious from the value), or find a way to better accommodate everything without it having to wrap to two lines of text everywhere. |
@jglovier Those colors I believe are coming from bootstrap. Also, the purchases table heading shown here has nothing to do with this PR. @turboMaCk I am thinking we shouldn't display the ranking on the item listing. I like what you've done there, but it's information that really is only needed for reporting and/or alerting purposes, so I don't think it belongs on the listing screen. |
Ahhh, right.
Okay, cool. I'll address that separately then. |
@jglovier is completely right. I used bootstrap's labels for this. The only thing I had to change in form is We have to decide if we want to show that rank column in list tables. It also could be done some other way like I mentioned before it at least makes sense to me to add some I also want to continue and work on this #209 you after we finish this if want to. |
If I should say my opinion on displaying this thing in list I will go this way:
|
@tangollama Any thoughts on this? |
I will probably find some time to continue on this tomorrow. Let me know about changes 🚀 |
@tangollama ping |
@jkleinsc so for now that setting will just do nothing. Ok, I do not thing that this is big deal so there is no need to sped much more time on this decision. I'll update this PR. and then ping for code review. |
READY. I also move component files to pod structure. I do not know why |
40ded82
to
d22287c
Compare
rebased |
d22287c
to
e202ae9
Compare
this._super(...arguments); | ||
|
||
// set available options | ||
this.set('rankOptions', Ember.A(['A', 'B', 'C'])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because of this options can not be overwrite. Also there is unfinished discussion with @stefanpenner
EDIT fixed on rebuid. |
@turboMaCk Not sure why PhantomJS died -- maybe just a problem in Travis. I re-ran the job and it looks good now. As far as the options are concerned, one pattern we have used is to use mixins for hardcoded options. If we ever want to change the options to pull from the database instead, we just change the mixin. |
@jkleinsc thank you! I know about mixins #225 (comment) I just waited for your feedback. Personally I like using components more than mixins in controllers (controllers are singletons & it's better isolated from other stuff) I can move this from component to mixin and use that mixin in that component but then there was no much other logic in component itself:D Let me know what you think. I'll do this your way. |
@turboMaCk I missed the comment about mixins earlier. I think for now we should just leave it the way you coded it. I will merge the PR unless you think there is another reason to wait. |
I do not think that there are any blocker. I'll look at this after merge: #209 |
inventory items rank attribute
Looks good @turboMaCk. Thanks for the PR! |
My pleasure to helping you guys with this amazing project. |
refactor(NewLabRequest): improve queries - remove function call tests
Implement rank (enum
['A', 'B', 'C']
) on inventory items.