-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: bhCurrencyInput to validate currencies #95
Feat: bhCurrencyInput to validate currencies #95
Conversation
@IMA-WorldHealth/local-contributors, all those working on components may want to look at this code for inspiration. It demonstrates:
@sfount, let me know if there is anything I can clear up in the PR text or the tests. |
5bc818a
to
3620be2
Compare
@sfount, could I get a review? |
This commit adds a currency input crmponent (bhCurrencyInput) that uses the CurrencyService to validate currency inputs automatically. It takes in four bindings: - model (two-way binding) The ng-model for the input. These changes are reflected in the parent controller - currencyId (one-way binding) The currency id selected to validate the currency input with. This is selected elsewhere, but bound so that changes will propigate to change the validation state. - form (one-way binding) The parent form in which the input resides. Used for validation triggers. - validationTrigger (one-way binding) The trigger for when to show error messages. The developer is expected to provide all of the above options. The currency input should be used in the form like this: <pre> <bh-currency-input model="ctrl.model" currency-id="ctrl.currencyId" form="ParentControllerFormName" validation-trigger="ParentControllerFormName.$submitted"> </bh-currency-input> </pre>
This commit includes a wrapper for the bhCurrencyInput component to allow developers to rapidly set and get the value without having to know the appropriate selectors for it. USAGE: ```js var components = require('../shared/components'); it('works like a charm', function () { components.currencyInput.set(1500); expect(components.currencyInput.get()).to.eventually.equal(true); }); ```
3620be2
to
7f56bb3
Compare
* Sets the value of the currency input. | ||
*/ | ||
set : function set(value) { | ||
var elm = element(by.css(this.selector)); |
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 idea of test utilities for directives is an excellent idea going forward. Very cleanly implemented.
Feat: bhCurrencyInput to validate currencies
Component: bhCurrencyInput
This PR adds a currency input component (bhCurrencyInput) that uses the CurrencyService to validate currency inputs automatically. It takes in four bindings:
The ng-model for the input. These changes are reflected in the parent
controller
The currency id selected to validate the currency input with. This is
selected elsewhere, but bound so that changes will propigate to
change the validation state.
The parent form in which the input resides. Used for validation
triggers.
The trigger for when to show error messages.
The developer is expected to provide all of the above options. The currency input should be used in the form like this:
Test Hooks
This PR also includes test hooks for developers to rapidly use the input in tests, without having to know the underlying details. You should be able to use it as follows:
Currency API
To keep with our current model of consuming APIs, this PR also introduces a
/currencies
API , which includes two methods:GET /currencies
GET /currencies/:id
This new API replaces the previous route
/finance/currencies
and all client-side routes have been migrated to using/currencies
. I've included integration tests as proof of work.Closes #72. Closes #90.