This repository has been archived by the owner on Nov 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
connection-type-card.component.ts
74 lines (62 loc) · 1.88 KB
/
connection-type-card.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from "@angular/core";
import { CardConfig } from "patternfly-ng";
import { ConnectionType } from "../../shared/connection-type.model";
@Component({
encapsulation: ViewEncapsulation.None,
selector: "app-connection-type-card",
templateUrl: "./connection-type-card.component.html",
styleUrls: ["./connection-type-card.component.css"]
})
export class ConnectionTypeCardComponent implements OnInit {
@Input() public connectionType: ConnectionType;
@Input() public selectedConnectionTypes: ConnectionType[];
@Output() public cardEvent: EventEmitter< {} > = new EventEmitter< {} >();
@Output() public selectEvent: EventEmitter< ConnectionType > = new EventEmitter< ConnectionType >();
public cardConfig: CardConfig;
constructor() {
// nothing to do
}
public ngOnInit(): void {
this.cardConfig = {
titleBorder: true,
noPadding: true,
topBorder: false
} as CardConfig;
}
/**
* @returns the ConnectionType name
*/
public get name(): string {
return this.connectionType.getName();
}
/**
* @returns the ConnectionType description
*/
public get description(): string {
return this.connectionType.getDescription();
}
/**
* @returns the ConnectionType image source
*/
public get imageSrc(): string {
return this.connectionType.getImageSrc();
}
/**
* @returns the ConnectionType image alt text
*/
public get imageAlt(): string {
return this.connectionType.getImageAlt();
}
/**
* @returns `true` if the ConnectionType represented by this card is selected
*/
public isSelected(): boolean {
return this.selectedConnectionTypes.indexOf( this.connectionType ) !== -1;
}
/**
* An event handler for when the card is clicked.
*/
public onSelect(): void {
this.selectEvent.emit( this.connectionType );
}
}