/
list-value.component.html
64 lines (57 loc) · 3.02 KB
/
list-value.component.html
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
<span *ngIf="mode !== 'read' && listRootNode !== undefined">
<!-- button to select a list node -->
<span [matTooltip]="(!selectedNode && !listRootNode.children.length) ? 'This list doesn\'t have any node values' : 'Select list value'" [matTooltipPosition]="'above'">
<button mat-stroked-button [matMenuTriggerFor]="mainMenu" type="button" placeholder="List value" [disabled]="!selectedNode && !listRootNode.children.length">
<!-- if no node is selected: display list label; if the list does not have any list nodes, the button should be disabled -->
<span *ngIf="!selectedNode">{{listRootNode.label}}</span>
<!-- if a node is selected: display node label -->
<span *ngIf="selectedNode">{{selectedNode.label}}</span>
</button>
</span>
<mat-menu #mainMenu="matMenu" [overlapTrigger]="false">
<span *ngFor="let child of listRootNode.children">
<span *ngIf="child.children && child.children.length > 0">
<button mat-menu-item [matMenuTriggerFor]="menu.childMenu" (click)="getSelectedNode(child)"
type="button">
{{child.label}}
</button>
<app-sublist-value #menu [children]="child.children" (selectedNode)="getSelectedNode($event)">
</app-sublist-value>
</span>
<span *ngIf="!child.children || child.children.length === 0">
<button mat-menu-item (click)="getSelectedNode(child)" type="button">
{{child.label}}
</button>
</span>
</span>
</mat-menu>
<mat-error *ngIf="valueFormControl.hasError('valueNotChanged') && valueFormControl.dirty">
<span class="custom-error-message">New value must be different than the current value.</span>
</mat-error>
<mat-error *ngIf="valueFormControl.hasError('duplicateValue')">
<span class="custom-error-message">This value already exists for this property. Duplicate values are not allowed.</span>
</mat-error>
</span>
<span *ngIf="mode === 'read'; else showForm" class="read-mode-view">
<span class="rm-value">{{valueFormControl.value}}</span>
<span class="rm-comment" *ngIf="shouldShowComment">{{commentFormControl.value}}</span>
</span>
<ng-template #showForm>
<span [formGroup]="form">
<mat-form-field class="large-field child-value-component" *ngIf="mode === 'read'" floatLabel="never">
<input [formControlName]="'value'" class="value" type="text" placeholder="List value" matInput readonly>
</mat-form-field>
<mat-form-field class="large-field value-component-comment">
<textarea matInput
cdkTextareaAutosize
cdkAutosizeMinRows="1"
cdkAutosizeMaxRows="6"
[formControlName]="'comment'"
class="comment"
placeholder="Comment"
type="text"
spellcheck="false">
</textarea>
</mat-form-field>
</span>
</ng-template>