diff --git a/src/assets/wise5/components/match/delete-choice-button/delete-choice-button.component.spec.ts b/src/assets/wise5/components/match/delete-choice-button/delete-choice-button.component.spec.ts index aee09eaa23b..9daec08a2b9 100644 --- a/src/assets/wise5/components/match/delete-choice-button/delete-choice-button.component.spec.ts +++ b/src/assets/wise5/components/match/delete-choice-button/delete-choice-button.component.spec.ts @@ -1,28 +1,32 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; import { DeleteChoiceButtonComponent } from './delete-choice-button.component'; +import { HarnessLoader } from '@angular/cdk/testing'; +import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; +import { MatButtonHarness } from '@angular/material/button/testing'; let component: DeleteChoiceButtonComponent; let fixture: ComponentFixture; - +let loader: HarnessLoader; describe('DeleteChoiceButtonComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [DeleteChoiceButtonComponent], - providers: [] + imports: [DeleteChoiceButtonComponent] }); fixture = TestBed.createComponent(DeleteChoiceButtonComponent); component = fixture.componentInstance; component.buckets = [{ items: [{ id: 1 }, { id: 2 }] }, { items: [{ id: 3 }] }]; component.item = { id: 2 }; + loader = TestbedHarnessEnvironment.loader(fixture); }); deleteChoice(); }); function deleteChoice() { - describe('deleteChoice', () => { - it('should delete a choice', () => { + describe('clicking on the button', () => { + it('should delete a choice', async () => { + expect(component.buckets[0].items.length).toEqual(2); spyOn(window, 'confirm').and.returnValue(true); - component.deleteChoice(); + await (await loader.getHarness(MatButtonHarness)).click(); expect(component.buckets[0].items.length).toEqual(1); }); }); diff --git a/src/assets/wise5/components/match/delete-choice-button/delete-choice-button.component.ts b/src/assets/wise5/components/match/delete-choice-button/delete-choice-button.component.ts index 6d23feb426f..ee4ecab3df3 100644 --- a/src/assets/wise5/components/match/delete-choice-button/delete-choice-button.component.ts +++ b/src/assets/wise5/components/match/delete-choice-button/delete-choice-button.component.ts @@ -28,14 +28,11 @@ import { MatTooltipModule } from '@angular/material/tooltip'; }) export class DeleteChoiceButtonComponent { @Input() buckets: any; - @Input() isDisabled: boolean; - @Input() item: any; - @Output() onItemDeleted = new EventEmitter(); - deleteChoice(): void { + protected deleteChoice(): void { if (confirm($localize`Are you sure you want to delete this item?`)) { this.buckets.forEach((bucket) => { let i = 0; diff --git a/src/assets/wise5/components/match/match-choice-item/match-choice-item.component.html b/src/assets/wise5/components/match/match-choice-item/match-choice-item.component.html index 23373e264c7..65ba48f5dcf 100644 --- a/src/assets/wise5/components/match/match-choice-item/match-choice-item.component.html +++ b/src/assets/wise5/components/match/match-choice-item/match-choice-item.component.html @@ -1,29 +1,37 @@ -
- drag_indicator +
+ @if (!isDisabled) { + drag_indicator + }
- - -
- + @if (item.feedback) { + + } diff --git a/src/assets/wise5/components/match/match-choice-item/match-choice-item.component.ts b/src/assets/wise5/components/match/match-choice-item/match-choice-item.component.ts index b57269a07f1..d2d10e85aab 100644 --- a/src/assets/wise5/components/match/match-choice-item/match-choice-item.component.ts +++ b/src/assets/wise5/components/match/match-choice-item/match-choice-item.component.ts @@ -1,24 +1,30 @@ import { Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core'; +import { DeleteChoiceButtonComponent } from '../delete-choice-button/delete-choice-button.component'; +import { FlexLayoutModule } from '@angular/flex-layout'; +import { MatchStatusIconComponent } from '../match-status-icon/match-status-icon.component'; +import { MatIconModule } from '@angular/material/icon'; +import { MatCardModule } from '@angular/material/card'; +import { CommonModule } from '@angular/common'; @Component({ + encapsulation: ViewEncapsulation.None, + imports: [ + CommonModule, + DeleteChoiceButtonComponent, + FlexLayoutModule, + MatCardModule, + MatchStatusIconComponent, + MatIconModule + ], selector: 'match-choice-item', - templateUrl: 'match-choice-item.component.html', - styleUrls: ['match-choice-item.component.scss'], - encapsulation: ViewEncapsulation.None + standalone: true, + styleUrl: 'match-choice-item.component.scss', + templateUrl: 'match-choice-item.component.html' }) -export class MatchChoiceItem { - @Input() - buckets: any; - - @Input() - hasCorrectAnswer: boolean; - - @Input() - isDisabled: boolean; - - @Input() - item: any; - - @Output() - onStudentDataChanged = new EventEmitter(); +export class MatchChoiceItemComponent { + @Input() buckets: any; + @Input() hasCorrectAnswer: boolean; + @Input() isDisabled: boolean; + @Input() item: any; + @Output() onStudentDataChanged = new EventEmitter(); } diff --git a/src/assets/wise5/components/match/match-common.module.ts b/src/assets/wise5/components/match/match-common.module.ts index 0356ca3c2ce..d7c4cc5e02d 100644 --- a/src/assets/wise5/components/match/match-common.module.ts +++ b/src/assets/wise5/components/match/match-common.module.ts @@ -5,25 +5,23 @@ import { FlexLayoutModule } from '@angular/flex-layout'; import { ReactiveFormsModule } from '@angular/forms'; import { MatButtonModule } from '@angular/material/button'; import { MatCardModule } from '@angular/material/card'; +import { MatchChoiceItemComponent } from './match-choice-item/match-choice-item.component'; import { MatDialogModule } from '@angular/material/dialog'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; import { MatTooltipModule } from '@angular/material/tooltip'; -import { DeleteChoiceButtonComponent } from './delete-choice-button/delete-choice-button.component'; -import { MatchChoiceItem } from './match-choice-item/match-choice-item.component'; import { MatchStatusIconComponent } from './match-status-icon/match-status-icon.component'; import { MatchFeedbackSectionComponent } from './match-student/match-feedback-section/match-feedback-section.component'; @NgModule({ - declarations: [MatchChoiceItem], imports: [ CommonModule, - DeleteChoiceButtonComponent, DragDropModule, FlexLayoutModule, MatButtonModule, MatCardModule, + MatchChoiceItemComponent, MatchFeedbackSectionComponent, MatchStatusIconComponent, MatDialogModule, @@ -35,13 +33,12 @@ import { MatchFeedbackSectionComponent } from './match-student/match-feedback-se ], exports: [ CommonModule, - DeleteChoiceButtonComponent, DragDropModule, FlexLayoutModule, MatButtonModule, MatCardModule, MatDialogModule, - MatchChoiceItem, + MatchChoiceItemComponent, MatchFeedbackSectionComponent, MatchStatusIconComponent, MatFormFieldModule, diff --git a/src/assets/wise5/components/match/match-show-work/match-show-work.component.html b/src/assets/wise5/components/match/match-show-work/match-show-work.component.html index b5fbd8cbd9c..0076471a3fa 100644 --- a/src/assets/wise5/components/match/match-show-work/match-show-work.component.html +++ b/src/assets/wise5/components/match/match-show-work/match-show-work.component.html @@ -29,7 +29,7 @@

[item]="item" [hasCorrectAnswer]="hasCorrectAnswer" [isDisabled]="true" - > + />
@@ -68,7 +68,7 @@

[item]="item" [hasCorrectAnswer]="hasCorrectAnswer" [isDisabled]="true" - > + /> diff --git a/src/assets/wise5/components/match/match-student/match-student-default/match-student-default.component.html b/src/assets/wise5/components/match/match-student/match-student-default/match-student-default.component.html index 865abc0aa8e..b9953c4e561 100644 --- a/src/assets/wise5/components/match/match-student/match-student-default/match-student-default.component.html +++ b/src/assets/wise5/components/match/match-student/match-student-default/match-student-default.component.html @@ -40,7 +40,7 @@

[hasCorrectAnswer]="hasCorrectAnswer" [isDisabled]="isDisabled" (onStudentDataChanged)="studentDataChanged()" - > + /> @@ -91,7 +91,7 @@

[hasCorrectAnswer]="hasCorrectAnswer" [isDisabled]="isDisabled" (onStudentDataChanged)="studentDataChanged()" - > + /> diff --git a/src/messages.xlf b/src/messages.xlf index cd20ce98816..1635aaa4a9e 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -19228,7 +19228,7 @@ Category Name: Are you sure you want to delete this item? src/assets/wise5/components/match/delete-choice-button/delete-choice-button.component.ts - 39 + 36