1
0
Fork 0
Commit Graph

240 Commits (c33adee21d9812ec131fb4e7b2bf34f93b505285)

Author SHA1 Message Date
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