-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathversion-entry-layout.component.ts
73 lines (62 loc) · 1.81 KB
/
version-entry-layout.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
import {Component, Input} from "@angular/core";
import {LogService} from "../../../../../logger/log.service";
@Component({
selector: "sbb-version-entry-layout",
templateUrl: "./version-entry-layout.component.html",
styleUrls: ["./version-entry-layout.component.scss"],
})
export class VersionEntryLayoutComponent {
@Input() state?: "conflict" | "added";
@Input() message?: string;
@Input() titleField: string | UserId;
@Input() dateField: Date;
@Input() commentField?: string;
constructor(private readonly logService: LogService) {
}
isInConflictState(): boolean {
return this.state === "conflict";
}
isInAddedState(): boolean {
return this.state === "added";
}
public getEntryStyle(): Record<string, boolean> {
return {
"in-conflict": this.isInConflictState(),
"new-added": this.isInAddedState(),
};
}
getUserId(): string | undefined {
if (this.titleField instanceof UserId) {
return this.titleField.value;
}
return undefined;
}
copyComment() {
const comment = this.commentField;
if (!comment) {
return;
}
navigator.clipboard.writeText(comment);
const msg = $localize`:@@app.view.variant.variant-view.variant-history.version-entry-layout.user-id-copied:copied ${comment}:msg:`;
this.logService.info(msg);
}
copyUserId() {
const userId = this.getUserId();
if (!userId) {
return;
}
navigator.clipboard.writeText(userId);
const msg = $localize`:@@app.view.variant.variant-view.variant-history.version-entry-layout.user-id-copied:copied ${userId}:msg:`;
this.logService.info(msg);
}
getTitle(): string | undefined {
if (typeof this.titleField === "string") {
return this.titleField;
}
return undefined;
}
}
export class UserId {
constructor(readonly value: string) {
}
}