@aurigma/ui-framework
Version:
A platform which allows building print product personalization editors based on Aurigma's Customer's Canvas.
360 lines (224 loc) • 7.83 kB
Markdown
# Class: AuWidgetPreflight
A widget that is used to verify that pre-designed user files are compatible with your printing equipment.
For details, you can refer to the [Preflight widget](https://customerscanvas.com/dev/editors/ui-framework/widgets/preflight.html) topic.
```
{
"widgets": [{
"name": "preflight",
"type": "preflight",
"params": {
"config": {
"backendUrl": "http://preflight.example.com",
"product": {
"dpi": 300,
"size": {
"width": 595,
"height": 842
},
"bleed": 20,
"safetyLines": [{
"color": "#00ff00",
"altColor": "#00ff00",
"margin": 40
}]
},
"rules": [
{
"type": "colorspace",
"severity": "error",
"enableFix": true,
"params": {
"allowedColorSpaces": [ "cmyk" ]
}
}
],
...
}
}]
}
```
You can find the detailed description of the preflight configuration in the [`config` reference](https://customerscanvas.com/dev/preflight/reference/config.html).
## Hierarchy
↳ [AuBaseWidget](aubasewidget.md)
↳ **AuWidgetPreflight**
## Implements
* [IWidget](../interfaces/iwidget.md)
* [IRestorableWidget](../interfaces/irestorablewidget.md)
## Index
### Properties
* [failedChecks](auwidgetpreflight.md#failedchecks)
* [hasEmptyPages](auwidgetpreflight.md#hasemptypages)
* [hasFiles](auwidgetpreflight.md#hasfiles)
* [hires](auwidgetpreflight.md#hires)
* [origins](auwidgetpreflight.md#origins)
* [page](auwidgetpreflight.md#page)
* [params](auwidgetpreflight.md#params)
* [preview](auwidgetpreflight.md#preview)
* [previews](auwidgetpreflight.md#previews)
* [stateId](auwidgetpreflight.md#stateid)
### Accessors
* [pages](auwidgetpreflight.md#pages)
### Methods
* [checkInitDependenciesWidgets](auwidgetpreflight.md#checkinitdependencieswidgets)
* [exportWidgetData](auwidgetpreflight.md#exportwidgetdata)
* [getPreviews](auwidgetpreflight.md#getpreviews)
* [getResults](auwidgetpreflight.md#getresults)
* [languageObserver](auwidgetpreflight.md#languageobserver)
* [resetPreloaderState](auwidgetpreflight.md#resetpreloaderstate)
* [restoreWidgetFromData](auwidgetpreflight.md#restorewidgetfromdata)
* [setFiles](auwidgetpreflight.md#setfiles)
* [setStep](auwidgetpreflight.md#setstep)
* [showPreloader](auwidgetpreflight.md#showpreloader)
* [showToast](auwidgetpreflight.md#showtoast)
## Properties
### failedChecks
• **failedChecks**: *[FailedChecksModel](failedchecksmodel.md)* = new FailedChecksModel([], [])
An object containing two arrays, **errors** and **warnings**, with failed validation rules.
___
### hasEmptyPages
• **hasEmptyPages**: *boolean* = false
If `true`, user upload file for every page.
___
### hasFiles
• **hasFiles**: *boolean* = false
If `true`, user upload at least one file.
___
### hires
• **hires**: *string[]* = []
A string array of URLs that link to the print-ready file in PDF format.
___
### origins
• **origins**: *[OriginModel](originmodel.md)[]* = []
An array of links to origin images of product pages.
___
### page
• **page**: *[PreflightToolStep](../README.md#preflighttoolstep)* = "" as PreflightToolStep
The current preflight page - either **uploader** or **editor**.
___
### params
• **params**: *any*
*Implementation of [IWidget](../interfaces/iwidget.md).[params](../interfaces/iwidget.md#optional-params)*
*Inherited from [AuBaseWidget](aubasewidget.md).[params](aubasewidget.md#params)*
Compiled widget configuration.
___
### preview
• **preview**: *string[]* = []
A string array of URLs that link to proof images.
___
### previews
• **previews**: *[PreviewModel](previewmodel.md)[]* = []
___
### stateId
• **stateId**: *string* = ""
The identifier of the last saved state file.
## Accessors
### pages
• **get pages**(): *number*
Gets the number of pages.
**Returns:** *number*
## 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[]*
___
### exportWidgetData
▸ **exportWidgetData**(`force`: boolean): *Promise‹PreflightExportData›*
*Implementation of [IRestorableWidget](../interfaces/irestorablewidget.md)*
**Parameters:**
Name | Type |
------ | ------ |
`force` | boolean |
**Returns:** *Promise‹PreflightExportData›*
___
### getPreviews
▸ **getPreviews**(): *Promise‹[PreviewModel](previewmodel.md)[]›*
Gets preview images.
**Returns:** *Promise‹[PreviewModel](previewmodel.md)[]›*
___
### getResults
▸ **getResults**(`renderPreview`: boolean): *Promise‹[FinishModel](finishmodel.md)›*
Gets links to print-ready and preview images and origin files.
**Parameters:**
Name | Type | Default |
------ | ------ | ------ |
`renderPreview` | boolean | true |
**Returns:** *Promise‹[FinishModel](finishmodel.md)›*
___
### languageObserver
▸ **languageObserver**(`lang`: string): *void*
**Parameters:**
Name | Type |
------ | ------ |
`lang` | string |
**Returns:** *void*
___
### resetPreloaderState
▸ **resetPreloaderState**(): *void*
*Inherited from [AuBaseWidget](aubasewidget.md).[resetPreloaderState](aubasewidget.md#resetpreloaderstate)*
**Returns:** *void*
___
### restoreWidgetFromData
▸ **restoreWidgetFromData**(`data`: PreflightExportData, `force`: boolean): *Promise‹void›*
**Parameters:**
Name | Type |
------ | ------ |
`data` | PreflightExportData |
`force` | boolean |
**Returns:** *Promise‹void›*
___
### setFiles
▸ **setFiles**(`fileUrls`: string[]): *Promise‹void›*
Inserts files into the current product starting from the first page.
**Parameters:**
Name | Type | Description |
------ | ------ | ------ |
`fileUrls` | string[] | An array of links to the files. |
**Returns:** *Promise‹void›*
___
### setStep
▸ **setStep**(`step`: [PreflightToolStep](../README.md#preflighttoolstep)): *Promise‹void›*
Sets the current preflight page.
**Parameters:**
Name | Type | Description |
------ | ------ | ------ |
`step` | [PreflightToolStep](../README.md#preflighttoolstep) | You can enable either `uploader` or `editor`. |
**Returns:** *Promise‹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*