]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | import { CdTableSelection } from './cd-table-selection'; |
2 | ||
3 | export class CdTableAction { | |
4 | // It's possible to assign a string | |
5 | // or a function that returns the link if it has to be dynamic | |
6 | // or none if it's not needed | |
7 | routerLink?: string | Function; | |
8 | ||
9 | // This is the function that will be triggered on a click event if defined | |
10 | click?: Function; | |
11 | ||
12 | permission: 'create' | 'update' | 'delete' | 'read'; | |
13 | ||
14 | // The name of the action | |
15 | name: string; | |
16 | ||
17 | // The font awesome icon that will be used | |
18 | icon: string; | |
19 | ||
20 | // You can define the condition to disable the action. | |
21 | // By default all 'update' and 'delete' actions will only be enabled | |
22 | // if one selection is made and no task is running on the selected item. | |
23 | disable?: (_: CdTableSelection) => boolean; | |
24 | ||
494da23a TL |
25 | /** |
26 | * In some cases you might want to give the user a hint why a button is | |
27 | * disabled. The specified message will be shown to the user as a button | |
28 | * tooltip. | |
29 | */ | |
30 | disableDesc?: Function; | |
31 | ||
11fdf7f2 TL |
32 | /** |
33 | * Defines if the button can become 'primary' (displayed as button and not | |
34 | * 'hidden' in the menu). Only one button can be primary at a time. By | |
35 | * default all 'create' actions can be the action button if no or multiple | |
36 | * items are selected. Also, all 'update' and 'delete' actions can be the | |
37 | * action button by default, provided only one item is selected. | |
38 | */ | |
39 | canBePrimary?: (_: CdTableSelection) => boolean; | |
40 | ||
41 | // In some rare cases you want to hide a action that can be used by the user for example | |
42 | // if one action can lock the item and another action unlocks it | |
43 | visible?: (_: CdTableSelection) => boolean; | |
44 | } |