au-widget-asset-storage-ajax/au-widget-asset-storage-ajax
Classes
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 }}"
}
}
]
}
Implements
Constructors
Constructor
new AuWidgetAssetStorageAjax(): AuWidgetAssetStorageAjax;
Returns
Inherited from
AuBaseInvisibleWidget.constructor;
Properties
apiResponse
apiResponse: any;
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
assetType: AssetType;
entriesFilter
entriesFilter: Function;
folder
folder: string;
folderFilter
folderFilter: Function;
params
params: IAuWidgetAssetStorageAjaxConfig;
Parameters of the widget.
Overrides
AuBaseInvisibleWidget.params;
previewOptions
previewOptions: IPreviewOptions;
requestPromise
requestPromise: Promise<any>;
Promise, for awaiting in #function for getting response.
"{{ #function $['image-request'].compile() }}",
"{{ #asyncFunction await $['image-request'].requestPromise }}"
response
response: IAssetDataResult[] = [];
Accessors
template
Get Signature
get static template(): any;
Returns
any
Inherited from
AuBaseInvisibleWidget.template;
Methods
checkInitDependenciesWidgets()
checkInitDependenciesWidgets(): string[];
Returns an array of widget names, due to which the current widget cannot receive parameters.
Returns
string[]
Inherited from
AuBaseInvisibleWidget.checkInitDependenciesWidgets;
exportWidgetData()
exportWidgetData(force): Promise<AssetStorageAjaxWidgetData>;
Parameters
| Parameter | Type |
|---|---|
force | boolean |
Returns
Promise<AssetStorageAjaxWidgetData>
Implementation of
IRestorableWidget.exportWidgetData
resetPreloaderState()
resetPreloaderState(): void;
Returns
void
Inherited from
AuBaseInvisibleWidget.resetPreloaderState;
restoreWidgetFromData()
restoreWidgetFromData(widgetData, force): Promise<void>;
Parameters
| Parameter | Type |
|---|---|
widgetData | AssetStorageAjaxWidgetData |
force | boolean |
Returns
Promise<void>
Implementation of
IRestorableWidget.restoreWidgetFromData
showPreloader()
showPreloader(isShow): void;
Shows a preloader.
Parameters
| Parameter | Type | Description |
|---|---|---|
isShow | boolean | If true, enables the preloader. |
Returns
void
Overrides
AuBaseInvisibleWidget.showPreloader;
showToast()
showToast(data?, duration?): void;
Shows a toast.
return editor.loadUserInfo(data)
.catch(err => {
this.widget.showToast("Error: Invalid data");
console.log(err);
});
Parameters
| Parameter | Type | Description |
|---|---|---|
data? | string | A string message to display in the toast. |
duration? | number | Defines how long to show the toast for. |
Returns
void
Inherited from
AuBaseInvisibleWidget.showToast;
References
widget
Renames and re-exports AuWidgetAssetStorageAjax