@aurigma/ui-framework
Version:
A platform which allows building print product personalization editors based on Aurigma's Customer's Canvas.
433 lines (267 loc) • 10.3 kB
Markdown
# Class: AuWidgetDataDrivenEditor
Represents a Data-Driven Editor widget,
enabling users to fill out pre-configured forms and modify designs accordingly.
For details, you can refer to the [Data-Driven Editor widget](https://customerscanvas.com/dev/ui-framework/widgets/data-driven-editor.html) topic.
```
{
"widgets": [
{
"name": "dde",
"type": "data-driven-editor",
"params": {
"config": {
"access": {
"tenantId": "12345",
"userId": "jon.snow",
"token": "..."
},
"design": {
"designId": "68e74591f70c72b7ce14f889",
"dataSetId": "68a24768aa00e6f0203564dc"
},
"api": {
"designAtoms": "https://api.example.com/atoms",
"assetProcessor": "https://api.example.com/processor",
"assetStorage": "https://api.example.com/storage"
},
"settings": {
"lang": "en",
"allowManipulations": false,
"itemsSnapLines": true
},
"renderer": {
"watermarkEnabled": true,
"watermarkOpacity": 0.5,
"format": "jpeg"
}
}
}
}
]
}
```
## Hierarchy
↳ [AuBaseWidget](aubasewidget.md)
↳ **AuWidgetDataDrivenEditor**
## Implements
* [IWidget](../interfaces/iwidget.md)
* [IWidgetDataDrivenEditor](../interfaces/iwidgetdatadriveneditor.md)
* [IRestorableWidget](../interfaces/irestorablewidget.md)
## Index
### Properties
* [idStr](auwidgetdatadriveneditor.md#idstr)
* [isValid](auwidgetdatadriveneditor.md#isvalid)
* [pdfUrl](auwidgetdatadriveneditor.md#pdfurl)
* [previewUrlLink](auwidgetdatadriveneditor.md#previewurllink)
* [previewUrls](auwidgetdatadriveneditor.md#previewurls)
* [stateId](auwidgetdatadriveneditor.md#stateid)
* [userId](auwidgetdatadriveneditor.md#userid)
### Methods
* [checkInitDependenciesWidgets](auwidgetdatadriveneditor.md#checkinitdependencieswidgets)
* [createIdStr](auwidgetdatadriveneditor.md#createidstr)
* [createPdfPreview](auwidgetdatadriveneditor.md#createpdfpreview)
* [createPreview](auwidgetdatadriveneditor.md#createpreview)
* [exportWidgetData](auwidgetdatadriveneditor.md#exportwidgetdata)
* [getFormData](auwidgetdatadriveneditor.md#getformdata)
* [resetPreloaderState](auwidgetdatadriveneditor.md#resetpreloaderstate)
* [restoreWidgetFromData](auwidgetdatadriveneditor.md#restorewidgetfromdata)
* [saveProduct](auwidgetdatadriveneditor.md#saveproduct)
* [setEditorConfig](auwidgetdatadriveneditor.md#seteditorconfig)
* [setLang](auwidgetdatadriveneditor.md#setlang)
* [setUserInfo](auwidgetdatadriveneditor.md#setuserinfo)
* [showPreloader](auwidgetdatadriveneditor.md#showpreloader)
* [showToast](auwidgetdatadriveneditor.md#showtoast)
* [updateToken](auwidgetdatadriveneditor.md#updatetoken)
* [validate](auwidgetdatadriveneditor.md#validate)
## Properties
### idStr
• **idStr**: *string*
*Implementation of [IWidgetDataDrivenEditor](../interfaces/iwidgetdatadriveneditor.md).[idStr](../interfaces/iwidgetdatadriveneditor.md#idstr)*
Product ID string
___
### isValid
• **isValid**: *boolean*
*Implementation of [IWidgetDataDrivenEditor](../interfaces/iwidgetdatadriveneditor.md).[isValid](../interfaces/iwidgetdatadriveneditor.md#isvalid)*
`true` if form of data driven editor is valid
___
### pdfUrl
• **pdfUrl**: *string*
*Implementation of [IWidgetDataDrivenEditor](../interfaces/iwidgetdatadriveneditor.md).[pdfUrl](../interfaces/iwidgetdatadriveneditor.md#pdfurl)*
URL for download PDF file
___
### previewUrlLink
• **previewUrlLink**: *string*
*Implementation of [IWidgetDataDrivenEditor](../interfaces/iwidgetdatadriveneditor.md).[previewUrlLink](../interfaces/iwidgetdatadriveneditor.md#previewurllink)*
URL preview image (First page)
___
### previewUrls
• **previewUrls**: *string[]* = []
*Implementation of [IWidgetDataDrivenEditor](../interfaces/iwidgetdatadriveneditor.md).[previewUrls](../interfaces/iwidgetdatadriveneditor.md#previewurls)*
URL's preview images
___
### stateId
• **stateId**: *string*
*Implementation of [IWidgetDataDrivenEditor](../interfaces/iwidgetdatadriveneditor.md).[stateId](../interfaces/iwidgetdatadriveneditor.md#stateid)*
Saved product ID
___
### userId
• **userId**: *string*
*Implementation of [IWidgetDataDrivenEditor](../interfaces/iwidgetdatadriveneditor.md).[userId](../interfaces/iwidgetdatadriveneditor.md#userid)*
Current user ID
## Methods
### checkInitDependenciesWidgets
▸ **checkInitDependenciesWidgets**(): *string[]*
*Inherited from [AuBaseWidget](aubasewidget.md).[checkInitDependenciesWidgets](aubasewidget.md#checkinitdependencieswidgets)*
Returns an array of widget names, due to which the current widget cannot receive parameters.
**Returns:** *string[]*
___
### createIdStr
▸ **createIdStr**(): *Promise‹string›*
*Implementation of [IWidgetDataDrivenEditor](../interfaces/iwidgetdatadriveneditor.md)*
Create id string from values from data driven form
**Returns:** *Promise‹string›*
___
### createPdfPreview
▸ **createPdfPreview**(`config?`: [IRendererConfig](../interfaces/irendererconfig.md)): *Promise‹string›*
*Implementation of [IWidgetDataDrivenEditor](../interfaces/iwidgetdatadriveneditor.md)*
Create link for download preview PDF file
**Parameters:**
Name | Type | Description |
------ | ------ | ------ |
`config?` | [IRendererConfig](../interfaces/irendererconfig.md) | Render configuration |
**Returns:** *Promise‹string›*
___
### createPreview
▸ **createPreview**(`config?`: [IRendererConfig](../interfaces/irendererconfig.md)): *Promise‹string[]›*
*Implementation of [IWidgetDataDrivenEditor](../interfaces/iwidgetdatadriveneditor.md)*
Create preview images
**Parameters:**
Name | Type | Description |
------ | ------ | ------ |
`config?` | [IRendererConfig](../interfaces/irendererconfig.md) | Render configuration |
**Returns:** *Promise‹string[]›*
___
### exportWidgetData
▸ **exportWidgetData**(`force`: boolean): *Promise‹Partial‹[IEditorConfig](../interfaces/ieditorconfig.md)››*
*Implementation of [IRestorableWidget](../interfaces/irestorablewidget.md)*
**Parameters:**
Name | Type |
------ | ------ |
`force` | boolean |
**Returns:** *Promise‹Partial‹[IEditorConfig](../interfaces/ieditorconfig.md)››*
___
### getFormData
▸ **getFormData**(`config`: [IFormDataConfig](../interfaces/iformdataconfig.md)): *object*
*Implementation of [IWidgetDataDrivenEditor](../interfaces/iwidgetdatadriveneditor.md)*
Allow to get current data of form
**Parameters:**
Name | Type |
------ | ------ |
`config` | [IFormDataConfig](../interfaces/iformdataconfig.md) |
**Returns:** *object*
___
### resetPreloaderState
▸ **resetPreloaderState**(): *void*
*Inherited from [AuBaseWidget](aubasewidget.md).[resetPreloaderState](aubasewidget.md#resetpreloaderstate)*
**Returns:** *void*
___
### restoreWidgetFromData
▸ **restoreWidgetFromData**(`data`: [IEditorConfig](../interfaces/ieditorconfig.md), `force`: boolean): *Promise‹void›*
**Parameters:**
Name | Type |
------ | ------ |
`data` | [IEditorConfig](../interfaces/ieditorconfig.md) |
`force` | boolean |
**Returns:** *Promise‹void›*
___
### saveProduct
▸ **saveProduct**(`asNew`: boolean): *Promise‹void›*
*Implementation of [IWidgetDataDrivenEditor](../interfaces/iwidgetdatadriveneditor.md)*
Saved or updated current product to private storage
**Parameters:**
Name | Type |
------ | ------ |
`asNew` | boolean |
**Returns:** *Promise‹void›*
___
### setEditorConfig
▸ **setEditorConfig**(`config`: [IEditorConfig](../interfaces/ieditorconfig.md)): *Promise‹void›*
*Implementation of [IWidgetDataDrivenEditor](../interfaces/iwidgetdatadriveneditor.md)*
Sets the configuration of data driven editor
**Parameters:**
Name | Type |
------ | ------ |
`config` | [IEditorConfig](../interfaces/ieditorconfig.md) |
**Returns:** *Promise‹void›*
___
### setLang
▸ **setLang**(`lang`: string): *void*
Sets the language of data driven editor
**Parameters:**
Name | Type |
------ | ------ |
`lang` | string |
**Returns:** *void*
___
### setUserInfo
▸ **setUserInfo**(`userInfo`: Record‹string, string›): *void*
*Implementation of [IWidgetDataDrivenEditor](../interfaces/iwidgetdatadriveneditor.md)*
Allow to set user info
**Parameters:**
Name | Type |
------ | ------ |
`userInfo` | Record‹string, string› |
**Returns:** *void*
___
### showPreloader
▸ **showPreloader**(`isPreload`: boolean, `message`: string | string[], `timeout`: number): *void*
*Inherited from [AuBaseWidget](aubasewidget.md).[showPreloader](aubasewidget.md#showpreloader)*
Shows a preloader.
```
"onClick": [
"{{#function main.showPreloader(true, 'Creating print files...')}}",
"{{#function $['editor'].getHiResImages(800,800)}}",
"{{#function main.showPreloader(false)}}"
]
```
**Parameters:**
Name | Type | Default | Description |
------ | ------ | ------ | ------ |
`isPreload` | boolean | - | If `true`, enables the preloader. |
`message` | string | string[] | [""] | A text message that appears next to the preloader. |
`timeout` | number | 5 | - |
**Returns:** *void*
___
### showToast
▸ **showToast**(`data?`: string, `duration?`: number): *void*
*Inherited from [AuBaseWidget](aubasewidget.md).[showToast](aubasewidget.md#showtoast)*
Shows a toast.
```
return editor.loadUserInfo(data)
.catch(err => {
this.widget.showToast("Error: Invalid data");
console.log(err);
});
```
**Parameters:**
Name | Type | Description |
------ | ------ | ------ |
`data?` | string | A string message to display in the toast. |
`duration?` | number | Defines how long to show the toast for. |
**Returns:** *void*
___
### updateToken
▸ **updateToken**(`token`: string): *void*
Update the token for data driven editor.
**`deprecated`**
**Parameters:**
Name | Type |
------ | ------ |
`token` | string |
**Returns:** *void*
___
### validate
▸ **validate**(): *boolean*
*Implementation of [IWidgetDataDrivenEditor](../interfaces/iwidgetdatadriveneditor.md)*
Validate form in editor
**Returns:** *boolean*