Back to Website
Show / Hide Table of Contents

Class AuWidgetAssetStorageAjax

A non-visual widget that is used to send requests to the server and receive responses, which can be used in other widgets. The following example illustrates how you can populate a gallery with images obtained through an HTTP request.

{
  "widgets": [
   {
     "name": "bg-request",
     "type": "asset-storage-ajax",
     "params": {
          "autoCompile": false,
          "assetType": "designs",
          "folder": "",
          "entriesFilter": [
              "{{ #function(asset) asset.metadata.surfaces[0].width > 100 }}"
          ],
          "previewOptions": {
              "name": "medium",
              "namespace": "storefront",
              "width": 600,
              "height": 600
          }
     }
   },
   {
     "name": "gallery",
     "title": "Gallery",
     "type": "gallery",
     "params": {
       "prompt": "Set a background",
       "showTitle": false,
       "forceSelection": true,
       "items": "{{ $['bg-request'].response }}"
     }
   }
 ]
}
Package: ui-framework

Properties

apiResponse

A server response, interpreted based on the responseType param. If autoCompile is true, it is automatically updated every time the widget gets a server response.

Declaration
public apiResponse: AssetStorageApiClientResult
Property Value
Type Description
AssetStorageApiClientResult

A server response, interpreted based on the responseType param. If autoCompile is true, it is automatically updated every time the widget gets a server response.

assetType

Declaration
public assetType: AssetType
Property Value
Type Description
AssetType

entriesFilter

Declaration
public entriesFilter: Function
Property Value
Type Description
Function

folder

Declaration
public folder: string
Property Value
Type Description
string

folderFilter

Declaration
public folderFilter: Function
Property Value
Type Description
Function

params

Parameters of the widget.

Declaration
public params: IAuWidgetAssetStorageAjaxConfig
Property Value
Type Description
IAuWidgetAssetStorageAjaxConfig

Parameters of the widget.

previewOptions

Declaration
public previewOptions: IPreviewOptions
Property Value
Type Description
IPreviewOptions

requestPromise

Promise, for awaiting in #function for getting response.

"{{ #function $['image-request'].compile() }}",
"{{ #asyncFunction await $['image-request'].requestPromise }}"
Declaration
public requestPromise: Promise<any> = Promise.resolve()
Property Value
Type Description
Promise<any>

Promise, for awaiting in #function for getting response.

"{{ #function $['image-request'].compile() }}",
"{{ #asyncFunction await $['image-request'].requestPromise }}"

response

Declaration
public response: Array<IAssetDataResult> = []
Property Value
Type Description
Array<IAssetDataResult>

template

Declaration
static HTMLTemplateElement template
Property Value
Type Description
HTMLTemplateElement

Methods

checkInitDependenciesWidgets()

Returns an array of widget names, due to which the current widget cannot receive parameters.

Declaration
function checkInitDependenciesWidgets()
Returns
Type Description
string[]

exportWidgetData(boolean)

Declaration
function exportWidgetData(force: boolean)
Parameters
Type Name Description
boolean force
Returns
Type Description
Promise<AssetStorageAjaxWidgetData>

resetPreloaderState()

Declaration
function resetPreloaderState()

restoreWidgetFromData(AssetStorageAjaxWidgetData, boolean)

Declaration
function restoreWidgetFromData(widgetData: AssetStorageAjaxWidgetData, force: boolean)
Parameters
Type Name Description
AssetStorageAjaxWidgetData widgetData
boolean force
Returns
Type Description
Promise<void>

showPreloader(boolean)

Shows a preloader.

Declaration
function showPreloader(isShow: boolean)
Parameters
Type Name Description
boolean isShow

If true, enables the preloader.

showToast(string, number)

Shows a toast.

return editor.loadUserInfo(data)
    .catch(err => {
        this.widget.showToast("Error: Invalid data");
        console.log(err);
    });
Declaration
function showToast(data?: string, duration?: number)
Parameters
Type Name Description
string data

A string message to display in the toast.

number duration

Defines how long to show the toast for.

Was this page helpful?
Thanks for your feedback!
Back to top Copyright © 2001–2024 Aurigma, Inc. All rights reserved.
Loading...
    Thank for your vote
    Your opinion is important to us. To provide details, send feedback.
    Send feedback