Skip to content

Commit

Permalink
Merge branch 'develop' into issue-1513-multiple-languages-per-unit
Browse files Browse the repository at this point in the history
  • Loading branch information
hirokiterashima committed Dec 1, 2023
2 parents bc3b915 + 1207add commit 63f86ee
Show file tree
Hide file tree
Showing 10 changed files with 318 additions and 309 deletions.
371 changes: 145 additions & 226 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"@babel/core": "^7.17.9",
"@babel/preset-env": "^7.16.11",
"@ngtools/webpack": "^16.2.6",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/github": "^8.0.4",
"@types/dom-mediacapture-record": "^1.0.11",
"@types/jasmine": "^4.3.1",
Expand Down Expand Up @@ -168,11 +169,20 @@
"npmPublish": false
}
],
[
"@semantic-release/exec",
{
"prepareCmd": "cd dist; tar -czf en-US.tar.gz en-US"
}
],
[
"@semantic-release/github",
{
"assets": [
{ "path": "dist/en-US/**", "label": "English build" }
{
"path": "dist/en-US.tar.gz",
"label": "English build"
}
]
}
]
Expand Down
2 changes: 2 additions & 0 deletions src/app/teacher/authoring-tool.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ import { ComponentTypeButtonComponent } from '../../assets/wise5/authoringTool/c
import { ComponentInfoDialogComponent } from '../../assets/wise5/authoringTool/components/component-info-dialog/component-info-dialog.component';
import { ComponentTypeSelectorComponent } from '../../assets/wise5/authoringTool/components/component-type-selector/component-type-selector.component';
import { EditNodeTitleComponent } from '../../assets/wise5/authoringTool/node/edit-node-title/edit-node-title.component';
import { AddComponentButtonComponent } from '../../assets/wise5/authoringTool/node/add-component-button/add-component-button.component';

@NgModule({
declarations: [
AddComponentButtonComponent,
AddLessonChooseLocationComponent,
AddLessonChooseTemplateComponent,
AddLessonConfigureComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<button
mat-icon-button
color="primary"
matTooltip="Add a new component"
i18n-matTooltip
matTooltipPosition="above"
(click)="addComponent()"
>
<mat-icon>add_circle</mat-icon>
</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AddComponentButtonComponent } from './add-component-button.component';
import { MatDialog, MatDialogModule } from '@angular/material/dialog';
import { TeacherProjectService } from '../../../services/teacherProjectService';
import { RouterTestingModule } from '@angular/router/testing';
import { MatIconModule } from '@angular/material/icon';
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
import { HarnessLoader } from '@angular/cdk/testing';
import { MatButtonHarness } from '@angular/material/button/testing';
import { ChooseNewComponent } from '../../../../../app/authoring-tool/add-component/choose-new-component/choose-new-component.component';
import { of } from 'rxjs';
import { Node } from '../../../common/Node';

class MockTeacherProjectService {
createComponent() {}
saveProject() {}
}
let loader: HarnessLoader;
describe('AddComponentButtonComponent', () => {
let component: AddComponentButtonComponent;
let fixture: ComponentFixture<AddComponentButtonComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [AddComponentButtonComponent],
imports: [MatDialogModule, MatIconModule, RouterTestingModule],
providers: [{ provide: TeacherProjectService, useClass: MockTeacherProjectService }]
});
fixture = TestBed.createComponent(AddComponentButtonComponent);
component = fixture.componentInstance;
component.node = { id: 'node1' } as Node;
loader = TestbedHarnessEnvironment.loader(fixture);
fixture.detectChanges();
});

describe('clicking on the button', () => {
it('shows add component dialog, create selected component, and save project', async () => {
const dialogSpy = spyOn(TestBed.inject(MatDialog), 'open').and.returnValue({
afterClosed: () => of({ action: 'create', componentType: 'OpenResponse' })
} as any);
const projectService = TestBed.inject(TeacherProjectService);
const createComponentSpy = spyOn(projectService, 'createComponent');
const saveProjectSpy = spyOn(projectService, 'saveProject');
await (await loader.getHarness(MatButtonHarness)).click();
expect(dialogSpy).toHaveBeenCalledWith(ChooseNewComponent, {
data: null,
width: '80%'
});
expect(createComponentSpy).toHaveBeenCalled();
expect(saveProjectSpy).toHaveBeenCalled();
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { TeacherProjectService } from '../../../services/teacherProjectService';
import { MatDialog } from '@angular/material/dialog';
import { ChooseNewComponent } from '../../../../../app/authoring-tool/add-component/choose-new-component/choose-new-component.component';
import { filter } from 'rxjs';
import { ActivatedRoute, Router } from '@angular/router';
import { Node } from '../../../common/Node';

@Component({
selector: 'add-component-button',
templateUrl: './add-component-button.component.html'
})
export class AddComponentButtonComponent {
@Input() insertAfterComponentId: string = null;
@Input() node: Node;
@Output() newComponentsEvent: EventEmitter<any> = new EventEmitter<any>();

constructor(
private dialog: MatDialog,
private projectService: TeacherProjectService,
private route: ActivatedRoute,
private router: Router
) {}

protected addComponent(): void {
this.dialog
.open(ChooseNewComponent, {
data: this.insertAfterComponentId,
width: '80%'
})
.afterClosed()
.pipe(filter((componentType) => componentType != null))
.subscribe(({ action, componentType }) => {
if (action === 'import') {
this.router.navigate(['import-component/choose-component'], {
relativeTo: this.route,
state: {
insertAfterComponentId: this.insertAfterComponentId
}
});
} else {
const component = this.projectService.createComponent(
this.node.id,
componentType,
this.insertAfterComponentId
);
this.projectService.saveProject();
this.newComponentsEvent.emit([component]);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,6 @@
<mat-icon>close</mat-icon>
</button>
</div>
<ng-template #addComponentButtonTemplate let-componentId="componentId">
<button
mat-icon-button
color="primary"
matTooltip="Add a new component"
i18n-matTooltip
matTooltipPosition="above"
(click)="addComponent(componentId)"
>
<mat-icon>add_circle</mat-icon>
</button>
</ng-template>
<div
*ngIf="!isGroupNode"
class="components-header"
Expand All @@ -57,9 +45,10 @@
fxLayoutGap="4px"
>
<h5 i18n>Components</h5>
<ng-container
*ngTemplateOutlet="addComponentButtonTemplate; context: { componentId: null }"
></ng-container>
<add-component-button
[node]="node"
(newComponentsEvent)="highlightNewComponentsAndThenShowComponentAuthoring($event)"
></add-component-button>
<div *ngIf="isAnyComponentSelected()">
<button
mat-icon-button
Expand Down Expand Up @@ -227,11 +216,12 @@ <h5 i18n>Components</h5>
[componentContent]="component"
></component-authoring-component>
</div>
<div class="add-component">
<ng-container
*ngTemplateOutlet="addComponentButtonTemplate; context: { componentId: component.id }"
></ng-container>
</div>
<add-component-button
class="add-component"
[insertAfterComponentId]="component.id"
[node]="node"
(newComponentsEvent)="highlightNewComponentsAndThenShowComponentAuthoring($event)"
></add-component-button>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { NodeAuthoringComponent } from './node-authoring.component';
import { StudentTeacherCommonServicesModule } from '../../../../../app/student-teacher-common-services.module';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { TeacherProjectService } from '../../../services/teacherProjectService';
import { MatDialogModule } from '@angular/material/dialog';
import { TeacherDataService } from '../../../services/teacherDataService';
import { TeacherWebSocketService } from '../../../services/teacherWebSocketService';
import { ClassroomStatusService } from '../../../services/classroomStatusService';
Expand All @@ -24,6 +23,7 @@ import { ActivatedRoute, Router, convertToParamMap } from '@angular/router';
import { of } from 'rxjs';
import { TeacherNodeService } from '../../../services/teacherNodeService';
import { EditNodeTitleComponent } from '../edit-node-title/edit-node-title.component';
import { AddComponentButtonComponent } from '../add-component-button/add-component-button.component';

let component: NodeAuthoringComponent;
let component1: any;
Expand All @@ -39,15 +39,19 @@ let teacherProjectService: TeacherProjectService;
describe('NodeAuthoringComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [EditNodeTitleComponent, NodeAuthoringComponent, TeacherNodeIconComponent],
declarations: [
AddComponentButtonComponent,
EditNodeTitleComponent,
NodeAuthoringComponent,
TeacherNodeIconComponent
],
imports: [
BrowserAnimationsModule,
ComponentAuthoringModule,
DragDropModule,
FormsModule,
HttpClientTestingModule,
MatCheckboxModule,
MatDialogModule,
MatIconModule,
MatInputModule,
PreviewComponentModule,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { Component, Input, OnInit, Signal, WritableSignal, computed, signal } from '@angular/core';
import { Subscription, filter } from 'rxjs';
import { Subscription } from 'rxjs';
import { TeacherDataService } from '../../../services/teacherDataService';
import { TeacherProjectService } from '../../../services/teacherProjectService';
import { ComponentTypeService } from '../../../services/componentTypeService';
import { ComponentServiceLookupService } from '../../../services/componentServiceLookupService';
import { Node } from '../../../common/Node';
import { ComponentContent } from '../../../common/ComponentContent';
import { temporarilyHighlightElement } from '../../../common/dom/dom';
import { MatDialog } from '@angular/material/dialog';
import { ConfigService } from '../../../../wise5/services/configService';
import { ChooseNewComponent } from '../../../../../app/authoring-tool/add-component/choose-new-component/choose-new-component.component';
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
import { ActivatedRoute, Router } from '@angular/router';
import { TeacherNodeService } from '../../../services/teacherNodeService';
Expand Down Expand Up @@ -37,7 +35,6 @@ export class NodeAuthoringComponent implements OnInit {
private configService: ConfigService,
private componentServiceLookupService: ComponentServiceLookupService,
private componentTypeService: ComponentTypeService,
private dialog: MatDialog,
private nodeService: TeacherNodeService,
private projectService: TeacherProjectService,
private dataService: TeacherDataService,
Expand Down Expand Up @@ -122,34 +119,6 @@ export class NodeAuthoringComponent implements OnInit {
this.scrollToTopOfPage();
}

protected addComponent(insertAfterComponentId: string): void {
const dialogRef = this.dialog.open(ChooseNewComponent, {
data: insertAfterComponentId,
width: '80%'
});
dialogRef
.afterClosed()
.pipe(filter((componentType) => componentType != null))
.subscribe(({ action, componentType }) => {
if (action === 'import') {
this.router.navigate(['import-component/choose-component'], {
relativeTo: this.route,
state: {
insertAfterComponentId: insertAfterComponentId
}
});
} else {
const component = this.projectService.createComponent(
this.nodeId,
componentType,
insertAfterComponentId
);
this.projectService.saveProject();
this.highlightNewComponentsAndThenShowComponentAuthoring([component]);
}
});
}

protected hideAllComponentSaveButtons(): void {
for (const component of this.components) {
const service = this.componentServiceLookupService.getService(component.type);
Expand Down Expand Up @@ -276,7 +245,7 @@ export class NodeAuthoringComponent implements OnInit {
* @param newComponents an array of the new components we have just added
* @param expandComponents expand component(s)' authoring views after highlighting
*/
private highlightNewComponentsAndThenShowComponentAuthoring(
protected highlightNewComponentsAndThenShowComponentAuthoring(
newComponents: any = [],
expandComponents: boolean = true
): void {
Expand Down
Loading

0 comments on commit 63f86ee

Please sign in to comment.