AbstractCrudManagerMixin
Mixin
Abstract
An abstract mixin that supplies most of the CrudManager functionality. It implements basic mechanisms of collecting stores to organize batch communication with a server. It does not contain methods related to data transfer nor encoding. These methods are to be provided in sub-classes. Out of the box there are mixins implementing support of AJAX for data transferring and JSON for data encoding system. For example this is how we make a model that will implement CrudManager protocol and use AJAX/JSON to pass the data to the server:
class SystemSettings extends JsonEncode(AjaxTransport(AbstractCrudManagerMixin(Model))) {
...
}
Data transfer and encoding methods
These are methods that must be provided by subclasses of this class:
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
trueto automatically persist store changes after edits are made in any of the stores monitored. Please note that sync request will not be invoked immediately but only after autoSyncTimeout interval. -
The timeout in milliseconds to wait before persisting changes to the server. Used when autoSync is set to
true. -
Specify as
trueto force sync requests to be sent when callingsync(), even if there are no local changes. Useful in a polling scenario, to keep client up to date with the backend.Has a corresponding runtime forceSync property.
-
Set to
trueto make STM ignore changes coming from the backend. This will allow user to only undo redo local changes.Has a corresponding runtime ignoreRemoteChangesInSTM property.
-
Field name to be used to transfer a phantom record identifier.
-
Field name to be used to transfer a phantom parent record identifier.
-
Trueto reset identifiers (defined byidFieldconfig) of phantom records before submitting them to the server. -
When
trueforces the CRUD manager to process responses depending on theirtypeattribute. Soloadrequest may be responded withsyncresponse for example. Can be used for smart server logic allowing the server to decide when it's better to respond with a complete data set (loadresponse) or it's enough to return just a delta (syncresponse). -
trueto write all fields from the record to the server. If set tofalseit will only send the fields that were modified. Note that any fields that have persist set tofalsewill still be ignored and fields having alwaysWrite set totruewill always be included.
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of AbstractCrudManagerMixin class, or subclass thereof.
-
Returns the data from all CrudManager
crudStoresin a format that can be consumed byinlineData. -
A list of registered stores whose server communication will be collected into a single batch. Each store is represented by a store descriptor.
Has a corresponding crudStores config.
-
Specify as
trueto force sync requests to be sent when callingsync(), even if there are no local changes. Useful in a polling scenario, to keep client up to date with the backend.Has a corresponding forceSync config.
-
Set to
trueto make STM ignore changes coming from the backend. This will allow user to only undo redo local changes.Has a corresponding ignoreRemoteChangesInSTM config.
-
Returns
trueif changes tracking is suspended -
Returns true if the crud manager is currently loading data
-
Returns true if the crud manager is currently syncing data
-
Generates unique request identifier.
-
An array of stores presenting an alternative sync responses apply order. Each store is represented by a store descriptor.
Has a corresponding syncApplySequence config.
-
Identifies an object as an instance of AbstractCrudManagerMixin class, or subclass thereof.
Functions
Functions are methods available for calling on the class-
Accepts all changes in all stores, resets the modification tracking:
- Clears change tracking for all records
- Clears added
- Clears modified
- Clears removed Leaves the store in an "unmodified" state.
-
doDestroy( )internal
Removes all stores and cancels active requests.
-
Reverts all changes in all stores and re-inserts any records that were removed locally. Any new uncommitted records will be removed.
-
Suspends automatic sync upon store changes. Can be called multiple times (it uses an internal counter).
-
Suspends hasChanges and noChanges events.