-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathedit-component-advanced.component.ts
More file actions
68 lines (66 loc) · 2 KB
/
Copy pathedit-component-advanced.component.ts
File metadata and controls
68 lines (66 loc) · 2 KB
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
import {
ApplicationRef,
Component,
ComponentRef,
createComponent,
ElementRef,
EnvironmentInjector,
Inject,
ViewChild,
ViewEncapsulation
} from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog';
import { MatDivider } from '@angular/material/divider';
import { Component as WISEComponent } from '../../../assets/wise5/common/Component';
import { components } from '../../../assets/wise5/components/Components';
@Component({
encapsulation: ViewEncapsulation.None,
imports: [MatDivider, MatDialogModule, MatButtonModule],
styles: [
`
.edit-component-advanced {
--mat-tab-divider-color: var(--mat-divider-color);
--mat-tab-divider-height: 1px;
.mat-divider {
margin: 0 -16px;
}
.mat-mdc-tab-body-content {
padding: 16px 0;
}
.mat-mdc-tab-header {
position: sticky;
top: 0;
z-index: 2;
background-color: white;
margin: 0 -16px;
}
}
`
],
templateUrl: './edit-component-advanced.component.html'
})
export class EditComponentAdvancedComponent {
@ViewChild('component') private componentElementRef: ElementRef;
private componentRef: ComponentRef<WISEComponent>;
constructor(
private applicationRef: ApplicationRef,
@Inject(MAT_DIALOG_DATA) protected data: { component: WISEComponent; tab?: string },
private injector: EnvironmentInjector
) {}
ngAfterViewInit(): void {
this.componentRef = createComponent(
components[this.data.component.content.type].authoringAdvanced,
{
hostElement: this.componentElementRef.nativeElement,
environmentInjector: this.injector
}
);
Object.assign(this.componentRef.instance, {
nodeId: this.data.component.nodeId,
componentId: this.data.component.id,
tab: this.data.tab
});
this.applicationRef.attachView(this.componentRef.hostView);
}
}