Skip to content

Commit

Permalink
refactor(SaveStarterStateComponent): Convert to standalone (#1811)
Browse files Browse the repository at this point in the history
  • Loading branch information
hirokiterashima authored May 23, 2024
1 parent d4a9c5b commit 23d1260
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ <h2 mat-dialog-title i18n>Preview Component</h2>
class="notice-bg-bg"
[component]="component"
[starterState]="starterState"
></save-starter-state>
/>
</ng-container>
<mat-divider></mat-divider>
<mat-dialog-content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ import { ComponentStudentModule } from '../../../../../assets/wise5/components/c
import { StudentTeacherCommonModule } from '../../../../../app/student-teacher-common.module';

@NgModule({
declarations: [
PreviewComponentButtonComponent,
PreviewComponentDialogComponent,
SaveStarterStateComponent
],
declarations: [PreviewComponentButtonComponent, PreviewComponentDialogComponent],
exports: [PreviewComponentButtonComponent],
imports: [StudentTeacherCommonModule, ComponentStudentModule]
imports: [SaveStarterStateComponent, StudentTeacherCommonModule, ComponentStudentModule]
})
export class PreviewComponentModule {}
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
<button
mat-icon-button
color="primary"
matTooltip="Save Starter State"
matTooltip="Save starter state"
matTooltipPosition="above"
(click)="confirmSave()"
[disabled]="!isDirty"
(click)="save()"
[disabled]="!dirty"
i18n-matToolTip
>
<mat-icon>save</mat-icon>
</button>
<button
mat-icon-button
matTooltip="Delete Starter State"
matTooltip="Delete starter state"
matTooltipPosition="above"
(click)="confirmDelete()"
(click)="delete()"
i18n-matToolTip
>
<mat-icon>close</mat-icon>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
import { Component, Input, OnInit, SimpleChanges } from '@angular/core';
import { Component, Input, SimpleChanges } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { TeacherNodeService } from '../../../services/teacherNodeService';
import { Component as WISEComponent } from '../../../common/Component';
import { FlexLayoutModule } from '@angular/flex-layout';
import { MatButtonModule } from '@angular/material/button';
import { MatIconModule } from '@angular/material/icon';
import { MatTooltipModule } from '@angular/material/tooltip';

@Component({
imports: [FlexLayoutModule, MatButtonModule, MatIconModule, MatTooltipModule],
selector: 'save-starter-state',
standalone: true,
templateUrl: 'save-starter-state.component.html'
})
export class SaveStarterStateComponent implements OnInit {
export class SaveStarterStateComponent {
@Input() private component: WISEComponent;
protected isDirty: boolean;
protected dirty: boolean;
@Input() private starterState: any;

constructor(private matDialog: MatDialog, private nodeService: TeacherNodeService) {}

ngOnInit(): void {}

ngOnChanges(changes: SimpleChanges) {
this.isDirty = !changes.starterState.isFirstChange();
ngOnChanges(changes: SimpleChanges): void {
this.dirty = !changes.starterState.isFirstChange();
}

protected confirmSave(): void {
protected save(): void {
if (confirm($localize`Are you sure you want to save the starter state?`)) {
this.nodeService.respondStarterState({
nodeId: this.component.nodeId,
componentId: this.component.id,
starterState: this.starterState
});
this.isDirty = false;
this.dirty = false;
}
}

protected confirmDelete(): void {
protected delete(): void {
if (
confirm(
$localize`Are you sure you want to delete the starter state? This will also close this preview window.`
Expand Down
12 changes: 6 additions & 6 deletions src/messages.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -9913,14 +9913,14 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
<source>Are you sure you want to save the starter state?</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/authoringTool/components/save-starter-state/save-starter-state.component.ts</context>
<context context-type="linenumber">24</context>
<context context-type="linenumber">28</context>
</context-group>
</trans-unit>
<trans-unit id="2719035378398088475" datatype="html">
<source>Are you sure you want to delete the starter state? This will also close this preview window.</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/authoringTool/components/save-starter-state/save-starter-state.component.ts</context>
<context context-type="linenumber">37</context>
<context context-type="linenumber">41</context>
</context-group>
</trans-unit>
<trans-unit id="d9921e33c659c824a3c39062f76cb572394ff373" datatype="html">
Expand Down Expand Up @@ -21234,28 +21234,28 @@ If this problem continues, let your teacher know and move on to the next activit
<source>File</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/directives/wise-tinymce-editor/wise-tinymce-editor.component.ts</context>
<context context-type="linenumber">149</context>
<context context-type="linenumber">141</context>
</context-group>
</trans-unit>
<trans-unit id="3075681036535086015" datatype="html">
<source>Insert from Notebook</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/directives/wise-tinymce-editor/wise-tinymce-editor.component.ts</context>
<context context-type="linenumber">163</context>
<context context-type="linenumber">155</context>
</context-group>
</trans-unit>
<trans-unit id="535405804327281099" datatype="html">
<source>Insert note +</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/directives/wise-tinymce-editor/wise-tinymce-editor.component.ts</context>
<context context-type="linenumber">164</context>
<context context-type="linenumber">156</context>
</context-group>
</trans-unit>
<trans-unit id="7138428925866529608" datatype="html">
<source>Image from notebook</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/directives/wise-tinymce-editor/wise-tinymce-editor.component.ts</context>
<context context-type="linenumber">190</context>
<context context-type="linenumber">182</context>
</context-group>
</trans-unit>
<trans-unit id="3570422532828875517" datatype="html">
Expand Down

0 comments on commit 23d1260

Please sign in to comment.