aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-main/buttons/action-dropdown.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/shared-main/buttons/action-dropdown.component.ts')
-rw-r--r--client/src/app/shared/shared-main/buttons/action-dropdown.component.ts15
1 files changed, 13 insertions, 2 deletions
diff --git a/client/src/app/shared/shared-main/buttons/action-dropdown.component.ts b/client/src/app/shared/shared-main/buttons/action-dropdown.component.ts
index 749773f8a..e39fbd66d 100644
--- a/client/src/app/shared/shared-main/buttons/action-dropdown.component.ts
+++ b/client/src/app/shared/shared-main/buttons/action-dropdown.component.ts
@@ -1,4 +1,5 @@
1import { Component, Input } from '@angular/core' 1import { ChangeDetectionStrategy, Component, Input } from '@angular/core'
2import { Params } from '@angular/router'
2import { GlobalIconName } from '@app/shared/shared-icons' 3import { GlobalIconName } from '@app/shared/shared-icons'
3 4
4export type DropdownAction<T> = { 5export type DropdownAction<T> = {
@@ -7,7 +8,10 @@ export type DropdownAction<T> = {
7 description?: string 8 description?: string
8 title?: string 9 title?: string
9 handler?: (a: T) => any 10 handler?: (a: T) => any
11
10 linkBuilder?: (a: T) => (string | number)[] 12 linkBuilder?: (a: T) => (string | number)[]
13 queryParamsBuilder?: (a: T) => Params
14
11 isDisplayed?: (a: T) => boolean 15 isDisplayed?: (a: T) => boolean
12 16
13 class?: string[] 17 class?: string[]
@@ -21,7 +25,8 @@ export type DropdownDirection = 'horizontal' | 'vertical'
21@Component({ 25@Component({
22 selector: 'my-action-dropdown', 26 selector: 'my-action-dropdown',
23 styleUrls: [ './action-dropdown.component.scss' ], 27 styleUrls: [ './action-dropdown.component.scss' ],
24 templateUrl: './action-dropdown.component.html' 28 templateUrl: './action-dropdown.component.html',
29 changeDetection: ChangeDetectionStrategy.OnPush
25}) 30})
26 31
27export class ActionDropdownComponent<T> { 32export class ActionDropdownComponent<T> {
@@ -44,6 +49,12 @@ export class ActionDropdownComponent<T> {
44 return [ this.actions as DropdownAction<T>[] ] 49 return [ this.actions as DropdownAction<T>[] ]
45 } 50 }
46 51
52 getQueryParams (action: DropdownAction<T>, entry: T) {
53 if (action.queryParamsBuilder) return action.queryParamsBuilder(entry)
54
55 return {}
56 }
57
47 areActionsDisplayed (actions: Array<DropdownAction<T> | DropdownAction<T>[]>, entry: T): boolean { 58 areActionsDisplayed (actions: Array<DropdownAction<T> | DropdownAction<T>[]>, entry: T): boolean {
48 return actions.some(a => { 59 return actions.some(a => {
49 if (Array.isArray(a)) return this.areActionsDisplayed(a, entry) 60 if (Array.isArray(a)) return this.areActionsDisplayed(a, entry)