new EntityModel()
Extends
Members
(static) states :Array.<string>
Sequence of all possible states an entity can be in during quickediting.
Type:
- Array.<string>
defaults :object
Type:
- object
el :HTMLElement
The DOM element that represents this entity.
It may seem bizarre to have a DOM element in a Backbone Model, but we need to be able to map entities in the DOM to EntityModels in memory.
Type:
- HTMLElement
entityID :string
An entity ID, of the form <entity type>/<entity ID>
Type:
- string
Example
"node/1"
entityInstanceID :number
An entity instance ID.
The first instance of a specific entity (i.e. with a given entity ID) is assigned 0, the second 1, and so on.
Type:
- number
fields :Drupal.quickedit.FieldCollection
A FieldCollection for all fields of the entity.
Type:
- Source:
- See:
fieldsInTempStore :Array.<string>
IDs of fields whose new values have been stored in PrivateTempStore.
We must store this on the EntityModel as well (even though it already is on the FieldModel) because when a field is rerendered, its FieldModel is destroyed and this allows us to transition it back to the proper state.
Type:
- Array.<string>
id :string
The unique ID of this entity instance on the page, of the form
<entity type>/<entity ID>[entity instance ID]
Type:
- string
Example
"node/1[0]"
inTempStore :bool
Whether one or more fields are already been stored in PrivateTempStore.
Type:
- bool
isActive :bool
Indicates whether this entity is currently being edited in-place.
Type:
- bool
isCommitting :bool
Whether the request to the server has been made to commit this entity.
Used to prevent multiple such requests.
Type:
- bool
isDirty :bool
Indicates whether a "Save" button is necessary or not.
Whether one or more fields have already been stored in PrivateTempStore or the field that's currently being edited is in the 'changed' or a later state.
Type:
- bool
label :string
The label of the entity.
Type:
- string
reload :bool
A flag the tells the application that this EntityModel must be reloaded in order to restore the original values to its fields in the client.
Type:
- bool
state :string
The current processing state of an entity.
Type:
- string
Methods
(static) followsStateSequence(from, to) → {bool}
Indicates whether the 'from' state comes before the 'to' state.
Parameters:
Name | Type | Description |
---|---|---|
from |
string | |
to |
string |
Returns:
Whether the 'from' state comes before the 'to' state.
- Type
- bool
_acceptStateChange(from, to, context) → {bool}
Checks if a state change can be accepted.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
from |
string | From state. |
|||||||||
to |
string | To state. |
|||||||||
context |
object | Context for the check. Properties
|
- Source:
- See:
Returns:
Whether the state change is accepted or not.
- Type
- bool
_fieldsHaveAcceptableStates(acceptedFieldStates) → {bool}
Checks if fields have acceptable states.
Parameters:
Name | Type | Description |
---|---|---|
acceptedFieldStates |
Array | An array of acceptable field states to check for. |
- Source:
- See:
Returns:
Whether the fields have an acceptable state.
- Type
- bool
_updateInTempStoreAttributes(entityModel, fieldModel)
Updates a Field and Entity model's "inTempStore" when appropriate.
Helper function.
Parameters:
Name | Type | Description |
---|---|---|
entityModel |
Drupal.quickedit.EntityModel | The model of the entity for which a field's state attribute has changed. |
fieldModel |
Drupal.quickedit.FieldModel | The model of the field whose state attribute has changed. |
- Source:
- See:
destroy(options)
Destroys the entity model.
Parameters:
Name | Type | Description |
---|---|---|
options |
object | Options for the entity model. |
fieldStateChange(fieldModel, state)
Reacts to state changes in this entity's fields.
Parameters:
Name | Type | Description |
---|---|---|
fieldModel |
Drupal.quickedit.FieldModel | The model of the field whose state attribute changed. |
state |
string | The state of the associated field. One of
|
save(options)
Fires an AJAX request to the REST save URL for an entity.
Parameters:
Name | Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
options |
object | An object of options that contains: Properties
|
set(key, val, optionsopt) → {*}
Set a value on the model
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
key |
object | string | The key to set a value for. |
|
val |
* | The value to set. |
|
options |
object |
<optional> |
Options for the model. |
- Inherited From:
- Source:
Returns:
The result of Backbone.Model.prototype.set
with the specified
parameters.
- Type
- *
stateChange(entityModel, state, options)
Updates FieldModels' states when an EntityModel change occurs.
Parameters:
Name | Type | Description |
---|---|---|
entityModel |
Drupal.quickedit.EntityModel | The entity model |
state |
string | The state of the associated entity. One of
|
options |
object | Options for the entity model. |
sync()
{@inheritdoc}
validate(attrs, options) → {string}
Validate the entity model.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
attrs |
object | The attributes changes in the save or set call. |
||||||||||||
options |
object | An object with the following option: Properties
|
Returns:
A string to say something about the state of the entity model.
- Type
- string