Skip to content

Commit

Permalink
refactor(PromptComponent): Convert to standalone (#1792)
Browse files Browse the repository at this point in the history
  • Loading branch information
hirokiterashima authored May 10, 2024
1 parent cc67ce9 commit a069ec4
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ describe('ShowNodeInfoDialogComponent', () => {
NodeInfoComponent,
OpenResponseStudent,
PreviewComponentComponent,
PromptComponent,
ShowNodeInfoDialogComponent
],
imports: [
Expand All @@ -57,7 +56,8 @@ describe('ShowNodeInfoDialogComponent', () => {
MatCardModule,
MatDialogModule,
MatIconModule,
MatToolbarModule
MatToolbarModule,
PromptComponent
],
providers: [
{ provide: MAT_DIALOG_DATA, useValue: nodeId1 },
Expand Down
9 changes: 3 additions & 6 deletions src/app/student/student.component.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { AddToNotebookButton } from '../../assets/wise5/directives/add-to-notebo
import { ComponentHeader } from '../../assets/wise5/directives/component-header/component-header.component';
import { ComponentSaveSubmitButtons } from '../../assets/wise5/directives/component-save-submit-buttons/component-save-submit-buttons.component';
import { ComponentAnnotationsComponent } from '../../assets/wise5/directives/componentAnnotations/component-annotations.component';
import { DynamicPromptComponent } from '../../assets/wise5/directives/dynamic-prompt/dynamic-prompt.component';
import { PromptComponent } from '../../assets/wise5/directives/prompt/prompt.component';
import { PossibleScoreComponent } from '../possible-score/possible-score.component';
import { StudentTeacherCommonModule } from '../student-teacher-common.module';
Expand All @@ -14,21 +13,19 @@ import { ComponentStateInfoComponent } from '../../assets/wise5/common/component
AddToNotebookButton,
ComponentAnnotationsComponent,
ComponentHeader,
ComponentSaveSubmitButtons,
PromptComponent
ComponentSaveSubmitButtons
],
imports: [
ComponentStateInfoComponent,
DynamicPromptComponent,
PossibleScoreComponent,
PromptComponent,
StudentTeacherCommonModule
],
exports: [
AddToNotebookButton,
ComponentAnnotationsComponent,
ComponentHeader,
ComponentSaveSubmitButtons,
PromptComponent
ComponentSaveSubmitButtons
]
})
export class StudentComponentModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('AiChatStudentComponent', () => {

beforeEach(() => {
TestBed.configureTestingModule({
declarations: [AiChatStudentComponent, ComponentHeader, PromptComponent],
declarations: [AiChatStudentComponent, ComponentHeader],
imports: [
AiChatModule,
BrowserAnimationsModule,
Expand All @@ -37,6 +37,7 @@ describe('AiChatStudentComponent', () => {
MatInputModule,
MatSnackBarModule,
PossibleScoreComponent,
PromptComponent,
StudentTeacherCommonServicesModule
],
providers: [AiChatService]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { PeerGrouping } from '../../../../../app/domain/peerGrouping';
import { PauseScreenService } from '../../../services/pauseScreenService';
import { StudentTeacherCommonServicesModule } from '../../../../../app/student-teacher-common-services.module';
import { FeedbackRule } from '../../common/feedbackRule/FeedbackRule';
import { DynamicPromptComponent } from '../../../directives/dynamic-prompt/dynamic-prompt.component';
import { PromptComponent } from '../../../directives/prompt/prompt.component';
import { PeerChatComponent } from '../PeerChatComponent';

Expand Down Expand Up @@ -121,7 +120,6 @@ describe('PeerChatStudentComponent', () => {
TestBed.configureTestingModule({
imports: [
BrowserAnimationsModule,
DynamicPromptComponent,
FormsModule,
HttpClientTestingModule,
MatCardModule,
Expand All @@ -130,10 +128,11 @@ describe('PeerChatStudentComponent', () => {
MatIconModule,
MatInputModule,
PeerChatModule,
PromptComponent,
PossibleScoreComponent,
StudentTeacherCommonServicesModule
],
declarations: [ComponentHeader, PeerChatStudentComponent, PromptComponent],
declarations: [ComponentHeader, PeerChatStudentComponent],
providers: [
AnnotationService,
ComponentService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentHeader } from './component-header.component';
import { DomSanitizer } from '@angular/platform-browser';
import { PromptComponent } from '../prompt/prompt.component';
import { DynamicPromptComponent } from '../dynamic-prompt/dynamic-prompt.component';
import { ComponentContent } from '../../common/ComponentContent';
import { Component } from '../../common/Component';

Expand All @@ -13,8 +12,8 @@ let fixture: ComponentFixture<ComponentHeader>;
describe('ComponentHeaderComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ComponentHeader, PromptComponent],
imports: [DynamicPromptComponent],
declarations: [ComponentHeader],
imports: [PromptComponent],
providers: [
{
provide: DomSanitizer,
Expand Down
4 changes: 1 addition & 3 deletions src/assets/wise5/directives/prompt/prompt.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { MatDialogModule } from '@angular/material/dialog';
import { StudentTeacherCommonServicesModule } from '../../../../app/student-teacher-common-services.module';
import { ComponentContent } from '../../common/ComponentContent';
import { ProjectService } from '../../services/projectService';
import { DynamicPromptComponent } from '../dynamic-prompt/dynamic-prompt.component';
import { DynamicPrompt } from '../dynamic-prompt/DynamicPrompt';
import { PromptComponent } from './prompt.component';

Expand All @@ -17,11 +16,10 @@ describe('PromptComponent', () => {

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [PromptComponent],
imports: [
DynamicPromptComponent,
HttpClientTestingModule,
MatDialogModule,
PromptComponent,
StudentTeacherCommonServicesModule
]
}).compileComponents();
Expand Down
18 changes: 9 additions & 9 deletions src/assets/wise5/directives/prompt/prompt.component.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { FeedbackRule } from '../../components/common/feedbackRule/FeedbackRule';
import { DynamicPrompt } from '../dynamic-prompt/DynamicPrompt';
import { CommonModule } from '@angular/common';
import { DynamicPromptComponent } from '../dynamic-prompt/dynamic-prompt.component';

@Component({
imports: [CommonModule, DynamicPromptComponent],
selector: 'prompt',
templateUrl: './prompt.component.html',
styleUrls: ['./prompt.component.scss']
standalone: true,
styleUrl: './prompt.component.scss',
templateUrl: './prompt.component.html'
})
export class PromptComponent implements OnInit {
export class PromptComponent {
@Input() componentId: string;
@Input() dynamicPrompt: DynamicPrompt;
@Output() dynamicPromptChanged: EventEmitter<FeedbackRule> = new EventEmitter<FeedbackRule>();
@Input() nodeId: string;
@Input() prompt: string;

constructor() {}

ngOnInit(): void {}

onDynamicPromptChanged(feedbackRule: FeedbackRule): void {
protected onDynamicPromptChanged(feedbackRule: FeedbackRule): void {
this.dynamicPromptChanged.emit(feedbackRule);
}
}

0 comments on commit a069ec4

Please sign in to comment.