-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathedit-advanced-component.component.ts
More file actions
89 lines (77 loc) · 3.05 KB
/
Copy pathedit-advanced-component.component.ts
File metadata and controls
89 lines (77 loc) · 3.05 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { Directive, inject, Input } from '@angular/core';
import { ComponentContent } from '../../../assets/wise5/common/ComponentContent';
import { Component } from '../../../assets/wise5/common/Component';
import { NotebookService } from '../../../assets/wise5/services/notebookService';
import { TeacherProjectService } from '../../../assets/wise5/services/teacherProjectService';
import { TeacherNodeService } from '../../../assets/wise5/services/teacherNodeService';
import { moveObjectDown, moveObjectUp } from '../../../assets/wise5/common/array/array';
import { ComponentServiceLookupService } from '../../../assets/wise5/services/componentServiceLookupService';
@Directive()
export abstract class EditAdvancedComponentComponent {
protected aiEnabled: boolean;
component: Component;
componentContent: ComponentContent;
protected selectedTabIndex: number = 0;
@Input() componentId: string;
@Input() nodeId: string;
@Input() tab: string = 'general';
private componentServiceLookupService = inject(ComponentServiceLookupService);
constructor(
protected nodeService: TeacherNodeService,
protected notebookService: NotebookService,
protected teacherProjectService: TeacherProjectService
) {}
ngOnInit(): void {
this.componentContent = this.teacherProjectService.getComponent(this.nodeId, this.componentId);
this.component = new Component(this.componentContent, this.nodeId);
this.aiEnabled = this.teacherProjectService.getProject().ai?.enabled;
if (this.aiEnabled && ['Discussion', 'OpenResponse'].includes(this.component.content.type)) {
if (this.component.content.ai == null) {
const componentService = this.componentServiceLookupService.getService(
this.component.content.type
);
this.component.content.ai = {
teacherSummarySystemPrompt: componentService.getDefaultTeacherSummarySystemPrompt(
this.component.content.prompt
)
};
}
}
this.teacherProjectService.uiChanged();
switch (this.tab) {
case 'visibility':
this.selectedTabIndex = 1;
break;
default:
this.selectedTabIndex = 0;
break;
}
}
setShowSubmitButtonValue(show: boolean = false): void {
this.componentContent.showSaveButton = show;
this.componentContent.showSubmitButton = show;
this.nodeService.broadcastComponentShowSubmitButtonValueChanged({
nodeId: this.nodeId,
componentId: this.componentId,
showSubmitButton: show
});
}
isNotebookEnabled(): boolean {
return this.notebookService.isNotebookEnabled();
}
connectedComponentsChanged(connectedComponents: any[]): void {
this.componentContent.connectedComponents = connectedComponents;
this.componentChanged();
}
componentChanged(): void {
this.teacherProjectService.nodeChanged();
}
moveObjectUp(objects: any[], index: number): void {
moveObjectUp(objects, index);
this.componentChanged();
}
moveObjectDown(objects: any[], index: number): void {
moveObjectDown(objects, index);
this.componentChanged();
}
}