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 }}"
}
}
]
}
Properties
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.
|
Declaration
public assetType: AssetType
Property Value
Declaration
public entriesFilter: Function
Property Value
Type |
Description |
Function |
|
Declaration
Property Value
Declaration
public folderFilter: Function
Property Value
Type |
Description |
Function |
|
Parameters of the widget.
Declaration
public params: IAuWidgetAssetStorageAjaxConfig
Property Value
Declaration
public previewOptions: IPreviewOptions
Property Value
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 }}"
|
Declaration
public response: Array<IAssetDataResult> = []
Property Value
Declaration
static HTMLTemplateElement template
Property Value
Type |
Description |
HTMLTemplateElement |
|
Methods
Returns an array of widget names, due to which the current widget cannot receive parameters.
Declaration
function checkInitDependenciesWidgets()
Returns
Type |
Description |
string[] |
|
Declaration
function exportWidgetData(force: boolean)
Parameters
Type |
Name |
Description |
boolean |
force |
|
Returns
Type |
Description |
Promise<AssetStorageAjaxWidgetData> |
|
Declaration
function resetPreloaderState()
Declaration
function restoreWidgetFromData(widgetData: AssetStorageAjaxWidgetData, force: boolean)
Parameters
Type |
Name |
Description |
AssetStorageAjaxWidgetData |
widgetData |
|
boolean |
force |
|
Returns
Type |
Description |
Promise<void> |
|
Declaration
function showPreloader(isShow: boolean)
Parameters
Type |
Name |
Description |
boolean |
isShow |
If true , enables the preloader.
|
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.
|