-
Notifications
You must be signed in to change notification settings - Fork 6
/
list-item-element.component.ts
78 lines (65 loc) · 2.32 KB
/
list-item-element.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
75
76
77
78
import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core';
import { ListNode } from '@dasch-swiss/dsp-js';
import { DEFAULT_MULTILANGUAGE_FORM, MultiLanguageFormArray } from '@dasch-swiss/vre/shared/app-string-literal';
import { ListItemService } from '../list-item/list-item.service';
@Component({
selector: 'app-list-item-element',
template: `
<div style="display: flex">
<button type="button" color="primary" mat-icon-button (click)="showChildren = !showChildren">
<mat-icon>{{ showChildren ? 'expand_more' : 'chevron_right' }}</mat-icon>
</button>
<div style="flex: 1">
<div (mouseenter)="mouseEnter()" (mouseleave)="mouseLeave()" style="position: relative">
<dasch-swiss-multi-language-input
[placeholder]="node.labels | appStringifyStringLiteral: 'all' | appTruncate: 128"
[editable]="false"
[formArray]="readOnlyFormArray"
[validators]="[]">
</dasch-swiss-multi-language-input>
<app-action-bubble
*ngIf="showActionBubble"
[position]="position"
[length]="length"
[node]="node"></app-action-bubble>
</div>
<app-list-item
*ngIf="showChildren"
[projectUuid]="listItemService.projectInfos.projectIri"
[rootNodeIri]="node.id"
[isAdmin]="isAdmin">
</app-list-item>
</div>
</div>
`,
styles: [':host ::ng-deep dasch-swiss-multi-language-input .mat-mdc-form-field-bottom-align { display: none;}'],
})
export class ListItemElementComponent implements OnInit, OnChanges {
@Input() node: ListNode;
@Input() position: number;
@Input() length: number;
@Output() refreshChildren = new EventEmitter<ListNode[]>();
@Output() updateView = new EventEmitter<unknown>();
@Input() isAdmin = false;
showChildren = false;
showActionBubble = false;
readOnlyFormArray: MultiLanguageFormArray;
constructor(public listItemService: ListItemService) {}
ngOnInit() {
this.buildForm();
}
ngOnChanges() {
this.buildForm();
}
private buildForm() {
this.readOnlyFormArray = DEFAULT_MULTILANGUAGE_FORM(this.node.labels);
}
mouseEnter() {
if (this.isAdmin) {
this.showActionBubble = true;
}
}
mouseLeave() {
this.showActionBubble = false;
}
}