]>
Commit | Line | Data |
---|---|---|
eacb25c4 C |
1 | import { Component, Input } from '@angular/core' |
2 | ||
3 | export type DropdownAction<T> = { | |
eacb25c4 | 4 | label?: string |
c199c427 C |
5 | handler?: (a: T) => any |
6 | linkBuilder?: (a: T) => (string | number)[] | |
7 | isDisplayed?: (a: T) => boolean | |
eacb25c4 C |
8 | } |
9 | ||
10 | @Component({ | |
11 | selector: 'my-action-dropdown', | |
12 | styleUrls: [ './action-dropdown.component.scss' ], | |
13 | templateUrl: './action-dropdown.component.html' | |
14 | }) | |
15 | ||
16 | export class ActionDropdownComponent<T> { | |
f97c91f7 | 17 | @Input() actions: DropdownAction<T>[] | DropdownAction<T>[][] = [] |
eacb25c4 | 18 | @Input() entry: T |
791645e6 | 19 | @Input() placement = 'bottom-left' |
79bd2632 | 20 | @Input() buttonSize: 'normal' | 'small' = 'normal' |
791645e6 C |
21 | @Input() label: string |
22 | @Input() theme: 'orange' | 'grey' = 'grey' | |
f97c91f7 C |
23 | |
24 | getActions () { | |
25 | if (this.actions.length !== 0 && Array.isArray(this.actions[0])) return this.actions | |
26 | ||
27 | return [ this.actions ] | |
28 | } | |
eacb25c4 | 29 | } |