From 9a091b8c8f82200f1d278ceaebe77a6c35cb069b Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Thu, 26 Sep 2024 12:45:22 -0700 Subject: [PATCH] refactor(EditComponentScoreComponent): Convert to standalone (#1956) --- src/app/teacher/grading-common.module.ts | 2 +- .../edit-component-annotations.component.html | 6 ++--- .../edit-component-score.component.html | 22 +++++++++++------ .../edit-component-score.component.spec.ts | 16 ++++++------- .../edit-component-score.component.ts | 24 ++++++++++++------- src/messages.xlf | 10 ++++---- 6 files changed, 47 insertions(+), 33 deletions(-) diff --git a/src/app/teacher/grading-common.module.ts b/src/app/teacher/grading-common.module.ts index d0ec032315a..0437ce757a2 100644 --- a/src/app/teacher/grading-common.module.ts +++ b/src/app/teacher/grading-common.module.ts @@ -18,6 +18,7 @@ import { NavItemProgressComponent } from '../classroom-monitor/nav-item-progress @NgModule({ imports: [ ComponentGradingModule, + EditComponentScoreComponent, IntersectionObserverModule, StatusIconComponent, StudentTeacherCommonModule, @@ -27,7 +28,6 @@ import { NavItemProgressComponent } from '../classroom-monitor/nav-item-progress declarations: [ EditComponentAnnotationsComponent, EditComponentCommentComponent, - EditComponentScoreComponent, GradingEditComponentMaxScoreComponent, NavItemProgressComponent, WorkgroupComponentGradingComponent, diff --git a/src/assets/wise5/classroomMonitor/classroomMonitorComponents/edit-component-annotations/edit-component-annotations.component.html b/src/assets/wise5/classroomMonitor/classroomMonitorComponents/edit-component-annotations/edit-component-annotations.component.html index 15b8883aa30..5b7d0616cfc 100644 --- a/src/assets/wise5/classroomMonitor/classroomMonitorComponents/edit-component-annotations/edit-component-annotations.component.html +++ b/src/assets/wise5/classroomMonitor/classroomMonitorComponents/edit-component-annotations/edit-component-annotations.component.html @@ -14,7 +14,7 @@ [periodId]="periodId" [runId]="runId" [toWorkgroupId]="toWorkgroupId" - > + /> / + /> / + /> / { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [EditComponentScoreComponent], - schemas: [NO_ERRORS_SCHEMA], - imports: [MatDialogModule, StudentTeacherCommonServicesModule], - providers: [provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()] -}); + imports: [ + BrowserAnimationsModule, + EditComponentScoreComponent, + StudentTeacherCommonServicesModule + ], + providers: [provideHttpClient(withInterceptorsFromDi())] + }); annotationService = TestBed.inject(AnnotationService); notificationService = TestBed.inject(NotificationService); fixture = TestBed.createComponent(EditComponentScoreComponent); diff --git a/src/assets/wise5/classroomMonitor/classroomMonitorComponents/edit-component-score/edit-component-score.component.ts b/src/assets/wise5/classroomMonitor/classroomMonitorComponents/edit-component-score/edit-component-score.component.ts index d7c00c5ac3a..391c651ec38 100644 --- a/src/assets/wise5/classroomMonitor/classroomMonitorComponents/edit-component-score/edit-component-score.component.ts +++ b/src/assets/wise5/classroomMonitor/classroomMonitorComponents/edit-component-score/edit-component-score.component.ts @@ -3,9 +3,16 @@ import { Subject, Subscription } from 'rxjs'; import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; import { AnnotationService } from '../../../services/annotationService'; import { NotificationService } from '../../../services/notificationService'; +import { CommonModule } from '@angular/common'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { FlexLayoutModule } from '@angular/flex-layout'; +import { MatInputModule } from '@angular/material/input'; +import { FormsModule } from '@angular/forms'; @Component({ + imports: [CommonModule, FlexLayoutModule, FormsModule, MatFormFieldModule, MatInputModule], selector: 'edit-component-score', + standalone: true, templateUrl: 'edit-component-score.component.html' }) export class EditComponentScoreComponent { @@ -13,24 +20,23 @@ export class EditComponentScoreComponent { @Input() componentStateId: string; @Input() disabled: boolean; @Input() fromWorkgroupId: number; + protected isAutoScore: boolean; @Input() latestAnnotationScore: any; @Input() nodeId: string; @Input() periodId: string; @Input() runId: string; - @Input() toWorkgroupId: number; - @ViewChild('scoreInput') scoreInputElement: ElementRef; - - isAutoScore: boolean; score: number; - scoreChanged: Subject = new Subject(); - subscriptions: Subscription = new Subscription(); + protected scoreChanged: Subject = new Subject(); + @ViewChild('scoreInput') scoreInputElement: ElementRef; + private subscriptions: Subscription = new Subscription(); + @Input() toWorkgroupId: number; constructor( private annotationService: AnnotationService, private notificationService: NotificationService ) {} - ngOnInit() { + ngOnInit(): void { this.isAutoScore = this.latestAnnotationScore?.type === 'autoScore'; this.score = this.latestAnnotationScore?.data.value ?? 0; this.subscriptions.add( @@ -41,7 +47,7 @@ export class EditComponentScoreComponent { ); } - ngOnDestroy() { + ngOnDestroy(): void { this.subscriptions.unsubscribe(); } @@ -66,7 +72,7 @@ export class EditComponentScoreComponent { }); } - focusScoreInput() { + protected focusScoreInput(): void { this.scoreInputElement.nativeElement.focus(); } } diff --git a/src/messages.xlf b/src/messages.xlf index ab45a4fbcb3..28675d142fd 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -5806,7 +5806,7 @@ Click "Cancel" to keep the invalid JSON open so you can fix it. src/assets/wise5/classroomMonitor/classroomMonitorComponents/edit-component-score/edit-component-score.component.html - 5 + 7 @@ -13339,28 +13339,28 @@ The branches will be removed but the steps will remain in the unit. Auto Score src/assets/wise5/classroomMonitor/classroomMonitorComponents/edit-component-score/edit-component-score.component.html - 4 + 5 Teacher Score: src/assets/wise5/classroomMonitor/classroomMonitorComponents/edit-component-score/edit-component-score.component.html - 8 + 13 Item Score: src/assets/wise5/classroomMonitor/classroomMonitorComponents/edit-component-score/edit-component-score.component.html - 9 + 15 Saved score src/assets/wise5/classroomMonitor/classroomMonitorComponents/edit-component-score/edit-component-score.component.ts - 65 + 71