attachments¶
Represents the link between an object (ex: Message, Idea) and a remote (url) or eventually local document attached to it.
-
class
AttachmentCollection
()¶ Attachements collection
- Extends
app.models.base.BaseCollection()
-
AttachmentCollection.
comparator
()¶ Compares dates between 2 documents
- Return type
Number
-
AttachmentCollection.
destroy
(models, options)¶ Helper method to destroy the models in a collection
- Arguments
models (Array|Backbone.Model) – Model or Array of models
options (Object) – Options hash to send to every model when destroyed
- Returns
if model was persisted, returns jqXhr else false
- Return type
Promse
-
AttachmentCollection.
destroyAll
(options)¶ Destroy the collection
- Arguments
options (Object) –
- Return type
jqXHR
-
AttachmentCollection.
initialize
()¶
-
AttachmentCollection.
save
(models, options)¶ Save models into database
- Arguments
models (Object) –
options (Object) –
- Return type
Promise
-
AttachmentCollection.
saveAll
(options)¶ Save models into database
- Arguments
options (Object) –
- Return type
jqXHR
-
AttachmentCollection.
url
()¶ Returns api url dedicated to attachments
- Return type
String
-
class
AttachmentModel
()¶ Attachement model Frontend model for
assembl.models.attachment.Attachment
- Extends
app.models.base.BaseModel()
-
AttachmentModel.
_saveMe
(attrs, options)¶ Set the id of the model attachment and save the model into database
- Arguments
attrs (Object) –
options (Object) –
- Return type
jqXHR
-
AttachmentModel.
destroy
()¶ Destroys or removes the document from the server by using the Backbone.sync method which delegates the HTTP “delete” request.
-
AttachmentModel.
getCreationDate
()¶ Returns the creation date of the attachment
- Return type
Moment
-
AttachmentModel.
getDocument
()¶ Returns the document attributes from the model
- Return type
Object
-
AttachmentModel.
isFailed
()¶ Returns if the model is unsavable.
- Return type
Boolean
-
AttachmentModel.
parse
()¶ Returns the model of the attachment according to its type (document or file)
- Return type
BaseModel
-
AttachmentModel.
save
(attrs, options)¶ Save the attachment
Update The architecture to load attachments + documents has now changed. Documents are eagerly saved to the database upon creation. The AttachmentView is responsible for the lifecycle of the document model. As a result, the attachment model save should no longer do a two-step save process. It is only responsible for saving itself.
- Arguments
attrs (Object) –
options (Object) –
-
AttachmentModel.
setFailed
()¶ Utility function. Makes the model unsavable.
-
AttachmentModel.
sync
(method, model, options)¶ This method uses a switch according to a CRUD operation Default: Used to persist the state of the model to the server. Update: It does nothing Create: Set the type attribute to the model
- Arguments
method (String) – update/create/read/delete methods
model (BaseModel) – the model to be save
options (Object) – It fires success or error message
-
AttachmentModel.
toJSON
(options)¶ Return a copy of the model’s attributes for JSON stringification. Override toJSON of the attachment model in order to ensure that backbone does NOT try to parse the an object that causes recursive read, as there is a message object which contains the attachment model.
- Arguments
options (Object) –
- Return type
Object
-
AttachmentModel.
urlRoot
()¶ Returns api url dedicated to attachments
- Return type
String
-
AttachmentModel.
validate
()¶ Returns an error message if one of those attributes (objectAttachedToModel, document, idCreator) is missing
- Return type
String