diff --git a/src/app/authoring-tool/edit-component-advanced/edit-component-advanced.component.html b/src/app/authoring-tool/edit-component-advanced/edit-component-advanced.component.html deleted file mode 100644 index 79e1be3824d..00000000000 --- a/src/app/authoring-tool/edit-component-advanced/edit-component-advanced.component.html +++ /dev/null @@ -1,13 +0,0 @@ -
-

Advanced Activity Settings

- -
-
-
- - - - -
diff --git a/src/app/authoring-tool/edit-component-advanced/edit-component-advanced.component.spec.ts b/src/app/authoring-tool/edit-component-advanced/edit-component-advanced.component.spec.ts index 2166cae3fe7..ee81e49755c 100644 --- a/src/app/authoring-tool/edit-component-advanced/edit-component-advanced.component.spec.ts +++ b/src/app/authoring-tool/edit-component-advanced/edit-component-advanced.component.spec.ts @@ -1,5 +1,4 @@ import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { MockComponent, MockProviders } from 'ng-mocks'; import { ComponentContent } from '../../../assets/wise5/common/ComponentContent'; import { EditShowMyWorkAdvancedComponent } from '../../../assets/wise5/components/showMyWork/edit-show-my-work-advanced/edit-show-my-work-advanced.component'; @@ -9,6 +8,7 @@ import { TeacherNodeService } from '../../../assets/wise5/services/teacherNodeSe import { TeacherProjectService } from '../../../assets/wise5/services/teacherProjectService'; import { EditComponentAdvancedComponent } from './edit-component-advanced.component'; import { ComponentServiceLookupService } from '../../../assets/wise5/services/componentServiceLookupService'; +import { Component } from '../../../assets/wise5/common/Component'; let component: EditComponentAdvancedComponent; let fixture: ComponentFixture; @@ -17,23 +17,6 @@ describe('EditComponentAdvancedComponent', () => { await TestBed.configureTestingModule({ imports: [MockComponent(EditShowMyWorkAdvancedComponent), EditComponentAdvancedComponent], providers: [ - { - provide: MAT_DIALOG_DATA, - useValue: { - component: { - content: { type: 'ShowMyWork' }, - id: 'component1', - nodeId: 'node1' - }, - tab: 'general' - } - }, - { - provide: MatDialogRef, - useValue: { - close: () => {} - } - }, MockProviders( ComponentServiceLookupService, TeacherNodeService, @@ -46,6 +29,11 @@ describe('EditComponentAdvancedComponent', () => { fixture = TestBed.createComponent(EditComponentAdvancedComponent); component = fixture.componentInstance; + component.component = { + id: 'component1', + nodeId: 'node1', + content: { type: 'ShowMyWork' } + } as Component; spyOn(TestBed.inject(TeacherProjectService), 'getComponent').and.returnValue({ type: 'ShowMyWork' } as ComponentContent); diff --git a/src/app/authoring-tool/edit-component-advanced/edit-component-advanced.component.ts b/src/app/authoring-tool/edit-component-advanced/edit-component-advanced.component.ts index febba44f6fe..b93a7cb52b9 100644 --- a/src/app/authoring-tool/edit-component-advanced/edit-component-advanced.component.ts +++ b/src/app/authoring-tool/edit-component-advanced/edit-component-advanced.component.ts @@ -5,12 +5,12 @@ import { createComponent, ElementRef, EnvironmentInjector, - Inject, + Input, ViewChild, ViewEncapsulation } from '@angular/core'; import { MatButtonModule } from '@angular/material/button'; -import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog'; +import { MatDialogModule } from '@angular/material/dialog'; import { MatDivider } from '@angular/material/divider'; import { Component as WISEComponent } from '../../../assets/wise5/common/Component'; import { components } from '../../../assets/wise5/components/Components'; @@ -18,50 +18,43 @@ import { components } from '../../../assets/wise5/components/Components'; @Component({ encapsulation: ViewEncapsulation.None, imports: [MatDivider, MatDialogModule, MatButtonModule], + selector: 'edit-component-advanced', styles: [ ` .edit-component-advanced { --mat-tab-divider-color: var(--mat-divider-color); --mat-tab-divider-height: 1px; - .mat-divider { - margin: 0 -16px; - } .mat-mdc-tab-body-content { - padding: 16px 0; + padding: 16px; } .mat-mdc-tab-header { position: sticky; top: 0; z-index: 2; background-color: white; - margin: 0 -16px; } } ` ], - templateUrl: './edit-component-advanced.component.html' + template: '
' }) export class EditComponentAdvancedComponent { + @Input() component: WISEComponent; @ViewChild('component') private componentElementRef: ElementRef; private componentRef: ComponentRef; constructor( private applicationRef: ApplicationRef, - @Inject(MAT_DIALOG_DATA) protected data: { component: WISEComponent; tab?: string }, private injector: EnvironmentInjector ) {} ngAfterViewInit(): void { - this.componentRef = createComponent( - components[this.data.component.content.type].authoringAdvanced, - { - hostElement: this.componentElementRef.nativeElement, - environmentInjector: this.injector - } - ); + this.componentRef = createComponent(components[this.component.content.type].authoringAdvanced, { + hostElement: this.componentElementRef.nativeElement, + environmentInjector: this.injector + }); Object.assign(this.componentRef.instance, { - nodeId: this.data.component.nodeId, - componentId: this.data.component.id, - tab: this.data.tab + nodeId: this.component.nodeId, + componentId: this.component.id }); this.applicationRef.attachView(this.componentRef.hostView); } diff --git a/src/app/authoring-tool/edit-component-field.component.ts b/src/app/authoring-tool/edit-component-field.component.ts index a8fe4df789d..db1ec2ee855 100644 --- a/src/app/authoring-tool/edit-component-field.component.ts +++ b/src/app/authoring-tool/edit-component-field.component.ts @@ -15,7 +15,7 @@ export abstract class EditComponentFieldComponent { this.inputChangedSubscription = this.inputChanged .pipe(debounceTime(1000), distinctUntilChanged()) .subscribe(() => { - this.projectService.componentChanged(); + this.projectService.saveProject(); }); } diff --git a/src/app/authoring-tool/edit-component-json/edit-component-json.component.ts b/src/app/authoring-tool/edit-component-json/edit-component-json.component.ts index cb629d507b5..d8e6247e87a 100644 --- a/src/app/authoring-tool/edit-component-json/edit-component-json.component.ts +++ b/src/app/authoring-tool/edit-component-json/edit-component-json.component.ts @@ -56,7 +56,7 @@ export class EditComponentJsonComponent { this.projectService .getNode(this.component.nodeId) .replaceComponent(this.component.id, JSON.parse(this.componentContentJSONString)); - this.projectService.componentChanged(); + this.projectService.saveProject(); this.notificationService.showJSONValidMessage(); } catch (e) { this.notificationService.showJSONInvalidMessage(); diff --git a/src/app/authoring-tool/edit-component-rubric/edit-component-rubric.component.ts b/src/app/authoring-tool/edit-component-rubric/edit-component-rubric.component.ts index 12c0bafd13e..8ca9c7b9f46 100644 --- a/src/app/authoring-tool/edit-component-rubric/edit-component-rubric.component.ts +++ b/src/app/authoring-tool/edit-component-rubric/edit-component-rubric.component.ts @@ -17,6 +17,6 @@ export class EditComponentRubricComponent { constructor(private projectService: TeacherProjectService) {} protected save(): void { - this.projectService.componentChanged(); + this.projectService.saveProject(); } } diff --git a/src/app/authoring-tool/edit-component-tags/edit-component-tags.component.ts b/src/app/authoring-tool/edit-component-tags/edit-component-tags.component.ts index ae7998727e0..ce820e29564 100644 --- a/src/app/authoring-tool/edit-component-tags/edit-component-tags.component.ts +++ b/src/app/authoring-tool/edit-component-tags/edit-component-tags.component.ts @@ -47,7 +47,7 @@ export class EditComponentTagsComponent { .pipe(debounceTime(1000), distinctUntilChanged()) .subscribe(({ tagIndex, tag }) => { this.componentContent.tags[tagIndex] = tag; - this.projectService.componentChanged(); + this.projectService.saveProject(); }); } @@ -60,7 +60,7 @@ export class EditComponentTagsComponent { this.componentContent.tags = []; } this.componentContent.tags.push(''); - this.projectService.componentChanged(); + this.projectService.saveProject(); } moveTagUp(index: number): void { @@ -68,7 +68,7 @@ export class EditComponentTagsComponent { const tag = this.componentContent.tags[index]; this.componentContent.tags.splice(index, 1); this.componentContent.tags.splice(index - 1, 0, tag); - this.projectService.componentChanged(); + this.projectService.saveProject(); } } @@ -77,14 +77,14 @@ export class EditComponentTagsComponent { const tag = this.componentContent.tags[index]; this.componentContent.tags.splice(index, 1); this.componentContent.tags.splice(index + 1, 0, tag); - this.projectService.componentChanged(); + this.projectService.saveProject(); } } deleteTag(indexOfTagToDelete: number): void { if (confirm($localize`Are you sure you want to delete this tag?`)) { this.componentContent.tags.splice(indexOfTagToDelete, 1); - this.projectService.componentChanged(); + this.projectService.saveProject(); } } } diff --git a/src/assets/wise5/authoringTool/components/component-authoring.component.ts b/src/assets/wise5/authoringTool/components/component-authoring.component.ts index 846486e9e73..d4a16616144 100644 --- a/src/assets/wise5/authoringTool/components/component-authoring.component.ts +++ b/src/assets/wise5/authoringTool/components/component-authoring.component.ts @@ -1,16 +1,18 @@ -import { Component, effect, EventEmitter, Input, Output } from '@angular/core'; +import { Component, effect, Input } from '@angular/core'; import { ComponentContent } from '../../common/ComponentContent'; import { PreviewComponentComponent } from './preview-component/preview-component.component'; -import { EditComponentComponent } from './edit-component/edit-component.component'; import { ComponentFactory } from '../../common/ComponentFactory'; import { Component as WISEComponent } from '../../common/Component'; import { TeacherProjectService } from '../../services/teacherProjectService'; import { MatTooltipModule } from '@angular/material/tooltip'; import { TeacherProjectTranslationService } from '../../services/teacherProjectTranslationService'; import { copy } from '../../common/object/object'; +import { MatDialog } from '@angular/material/dialog'; +import { EditComponentDialogComponent } from './edit-component-dialog/edit-component-dialog.component'; +import { Subscription } from 'rxjs'; @Component({ - imports: [PreviewComponentComponent, EditComponentComponent, MatTooltipModule], + imports: [PreviewComponentComponent, EditComponentDialogComponent, MatTooltipModule], selector: 'component-authoring', styles: [ ` @@ -33,41 +35,48 @@ import { copy } from '../../common/object/object'; } ` ], - template: `@if (editing) { - - } @else { - - }` + template: ` + + ` }) export class ComponentAuthoringComponent { protected component: WISEComponent; @Input() componentContent: ComponentContent; - @Input() editing: boolean; - @Output() editComponentEvent: EventEmitter = new EventEmitter(); @Input() nodeId: string; + private subscriptions = new Subscription(); constructor( + private dialog: MatDialog, private projectService: TeacherProjectService, private projectTranslationService: TeacherProjectTranslationService ) { effect(() => { this.setComponent(); }); + this.subscriptions.add( + this.projectService.projectSaved$.subscribe(() => { + this.setComponent(); + }) + ); } ngOnChanges(): void { this.setComponent(); } + ngOnDestroy(): void { + this.subscriptions.unsubscribe(); + } + private setComponent(): void { // when current translations change, apply translations to a copy of the component content // so the original component content is not modified for subsequent use. @@ -81,4 +90,15 @@ export class ComponentAuthoringComponent { this.nodeId ); } + + protected editComponent(): void { + this.dialog.open(EditComponentDialogComponent, { + data: { + componentContent: this.componentContent, + nodeId: this.nodeId + }, + height: '90vh', + panelClass: 'dialog-xl' + }); + } } diff --git a/src/assets/wise5/authoringTool/components/edit-component-dialog/edit-component-dialog.component.ts b/src/assets/wise5/authoringTool/components/edit-component-dialog/edit-component-dialog.component.ts new file mode 100644 index 00000000000..473a6be0a7c --- /dev/null +++ b/src/assets/wise5/authoringTool/components/edit-component-dialog/edit-component-dialog.component.ts @@ -0,0 +1,76 @@ +import { Component, Inject } from '@angular/core'; +import { MAT_DIALOG_DATA, MatDialogModule } from '@angular/material/dialog'; +import { EditComponentComponent } from '../edit-component/edit-component.component'; +import { MatButtonModule } from '@angular/material/button'; +import { MatDividerModule } from '@angular/material/divider'; +import { ComponentTypeService } from '../../../services/componentTypeService'; +import { MatSlideToggle } from '@angular/material/slide-toggle'; +import { FormsModule } from '@angular/forms'; +import { Component as WISEComponent } from '../../../common/Component'; +import { EditComponentAdvancedComponent } from '../../../../../app/authoring-tool/edit-component-advanced/edit-component-advanced.component'; +import { TeacherProjectService } from '../../../services/teacherProjectService'; + +@Component({ + imports: [ + EditComponentComponent, + EditComponentAdvancedComponent, + FormsModule, + MatButtonModule, + MatDialogModule, + MatDividerModule, + MatSlideToggle + ], + template: ` +
+

Edit: {{ componentIndex }}. {{ componentTypeLabel }}

+ Advanced +
+ + + @if (advancedMode) { + + } @else { + + } + + + + + + `, + styles: ` + .mat-divider { + margin: 0; + } + .advanced { + padding: 0 !important; + } + ` +}) +export class EditComponentDialogComponent { + protected advancedMode = false; + protected component: WISEComponent; + protected componentIndex: number; + protected componentTypeLabel: string; + + constructor( + private componentTypeService: ComponentTypeService, + @Inject(MAT_DIALOG_DATA) public data: any, + private projectService: TeacherProjectService + ) { + this.component = new WISEComponent(this.data.componentContent, this.data.nodeId); + this.componentIndex = + this.projectService + .getNode(this.data.nodeId) + .getComponentIndex(this.data.componentContent.id) + 1; + this.componentTypeLabel = this.componentTypeService.getComponentTypeLabel( + this.data.componentContent.type + ); + } +} diff --git a/src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html b/src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html index 0be75da4469..a77d8e31043 100644 --- a/src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html +++ b/src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html @@ -21,15 +21,8 @@ @for (component of components; track component.id; let i = $index; let last = $last) {
- -
+ +
@if (components.length > 1) {
- @if (component.id === editingComponentId) { - - }
- +
diff --git a/src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.ts b/src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.ts index 4aa086dc236..b98485b853a 100644 --- a/src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.ts +++ b/src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.ts @@ -24,7 +24,6 @@ import { MatButtonModule } from '@angular/material/button'; import { MatCardModule } from '@angular/material/card'; import { CommonModule } from '@angular/common'; import { ComponentAuthoringComponent } from '../../components/component-authoring.component'; -import { EditComponentAdvancedButtonComponent } from '../../components/edit-component-advanced-button/edit-component-advanced-button.component'; import { ToggleComponentTagComponent } from '../../components/toggle-component-tag/toggle-component-tag.component'; import { VisibilityConstraintIconComponent } from '../../components/visibility-constraint-icon/visibility-constraint-icon.component'; import { EditNodeAdvancedButtonComponent } from '../../components/edit-node-advanced-button/edit-node-advanced-button.component'; @@ -36,7 +35,6 @@ import { EditNodeAdvancedButtonComponent } from '../../components/edit-node-adva ComponentAuthoringComponent, CopyComponentButtonComponent, DragDropModule, - EditComponentAdvancedButtonComponent, EditNodeAdvancedButtonComponent, EditNodeTitleComponent, FormsModule, @@ -56,7 +54,6 @@ import { EditNodeAdvancedButtonComponent } from '../../components/edit-node-adva }) export class NodeAuthoringComponent implements OnInit { components: ComponentContent[] = []; - protected editingComponentId: string; protected isGroupNode: boolean; protected node: Node; private nodeJson: any; @@ -86,7 +83,6 @@ export class NodeAuthoringComponent implements OnInit { this.isGroupNode = this.projectService.isGroupNode(this.nodeId); this.nodeJson = this.projectService.getNodeById(this.nodeId); this.components = this.projectService.getComponents(this.nodeId); - this.editingComponentId = null; if (history.state.newComponents && history.state.newComponents.length > 0) { this.highlightComponents(history.state.newComponents); @@ -256,8 +252,4 @@ export class NodeAuthoringComponent implements OnInit { } this.projectService.saveProject(); } - - protected editComponent(componentId: string): void { - this.editingComponentId = componentId; - } } diff --git a/src/assets/wise5/common/Node.ts b/src/assets/wise5/common/Node.ts index 2cb5b0f6e19..98378391fa3 100644 --- a/src/assets/wise5/common/Node.ts +++ b/src/assets/wise5/common/Node.ts @@ -160,7 +160,7 @@ export class Node { this.components[this.getComponentIndex(componentId)] = component; } - private getComponentIndex(componentId: string): number { + getComponentIndex(componentId: string): number { return this.components.findIndex((component) => component.id === componentId); } diff --git a/src/messages.xlf b/src/messages.xlf index 9513ce72c8e..257f9838f73 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -824,28 +824,6 @@ 16,19 - - Advanced Activity Settings - - src/app/authoring-tool/edit-component-advanced/edit-component-advanced.component.html - 2,5 - - - - Close - - src/app/authoring-tool/edit-component-advanced/edit-component-advanced.component.html - 10,14 - - - src/assets/wise5/authoringTool/node/advanced/node-advanced-authoring/node-advanced-authoring.component.html - 46,50 - - - src/assets/wise5/themes/default/notebook/edit-notebook-item-dialog/edit-notebook-item-dialog.component.html - 114,119 - - Add Visibility Constraint @@ -1227,7 +1205,7 @@ src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 35,37 + 28,30 src/assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.component.html @@ -1288,7 +1266,7 @@ src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 83,85 + 68,70 src/assets/wise5/components/common/feedbackRule/edit-feedback-rules/edit-feedback-rules.component.html @@ -1323,7 +1301,7 @@ src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 94,97 + 79,82 src/assets/wise5/components/common/feedbackRule/edit-feedback-rules/edit-feedback-rules.component.html @@ -10450,7 +10428,7 @@ src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.html - 59,61 + 49,51 @@ -11172,17 +11150,39 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.22,26 + + Edit: . + + src/assets/wise5/authoringTool/components/edit-component-dialog/edit-component-dialog.component.ts + 25,26 + + Advanced - src/assets/wise5/authoringTool/components/edit-component-advanced-button/edit-component-advanced-button.component.html - 6,10 + src/assets/wise5/authoringTool/components/edit-component-dialog/edit-component-dialog.component.ts + 26,29 src/assets/wise5/authoringTool/components/edit-node-advanced-button/edit-node-advanced-button.component.ts 17,21 + + Close + + src/assets/wise5/authoringTool/components/edit-component-dialog/edit-component-dialog.component.ts + 43,48 + + + src/assets/wise5/authoringTool/node/advanced/node-advanced-authoring/node-advanced-authoring.component.html + 46,50 + + + src/assets/wise5/themes/default/notebook/edit-notebook-item-dialog/edit-notebook-item-dialog.component.html + 114,119 + + Authoring Tool Menu @@ -13047,7 +13047,7 @@ The branches will be removed but the steps will remain in the unit. . src/assets/wise5/authoringTool/node/node-authoring/node-authoring.component.ts - 170 + 166