Skip to content

Commit 48b61cc

Browse files
feat(Notes): Display in dialog instead of mat-drawer (#2254)
Co-authored-by: Jonathan Lim-Breitbart <breity10@gmail.com>
1 parent 3085a0a commit 48b61cc

9 files changed

Lines changed: 48 additions & 77 deletions

File tree

src/app/notebook/notebook-launcher/notebook-launcher.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { Component, Input } from '@angular/core';
2-
import { NotebookService } from '../../../assets/wise5/services/notebookService';
32
import { ProjectService } from '../../../assets/wise5/services/projectService';
43
import { Subscription } from 'rxjs';
54
import { MatButtonModule } from '@angular/material/button';
65
import { MatIconModule } from '@angular/material/icon';
76
import { MatTooltipModule } from '@angular/material/tooltip';
7+
import { MatDialog } from '@angular/material/dialog';
8+
import { NotebookNotesComponent } from '../notebook-notes/notebook-notes.component';
89

910
@Component({
1011
imports: [MatButtonModule, MatIconModule, MatTooltipModule],
@@ -17,7 +18,7 @@ export class NotebookLauncherComponent {
1718
private subscription: Subscription = new Subscription();
1819

1920
constructor(
20-
private notebookService: NotebookService,
21+
private dialog: MatDialog,
2122
private projectService: ProjectService
2223
) {}
2324

@@ -35,6 +36,8 @@ export class NotebookLauncherComponent {
3536
}
3637

3738
protected showNotes(): void {
38-
this.notebookService.setNotesVisible(true);
39+
this.dialog.open(NotebookNotesComponent, {
40+
panelClass: 'dialog-lg'
41+
});
3942
}
4043
}

src/app/notebook/notebook-notes/notebook-notes.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@for (note of group.items; track note) {
77
@if (note.serverDeleteTime == null) {
88
<notebook-item
9-
class="w-full sm:w-1/2"
9+
class="w-full sm:w-1/2 md:w-1/3 lg:w-1/4"
1010
[config]="config"
1111
[group]="group.name"
1212
[itemId]="note.localNotebookItemId"

src/app/notebook/notebook-notes/notebook-notes.component.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Input, ViewEncapsulation } from '@angular/core';
1+
import { Component, Inject, Input, Optional, ViewEncapsulation } from '@angular/core';
22
import { Subscription } from 'rxjs';
33
import { ConfigService } from '../../../assets/wise5/services/configService';
44
import { NotebookService } from '../../../assets/wise5/services/notebookService';
@@ -13,6 +13,7 @@ import { MatDividerModule } from '@angular/material/divider';
1313
import { MatTooltipModule } from '@angular/material/tooltip';
1414
import { MatButtonModule } from '@angular/material/button';
1515
import { MatIconModule } from '@angular/material/icon';
16+
import { MAT_DIALOG_DATA } from '@angular/material/dialog';
1617

1718
@Component({
1819
imports: [
@@ -34,9 +35,6 @@ export class NotebookNotesComponent extends NotebookParentComponent {
3435
protected groups = [];
3536
private groupNameToGroup = {};
3637
protected hasPrivateNotes: boolean = false;
37-
protected insertArgs: any = {
38-
insertMode: false
39-
};
4038
protected label: any;
4139
protected selectedTabIndex = 0;
4240
private subscriptions: Subscription = new Subscription();
@@ -46,9 +44,16 @@ export class NotebookNotesComponent extends NotebookParentComponent {
4644
configService: ConfigService,
4745
private dataService: StudentDataService,
4846
NotebookService: NotebookService,
49-
private projectService: ProjectService
47+
private projectService: ProjectService,
48+
@Optional() @Inject(MAT_DIALOG_DATA) public insertArgs: any
5049
) {
5150
super(configService, NotebookService);
51+
this.insertArgs = this.insertArgs ?? {
52+
insertMode: false
53+
};
54+
if (this.insertArgs.visibleSpace) {
55+
this.selectedTabIndex = this.insertArgs.visibleSpace === 'public' ? 1 : 0;
56+
}
5257
}
5358

5459
ngOnInit(): void {
@@ -73,15 +78,6 @@ export class NotebookNotesComponent extends NotebookParentComponent {
7378
})
7479
);
7580

76-
this.subscriptions.add(
77-
this.NotebookService.insertMode$.subscribe((args) => {
78-
this.insertArgs = args;
79-
if (args.visibleSpace) {
80-
this.selectedTabIndex = args.visibleSpace === 'public' ? 1 : 0;
81-
}
82-
})
83-
);
84-
8581
this.subscriptions.add(
8682
this.NotebookService.publicNotebookItemsRetrieved$.subscribe(() => {
8783
for (const group of this.groups) {

src/app/notebook/notebook-report/notebook-report.component.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import { NotebookService } from '../../../assets/wise5/services/notebookService'
1616
import { ProjectService } from '../../../assets/wise5/services/projectService';
1717
import { NotebookParentComponent } from '../notebook-parent/notebook-parent.component';
1818
import { BreakpointObserver } from '@angular/cdk/layout';
19+
import { NotebookNotesComponent } from '../notebook-notes/notebook-notes.component';
20+
import { MatDialog } from '@angular/material/dialog';
1921

2022
@Component({
2123
imports: [
@@ -48,6 +50,7 @@ export class NotebookReportComponent extends NotebookParentComponent {
4850
constructor(
4951
private breakpointObserver: BreakpointObserver,
5052
configService: ConfigService,
53+
private dialog: MatDialog,
5154
notebookService: NotebookService,
5255
private projectService: ProjectService
5356
) {
@@ -148,8 +151,10 @@ export class NotebookReportComponent extends NotebookParentComponent {
148151
}
149152

150153
protected addNotebookItemContent($event: any): void {
151-
this.NotebookService.setInsertMode({ insertMode: true, requester: 'report' });
152-
this.NotebookService.setNotesVisible(true);
154+
this.dialog.open(NotebookNotesComponent, {
155+
data: { insertMode: true, requester: 'report' },
156+
panelClass: 'dialog-md'
157+
});
153158
}
154159

155160
protected changed(value: string): void {

src/assets/wise5/components/component-student.component.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { ComponentStateRequest } from './ComponentStateRequest';
1818
import { ComponentStateWrapper } from './ComponentStateWrapper';
1919
import { Annotation } from '../common/Annotation';
2020
import $ from 'jquery';
21+
import { NotebookNotesComponent } from '../../../app/notebook/notebook-notes/notebook-notes.component';
2122

2223
@Directive()
2324
export abstract class ComponentStudent {
@@ -630,14 +631,16 @@ export abstract class ComponentStudent {
630631
}
631632

632633
copyPublicNotebookItem() {
633-
this.notebookService.setInsertMode({
634-
nodeId: this.nodeId,
635-
componentId: this.componentId,
636-
insertMode: true,
637-
requester: this.nodeId + '-' + this.componentId,
638-
visibleSpace: 'public'
634+
this.dialog.open(NotebookNotesComponent, {
635+
data: {
636+
nodeId: this.nodeId,
637+
componentId: this.componentId,
638+
insertMode: true,
639+
requester: this.nodeId + '-' + this.componentId,
640+
visibleSpace: 'public'
641+
},
642+
panelClass: 'dialog-md'
639643
});
640-
this.notebookService.setNotesVisible(true);
641644
}
642645

643646
isNotebookEnabled() {
@@ -745,14 +748,16 @@ export abstract class ComponentStudent {
745748
}
746749

747750
copyPublicNotebookItemButtonClicked(): void {
748-
this.notebookService.setInsertMode({
749-
nodeId: this.nodeId,
750-
componentId: this.componentId,
751-
insertMode: true,
752-
requester: this.nodeId + '-' + this.componentId,
753-
visibleSpace: 'public'
751+
this.dialog.open(NotebookNotesComponent, {
752+
data: {
753+
nodeId: this.nodeId,
754+
componentId: this.componentId,
755+
insertMode: true,
756+
requester: this.nodeId + '-' + this.componentId,
757+
visibleSpace: 'public'
758+
},
759+
panelClass: 'dialog-md'
754760
});
755-
this.notebookService.setNotesVisible(true);
756761
}
757762

758763
getElementById(id: string, getFirstResult: boolean = false): any {

src/assets/wise5/services/notebookService.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ export class NotebookService {
6363
public publicNotebookItemsRetrieved$ = this.publicNotebookItemsRetrievedSource.asObservable();
6464
private showReportAnnotationsSource: Subject<void> = new Subject<void>();
6565
public showReportAnnotations$ = this.showReportAnnotationsSource.asObservable();
66-
private notesVisibleSource: Subject<boolean> = new Subject<boolean>();
67-
public notesVisible$ = this.notesVisibleSource.asObservable();
68-
private insertModeSource: Subject<any> = new Subject<any>();
69-
public insertMode$ = this.insertModeSource.asObservable();
7066
private reportFullScreenSource: Subject<boolean> = new Subject<boolean>();
7167
public reportFullScreen$ = this.reportFullScreenSource.asObservable();
7268

@@ -641,16 +637,7 @@ export class NotebookService {
641637
}
642638

643639
closeNotes(): void {
644-
this.setNotesVisible(false);
645-
this.setInsertMode({ insertMode: false });
646-
}
647-
648-
setNotesVisible(value: boolean): void {
649-
this.notesVisibleSource.next(value);
650-
}
651-
652-
setInsertMode(args: any): void {
653-
this.insertModeSource.next(args);
640+
this.dialog.closeAll();
654641
}
655642

656643
setReportFullScreen(value: boolean): void {

src/assets/wise5/vle/vle.component.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@
33
<link rel="stylesheet" [href]="projectStylePath | safeUrl" />
44
@if (initialized) {
55
<mat-drawer-container [hasBackdrop]="false">
6-
<mat-drawer #drawer mode="over" position="end" (keydown.escape)="closeNotes()">
7-
<notebook-notes [config]="notebookConfig" />
8-
</mat-drawer>
96
@if (chatbotEnabled) {
107
<mat-drawer
11-
#chatbotDrawer
128
[mode]="mdScreen ? 'over' : 'side'"
139
position="end"
1410
(keydown.escape)="chatbotVisible = false"

src/assets/wise5/vle/vle.component.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import { Node } from '../common/Node';
2121
import { NodeComponent } from './node/node.component';
2222
import { NodeNavigationComponent } from '../directives/node-navigation/node-navigation.component';
2323
import { NodeStatusService } from '../services/nodeStatusService';
24-
import { NotebookNotesComponent } from '../../../app/notebook/notebook-notes/notebook-notes.component';
2524
import { NotebookReportComponent } from '../../../app/notebook/notebook-report/notebook-report.component';
2625
import { NotebookService } from '../services/notebookService';
2726
import { NotificationService } from '../services/notificationService';
@@ -49,7 +48,6 @@ import { BreakpointObserver } from '@angular/cdk/layout';
4948
NavigationComponent,
5049
NodeComponent,
5150
NodeNavigationComponent,
52-
NotebookNotesComponent,
5351
NotebookReportComponent,
5452
RunEndedAndLockedMessageComponent,
5553
SafeUrl,
@@ -67,11 +65,10 @@ export class VLEComponent implements AfterViewInit {
6765
protected chatbotVisible: boolean = false;
6866
protected currentNode: Node;
6967
@ViewChild('defaultVLETemplate') private defaultVLETemplate: TemplateRef<any>;
70-
@ViewChild('drawer') public drawer: any;
7168
protected initialized: boolean;
7269
private isSurvey: boolean;
7370
protected layoutState: string;
74-
private mdScreen: boolean;
71+
protected mdScreen: boolean;
7572
protected notebookConfig: any;
7673
protected notesEnabled: boolean = false;
7774
protected notesVisible: boolean = false;
@@ -205,14 +202,9 @@ export class VLEComponent implements AfterViewInit {
205202
return convertToPNGFile(canvas);
206203
}
207204

208-
closeNotes(): void {
209-
this.notebookService.closeNotes();
210-
}
211-
212205
private initializeSubscriptions(): void {
213206
this.subscribeToShowSessionWarning();
214207
this.subscribeToCurrentNodeChanged();
215-
this.subscribeToNotesVisible();
216208
this.subscribeToReportFullScreen();
217209
this.subscribeToViewCurrentAmbientNotification();
218210
this.subscriptions.add(this.projectService.projectParsed$.subscribe(() => this.setProject()));
@@ -269,19 +261,6 @@ export class VLEComponent implements AfterViewInit {
269261
);
270262
}
271263

272-
private subscribeToNotesVisible(): void {
273-
this.subscriptions.add(
274-
this.notebookService.notesVisible$.subscribe((notesVisible: boolean) => {
275-
this.notesVisible = notesVisible;
276-
if (this.notesVisible) {
277-
this.drawer.open();
278-
} else {
279-
this.drawer.close();
280-
}
281-
})
282-
);
283-
}
284-
285264
private subscribeToReportFullScreen(): void {
286265
this.subscriptions.add(
287266
this.notebookService.reportFullScreen$.subscribe((full: boolean) => {

src/messages.xlf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7079,7 +7079,7 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
70797079
<source>Personal</source>
70807080
<context-group purpose="location">
70817081
<context context-type="sourcefile">src/app/notebook/notebook-notes/notebook-notes.component.ts</context>
7082-
<context context-type="linenumber">119</context>
7082+
<context context-type="linenumber">115</context>
70837083
</context-group>
70847084
</trans-unit>
70857085
<trans-unit id="4929778113156900100" datatype="html">
@@ -10666,7 +10666,7 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
1066610666
</context-group>
1066710667
<context-group purpose="location">
1066810668
<context context-type="sourcefile">src/assets/wise5/vle/vle.component.ts</context>
10669-
<context context-type="linenumber">232</context>
10669+
<context context-type="linenumber">224</context>
1067010670
</context-group>
1067110671
</trans-unit>
1067210672
<trans-unit id="537022937435161177" datatype="html">
@@ -10681,7 +10681,7 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
1068110681
</context-group>
1068210682
<context-group purpose="location">
1068310683
<context context-type="sourcefile">src/assets/wise5/vle/vle.component.ts</context>
10684-
<context context-type="linenumber">233</context>
10684+
<context context-type="linenumber">225</context>
1068510685
</context-group>
1068610686
</trans-unit>
1068710687
<trans-unit id="3407061818321766940" datatype="html">

0 commit comments

Comments
 (0)