[ADF-2695] DocumentList content action documentation (#3198)

* update action component documentation

* fix after review
This commit is contained in:
Eugenio Romano
2018-04-16 15:48:19 +01:00
committed by GitHub
parent 62f91b567c
commit e4b9d775a2

View File

@@ -17,9 +17,9 @@ Adds options to a Document List actions menu for a particular content type.
- [Details](#details) - [Details](#details)
- [Built-in action examples](#built-in-action-examples) - [Examples](#examples)
- [Error, Permission and Success callbacks](#error-permission-and-success-callbacks)
- [Customizing built-in actions](#customizing-built-in-actions) - [Customizing built-in actions](#customizing-built-in-actions)
- [Error, Permission and Success callbacks](#error-permission-and-success-callbacks)
- [See also](#see-also) - [See also](#see-also)
@@ -100,11 +100,12 @@ export class MyView {
## Details ## Details
The document actions are rendered on a dropdown menu for each items of content. You can use the The document actions are rendered on a dropdown menu for each items of content. You can use the
`target` property to choose whether the action applies to folders or documents. `target` property to choose whether the action applies to folders , documents or both. (By default the actions arre applied to both)
A number of built-in actions are defined to handle common use cases: A number of built-in actions are defined to handle common use cases:
- **Download** (document) - **Download** (document)
- **lock** (document)
- **Copy** (document, folder) - **Copy** (document, folder)
- **Move** (document, folder) - **Move** (document, folder)
- **Delete** (document, folder) - **Delete** (document, folder)
@@ -152,14 +153,63 @@ type and other details of the item just deleted:
![Custom delete message screenshot](../docassets/images/ContentActSnackMessage.png) ![Custom delete message screenshot](../docassets/images/ContentActSnackMessage.png)
### Built-in action examples ### Examples
#### Delete - System handler combined with custom handler #### System handler
This action simply execute one of the built-in actions described above:
If you specify both `handler="delete"` and your own custom handler with ```html
`(execute)="myCustomActionAfterDelete($event)"`, your handler will run after a delete completes <adf-document-list [contentActions]="true"...>
successfully. A delete operation is considered successful if there are no permission or <content-actions>
network-related errors for the delete request. You can avoid permission errors simply by disabling
<content-action
target="document"
title="Download"
handler="download">
</content-action>
</content-actions>
</adf-document-list>
```
![Download document action](../docassets/images/document-action-download.png)
#### Custom handler
If you specify a custom handler it will be executed at any click of the action:
```html
<adf-document-list [contentActions]="true"...>
<content-actions>
<content-action
title="custom-action"
(execute)="myCustomAction($event)">
</content-action>
</content-actions>
</adf-document-list>
```
```ts
export class MyComponent {
myCustomAction(event: any) {
//Your cusrtom logic
}
}
```
#### System handler combined with custom handler
If you specify both system handler and your own custom handler with
`(execute)="myCustomActionAfterDelete($event)"`, your handler will run after a system handler completes
successfully. A system operation is considered successful if there are no permission or
network-related errors for the system request. You can avoid permission errors simply by disabling
an item for users who don't have permission to use it (set `disableWithNoPermission="true"`). an item for users who don't have permission to use it (set `disableWithNoPermission="true"`).
```html ```html
@@ -171,6 +221,7 @@ an item for users who don't have permission to use it (set `disableWithNoPermiss
title="Delete" title="Delete"
permission="delete" permission="delete"
disableWithNoPermission="true" disableWithNoPermission="true"
(execute)="myCustomActionAfterDelete($event)"
handler="delete"> handler="delete">
</content-action> </content-action>
@@ -178,8 +229,20 @@ an item for users who don't have permission to use it (set `disableWithNoPermiss
</adf-document-list> </adf-document-list>
``` ```
```ts
export class MyComponent {
myCustomActionAfterDelete(event: any) {
//Your cusrtom logic
}
}
```
![Delete disable action button](../docassets/images/content-action-disable-delete-button.png) ![Delete disable action button](../docassets/images/content-action-disable-delete-button.png)
#### Permission check
You can also implement the `permissionEvent` to handle permission errors You can also implement the `permissionEvent` to handle permission errors
(to show the user a notification, for example). Subscribe to this event from your component (to show the user a notification, for example). Subscribe to this event from your component
and use the [Notification service](../core/notification.service.md) to show a message. and use the [Notification service](../core/notification.service.md) to show a message.
@@ -192,6 +255,7 @@ and use the [Notification service](../core/notification.service.md) to show a me
target="document" target="document"
title="Delete" title="Delete"
permission="delete" permission="delete"
(execute)="myCustomActionAfterDelete($event)"
(permissionEvent)="onPermissionsFailed($event)" (permissionEvent)="onPermissionsFailed($event)"
handler="delete"> handler="delete">
</content-action> </content-action>
@@ -212,25 +276,6 @@ export class MyComponent {
![Delete show notification message](../docassets/images/content-action-notification-message.png) ![Delete show notification message](../docassets/images/content-action-notification-message.png)
#### Download
This action simply starts a download of the corresponding document file.
```html
<adf-document-list [contentActions]="true"...>
<content-actions>
<content-action
target="document"
title="Download"
handler="download">
</content-action>
</content-actions>
</adf-document-list>
```
![Download document action](../docassets/images/document-action-download.png)
#### Copy and move #### Copy and move
@@ -272,6 +317,14 @@ allow the item being copied/moved to be the destination if it is itself a folder
</adf-document-list> </adf-document-list>
``` ```
### Customizing built-in actions
The built-in actions are defined in the [Document Actions service](document-actions.service.md) and
[Folder Actions service](folder-actions.service.md) but you can register new actions with these services
and override the default implementations. See the doc pages for
[Document Actions service](document-actions.service.md) and [Folder Actions service](folder-actions.service.md)
for details and examples.
### Error, Permission and Success callbacks ### Error, Permission and Success callbacks
Defining error, permission and success callbacks are pretty much the same as doing it for the delete permission handling. Defining error, permission and success callbacks are pretty much the same as doing it for the delete permission handling.
@@ -282,14 +335,6 @@ Defining error, permission and success callbacks are pretty much the same as doi
![Copy/move document action](../docassets/images/document-action-copymove.png) ![Copy/move document action](../docassets/images/document-action-copymove.png)
### Customizing built-in actions
The built-in actions are defined in the [Document Actions service](document-actions.service.md) and
[Folder Actions service](folder-actions.service.md) but you can register new actions with these services
and override the default implementations. See the doc pages for
[Document Actions service](document-actions.service.md) and [Folder Actions service](folder-actions.service.md)
for details and examples.
<!-- Don't edit the See also section. Edit seeAlsoGraph.json and run config/generateSeeAlso.js --> <!-- Don't edit the See also section. Edit seeAlsoGraph.json and run config/generateSeeAlso.js -->
<!-- seealso start --> <!-- seealso start -->