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

inventory items rank attribut #225

Merged
merged 2 commits into from
Dec 10, 2015

Conversation

turboMaCk
Copy link
Contributor

Implement rank (enum ['A', 'B', 'C']) on inventory items.

@@ -0,0 +1,16 @@
import Ember from 'ember';
import SelectValues from 'hospitalrun/utils/select-values';
Copy link
Contributor Author

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.

@turboMaCk
Copy link
Contributor Author

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'],

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.

Copy link
Contributor Author

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.

@turboMaCk turboMaCk changed the title inventory/rank-select component inventory items rank attribut Dec 6, 2015
@turboMaCk turboMaCk force-pushed the feature/inventory_items_rank branch from bf5f068 to 6edc204 Compare December 6, 2015 16:14
@turboMaCk
Copy link
Contributor Author

Design

This is how it looks like in lists:
screen shot 2015-12-06 at 17 15 34

this is edit form:
screen shot 2015-12-06 at 17 15 51

Ideas on improvements:

We can add binding on item.quantity to inventory/rank-display component and compute classes (danger/success...) based on quantity and rank. But I'm nut sure if this should also depend on Distribution Unit type, so I'm leaving it as it is since this needs definition.

Let me know what you think about this PR. I'm ready to work on improvements based on your feedback.

@tangollama
Copy link
Member

@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: [],

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`
}

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@jglovier
Copy link
Member

jglovier commented Dec 7, 2015

@turboMaCk thanks for your work here. Some design feedback:

image

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.

@jkleinsc
Copy link
Member

jkleinsc commented Dec 7, 2015

@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.

@jglovier
Copy link
Member

jglovier commented Dec 7, 2015

Those colors I believe are coming from bootstrap

Ahhh, right.

Also, the purchases table heading shown here has nothing to do with this PR.

Okay, cool. I'll address that separately then.

@turboMaCk
Copy link
Contributor Author

@jglovier is completely right. I used bootstrap's labels for this. The only thing I had to change in form is name input and that rank select. I made a name input smaller.

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 running out of icon in the future.

I also want to continue and work on this #209 you after we finish this if want to.

@turboMaCk
Copy link
Contributor Author

If I should say my opinion on displaying this thing in list I will go this way:

  • keep displaying this information colorised in list till alert system will be done.
  • after alert system is ready change this to displaying something like condition based on rank and quantity.

@jkleinsc
Copy link
Member

jkleinsc commented Dec 7, 2015

@tangollama Any thoughts on this?

@turboMaCk
Copy link
Contributor Author

I will probably find some time to continue on this tomorrow. Let me know about changes 🚀

@jkleinsc
Copy link
Member

jkleinsc commented Dec 9, 2015

@tangollama ping
I am of the opinion we do not include the rank on the inventory listing screen, primarily because there are a decent number of fields being displayed currently. Also, if we are looking for a visual indicator, that could be applied to the quantity column, but I think that should be handled as a separate issue/PR

@turboMaCk
Copy link
Contributor Author

@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.

@turboMaCk
Copy link
Contributor Author

READY.

I also move component files to pod structure. I do not know why ember g component do not generate this by default.

@turboMaCk turboMaCk force-pushed the feature/inventory_items_rank branch from 40ded82 to d22287c Compare December 10, 2015 16:10
@turboMaCk
Copy link
Contributor Author

rebased

@turboMaCk turboMaCk force-pushed the feature/inventory_items_rank branch from d22287c to e202ae9 Compare December 10, 2015 16:13
this._super(...arguments);

// set available options
this.set('rankOptions', Ember.A(['A', 'B', 'C']));
Copy link
Contributor Author

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

#225 (diff)
#225 (comment)

@turboMaCk
Copy link
Contributor Author

not ok 21 PhantomJS - Browser "phantomjs /home/travis/build/HospitalRun/hospitalrun-frontend/node_modules/ember-cli/node_modules/testem/assets/phantom.js http://localhost:7357/5350" exited unexpectedly.

EDIT fixed on rebuid.

@jkleinsc
Copy link
Member

@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.

@turboMaCk
Copy link
Contributor Author

@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.

@jkleinsc
Copy link
Member

@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.

@turboMaCk
Copy link
Contributor Author

I do not think that there are any blocker. I'll look at this after merge: #209

jkleinsc added a commit that referenced this pull request Dec 10, 2015
@jkleinsc jkleinsc merged commit 1c6dc42 into HospitalRun:master Dec 10, 2015
@jkleinsc
Copy link
Member

Looks good @turboMaCk. Thanks for the PR!

@turboMaCk
Copy link
Contributor Author

My pleasure to helping you guys with this amazing project.

matteovivona pushed a commit that referenced this pull request Jan 15, 2021
refactor(NewLabRequest): improve queries - remove function call tests
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants