1
0
Fork 0
Commit Graph

451 Commits (master)

Author SHA1 Message Date
Jeffrey Fisher 0f9ae0d08e [DEV-3497] Updated selection if selection is disabled 2018-08-30 13:55:57 -04:00
Jeffrey Fisher ee5306a279 [DEV-3497] Updated variable name 2018-08-30 10:24:21 -04:00
Jeffrey Fisher 43596eeed7 [DEV-3497] Updated tabbed block to use default selection 2018-08-29 13:33:41 -04:00
Joseph Frazer dc39c636a4 [DEV-3393] Merge branch 'jira-3393' of gitlab.lovullo.com:floss/liza into jira-3393 2018-08-16 10:01:20 -04:00
Joseph Frazer b4ecb5a14c [DEV-3393] Made sure the entity id is a number 2018-08-16 07:35:52 -04:00
Joseph Frazer 11a565422a [DEV-3393] Use the correct variable name 2018-08-15 16:13:35 -04:00
Joseph Frazer c61c1196c4 [DEV-3393] Chnage property type to correct type 2018-08-15 15:14:10 -04:00
Joseph Frazer 52491c1ce0 [DEV-3393] The entity id should not be sent unless the request is
internal.
2018-08-15 15:10:13 -04:00
Joseph Frazer 4b1fda57b8 [DEV-3393] minor changes to improve code quality 2018-08-15 15:05:21 -04:00
Joseph Frazer eb980f4fb7 [DEV-3393] Replace UNIX with Unix 2018-08-15 14:48:48 -04:00
Mike Gerwitz 2b93a0bbe4 [bugfix] Daemon: Do not un-initialize controller no_result_url
* src/server/daemon/Daemon.js (getProgramController): Do not initialize
  `no_results_url' to an empty string if not provided; instead, keep any
  existing value.  Otherwise, later calls with no arguments will clear
  previously-set values.

DEV-3254
2018-08-15 14:22:01 -04:00
Joseph Frazer 2c0bf764d1 [DEV-3393] Add more metadata to the init endpoint 2018-08-15 14:06:07 -04:00
Mike Gerwitz cd56bae358 DataApiMediator: Do not check bucket value until after stack clears
This further highlights that we probably should not be handling this
here.  We want to ensure that we check the state of the bucket right before
we're about to do option setting, otherwise we could be in an inconsistent
state (looking at old data).

* src/client/dapi/DataApiMediator.js (_updateFieldData): Check bucket after
  stack clears (along with all other operations).
2018-08-13 12:29:35 -04:00
Mike Gerwitz e24038503b [bugfix] DapiMediator: Wait for stack to clear before updating options
This allows the UI to update before we add elements.  This really isn't the
best place to do this, but it will do for now.

DEV-3257
2018-08-10 15:25:29 -04:00
Mike Gerwitz b47deedf9c [DEV-3257] DataApiMediator: Set bucket data after stack clear
Allowing the stack to clear ensures that (in practice) DelayedStagingBucket
is given a chance to do necessary processing before data are requested from
it by bucket hooks as a result of _this_ invocation, which in turn
results (in some cases) in infinite recursion.

* src/client/dapi/DataApiMediator.js (_updateFieldData): Allow stack to
    clear before invoking `quote.setData'.
* test/client/dapi/DataApiMediatorTest.js: Test respectively.

DEV-3257
2018-08-10 13:33:54 -04:00
Mike Gerwitz 9243eeb8bc [DEV-3257] DelayedStagingBucket: Preempt infinite recursion on #processValues
* src/bucket/DelayedRecursionError.js: New class.
* src/bucket/DelayedStagingBucket.js: Update copyright and docblock.
  (_processing): New field.
  (getDataByName): Check against undefined before invoking
    `#processValues'.
  (processValues): Increment lock (_withProcessLock).
  (_withProcessLock): Error on recursion >= 5.

DEV-3257
2018-08-10 11:17:13 -04:00
Mike Gerwitz 9f944bb7ec DelayedStagingBucket: Remove this.__super workaround
This was fixed in GNU ease.js 0.2.0 (which was released years ago).
2018-08-02 14:47:26 -04:00
Mike Gerwitz 7fd07f00e9 Client: Default dapimap to empty object
Without this, we have a BC break.

* src/client/Client.js (_init): Default program.dapimap to DataApiMediator
  instance to an empty object to maintain BC.
2018-07-18 16:52:04 -04:00
Mike Gerwitz abc2564d9c DataApiMediator: Do not auto-expand into populated fields
* src/client/dapi/DataApiMediator.js (_populateWithMap): Update
    docblock.  Ignore field during expansion if it would overwrite an
    existing value.
* test/client/dapi/DataApiMediatorTest.js: Update tests data to include
    values for all bucket fields, not just `name'.  Add test for new
    condition.

DEV-3257
2018-07-17 15:44:37 -04:00
Mike Gerwitz 839952a56d [DEV-3257] DataApiMediator: Auto-expand into fields on reply [*]
[*] You should not use this commit directly since this may wipe out data in
fields the user has changed.  See future commit where this situation is
properly handled.

* src/client/Client (_init): Provide dapimap to DataApiMediator instance.
* src/client/dapi/DataApiMediator.js
  (_dapi_map): New field.
  (constructor): Accept dapimap.  BC break (which is okay, since this is
    still part of a topic branch).  Assing to _dapi_map.  Update docblock.
  (monitor): Bind `dapi_manager' to first argument of handlers.
  (_updateFieldData): Accept `dapi_manager' as first argument.  Use
    `_populateWithMap' to generate additional update data.
  (_populateWithMap): New method.
  (_clearFieldFailures): Accept `dapi_manager' as first argument.
* src/dapi/DataApiManager.js: Update copyright year.
  (getDataExpansion): Return empty object (consistent with interface) rather
    than `undefined' when field value is undefined.  Use
    {Error=>MissingDataError} when field data are missing.  Throw instead of
    emit.  Fix missing comma in var declarations.
* src/dapi/MissingDataError.js: New class.
* test/client/dapi/DataApiMediatorTest.js: Update test data to test field
    expansion.  New test against ignoring field expansion when data are not
    available.  Update Sut constructors of other tests for new dapimap
    parameter.

DEV-3257
2018-07-17 15:44:37 -04:00
Mike Gerwitz 160ab01f9a DataApiMediator: setData{ByName=>} to prepare for multi-field set
See following commit.

* src/client/dapi/DataApiMediator.js (_updateFieldData):
  `setData{ByName=>}'.
* test/client/dapi/DataApiMediatorTest.js: Update respective tests.

DEV-3257
2018-07-17 15:44:37 -04:00
Mike Gerwitz e25bec5ac0 DataApiMediator: New class
This extracts existing code from Client and adds tests.  The glue code is
far from ideal and highlights the amount of work needed to decouple Client
from so many parts of the system.

* src/client/Client.js (_dapiManager): New field.
  (_init): Use DataApiMediator.
  (_createProgram): Assign `_dapiManager' (this is not at all
  ideal).  Remove hooks from it: fieldLoading, updateFieldData,
  clearFieldData.
* src/client/ClientDependencyFactory.js (createDataApiMediator): New alias
  to DataApiMediator constructor.
* src/client/dapi/DataApiMediator.js: New class.
* test/client/dapi/DataApiMediatorTest.js: New test case.

DEV-3257
2018-07-17 15:44:33 -04:00
Mike Gerwitz 3261fbd7ec controller: Fix progdata route error reporting
* src/server/daemon/controller.js (doRoute): response.{error=>internalError}.
2018-06-20 10:48:23 -04:00
Jeffrey Fisher 8600c3beb7 [DEV-3192] Renamed variables and added test case 2018-06-19 10:28:48 -04:00
Jeffrey Fisher e079a5eb0a [DEV-3192] Simplified logic and corrected issue with bucket data 2018-06-19 10:28:48 -04:00
Jeffrey Fisher b72fb4b2c7 [DEV-3192] Added check for no doc_data 2018-06-19 10:28:48 -04:00
Jeffrey Fisher 94f76c5a77 [DEV-3192] fixed test cases 2018-06-19 10:28:48 -04:00
Jeffrey Fisher 3e32442a43 [DEV-3192] fixed default value initialization 2018-06-19 10:28:48 -04:00
Jeffrey Fisher 345e570e67 [DEV-3192] Fix hiding the header when all contents are hidden 2018-06-19 10:28:48 -04:00
Jeffrey Fisher 8ac2a367db [DEV-3192] Fix populating default bucket data to meet min required bucket values 2018-06-19 10:28:48 -04:00
Mark Goldsmith bb9bb68a0f [DEV-2871] DocumentProgramFormatter: changed field match from any to all 2018-06-15 09:02:16 -04:00
Mark Goldsmith 7935c699de [DEV-2871] DocumentProgramFormatter: Match on fields from FieldClassMatcher instead of __classes and program.whens 2018-06-13 15:42:45 -04:00
Mike Gerwitz de931cf91b FieldClassMatcher: Minor refactoring/cleanup
This does not go all the way, but helps improve the readability of the
algorithm a little bit and modernizes the code.

* src/field/FieldClassMatcher.js (constructor): Renamed from
    `__constructor'.
  (__constructor): Remove method.
  (match): Extract most code into `#_reduceFieldMatches'.
  (_reduceFieldMatches): New method, simplifying the algorithm slightly.
  (_reduceMatch): Simplify.
* test/field/FieldClassMatcherTest.js: Update accordingly.
2018-06-12 16:52:14 -04:00
Mike Gerwitz 5164c9dcbb FieldClassMatcher: Always yield integer indexes
* src/field/FieldClassMatcher.js (match): Cast `vis' to number.
* test/field/FieldClassMatcherTest.js: Remove FIXME and change assertion.
2018-06-12 15:11:24 -04:00
Andrew Elbaneh 28fef16971 [DEV-2871] cleaned up some of the code based on the merge request 2018-06-12 09:02:54 -04:00
Mark Goldsmith 14a8af2282 [DEV-2871] Added link and id to group in DocumentProgramFormatter 2018-06-12 09:02:54 -04:00
Mark Goldsmith e2461a023c [DEV-2871] Added field type to DocumentProgramFormatter 2018-06-12 09:02:54 -04:00
Mark Goldsmith 856c9a1a83 [DEV-2871] Passed __classes directly into private functions, updated documentation 2018-06-12 09:02:54 -04:00
Mark Goldsmith 9907c698d1 [DEV-2871] Added DocumentProgramFormatter to format program data by step, group and field metadata 2018-06-12 09:02:54 -04:00
Chase Gregory a94dab9cc0 [DEV-3040] Fixed year Calculations 2018-06-08 15:23:37 -04:00
Chase Gregory ac32f5d8ad [DEV-3040] Fixed code styling 2018-06-08 14:29:02 -04:00
Chase Gregory 4593fd8002 [DEV-3040] Fixed relativeDate function with update date methods 2018-06-07 11:38:00 -04:00
Mike Gerwitz 4ce7ba7545 Server: Add program_id to /init
We need to add API versioning.  But until then...

* src/server/Server.js (_processInit): Return program_id.
2018-05-03 16:11:32 -04:00
Mike Gerwitz ad52dbec9a controller: Only init submit notification if requested
* src/server/daemon/controller.js (exports.init): Do not initialize submit
    notifier if no URL was provided.
2018-05-03 14:39:04 -04:00
Mike Gerwitz b32d4e3d1b MongoServerDao#getDocumentField retrieval fix
* src/server/db/MongoServerDao.js (getDocumentField): Check key on first
  record.
2018-05-02 15:27:35 -04:00
Mike Gerwitz 99e33a5089 RatingServiceSubmitNotify: Do not flag as notified on error
If the submission failed, we probably want to try again next time around.

* src/server/service/RatingServiceSubmitNotify.js
  (_maybeNotify): Extract logic from `#postProcessRaterData'.  Only set
    notification flag in absence of dapi error.
  (postProcessRaterData): Use it.
* test/server/service/RatingServiceSubmitNotifyTest.js: Update tests
    accordingly.
2018-05-02 14:23:39 -04:00
Mike Gerwitz 458064339d Server: Output assertion failure messages
Previously, it was just trying to serialize an object, which was useless.

* src/server/Server.js (_formatValidationFailures): New method.
  (_doQuoteSave): Use it.
2018-05-01 15:09:22 -04:00
Mike Gerwitz fac64b6ae1 Server: Set program internal flag before assertions
Requests that came in between (for example) a post request and the actual
validation of the posted data would potentially reset the flag, causing
internal assertions to fail.

* src/server/Server.js
  (sendStep): Provide session to #_forwardValidate.
  (_forwardValidate): Set `program.isInternal' immediately before invoking
    event.  Provide session to #quoteFill.
    [session]: New argument.
  (quoteFill): Add `session' argument.  Provide session to hooks.
  (loadProgram): Receive session via #quoteFill hook.  Set
    `program.isInternal' before submit hook.
* src/server/daemon/controller.js (doRoute): Remove `program.isInternal'
    set.
2018-05-01 15:03:55 -04:00
Mike Gerwitz ea30e94527 Integrate noResultsUrl configuration
This is not the ideal implementation.  Instantiation of RatingService and
such should be moved out of the controller entirely, but we don't have the
time for that right now.
2018-05-01 09:44:55 -04:00
Mike Gerwitz 25cb1f62c1 controller: Integrate RatingServiceSubmitNotify
This is not an ideal location.
2018-05-01 09:44:55 -04:00
Mike Gerwitz 3bed93e750 SpoofedNodeHttpImpl: Fix docblocks (User{Session=>Request})
Wrong object!
2018-05-01 09:44:55 -04:00
Mike Gerwitz ae0d9b3862 RatingServiceSubmitNotify: Create dapi dynamically with session
Session information needs to be available for request session spoofing.
2018-05-01 09:44:55 -04:00
Mike Gerwitz d9c442b8e2 QuoteDataApi: Correct constructor argument error 2018-05-01 09:44:55 -04:00
Mike Gerwitz 2d1582059f RatingServiceSubmitNotify: Notify only once
* src/server/db/MongoServerDao.js
  (getDocumentField,setDocumentField): New methods.
* src/server/service/RatingServiceSubmitNotify.js
  (postProcessRaterData): Only notify when notification flag is not set.
  (_getNotifyState, _setNotified): New methods.
* test/server/service/RatingServiceSubmitNotifyTest.js: Modify accordingly.
2018-05-01 09:44:55 -04:00
Mike Gerwitz d8338b50e0 RatingServiceSubmitNotify: Add trait
* src/server/service/RatingServiceSubmitNotify.js: New trait.
* test/server/service/RatingServiceSubmitNotifyTest.js: Respective test.
2018-05-01 09:44:55 -04:00
Jeffrey Fisher 7d0dc97162 Add HttpDataApiUrlData 2018-05-01 09:44:53 -04:00
Jeffrey Fisher 5b410005cd RatingService: ensure #postProcessRaterData is called before save 2018-05-01 09:44:51 -04:00
Mike Gerwitz 9ad8cb96b8 Cmatch: Do not fail given __classes question
* src/client/Cmatch.js (handleClassMatch): Rename from
  _handleClassMatch.  Make protected.  Check for truthy `vis'.
* test/client/CmatchTest.js: Update accordingly.
2018-04-16 15:30:19 -04:00
Mike Gerwitz f5f753d3bb Client: updateFieldData setOptions cur fix
* src/client/Client.js (_createProgram): Properly capture current value in
  closure for `setOptions'.
2018-04-03 16:04:30 -04:00
Mike Gerwitz 6733556582 Remove hard-coded skey
This wasn't intended to make its way into a public repo. :)

The existing key was a long-forgotten kluge that was supposed to be
temporary, allowing internal services to create quotes without
authentication.  The chances of this being practically exploited are minimal
in our environment, and it's auditable using webserver logs.

This moves the skey into a configuration file, which allows it to vary by
server and be rotated until a better solution is made available.  skey is
disabled by default (empty string), and when used by us internally, the keys
are now generated using a CSPRNG rather than a brute-forcable 5-byte key
that was hard-coded.

The fact that this appears in webserver logs is a big issue as well.  I
added a task to address that.

* conf/vanilla-server.json (skey): New key.  Default empty.
* src/server/daemon/Daemon.js (start): Provide skey to `#getRouters'.
  (getRouters): Provide skey to `#getProgramController'.
  (getProgramController): Set skey on `controller'.
* src/server/daemon/controller.js (skey): New mutable export (unideal; quick
    change).
  (has_skey): Use it.
2018-04-03 15:29:47 -04:00
Mike Gerwitz 460a533777 MongoServerDao: Always clear quicksave data
quicksave data wouldn't always be cleared on save, meaning it might not be
cleared until the next _empty_ quicksave from the client.

* src/server/db/MongoServerDao.js (saveQuote): Always clear quicksave.
2018-03-14 11:47:50 -04:00
Mike Gerwitz c33adee21d client: Truncate diff posted to server after first null
Before this change, since `undefined' is encoded as `null' when serialized,
there was no way for the server to disambiguate between unmodified values
and a truncation point.  For example:

  [ undefined, undefined, null, null, null ]

The above array represents two unmodified and three removed indexes.  But
this is serialzed into JSON as:

  [ null, null, null, null, null ]

It isn't possible for the server to determine what the truncation point is
from that diff.  The solution is to therefore truncate the array _before_
sending it to the server, providing a trailing null to indicate that a
truncation has occurred:

  [ null, null, null ]

The above means that the first two indexes are unmodified, and that index 2
and later should all be truncated.

* doc/client.texi (Saving to Server): New section.
* src/client/transport/XhttpQuoteTransport.js (_truncateDiff): New method to
  perform truncation.
  (getBucketDataJson): Use it.
* test/client/transport/XhttpQuoteTransportTest.js: New file with respective
  test case.
2018-03-07 13:46:05 -05:00
Mike Gerwitz 9727b9a157 Support default program id if none provided via URL
* src/client/Client.js (_defaultId): New property.
  (__construct)[default_id]: New parameter.  Set `_defaultId'.
  (_getProgramId): Use `_defaultId' if not found in URL.
* src/ui/nav/HashNav.js (_initUrl): Do not require leading program id.
  This technically worked fine before with our URL scheme, but that is not
  guaranteed to be the case generally.
2018-03-01 12:23:35 -05:00
Mike Gerwitz cfadc217cc DslRater: Correct missing raters error message 2018-03-01 12:23:35 -05:00
Mike Gerwitz 79fc82614e ElementStyler: console.warn{ing=>}
Crap.

* src/ui/ElementStyler.js (setValueByName): console.warn{ing=>}
2018-02-12 10:35:23 -05:00
Mike Gerwitz 3b303e50a9 Cmatch: Fix combined show/hide of same field, multi-index
This is something that managed to slip by (but not unnoticed) for almost
exactly one year to this day (028606242a).  It
can only be reproduced by changing classes that result in visibility changes
differing on the same field by index.  The issue hides itself on first
load (because all fields are shown by default) and on refresh.

The problem is that, when one index shows a field but another hides it, the
hide overrode the show indexes, so only the hide took place.

* src/client/Cmatch.js (markShowHide): Make virtual.  New implementation to
    support concurrent show/hide.
  (_handleClassMatch): Use it.
* test/client/CmatchTest.js: New test.
* npm-shrinkwrap.json: ease.js v0.2.{8=>9}.
2018-02-09 11:55:46 -05:00
Mike Gerwitz 0a50b22496 Cmatch: Extract show/hide marking into own method
This is to give us a fairly easy means of testing this logic for a bugfix.

This refactoring also obviates a pretty nasty bug; see docblock.

* src/client/Cmatch.js (_handleClassMatch): Extract show/hide marking.
  (markShowHide): New method.
2018-02-09 11:20:48 -05:00
Mike Gerwitz 4b114d0137 Client: Extract cmatch methods
This makes the minimal number of changes necessary to ensure that all object
references remain available.  It is a mess.

And despite moving all of this, Client is still a massive clusterfuck.

* src/client/Client.js (system): Add import.
  (_cmatch): Now references new Cmatch class instance.
  (_cmatchHidden, _classMatcher): Remove fields.
  (_forceCmatchAction): Rename to `forceCmatchAction'.
  (_hookClassifier, _postProcessCmatch, _cmatchVisFromUi, _handleClassMatch,
    _mergeCmatchHidden, _clearCmatchFields): Extract methods.  Update
    references as necessary.
  (getCmatchData): Remove unused method.
  (_handleError): Rename to `handleError' to make accessible to
    Cmatch.  Update references.
* src/client/ClientDependencyFactory.js (FieldClassMatcher): Remove import.
  (createFieldClassMatcher): Remove method.  See `system/client'.
* src/client/Cmatch.js: New class.
* src/system/client.js (Cmatch, field): Add imports.
  (cmatch): Add export.
2018-02-09 11:20:45 -05:00
Mike Gerwitz cc7370711d Client: Eliminate old event handling system
All of the old events have been removed!

* src/client/Client.js (handleEvent): Remove remainder of old system (after
  last commit, all that was left was error handling).  Correct docblock.
2018-02-08 16:18:46 -05:00
Mike Gerwitz 58533f6d72 Client: Remove unused `reset' event
This event hasn't seen use in ...possibly ever.

* src/client/Client.js (handleEvent): Remove `reset' event.
  Always return `this'.
2018-02-08 16:13:25 -05:00
Mike Gerwitz de578c6e93 ElementStyler: jQuery BC for radios (bugfix)
Of course, the radios are actually checkboxes...radioboxes.

* src/ui/ElementStyler.js (setValueByName): Recognize both jQuery and DOM
  elements.
2018-02-08 09:28:15 -05:00
Mike Gerwitz 943231ee81 ValueSetEventHandler: New handler for `set' event
The `set' event already existed---this merely extracts it into its own
handler.

* src/client/Client.js (handleEvent): Extract `set' handler.
* src/client/ClientDependencyFactory.js (createClientEventHandler): Add
  `set'.
* src/client/event/ValueSetEventHandler.js: New class.
* test/event/ValueSetEventHandlerTest.js: Associated test case.
2018-02-07 14:59:50 -05:00
Mike Gerwitz f5346bef39 ElementStyler: Ignore noyes/radio/legacyradio when DOM element unknown
* src/ui/ElementStyler.js (setValueByName): Ignore `question' if undefined.
2018-02-07 14:57:51 -05:00
Mike Gerwitz 88e32f3c0d Client: Use last available index for `set' action
This matches the behavior of assertions.

This needs to be refactored into an even handler.

* src/client/Client.js (handleEvent)[set]: Use last available index.
2018-02-07 14:21:02 -05:00
Mike Gerwitz 9d0cd5a3f3 ElementStyler: Fix rendering of noyes, radio, legacyradio
* src/ui/ElementStyler.js (setValueByName): Correctly operate on  DOM
  element rather than jQuery object.
2018-02-07 12:02:28 -05:00
Mike Gerwitz 1325dc9a86 ElementStyler: Re-add change_event check as warning
* src/ui/ElementStyler.js (setValueByName)[change_event]: Re-add
  `change_event' check, but as a warning instead of an Error.  This
  shouldn't be used anymore, but let's be certain _without_ breaking
  things.
2018-02-07 12:01:35 -05:00
Mike Gerwitz 51e8c1428f ElementStyler: Remove change_event error
The intent wasn't go have this be permanant, and apparently it _is_ being
used in generated code!

* src/ui/ElementStyler.js (setValueByName): Remove error on `change_event'.
2018-02-06 16:58:58 -05:00
Jeffrey Fisher 9ae544fcbd dapi: Updated correct field index 2018-02-06 15:20:09 -05:00
Mike Gerwitz d0bbc04218 ElementStyler: Remove jQuery for legacyradio value setting
Continued eradication of jQuery for performance reasons.

* src/ui/ElementStyler.js (setValueByName): Do not use jQuery for
  legacyradio styling.  Throw exception on `change_event' argument set (this
  should no longer be used).
2018-02-02 16:55:50 -05:00
Mike Gerwitz fa9ee5d340 ElementStyler: Remove unused `autochange'
This used to be a thing back when we used Dojo, but it doesn't appear to be
used anymore.

* src/ui/ElementStyler.js (setValueByName): Remove `autochange' check.

 Lines starting
2018-02-02 16:43:34 -05:00
Mike Gerwitz 1f6ea234ff StackedGroupUi: New group
* doc/program.texi (Group Styles): Add `stacked' to table.
* src/client/ClientDependencyFactory.js (createGroupUi): Recognize
  `stacked'.
* src/css/base.css (.stack-header): Style stack header.
* src/ui/group/StackedGroupUi.js: New group class.
2018-02-02 14:48:37 -05:00
Mike Gerwitz 799a74d7a1 NaFieldStylerAnimation: Remove trait
These animations are ugly and slow when there are many questions on a
step.  I've wanted them gone for quite some time, and now we don't have a
disagreement among developers.

* src/client/ClientDependencyFactory.js (createNaFieldStyler): Remove
  NaFieldStylerAnimation mixin.
* src/ui/styler/NaFieldStylerAnimation.js: Remove trait.
2018-02-01 14:23:33 -05:00
Mike Gerwitz af7774a272 dapi: Do not perform static additions in invalid response data
* src/dapi/StaticAdditionDataApi.js (request): Do not unshift data if
    `response' is not an array.
2018-01-15 11:03:46 -05:00
Mike Gerwitz 5f3ad6dbf1 client/debug: Append null to bucket editor field change diff
This is necessary to truncate on index removal; otherwise, it's not possible
to remove indexes through the editor.

* src/client/debug/BucketClientDebugTab.js (_getStagingButtons): Append null
    on value change.
2018-01-15 10:53:25 -05:00
Mike Gerwitz 87c4cf50d2 Use {ch=>em} units for CSS (because of IE)
See comments in base.css.

* src/css/base.css: {ch=>em} for all styles.  Matched sizes approximately;
  it doesn't need to be exact.
2017-11-10 10:20:10 -05:00
Mike Gerwitz f7a320b58c Remove paragraph from dev dialog
It lies now.

* src/client/debug/ClientDebugDialog.js (_createDialog): Remove paragraph.  Adjust case
    on keybinding text.
2017-11-08 14:09:06 -05:00
Mike Gerwitz e1db46ad9e Extract dialog styling into new base.css
* src/client/Client.js (createSideBar): Remove width/height, add
    `dialogClass'.
* src/client/debug/BucketClientDebugTab.js
  (showBucketEditor, _genBucketEditorFields): Remove width/height and other
    CSS, add `dialogClass'.
* src/client/debug/ClientDebugDialog.js (_createDialog): Remove
    width/height, add `dialogClass'.
* src/css/base.css: New file.
* src/ui/dialog/DirtyDialog.js (init): Remove size, set type id.
* src/ui/dialog/EmailDialog.js (init): Remove size, set type id.
* src/ui/dialog/ErrorDialog.js (init): Remove size, set type id.
* src/ui/dialog/NotificationDialog.js (init): Remove size, set type id.
* src/ui/dialog/QuoteNavDialog.js (init): Remove size, set type id.
* src/ui/dialog/UiDialog.js
  (showErrorDialog): Remove size.  Remove width param.
  (showNavErrorDialog): Remove size.
  (showQuoteNumberPrompt): Remove size, set type.
2017-11-08 14:09:03 -05:00
Mike Gerwitz 72783a5f35 Add Dialog type id support for CSS styling
* src/ui/dialog/Dialog.js (setTypeId): Add method.
* src/ui/dialog/DialogDecorator.js (setTypeId): Add method.
* src/ui/dialog/JqueryDialog.js (setTypeId): Add method.
2017-11-08 11:19:02 -05:00
Mike Gerwitz c41d0aa924 GeneralStepUi: Do not try to sort one group
An error was being thrown because there are no siblings to reference when
there is only a single group.  Obviously sorting is not even needed in such
a situation.

src/ui/step/GeneralStepUi.js (_sortGroups): Abort if <= 1 groups.
2017-10-23 14:56:51 -04:00
Mike Gerwitz 2baabf5e7e Output correct HTTP server port on start
Was outputting NaN, because the property that was being used no longer
existed after previous changes.

* src/server/daemon/Daemon.js (_initHttpServer): Use HTTP port number
  in output.
2017-09-08 14:19:58 -04:00
Mike Gerwitz 73354e39d0 Fix restoring of document metadata after clearing
Previous to this change, we'd write the clear to the database, but
then immediately after, the quote save would restore it.  Oops.

* src/server/Server.js (_monitorMetadataPromise): Clear data in
    metabucket rather than directly invoking a DB call.  This will be
    applied when the quote is saved.
2017-09-07 15:31:43 -04:00
Mike Gerwitz 68649dfd9b [DEV-2692] [BC-BREAK] Bucket stability and consistency fixes and non-term nulls
This mixes in support for non-terminating nulls.  It would have been
nice to handle that in a separate commit for clarity, but the
refactoring came as a consequence of trying to provide a working
implementation.

Various inconsistencies and subtle bugs in unlikely situations have
been fixed by this, including modifying objects passed as arguments to
various methods, and inconsistent handling of diff data.

Changes are more consistently recognized.  Perhaps the most noticeable
consequence is that moving between steps no longer prompts to discard
changes---previously calculated values would trigger the dirty flag on
steps even if the user didn't actually change anything.  I (and
others) have wanted this fixed for many years.

This is a very dense commit that touches a core part of the
system.  Hopefully the Changelog below helps.

* src/bucket/Bucket.js
  (setValues): [BC-BREAK] Remove parameters `merge_index' and
    `merge_null' parameters.
* src/bucket/DelayedStagingBucket.js
  (setValues): [BC-BREAK] Remove `merge_index' and `merge_null
    parameters.  Remove distinction between `merge_index' and non-.
* src/bucket/QuoteDataBucket.js
  (setValues): [BC-BREAK] Remove `merge_index' and `merge_null
    parameters.  Remove respective arguments from `_mergeData' call.
  (_mergeData): Remove same parameters.  Remove handling of
    `merge_index' and `merge_null'.
  (overwriteValues): Append `null' to each vector.
* src/bucket/StagingBucket.js
  (_initState): Use `Object.create' instead of explicit prototype
    instantiation (functionally equivalent).
  (merge): Minor comment correction.
  (_hasChanged): Rename to `_parseChanges'.
  (_parseChanges): Rename from `_hasChanged'.  Remove `merge_index'
    parameter.  Generate new object rather than mutation original
    data (prevent dangerous and subtle bugs from side-effects).  Clone
    each vector rather than modifying/referencing directly (this was
    previously done during merge).  Remove `merge_index'
    distinction.  Handle non-terminating `null' values.
  (setValues): [BC-BREAK] Remove `merge_index' and `merge_null'
    parameters.  Use new object generated by `_parseChanges'.  Remove
    cloning of each vector (`_parseChanges' now does that).  Remove
    `merge_index' distinction.
  (overwriteValues): Remove argument to `setValues' call.
  (getFilledDiff): [BC-BREAK] Use `_staged' rather than `_curdata'.
  (commit): Remove second and third arguments of call to `setValues'
    of underlying bucket.
* src/client/Client.js
  (_initStepUi): Remove second argument of calls to quote `setData'.
* src/client/quote/ClientQuote.js
  (setData): [BC-BREAK] Remove `merge_nulls' parameter.  Remove second
    and third arguments of call to staging bucket `setValues'.  Add
    comment indicating a long-standing problem with committing the
    staging bucket contents before save has succeeded.
* src/server/request/DataProcessor.js
  (processDiff): Remove `permit_null' argument of `sanitizeDiff'
    call.
  (sanitizeDiff): Remove `permit_null' parameter.  Hard-code filter
    call's `permit_null' argument to `true'.
  (_determineDapiFields): Properly handle `null's (ignore) rather than
    inadvertently converting them into the string "null".
* test/bucket/StagingBucketTest.js: Modify test cases
    accordingly.  Add tests to verify that updates and diffs operate
    as expected, especially support for non-terminating `null's.
  (createStubBucket): Use `QuoteDataBucket'.  Ideally remove this
    coupling in the future, but this is a more realistic test case for
    the time being.
* test/server/request/DataProcessorTest.js: Update test to account for
    hard-coded `given_null' argument.
2017-09-06 09:03:45 -04:00
Mike Gerwitz 8a1ac4781c [DEV-2692] Store cleaned rate response data separately
I'm not sure if this has ever caused real problems, but this was
dangerous.

* src/server/service/RatingService.js (_performRating): Store cleaned
    rating data in separate variable to ensure cleaned data are not
    saved in place of the actual complete response.
2017-09-05 16:26:59 -04:00
Mike Gerwitz 3fa464bc3a Extract bucket init code into ProgramInit
This represents a portion of the refactoring that I had intended to do
until I realized that there was a simpler solution to the problem that
we were having (having proguic add stored calculated values to the
defaults object).

So ideally we'll continue extracting all quote init code out of
`Server' and into `ProgramInit' in the future.

* doc/server.texi (Liza Server): Mention `ProgramInit'.
* src/program/ProgramInit.js: Add class.
* src/server/DocumentServer.js: Use it.
* src/server/Server.js (_progInit): Add private field.
  (__construct): Accept ProgramInit instance and assign to field.
  (initQuote): Use promise returned by `_getDefaultBucket'.
  (_getDefaultBucket): Proxy to `ProgramInit#init', which returns a
    promise.
2017-08-30 11:20:19 -04:00
Mike Gerwitz 445783c256 [BC BREAK] DataApi config lookup
This was a bit involved because the system had to be made async all
the way up the stack.  No attempt was made to clean up the mess up the
stack---no time.

* src/dapi/DataApiFactory.js
  (fromType): [BC BREAK] Fix docblock.  Add `api_name' param.  Call
    `#descLookup' and return promise.
  (descLookup): Add method.  Return promise resolving to provided
    descriptor.  Intended to be overridden by subtype.
* src/dapi/DataApiManager.js
  (_dataApis): Update docblock to indicate that it now stores
    promises.
  (getApiData): Expect promise for `DataApiFactory#fromType' call.
* src/server/DocumentServer.js: (create): [BC BREAK] Accept
    configuration.  Look up dapi conf and pass to
    `ServerDataApiFactory' ctor.  Return promise.
* src/server/daemon/Daemon.js (_initRouters): Provide configuration.
* src/server/daemon/controller.js
  (init): Accept configuration.  Handle return of promise from
    `_createDocumentServer'.
  (_createDocumentServer): Accept configuration, providing to
    `DocumentServer#create'.  Because of aforementioned change to
    `#create', returns promise.
* src/server/request/ServerDataApiFactory.js: Add StoreMissError
    import.
  (_conf): Add property.
  (constructor): [BC BREAK] Accept configuration.
  (descLookup): Add override.  Look up configuration for provided
    dapi.
2017-08-29 15:11:28 -04:00
Mike Gerwitz 985819c31b [BC BREAK] bin/server.js and associated changes
This is based (very) loosely on an internal script to start the
daemon.  It accepts a configuration and starts the daemon.

To accommodate the configuration, a number of miscellaneous changes
have been made.

The vanilla configuration shows the concept, but it has not yet been
fully implemented; that'll likely happen at a later date.  Until then,
the existing environment-variable-based configuration will be used.

* bin/server.js: Add file.
* conf/vanilla-server.json: Example configuration added.
* src/server/daemon/Daemon.js (_httpPort): Remove field.
  (_conf): Add field.
  (__construct): [BC BREAK] Accept conf instead of port and log
    priority.  Move initialization code into `start'.
  (start): [BC BREAK] Initialization code moved here.  Now returns
    promise for entire daemon, which will error in the event of an
    error starting.  Move existing code into `_startDaemon'.
  (_startDaemon): Old `start' code.  Invoked after `start'
    initialization.
  (_createDebugLog, _createAccessLog): Use configuration.  Return
    promise.
  (_initHttpServer): Use configuration.
  (_httpError): Add function to output error and exit.  Extracted from
    `_initHttpServer'.
* src/server/daemon/scripts.js: [BC BREAK] Append "program/" to
    `LV_LEGACY_PATH' so that it can be re-used for script lookups
    rather than using the cwd.  This removes the need of the cwd being
    the legacy src path.
2017-08-29 14:56:10 -04:00
Mike Gerwitz 464a46abf0 Add ConfStore
* src/conf/ConfStore.js: Add file.
2017-08-29 14:34:41 -04:00
Mike Gerwitz 24e8b51745 Add DelimitedKey Store trait
This will make life much easier and less verbose, especially
considering the verbosity of promises.

* src/store/DelimitedKey.js: Add trait.
* test/store/DelimitedKeyTest.js: Add test case.
2017-08-29 14:34:40 -04:00
Mike Gerwitz c857dcb056 Add ConfLoader
* src/conf/ConfLoader.js: Add class.
* test/conf/ConfLoaderTest.js: Respective test case.
2017-08-28 09:07:28 -04:00
Mike Gerwitz dfcca807de Add AutoObjectStore
* src/store/AutoObjectStore.js: Add class.
* test/store/AutoObjectStoreTest.js: Add test case.
2017-08-28 09:07:26 -04:00
Mike Gerwitz edce23f14b Add Store#populate
* src/store/DiffStore.js (populate): Add method.
* src/store/MemoryStore.js (populate): Add method.
* src/store/Store.js (populate): Add abstract method.
* test/store/DiffStoreTest.js: Add populate tests.
* test/store/MemoryStoreTest.js: Add populate tests.
2017-08-24 14:27:01 -04:00
Mike Gerwitz 6a777c3c51 Auto-reconnect to mongo database
I wish I knew this option existed ~7yr ago.  This should have been
done long ago, but we've had so few problems with it, that it had
never been explored.

This [version of this] mongo library is ancient and needs to be
upgraded.  Until then, this'll do.

* src/server/daemon/controller.js (init): Set `auto_reconnect'.
2017-08-22 16:46:47 -04:00
Mike Gerwitz eb8016364c DataProcessor: minor whitespace fix
* src/server/request/DataProcessor.js (_genClearMetaValues): Fix closing method brace indentation.
2017-08-16 08:52:46 -04:00
Mike Gerwitz 0e1cbe7c34 Clear metadata for pending dapi calls
* src/server/Server.js (_monitorMetadataPromise): Save metadata
  immediately after pending dapi requests (to clear in db).
  (handlePost): Pass clear update to _monitorMetadataPromise.

* src/server/request/DataProcessor.js (processDiff): Return meta clear
  update.
  (_triggerDapis): Call _genClearMetaValues and return results to
  caller.
  (_genClearMetaValues): Add method to calculate bucket update.

* test/server/request/DataProcessorTest.js: Update accordingly.
2017-08-15 15:13:22 -04:00
Mike Gerwitz b09d7ecd60 Don't corrupt PHP session if missing session data
`undefined' was inserted into the session if data could not be
retrieved.

* src/server/request/UserSession.js (_appendSessionData): Do not write
  session data if original data cannot be retrieved.
2017-08-15 12:00:41 -04:00
Mike Gerwitz 8cb23711ce Recognize non-changes in posted data server-side
This is a terrible kluge, but time doesn't permit modifying the
system.  All of this also touches old code that is untested, which is
difficult to modify with confidence.

* src/server/DocumentServer.js (DocumentServer#create): Use
  StagingBucket.
* src/server/Server.js: Remove logic now handled by DataProcessor.
* src/server/request/DataProcessor.js (processDiff): Wrap in
  StagingBucket to filter out values that do not result in changes.
* test/server/request/DataProcessorTest.js: Update failing cases.
2017-08-11 13:40:55 -04:00
Mike Gerwitz 1123bccf71 StagingBucket: Better consideration of nulls for change detection
`null` indicates a truncation.

* src/bucket/StagingBucket.js (_length, _deepEqual): Add methods.
  (_hasChanged): Better consider how nulls affect the bucket.
* test/bucket/StagingBucketTest.js: Modify tests accordingly.
2017-08-11 12:03:34 -04:00
Mike Gerwitz 5078c7d8d9 [DEV-2506] StagingBucket: Add ability to prevent bypass
This is a kluge until time can be spent better factoring this
system (using Traits).

* src/bucket/StagingBucket.js (_noStagingBypass): Add field.
  (forbidBypass): Add method to set field.
  (setCommittedValues): Use field.
2017-08-11 11:57:48 -04:00
Mike Gerwitz 12d3b5b8d0 Calc: Add `index' method
* src/calc/Calc.js (index): Add method.
2017-08-10 14:50:18 -04:00
Mike Gerwitz 874a638c43 Calc: Add repeat{,Concat}
* src/calc/Calc.js (repeat, repeatConcat): Add methods.
2017-08-10 14:49:59 -04:00
Mike Gerwitz 5d95d0eb80 Calc: 0-pad ISO dates as necessary
* src/calc/Calc.js (date, relativeDate): 0-pad output.
2017-08-10 14:46:41 -04:00
Mike Gerwitz 642dd8deb3 Calc: Handle null values
`null' is used to represent a truncation in a diff.

* src/calc/Calc.js (_each): Proper null handling.
2017-08-10 14:46:01 -04:00
Mike Gerwitz 9b3ca7a90a Server: Fix botched logging of metadata promise error
* src/server/Server.js (_monitorMetadataPromise): Fix/remove invalid
  references.
2017-08-10 09:52:07 -04:00
Mike Gerwitz c1b6f796fe Add `quote' Data API type
* src/dapi/DataApiFactory.js (_createDataApi): Add support for
  `quote'.
* src/dapi/http/HttpDataApi.js (__construct): New `enctype' argument.
  (_encodeData, _encodeKeys): Remove former, rename latter to former.
  (encodeData, _urlEncode): Encode based on enctype and method.
  (*): Strict mode, es6 style.
2017-08-10 09:52:07 -04:00
Mike Gerwitz d31e12193a Add ResponseApply
* src/dapi/format/ResponseApply.js: Add trait.
* test/dapi/format/ResponseApplyTest.js: Test it.
2017-08-10 09:52:07 -04:00
Mike Gerwitz e2845b72ec RestrictedDataApi#request: Make virtual
This is a bug (as this prohibits mixin overrides).

* src/dapi/RestrictedDataApi.js (#request): Make method virtual.
2017-08-10 09:52:07 -04:00
Mike Gerwitz 020ca01458 HttpDataApi: Only serialize JSON on POST
* src/dapi/http/HttpDataApi.js (_encodeKeys): JSON.stringify on POST.
* test/dapi/http/HttpDataApiTest.js: Update tests accordingly.
  Add POST test.
2017-08-10 09:52:07 -04:00
Mike Gerwitz ae9c293518 DataApi: Update docblock and strict mode
This just updates the file a bit and provides a more specific
docblock (as used in HttpDataApi).

* src/dapi/DataApi.js: strict mode and var=>const.
  (request): Docblock update for params.
2017-08-10 09:52:07 -04:00
Mike Gerwitz 47cb736387 Add QuoteDataApi 2017-08-10 09:52:03 -04:00
Mike Gerwitz 4522525260 DataApi#request data param docblock correction
* src/dapi/DataApi.js (#request): Correct docblock for `data' param.
2017-08-04 11:45:24 -04:00
Mike Gerwitz 39d4e20e92 Add temporary ITableDialog for ColumnLink workaround
I'm still waiting to release GNU ease.js 0.2.9 because I still (after
months) am trying to secure a copyright waiver from my employer.  The
bugs affecting this were fixed back in December!

This works around the issue of traits extending named classes, and
some internal issues with extending constructors defined by the system
for traits.

https://mikegerwitz.com/projects/easejs/commit/?id=e93f3a70f9a699f1577df6ce3ba9201b2ea97542

So, this commit is temporary; revert after 0.2.9.

* src/ui/dialog/ITableDialog.js: Add interface (temporarily).
* src/ui/dialog/ColumnLink.js: Use it.
2017-07-31 10:26:24 -04:00
Mike Gerwitz 5bd6920588 ProcessManager: SIGHUP reinit method call fix
* src/server/rater/ProcessManager.js (init): Fix re-init method
  call (still referenced `exports'; has since been refactored into a
  class).
2017-07-25 16:06:41 -04:00
Mike Gerwitz 229a356a9a Do not convert non-truthy dapi return values to empty string
* src/dapi/DataApiManager.js (getDataExpansion): Explicit undefined
  check before triggering default (empty string).
* test/dapi/DataApiManagerTest.js: Add associated test cases.
2017-07-21 15:20:55 -04:00
Mike Gerwitz deeb5648b0 ProgramQuoteCleaner: Handle case of missing meta field data
* src/server/quote/ProgramQuoteCleaner.js (_fixMeta): `program.meta'
  does not exist on programs compiled previous to the proguic update.
2017-07-14 15:07:08 -04:00
Mike Gerwitz 2eacd310b2 Process metadata and provide to rate process
Prefixes with "meta:".

* src/server/Server.js (initQuote): Initialze metadata to empty.
* src/server/daemon/controller.js (createQuote): Add metabucket.
* src/server/db/MongoServerDao.js (saveQuote): Add additional
  documentation to docblock.  Save all metadata if no bucket data
  provided (which indicates a full quote save).  This happens on
  version change.
* src/server/rater/ProcessManager.js (_genData): Add method to merge
  metadata into bucket data with "meta:" prefix.
  (byId): Use merged data.
2017-07-10 10:09:24 -04:00
Mike Gerwitz 22c3a21cdf ServerSideQuote: Add metabucket
* src/server/quote/ServerSideQuote.js (_metabucket): Add field.
  (getMetabucket, setMetabucket, setMetadata): Add methods.
2017-07-10 10:09:24 -04:00
Mike Gerwitz 37f84b7da8 Initialize metadata on quote version change
Consequently, on quote load as well.

* src/server/quote/ProgramQuoteCleaner.js (_fixMeta): New method.
  (clean): Use it.
2017-07-10 10:09:22 -04:00
Mike Gerwitz e963761d22 DataProcessor {type=>param} docblock correction
I seem to like messing trivial things up.

* src/server/request/DataProcessor.js (constructor): Docblock fix.
2017-07-06 15:06:57 -04:00
Mike Gerwitz 4d22107a57 Create ProcessManager out of rater/service
* src/server/daemon/Daemon.js (__construct): Reference new class.
* src/server/rater/ProcessManager.js: Add class (extracted from
  service).
* src/server/rater/service.js: Refactored into ProcessManager.
2017-07-06 15:06:57 -04:00
Mike Gerwitz 00f457d3d8 DataProcessor code formatting fix (= alignment)
Was bugging the hell out of me.

* src/server/request/DataProcessor.js (constructor): Align `='s.
2017-07-06 15:06:57 -04:00
Mike Gerwitz 7e4d872db2 Rating s/thread/process/ terminology fix
It never was a thread; it's always been a process.

* src/server/rater/thread.js: Renamed.
* src/server/rater/process.js: Renamed from thread.js.
* src/server/rater/service.js: s/thread/process/.
2017-07-06 15:06:55 -04:00
Mike Gerwitz d961a16420 Shorten "unlock quote" string
A bit arbitrary, but it contains text that's coupled to the layout of
the UI, and it usually pushes the button down off of the bar.

* src/client/Client.js (_showLockedNotification): Remove end of
  "unlock quote" string.
2017-07-05 16:01:15 -04:00
Mike Gerwitz 81a829549c Remove accidentally committed console.log on script filename
* src/server/daemon/scripts.js: Remove console.log.
2017-07-05 11:40:27 -04:00
Mike Gerwitz c20fbbeded Rename {Rating=>Calc}Worksheet
The class was renamed, but not the file.  Whoops.

* src/ui/worksheet/CalcWorksheet.js: Rename from RatingWorksheet.js.
* src/ui/worksheet/RatingWorksheet.js: Remove file.
2017-06-29 16:21:48 -04:00
Mike Gerwitz c0d0f4b463 Revert CapturedUserResponse temporarily
This reverts CapturedUserResponse to the state it was in prior to
being extracted into liza.  The issue was supposed to have been
resolved by now, but I haven't wanted to make an ease.js release until
the company that bought the company I work for signs the copyright
waiver.  Which has been slow-going, to say the least.

The problem is that it is not recognizing a named trait extending a
class as a parameterized trait (it's not seeing __mixin).

* src/server/request/CapturedUserResponse.js: Use interface.
* src/server/request/IProtUserResponse.js: Add temporary interface.
2017-06-29 15:57:22 -04:00
Mike Gerwitz 0401860377 Cast value to string before validating
* src/validate/BucketDataValidator.js (_forEach): Cast data to string
  before passing to formatter, which expects a string.
2017-06-29 14:18:01 -04:00
Mike Gerwitz 0c24e3d280 Populate document metadata using Data APIs
What a cluster.

This was a lot of work to work around existing, bad APIs; there is no
time to refactor at the moment; this already took much longer than
expected.
2017-06-28 16:33:24 -04:00
Mike Gerwitz 65ab92f701 Add SpoofedNodeHttpImpl
Session spoofing is needed for making authenticated requests.
2017-06-28 15:51:18 -04:00
Mike Gerwitz d47d77bb5e Add server.meta.DapiMetaSource
Encapsulates the nasty.

* src/server/meta/DapiMetaSource.js: Add class.
* test/server/meta/DapiMetaSourceTest.js: Add test case.
2017-06-28 14:56:28 -04:00
Mike Gerwitz b3f8ed96dd Fix typo in RestrictedDataApi error
* src/dapi/RestrictedDataApi.js (_requestParamCheck): Unknown param
  error typo fix.
2017-06-28 14:56:28 -04:00
Mike Gerwitz 95c28d4db4 Extract Server construction into DocumentServer
* src/server/DocumentServer.js: Add facade.
* src/server/daemon/controller.js: Use it.
2017-06-28 14:56:26 -04:00
Mike Gerwitz 630af0a062 Add ability to provide origin to NodeHttpImpl
* src/dapi/http/NodeHttpImpl.js (_parseUrl): Add method.
  (__construct): Add argument.
  (requestData): Use it.

* test/dapi/http/NodeHttpImplTest.js: Add tests.
2017-06-21 13:55:15 -04:00
Mike Gerwitz a1d5e7d3c5 Instantiate appropriate HttpImpl
* src/dapi/DataApiFactory.js (fromType): Instantiate NodeHttpImpl when
  XMLHttpRequest is undefined.
2017-06-21 10:52:46 -04:00
Mike Gerwitz 624f35a489 XhrHttpImpl: throw {=>Http}Error
* src/dapi/http/XhrHttpImpl.js (serveError): Throw HttpError instead
  of Error.
* test/dapi/http/XhrHttpImplTest.js: Test updated accordingly.
2017-06-21 10:52:46 -04:00
Mike Gerwitz a3e359a050 Add node dapi HTTP implementation
* src/dapi/http/HttpError.js: Add error subtype.
* src/dapi/http/NodeHttpImpl.js: Add node-based HTTP impl.
* test/dapi/http/HttpErrorTest.js: Add test.
* test/dapi/http/NodeHttpImplTest.js: Add test.
2017-06-21 10:52:46 -04:00
Mike Gerwitz 3be28a7858 Re-add missing Server#_sanitizeBucketData return
During liberation, this was accidentally removed...which breaks stuff.

* src/server/Server.js (_sanitizeBucketData): Re-add missing return statement.
2017-06-21 10:52:41 -04:00
Mike Gerwitz 1bb5191e3e LoVullo Associates => R-T Specialty
Copyright notices updated.  More casual references to "LoVullo
Associates" replaced with "RT Specialty / Lovullo", which will be "RT
Specialty Buffalo" in the future.  Or "RT Specialty", depending on how
this is rolled out.  Or "Ryan Specialty Group".  Who knows.

"R-T Specialty, LLC." is the legal name, which includes the dash.  Not
to be confused with a certain television network.
2017-06-08 14:48:43 -04:00
Mike Gerwitz 657573ab63 Near-complete liberation of liza
I have sat on releasing a lot of this code for years because I wanted
the liza repo to be in a pristine state---tests and all---which
required a great deal of refactoring.  Well, that never happened, and
time is up.

LoVullo Associates---my employer---has been purchased by another
company.  This means that any agreement with LoVullo regarding
releasing free software is going to have to be re-negotiated with this
new company, and I have no idea how those negotiations will go.  So,
I have no choice but to simply release everything in its current state,
or risk it being lost forever.

This represents work over the past 6--7 years, 99.9% of it written by
me.  This project has been my baby for quite some time, and has been
through a number of battles with deadlines and other unfortunate
circumstances; the scars show.  I also didn't really "know" JS when
starting this project.  Perhaps you can help improve upon it.

There are some odds-and-ends that could be committed.  And references
to insurance and LoVullo need to be removed to generalize this.

I hope that this will not be the last public commit for this project.
I'll fight the good fight and we'll see where that takes us.  Maybe
it'll be easy.

Happy hacking.
2017-06-08 14:38:28 -04:00
Mike Gerwitz 7567306123 FieldStyler: Remove classes not added by #addClass
This code assumed that no classes would be removed that were _not_
added by #addClass.  Well, that's false.

* src/ui/styler/FieldStyler.js (removeClass): Consider both spaces and
  boundary preceding class name.

* test/ui/styler/FieldStylerTest.js: Add test case.
2017-03-17 14:11:16 -04:00
Mike Gerwitz 6bba4322bf ValidStateMonitor: Consider scalar diff to affect all indexes
Classifications often yield scalar results.  Since those results are
used directly in the diff, we have the situation where the expected
diff format (an array) is not provided.  Consistent with the rest of
the system, we should consider a scalar to affect every index.

* src/validate/ValidStateMonitor.js (_checkCauseFix): Consider scalar
    diffs to affect every index when checking for fixes.
* test/validate/ValidStateMonitorTest.js: Add test.
2017-03-17 11:17:42 -04:00
Mike Gerwitz 6908e62206 Client: clear validation errors on dapi fieldLoaded
Previously, the system relied on the preStagingUpdate StagingBucket
event to do this implicitly, but that is no longer kicked off when
the diff doesn't produce any bucket changes.

* src/client/Client.js (_createProgram) [dapi]: Clear validation
  failures on dapi fieldLoaded.
2017-02-22 09:54:03 -05:00
Mike Gerwitz 45889f556f DataApiManager: emit fieldLoaded after request completes
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
2017-02-22 09:53:59 -05:00
Mike Gerwitz 2ac393070a DataValidator: properly chain queue
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.
2017-02-21 16:21:18 -05:00
Mike Gerwitz 62996102a8 StagingBucket: Use strict mode (and fix accidental globals)
This fixes accidental global variables and enables strict mode to
prevent it in the future.

* src/bucket/StagingBucket.js: Enable strict mode.  Use const/let where
    appropriate instead of var.
2017-02-20 12:16:49 -05:00
Mike Gerwitz c5194b4ec5 StagingBucket: Do not process non-changes
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
2017-02-20 12:16:24 -05:00
Mike Gerwitz 4f7654c7c4 Liberate numerous bucket classes
* src/bucket/DelayedStagingBucket.js: Add class.
* src/bucket/QuoteDataBucket.js: Add class.
* src/bucket/StagingBucket.js: Add class.
* src/bucket/StagingBucketAutoDiscard.js: Add class.
* src/client/ClientDependencyFactory.js: Add class.
2017-02-17 15:14:17 -05:00
Mike Gerwitz ac7ec6c5f2 DataValidator: Hold concurrent requests
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.
2017-02-17 11:31:32 -05:00
Mike Gerwitz eefd268abf Revert "DataValidator: Always clear store state"
This breaks everything. :x

This reverts commit e0c2e4dc86, reversing
changes made to e610372c84.
2017-02-16 16:49:29 -05:00
Mike Gerwitz 71024bd389 DataValidator: Queue validations when incomplete
* src/validate/DataValidator.js (validate): If a validation is
    ongoing, queue requests.

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

DEV-2299
2017-02-16 12:37:46 -05:00
Mike Gerwitz d99d1e3bed Program UI testing library 2017-02-16 09:12:44 -05:00
Mike Gerwitz 5f36d9272f Testing utilities for stubbing Program
This allows for testing assertions.  It's fairly primitive, but will
work for the time being.

* src/test/README: Add file.
* src/test/program/DummyClassifier.js: Add module.
* src/test/program/Program.js: Add class.
* src/test/program/util.js: Add module.
2017-02-15 14:19:33 -05:00
Mike Gerwitz 3b1df602e1 DataValidator: Always clear store state
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
2017-02-13 15:07:26 -05:00
Mike Gerwitz cc79f8e1f3 FieldVisibilityEventHandler: use new DataValidator API
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.
2017-02-09 15:20:23 -05:00
Mike Gerwitz 028606242a Integrate field visibility event handler
* src/client/Client.js
  (_hideField): Remove method (extracted into
    FieldVisibilityEventHandler).
  (handleEvent): Remove show/hide handling.
  (_handleClassMatch): Adjust to new class/API.

* src/client/ClientDependencyFactory.js
  (createClientEventHandler): Add show/hide event handlers.
2017-02-08 11:24:56 -05:00
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 e7700e8b69 Liberate ClientDebug classes
This is a separate program of sorts that sits alongside and hooks the
Client.

* src/client/debug/AssertionClientDebugTab.js: Add class.
* src/client/debug/BucketClientDebugTab.js: Add class.
* src/client/debug/CalcClientDebugTab.js: Add class.
* src/client/debug/ClassifyClientDebugTab.js: Add class.
* src/client/debug/ClientDebug.js: Add class.
* src/client/debug/ClientDebugDialog.js: Add class.
* src/client/debug/ClientDebugTab.js: Add interface.
2017-02-08 11:24:56 -05:00
Mike Gerwitz dd7c2760f4 Client: Extract from internal repo
This thing is an ugly monstrosity that has witheld some pretty rough
development times.  As code is touched, it is being removed.

This depends on many things not yet in the liza repo; they'll be added
in time.

These classes were changed slightly to work within liza (e.g. paths).

* src/client/Client.js: Extract from rating-fw
  as of 5d4019f1973f9271f4b1bd24ce1f55b56ccda09e.

* src/client/ClientDependencyFactory.js: Extract from rating-fw
  as of 5d4019f1973f9271f4b1bd24ce1f55b56ccda09e.
2017-02-07 15:38:33 -05:00
Mike Gerwitz a65f568714 UnknownEventError: use ease.js
ease.js supports Error extending now.

* src/event/UnknownEventError.js: Use easejs.
2017-02-06 16:12:26 -05:00
Mike Gerwitz bd81e2e726 Liberate event handlers
These are extracted from rating-fw commit
5d4019f1973f9271f4b1bd24ce1f55b56ccda09e.
2017-02-06 16:12:26 -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 3289e42003 Update MemoryStore syntax to ES6
`#reduce` is much better.

* src/store/MemoryStore.js: Update syntax.

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 29fb75d1a3 ES6-ify ValidStateMonitor
This also helps to demonstrate how the more concise syntax improves
readability.

* src/validate/ValidStateMonitor.js: Syntax to ES6.

DEV-2296
2017-01-29 22:44:35 -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 c8d77085ec Make BucketDataValidator public methods virtual
This class is terribly factored and not tested.

* src/validate/BucketDataValidator.js
  (validate,format): Make methods virtual.

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 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 e883c45e35 Add Currency formatter
* src/validate/formatter/Currency.js: Add class.
2016-12-01 12:44:09 -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 14711cd4c6 Correct Number formatter docblock
* src/validate/formatter/Number.js: Correct trait docblock.
2016-11-28 14:01:09 -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 66f78c8886 Accept jQuery in GeneralStepUi
This defaults to the global jQuery just so we don't break
everything (BC); that'll be removed in the future.

* src/ui/step/GeneralStepUi.js (__construct): Accept jQuery.
  (setContent): Use jQuery instance passed via ctor
2016-08-05 11:41:27 -04:00
Mike Gerwitz 72f29a9734 Corrected GeneralStepUi class name
* src/ui/step/GeneralStepUi.js: Class name {=>General}StepUi
2016-07-28 16:25:47 -04:00
Mike Gerwitz 8d68880712 Remove multitext answer styler
This can now be handled with the existing formatters, specifically the
MultiDimension trait.  Specifically, multitext simply handled the
styling of vectors.

* src/ui/ElementStyler.js (_answerStylers): Remove multilimit
2016-07-20 15:23:35 -04:00