Constructor
new EMLAttributes()
- Since:
- Source:
Extends
Members
model
- Source:
Methods
addAttribute(attributes, options) → {EMLAttribute}
Add an attribute to the collection
Parameters:
Name |
Type |
Description |
attributes |
object
|
The model attributes of the new EML
attribute, optional. May include the parentModel |
options |
object
|
Options to pass to the add method |
- Source:
Returns:
The newly added attribute
-
Type
-
EMLAttribute
addNewAttribute(parentModel) → {EMLAttribute}
Add a new attribute to the collection. Only allows one new attribute
to be added at a time. Returns the existing new attribute if one is
already present.
Parameters:
Name |
Type |
Description |
parentModel |
EMLEntity
|
The model that contains this
collection, optional |
- Source:
Returns:
The newly added attribute model
-
Type
-
EMLAttribute
comparator(model) → {number}
Ensure new models are always at the end of the collection.
Parameters:
Name |
Type |
Description |
model |
EMLAttribute
|
The model to compare |
- Source:
Returns:
A value greater than 0 if the model is new, 0
otherwise
-
Type
-
number
Find the first attribute in the collection that is marked as new
- Source:
Returns:
The new attribute model or null if none found
-
Type
-
EMLAttribute
getParentModel() → {EMLEntity}
Get the model that contains this collection. Searches through all of
the attributes in the collection to find the one that has the
parentModel set.
- Source:
Returns:
The model that contains this collection or null if
no parent model is found
-
Type
-
EMLEntity
hasNonEmptyAttributes() → {boolean}
Check that the collection has at least one attribute that has data.
- Source:
Returns:
True if the collection has at least one attribute
that is not empty, false otherwise
-
Type
-
boolean
isValid() → {boolean}
Check if the collection is valid. If not, set the validationError
property to the validation errors.
- Source:
Returns:
True if the collection is valid, false otherwise
-
Type
-
boolean
parse()
- Source:
removeEmptyAttributes() → {Array.<EMLAttribute>}
Remove all attributes that are empty
- Source:
Returns:
The removed attributes
-
Type
-
Array.<EMLAttribute>
serialize() → {string}
Serialize the collection of attributes to an XML string
- Source:
Returns:
The XML string representing the collection of
attributes
-
Type
-
string
updateDOM(currentDOM) → {object}
Update the XML DOM object with the collection's attributes
Parameters:
Name |
Type |
Description |
currentDOM |
HTMLElement
|
The current XML DOM object
representing the collection of attributes. If not provided, a new XML
DOM object will be created. |
- Source:
Returns:
The updated XML DOM object
-
Type
-
object
updateNames(names, parentModel, options)
Given an array of strings, update the names of the attributes in the
collection to match the array. If the number of names in the array
exceeds the number of attributes in the collection, new attributes will
be added to the collection. If the number of names is less than the
number of attributes in the collection, the extra attributes will be
removed.
Parameters:
Name |
Type |
Description |
names |
Array.<string>
|
An array of new attribute names |
parentModel |
EMLEntity
|
The model that contains this
collection |
options |
object
|
Options to pass to the add, remove, and set
methods |
- Source:
validate()
- Source: