-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcard.component.ts
46 lines (41 loc) · 1.42 KB
/
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
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Structure } from '../../../map/models/structure.model';
@Component({
selector: 'app-card',
templateUrl: './card.component.html',
styleUrls: ['./card.component.scss']
})
export class CardComponent {
@Input() public structure: Structure;
@Input() public isSelected: boolean;
@Input() public isOrientation: boolean;
@Input() public isClaimed = true;
@Output() public showDetails: EventEmitter<Structure> = new EventEmitter<Structure>();
@Output() public addToList: EventEmitter<Structure> = new EventEmitter<Structure>();
@Output() public hover: EventEmitter<Structure> = new EventEmitter<Structure>();
constructor(private route: ActivatedRoute, private router: Router) {}
public cardClicked(): void {
this.showDetails.emit(this.structure);
if (!this.isOrientation) {
const queryString = this.route.snapshot.queryParamMap.get('search');
this.router.navigate([], {
relativeTo: this.route,
queryParams: queryString
? {
id: this.structure._id,
search: queryString
}
: {
id: this.structure._id
}
});
}
}
public cardHover(): void {
this.hover.emit(this.structure);
}
public cardAddToList(): void {
this.addToList.emit(this.structure);
}
}