/ui/locations/entries/cloudinary
The cloudinary module exports a method to upload or destroy resources with signed requests on cloudinary.
The exported method creates an interface in the location view with input for images and documents.
Requires
- module:/utils/xhr
- module:/utils/imagePreview
Methods
(inner) docLoad(e, entry)
The docLoad method handles the upload of document files to via signed URL to cloudinary.
Name | Type | Description |
---|---|---|
e | event | |
entry | Object |
(inner) documents(entry) → {HTMLElement}
The documents entry.type function returns an document-list element of documents with the ability to destroy resources if the entry is editable. An input is show to upload additional documents if the entry is editable.
Name | Type | Description |
---|---|---|
entry | Object |
A list element with existing documents and an input to upload additional documents on editable entry.
- Type:
- HTMLElement
(async, inner) getSignedUrl(entry, params) → {Promise.<String>}
Signs a parameterised request to upload or destroy a resource on cloudinary.
Name | Type | Description |
---|---|---|
entry | Object | |
params | Object |
Name | Type | Attributes | Description |
---|---|---|---|
entry.cloudinary_folder | string | ||
params.public_id | string | ||
params.destroy | boolean | <optional> | The request is to detroy a stored resource. |
signedURL
- Type:
- Promise.<String>
(inner) image(entry) → {HTMLElement}
The image entry.type function returns an image with a button to detroy the image the entry has a value and is editable.
Name | Type | Description |
---|---|---|
entry | Object |
Name | Type | Description |
---|---|---|
entry.value | string | An existing cloudinary resource URL. |
entry.edit | Object | The entry is editable. |
Returns either an image element or an input element to upload an image.
- Type:
- HTMLElement
(inner) images(entry) → {HTMLElement}
The images entry.type function returns an image-grid element of images with the ability to destroy resources if the entry is editable. An input is show to upload additional images if the entry is editable.
Name | Type | Description |
---|---|---|
entry | Object |
Name | Type | Description |
---|---|---|
entry.value | Array | An array of existing cloudinary resource URLs. |
entry.edit | Object | The entry is editable. |
A grid element with existing images and an input to upload additional images on editable entry.
- Type:
- HTMLElement
(inner) imgOnload(img, entry)
The onload method of the image element will create a canvas element and apply a size transformation in regards to the max_size entry property.
A signeUrl will be requested to upload a dataURL for the canvas to the cloudinary service.
A successful cloudinary upload will respond with an item reference for the cloudinary resource.
The updateLocation method is called to store the item reference to the location [entry] field.
Name | Type | Description |
---|---|---|
img | image | The image element to upload. |
entry | object |
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
entry.max_size | integer | <optional> | 1024 | The default max_size applied to image size transformation. |
(inner) newImage(e, entry)
The method creates a new Image object with the event target result as source. The imgOnload method is assigned as image onload.
Name | Type | Description |
---|---|---|
e | event | |
entry | Object |
(inner) trash(e, entry)
The trash function handles the deletion an image file.
Name | Type | Description |
---|---|---|
e | event | |
entry | Object |
(inner) updateLocation(entry)
The method disables the location view before updating the location data and re-creating the cloudinary entry.type interface.
Name | Type | Description |
---|---|---|
entry | Object |
Name | Type | Description |
---|---|---|
entry.node | HTMLElement | The location view element which holds the cloudinary interface elements. |
(inner) upload(e, entry)
The upload event can be assigned to the onchange event of an input to upload the resource selected in the input element.
Name | Type | Description |
---|---|---|
e | event | The onchange event from the input element to select a resource. |
entry | Object |