| 1 | /* |
| 2 | * Copyright (c) 2024 sovity GmbH |
| 3 | * |
| 4 | * This program and the accompanying materials are made available under the |
| 5 | * terms of the Apache License, Version 2.0 which is available at |
| 6 | * https://www.apache.org/licenses/LICENSE-2.0 |
| 7 | * |
| 8 | * SPDX-License-Identifier: Apache-2.0 |
| 9 | * |
| 10 | * Contributors: |
| 11 | * sovity GmbH - initial implementation |
| 12 | */ |
| 13 | import {Component, Inject, Input} from '@angular/core'; |
| 14 | import {Router} from '@angular/router'; |
| 15 | import {APP_CONFIG, AppConfig} from '../../../core/services/config/app-config'; |
| 16 | import {SelectionBoxModel} from './selection-box.model'; |
| 17 | |
| 18 | @Component({ |
| 19 | selector: 'app-selection-box', |
| 20 | templateUrl: './selection-box.component.html', |
| 21 | }) |
| 22 | export class SelectionBoxComponent { |
| 23 | @Input() selectionBoxConfig!: SelectionBoxModel; |
| 24 | constructor( |
| 25 | @Inject(APP_CONFIG) public appConfig: AppConfig, |
| 26 | private router: Router, |
| 27 | ) {} |
| 28 | |
| 29 | onAction() { |
| 30 | if (this.selectionBoxConfig?.action?.url) { |
| 31 | if (!this.selectionBoxConfig.action.isDisabled) { |
| 32 | this.router.navigate([this.selectionBoxConfig.action.url]); |
| 33 | } |
| 34 | } |
| 35 | if (this.selectionBoxConfig?.action?.externalUrl) { |
| 36 | window.open(this.selectionBoxConfig.action.externalUrl, '_blank'); |
| 37 | } |
| 38 | } |
| 39 | } |