The intent of this is to allow for clearing errors after fields
load (e.g. a "field loading" message if the user attempts to continue
past the step when a field hasn't yet finished loading).
* src/dapi/DataApiManager.js (getApiData): Emit fieldLoaded after
request completes.
* test/dapi/DataApiManagerTest.js: Add test case.
DEV-2299
This was not properly chain the promises---it was always chaining on
the original _pending (so, the first request) and never clearing
_pending after that point.
* src/validate/DataValidator.js (_onceReady): Properly chain.
* test/validate/DataValidatorTest.js: Updated test. Don't ask.
Since changes trigger any event observers---which can be
expensive---it is ideal to ignore sets that do not result in any
changes to the bucket.
This also resolves issues with systems that are confused by empty
diffs.
* src/bucket/StagingBucket.js
(_hasChanged): Add method.
(setValues): Use it.
* test/bucket/StagingBucketTest.js: Add test case.
DEV-2299
Since we maintain state (as a kluge for the time being to integrate
with the rest of the system), we need to be careful to protect against
concurrent requests that might mess with it before the original
request is complete.
* src/validate/DataValidator.js
(validate, updateFailures): Hold concurrent requests.
(_onceReady): Add method.
* test/validate/DataValidatorTest.js: Add tests.
In practice, not clearing the store and allowing it to use previous
state has the effect of instantly "fixing" failures if there happens
to be more than one validation call.
This was a log of debugging for a one-line change.
* src/validate/DataValidator.js (_populateStore): Always clear store.
* test/validate/DataValidatorTest.js: Add test.
DEV-2299
I updated DataValidator but never updated the caller. Damnit. It's
an unfortunate side-effect of dynamic, loosely typed languages and
mitigating it requires what should be boilerplate functional tests (in
this case---functional tests are useful for many other integration
aspects).
* src/event/FieldVisibilityEventHandler.js
(handle): Use updated DataValidator#clearFailures API, which has
a different descriptor format.
* test/event/FieldVisibilityEventHandlerTest.js: Update test.
* 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
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
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
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
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
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
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
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.
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.
* 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
This will simplify, through composition, a number of other
validator-formatters.
* src/validate/formatter/MultiDelimited.js: Added
* test/validate/formatter/MultiDelimitedTest.js: Added
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.
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.
* 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.
* 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
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.
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.
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
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
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
Field stylers now determine whether they've been applied to the target field
on their own, which solves the problem of the system getting out of sync.
* src/ui/styler/ErrorFieldStyler.js (isApplied): Added
* src/ui/styler/FieldStyler.js (isApplied): Added
* src/ui/styler/NaFieldStyler.js (isApplied): Added
* test/ui/styler/NaFieldStylerTest.js: Test for #isApplied
This is necessarily primarily for a specific case: option elements in IE,
which cannot be styled. >:O
This implementation is not complete: we want to re-attach the field at the
same position it was at before it was detached. This might not be
trivial---imagine if its sibling was also detached.
* src/ui/styler/NaFieldStyler.js (isSubField): Receive field instead of
element (to check parent)
(applyStyle, revokeStyle): Detach and re-attach field from/to DOM
respectively
* test/ui/styler/NaFieldStylerTest.js: Associated tests
It is expected that support for promises will be available in whatever
environment liza is run. Here, we're adding a shim for the sake of testing
in ancient environments.
It's almost as if I'm stuck using an ancient environment somewhere...*cough*
The Data API is being heavily refactored and tested; while moving files into the
Liza repository, I noticed some inefficiencies with the design. These are being
heavily improved upon.