1
0
Fork 0
Commit Graph

75 Commits (e26a7c3cac34ae498800e8835f9312d4e717e51f)

Author SHA1 Message Date
Mike Gerwitz e26a7c3cac FieldVisibilityEventHandler: Add class
This extracts code from internal lovullo repo rating-fw (originally
Client#_hideFields), 5d4019f1973f9271f4b1bd24ce1f55b56ccda09e.

* src/event/FieldVisibilityEventHandler.js: Add class.
* test/event/FieldVisibilityEventHandlerTest.js: Add test case.
2017-02-08 11:24:56 -05:00
Mike Gerwitz ed21707920 DataValidator, ValidStateMonitor: Add #clearFailures argument
This allows clearing only the specified failures.

* src/validate/ValidStateMonitor.js
  (clearFailures): Add `fields' argument.  Make method more concise.
  (_fixFailure): Handle clearing `_failures' record.

* src/validate/DataValidator.js
  (clearFailures): Add `fields' argument.

* test/validate/ValidStateMonitorTest.js: Add test.
* test/validate/DataValidatorTest.js: Add test.
2017-02-08 11:24:56 -05:00
Mike Gerwitz c7b5ce5595 DataValidator, ValidStateMonitor: Add #clearFailures
* src/validate/DataValidator.js (clearFailures): Add public method.
* test/validate/DataValidatorTest.js: Add #clearFailures test.

* src/validate/ValidStateMonitor.js (clearFailures): Add public method.
* test/validate/ValidStateMonitorTest.js: Add #clearFailures test.
2017-02-02 14:01:13 -05:00
Mike Gerwitz 61a59db4e0 system.client: working data.diffStore
* src/system/client.js (data.diffStore): Compose all stores.
* test/system/clientTest.js: Update test case.

DEV-2296
2017-01-30 00:43:13 -05:00
Mike Gerwitz 0dcbd32202 DataValidator: accept classification results
* src/validate/DataValidator.js
  (validate): New `classes' parameter.  API BC break from previous
    commits.
  (populateStore, updateFailures): Generalize methods.

* test/validate/DataValidatorTest.js:
  Add associated test.
  Refactor existing tests to adhere to new API/expectations.

DEV-2206
2017-01-30 00:29:25 -05:00
Mike Gerwitz 28d74d7068 ValidStateMonitor: handle empty diff on past failure
See the description in the test case.  This is a bug fix.

* src/validate/ValidStateMonitor.js
  (_checkCauseFix): Do not consider an empty diff on a past failure to
    be a fix.

* test/validate/ValidStateMonitorTest.js: Add test.

DEV-2296
2017-01-30 00:29:25 -05:00
Mike Gerwitz 24180e704a Add DiffStore
* src/store/DiffStore.js: Add class.
* test/store/DiffStoreTest.js: Add test case.

DEV-2296
2017-01-30 00:29:25 -05:00
Mike Gerwitz 282c0acf54 Store#clear to return self
* src/store/MemoryStore.js (clear): Promise resolve to self.
* src/store/Store.js (clear): Update docblock.
* test/store/MemoryStoreTest.js: Update test case accordingly.

DEV-2296
2017-01-30 00:29:25 -05:00
Mike Gerwitz b62673791b Add PatternProxy Store trait
Life is so much less miserable now that the project is supporting ES6.

* src/store/PatternProxy.js: Add trait.
* src/store/StorePatternError.js: Add Error.
* test/store/PatternProxyTest.js: Add test case.

DEV-2296
2017-01-30 00:29:15 -05:00
Mike Gerwitz 4d981bd39f Store#add to return self
This allows for Promise chaining (and consequently temporary classes,
great for testing).

* src/store/MemoryStore.js
  (add): Resolve promise to self.
    Modify docblock.
* src/store/Store.js (add): Modify docblock.
* src/store/Cascading.js (add): Modify docblock.

* test/store/MemoryStoreTest.js: Modify test accordingly.

DEV-2296
2017-01-29 22:44:34 -05:00
Mike Gerwitz 38b4a58dde Began system/ with client
This will contain various factories (compounded in some cases) to
instantiate various parts of a coherent system.  It aims to replace
(as one of many pieces) the ClientDependencyFactory that's referenced
in the code, which is still part of rating-fw (internal LoVullo repo
from which liza is being liberated).

* src/system/client.js: Add module.
* test/system/clientTest.js: Add functional test case.

DEV-2296
2017-01-29 22:44:34 -05:00
Mike Gerwitz 2045c76f7e Integrate Store into DataValidator, ValidStateMonitor
ValidStateMonitor now uses a Store in place of the original primitive
object-based diff format.  The original format is translated by
DataValidator.  The code is in a transitional state, and considering
the amount of time we spend on various areas of this project, will
likely stay this way for a while.

* src/validate/DataValidator.js
  (__construct): Accept Store factory parameter.
  (_store_factory): Add field.
  (_createStores): Add method.
  (_validate): Handle Store.
  (updateFailures): Add method.
  (_populateStore): Add method.

* test/validate/DataValidatorTest.js: Add tests.

* src/validate/ValidStateMonitor.js
  (update): Enforce Store diff.
    Wait to process failures until fixes are calculated.
  (_checkFailureFix): Handle asynchronous, Promise-based diff.
  (_checkCauseFix): Extract logic from _checkCauseFix.

* test/validate/ValidStateMonitorTest.js:
  Modify test cases to be Promise-based and handle async calls where
  appropriate.  That was a friggin' expensive mess.

DEV-2296
2017-01-29 22:44:27 -05:00
Mike Gerwitz 203b25f10e Add DataValidator
This extracts some gross code from Client in the rating-fw repo, which
is responsible for gluing change validations together.

* src/validate/DataValidator.js: Add class.
* test/validate/DataValidatorTest.js: Add test case.

DEV-2296
2017-01-27 15:57:43 -05:00
Mike Gerwitz fb3cd11265 ValidStateMonitor#update return Promise
Stepping stone to async. fix checks.

* src/validate/ValidStateMonitor.js
  (update, detectFixes, _checkFailureFix): Return Promise.
* test/validate/ValidStateMonitorTest.js: Update to use promises.

DEV-2296
2017-01-27 15:57:40 -05:00
Mike Gerwitz bb17085448 Test to ensure Cascading does not clear self
* test/store/CascadingTest.js: Test that Cascading store does not
  clear itself.
2017-01-04 16:17:37 -05:00
Mike Gerwitz 0c18a6321a Add StoreMissError
Nice and trivial with the new easejs transparent error subtyping!

* src/store/StoreMissError.js: Add error class.
* src/store/MemoryStore.js (get): Use it.
* test/store/MemoryStoreTest.js (#get): Modify test to expect type.
2017-01-04 16:17:37 -05:00
Mike Gerwitz 7d97569027 Add MissLookup trait
* src/store/MissLookup.js: Add trait.
* test/store/MissLookupTest.js: Add test case.
2017-01-04 16:17:37 -05:00
Mike Gerwitz 0be39adfdb Make {,Memory}Store asynchronous
This isn't terribly useful as a general-purpose cache if it can't
handle async requests.
2017-01-04 16:17:35 -05:00
Mike Gerwitz 29f67bd157 Add store.Cascading
* src/store/Cascading.js: Add trait.
* test/store/CascadingTest.js: Add test case.
2017-01-03 09:11:18 -05:00
Mike Gerwitz d8d44130e8 Add {,Memory}Store
* src/store/Store.js: Add interface.
* src/store/MemoryStore.js: Add class.
* test/store/MemoryStoreTest.js: Add test case.
2017-01-03 09:10:53 -05:00
Mike Gerwitz 5607bf1927 Replace Currency formatter with StringFormat
This is a much more general solution.

* src/validate/formatter/Currency.js: Remove trait.
* test/validate/formatter/CurrencyTest.js: Remove test case.

* src/validate/formatter/StringFormat.js: Add trait.
* test/validate/formatter/StringFormatTest.js: Add test case.
2016-12-01 08:47:23 -05:00
Mike Gerwitz ab3f5f4cb6 Validate correct Number format
* src/validate/formatter/Number.js
  (parse): Validate number format.

* test/validate/formatter/NumberTest.js: Modify accordingly.
2016-12-01 08:43:51 -05:00
Mike Gerwitz 5947e7646e Add scale to Number formatter
* src/validate/formatter/Number.js
  (__mixin): Add mixin ctor.
  (parse): Handle scale.
  (styleNumber): Handle scale.
  (scale, split): Add methods.

* test/validate/formatter/NumberTest.js: Modified accordingly.
2016-12-01 08:43:46 -05:00
Mike Gerwitz 6db99c8632 Add Currency formatter
* src/validate/formatter/Currency.js: Add trait.
* test/validate/formatter/CurrencyTest.js: Add test case.
2016-11-28 14:01:44 -05:00
Mike Gerwitz c124086673 Correct and test GeneralStepUi#scrollTo
* src/ui/step/GeneralStepUi.js (scrollTo):
  Will now abort after each error rather than falling through.
  Visibility error message will now show field index.

* test/ui/step/GeneralStepUiTest.js: Added respective test cases
2016-08-05 11:45:09 -04:00
Mike Gerwitz 5ce106710e Add MultiDimension formatter
* src/validate/formatter/MultiDimension.js: Added
* test/validate/formatter/MultiDimensionTest.js: Added
2016-06-28 10:27:59 -04:00
Mike Gerwitz b90f6d7474 Add accept/reject styler
* src/validate/formatter/AcceptReject.js: Added.
* test/validate/formatter/AcceptRejectTest.js: Added.
2016-06-28 10:27:56 -04:00
Mike Gerwitz 31f3ab010e Add Limit formatter
* src/validate/formatter/insurance/Limit.js: Added
* test/validate/formatter/insurance/LimitTest.js: Added
2016-06-27 16:51:25 -04:00
Mike Gerwitz c0df3ef02e Add Number formatter
* src/validate/formatter/Number.js: Added
* test/validate/formatter/NumberTest.js: Added
2016-06-27 16:51:25 -04:00
Mike Gerwitz 8a26406468 Add MultiDelimited formatter trait
This will simplify, through composition, a number of other
validator-formatters.

* src/validate/formatter/MultiDelimited.js: Added
* test/validate/formatter/MultiDelimitedTest.js: Added
2016-06-27 16:51:17 -04:00
Mike Gerwitz 4aa88fc08c UnorderedList{Formatter=>} now a trait
This adds a great deal of flexibility through composition via trait
stacking.

* src/validate/formatter/UnorderedList.js: Renamed from
  UnorderedListFormatter; now a trait.

* test/validate/formatter/UnorderedListTest.js: Renamed from
  UnorderedListFormatterTest and adjusted to instantiate trait.
2016-06-24 15:57:10 -04:00
Mike Gerwitz bc45b70644 Add mixin testing to common vformat functions
* test/validate/formatter/common.js (testMixin): Added.
2016-06-23 11:38:09 -04:00
Mike Gerwitz ac52f42d1c Add EchoFormatter
* src/validate/formatter/EchoFormatter.js: Added.
* test/validate/formatter/EchoFormatterTest.js: Added.
2016-06-23 10:12:59 -04:00
Mike Gerwitz 391a819536 Liberated UnorderedListFormatter
These have been refacored from the original: rather than abusing what is now
the PatternFormatter, it is now its own class.

* src/validate/formatter/UnorderedListFormatter.js: Added.
* test/validate/formatter/UnorderedListFormatterTest.js: Added.
2016-06-23 09:14:05 -04:00
Mike Gerwitz ab6be11bb6 Liberate common validator-formatter test function
This has been modified from the original to use Chai instead of the `assert'
module.

* test/validate/formatter/common.js: Added.
2016-06-23 09:13:50 -04:00
Mike Gerwitz d6cecf1ff6 VFormat => PatternFormatter with added interface
* src/validate/ValidatorFormatter.js: Interface added.
* src/validate/formatter/PatternFormatter.js: Renamed from ../VFormat.js.
* test/validate/formatter/PatternFormatterTest.js: Renamed from
  ../VFormatTest.js.
2016-06-22 15:59:12 -04:00
Mike Gerwitz a509e53a3e Liberate VFormat
This will likely undergo some refactoring.

* src/validate/VFormat.js: Added.
* test/validate/VFormatTest.js: Added.
2016-06-22 15:41:03 -04:00
Mike Gerwitz f5549795d5 GeneralStepUi vformat styling
* package.json (devDependencies): Add sinon

* src/ui/step/GeneralStepUi.js (answerDataUpdate): Attempt formatting with
  formatter prior to "old" answer styling.

* test/ui/step/GeneralStepUiTest.js: Added
2016-06-21 16:46:05 -04:00
Mike Gerwitz e6ede4ad3a ValidStateMonitor: merge subsequent failures before fixes
* src/validate/ValidStateMonitor.js (mergeFailures):
Another error on a field that previously failed will no longer overwrite the
previous failure, which caused issue when the causes changed (leaving fields
potentially unfixed).

* test/validate/ValidStateMonitorTest.js: Respective tests added.
2016-04-28 11:53:14 -04:00
Mike Gerwitz e406c198d2 Add Failure#merge
* src/validate/Failure.js (merge): Added
* test/validate/FailureTest.js: Respective tests added
2016-04-28 11:31:42 -04:00
Mike Gerwitz 0a8329b405 Support multiple validation failure causes
* src/validate/Failure.js (__construct): Takes an array of causes.
(getCauses): Now returns an array of causes.

* src/validate/ValidStateMonitor.js: Recognize fixes on array of causes.

* test/validate/FailureTest.js: Updated

* test/validate/ValidStateMonitorTest.js: Updated
2016-04-21 16:23:41 -04:00
Mike Gerwitz f624710451 Consider field failure cause when checking fixes
This maintains BC with the old string-based system.

* src/validate/ValidStateMonitor.js (_getCause): Added.
(detectFixes): Consider failure cause if available when checking for fixes.
2016-04-20 12:11:17 -04:00
Mike Gerwitz f784db5f2b Ensure that Failure objects will work transparently in ValidStateMonitor
This is to facilitate a transition to Failure without a BC break.

* test/validate/ValidStateMonitorTest.js: Ensure that replacing messages
with Failure will continue to operate as expected.
2016-04-20 11:12:08 -04:00
Mike Gerwitz ac5d04e9a4 Add validation Failure
* src/validate/Failure.js: Added
* test/validate/FailureTtest.js: Added
2016-04-20 10:31:49 -04:00
Mike Gerwitz ddffb4e301 No failure event if failures have not changed in ValidStateMonitor
* src/validate/ValidStateMonitor.js (mergeFailures): Return count of new
failures

* test/validate/ValidStateMonitorTest.js: Respective test added
2016-04-19 11:29:14 -04:00
Mike Gerwitz 7651e9499f Remove debugging console.log from XhrHttpImplTest
* test/dapi/http/XhrHttpImplTest.js: Remove accidentally-committed
console.log
2016-04-19 00:05:47 -04:00
Mike Gerwitz a6115018d2 Add x-www-form-urlencoded header for XhrHttpImpl
It might be the case that we may want to post raw data in the future; in
fact, I can guarantee it.  We'll cross that bridge when we come to it.

* src/dapi/http/XhrHttpImpl.js (openRequest): Set ContentType header
on POST

* test/dapi/http/XhrHttpImplTest.js: Modified accordingly
2016-04-14 12:08:00 -04:00
Mike Gerwitz 659c820eb6 Add ValidStateMonitor
The intent is to ultimately replace ClientFieldValidator with this and
individual validators that interact with it.

* src/validate/ValidStateMonitor.js: Added
* test/validate/ValidStateMonitorTest.js: Added
2016-04-12 13:57:34 -04:00
Mike Gerwitz a145bfe1f8 Use HTMLElement#setAttribute in NaFieldStyler for IE<9
element.style is not supported as an lvalue in IE<9.

All the rest of the sane world that doesn't support IE<9 should be laughing
at me in pity right now.

* src/ui/styler/NaFieldStyler.js (hideField):
Use HTMLElement#setAttribute instead of HTMLElement#style as an lvalue

* test/ui/styler/NaFieldStylerTest.js: Modify test cases to check for
invocation of setAttribute
2016-04-05 11:53:30 -04:00
Mike Gerwitz befca68110 Extract NaFieldStyler show/hide actions into protected methods
* src/ui/styler/NaFieldStyler.js (showField, hideField): Added
* test/ui/styler/NaFieldStyler.js: Added respective tests
2016-04-04 23:59:57 -04:00