Data representation

The data stored in instances of CisModel uses an internal system representation, not a localized representation. This means code that manipulates the model is unaware of the user's locale and display preferences. For instance, date values are always stored using the ISO 8601 string representation YYYY-MM-DD, and numbers are always stored as strings, not JavaScript numbers (because the required precision may exceed that of JavaScript's native number type).

The data takes the form of a tree of data nodes of two classes, DataElement (the singleton node class holding data attributes as JavaScript properties), and List, which manages an array of DataElement instances. Every list has a unique name property, regardless of its position in the tree (e.g. independent of nesting depth), making it possible to uniquely identify and retrieve any list by its name. The DataElement instances each keep a "dirty" flag to mark whether the user modified any properties, representing work that needs to be persisted to the database.

Every element instance is always in one of three logical states:

Persistent

New/Dirty

New/Clean (e.g. a "phantom")

Phantom elements are used to populate otherwise empty lists, to give a starting point in which to enter data. Unlike other new objects, phantoms are initially clean so they don't participate in persistence operations until explicitly modified.

Many CisModel methods act as starting points for recursive implementation through the data tree, and methods with the same or similar names are available on the DataElement class.