/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

Methods

(inner) docLoad(e, entry)

The docLoad method handles the upload of document files to via signed URL to cloudinary.

Parameters:
NameTypeDescription
eevent
entryObject

(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.

Parameters:
NameTypeDescription
entryObject
Returns:

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.

Parameters:
NameTypeDescription
entryObject
paramsObject
Properties
NameTypeAttributesDescription
entry.cloudinary_folderstring
params.public_idstring
params.destroyboolean<optional>

The request is to detroy a stored resource.

Returns:

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.

Parameters:
NameTypeDescription
entryObject
Properties
NameTypeDescription
entry.valuestring

An existing cloudinary resource URL.

entry.editObject

The entry is editable.

Returns:

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.

Parameters:
NameTypeDescription
entryObject
Properties
NameTypeDescription
entry.valueArray

An array of existing cloudinary resource URLs.

entry.editObject

The entry is editable.

Returns:

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.

Parameters:
NameTypeDescription
imgimage

The image element to upload.

entryobject
Properties
NameTypeAttributesDefaultDescription
entry.max_sizeinteger<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.

Parameters:
NameTypeDescription
eevent
entryObject

(inner) trash(e, entry)

The trash function handles the deletion an image file.

Parameters:
NameTypeDescription
eevent
entryObject

(inner) updateLocation(entry)

The method disables the location view before updating the location data and re-creating the cloudinary entry.type interface.

Parameters:
NameTypeDescription
entryObject
Properties
NameTypeDescription
entry.nodeHTMLElement

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.

Parameters:
NameTypeDescription
eevent

The onchange event from the input element to select a resource.

entryObject