diff --git a/src/app/notebook/notebook-item/notebook-item.component.html b/src/app/notebook/notebook-item/notebook-item.component.html index b38afc3e542..4bdf85129fe 100644 --- a/src/app/notebook/notebook-item/notebook-item.component.html +++ b/src/app/notebook/notebook-item/notebook-item.component.html @@ -1,23 +1,29 @@ - -
-
- {{ item.content.text }} -
+ + @if (item.content.attachments.length > 0) { +
+ } + @if (item.content.text) { +
+ {{ item.content.text }} +
+ }
@@ -25,29 +31,27 @@ place{{ getItemNodePosition() }} - - + @if (canDelete) { + + } + @if (canRevive) { + + }
diff --git a/src/app/notebook/notebook-item/notebook-item.component.spec.ts b/src/app/notebook/notebook-item/notebook-item.component.spec.ts index e6c0616918f..d833858e90f 100644 --- a/src/app/notebook/notebook-item/notebook-item.component.spec.ts +++ b/src/app/notebook/notebook-item/notebook-item.component.spec.ts @@ -1,49 +1,23 @@ -import { provideHttpClientTesting } from '@angular/common/http/testing'; -import { NO_ERRORS_SCHEMA } from '@angular/core'; import { TestBed } from '@angular/core/testing'; -import { MatDialogModule } from '@angular/material/dialog'; -import { Subscription } from 'rxjs'; import { StudentTeacherCommonServicesModule } from '../../student-teacher-common-services.module'; import { NotebookItemComponent } from './notebook-item.component'; import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http'; let component: NotebookItemComponent; - describe('NotebookItemComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [NotebookItemComponent], - schemas: [NO_ERRORS_SCHEMA], - imports: [MatDialogModule, StudentTeacherCommonServicesModule], - providers: [provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()] -}); + imports: [NotebookItemComponent, StudentTeacherCommonServicesModule], + providers: [provideHttpClient(withInterceptorsFromDi())] + }); const fixture = TestBed.createComponent(NotebookItemComponent); component = fixture.componentInstance; - component.notebookUpdatedSubscription = new Subscription(); + component.note = { type: 'note', content: { attachments: [] } }; + component.config = { itemTypes: { note: { label: 'note!' } } }; + fixture.detectChanges(); }); - isItemInGroup(); - isNotebookItemActive(); -}); - -function isItemInGroup() { - it('should check if an notebook item is in group when it is not in the group', () => { - component.item = { groups: ['Group A'] }; - expect(component.isItemInGroup('Group B')).toEqual(false); - }); - it('should check if an notebook item is in group when it is in the group', () => { - component.item = { groups: ['Group A'] }; - expect(component.isItemInGroup('Group A')).toEqual(true); + it('should create', () => { + expect(component).toBeTruthy(); }); -} - -function isNotebookItemActive() { - it('should check if a notebook item is active when it is not active', () => { - component.item = { serverDeleteTime: 1607704074794 }; - expect(component.isNotebookItemActive()).toEqual(false); - }); - it('should check if a notebook item is active when it is active', () => { - component.item = { serverDeleteTime: null }; - expect(component.isNotebookItemActive()).toEqual(true); - }); -} +}); diff --git a/src/app/notebook/notebook-item/notebook-item.component.ts b/src/app/notebook/notebook-item/notebook-item.component.ts index 3e8441110fa..291412d0b3a 100644 --- a/src/app/notebook/notebook-item/notebook-item.component.ts +++ b/src/app/notebook/notebook-item/notebook-item.component.ts @@ -1,36 +1,52 @@ import { Component, EventEmitter, Input, Output } from '@angular/core'; -import { MatDialog } from '@angular/material/dialog'; +import { MatDialog, MatDialogModule } from '@angular/material/dialog'; import { Subscription } from 'rxjs'; import { DialogWithConfirmComponent } from '../../../assets/wise5/directives/dialog-with-confirm/dialog-with-confirm.component'; import { ConfigService } from '../../../assets/wise5/services/configService'; import { NotebookService } from '../../../assets/wise5/services/notebookService'; import { ProjectService } from '../../../assets/wise5/services/projectService'; +import { MatCardModule } from '@angular/material/card'; +import { CommonModule } from '@angular/common'; +import { MatIconModule } from '@angular/material/icon'; +import { FlexLayoutModule } from '@angular/flex-layout'; +import { MatTooltipModule } from '@angular/material/tooltip'; +import { MatButtonModule } from '@angular/material/button'; @Component({ + imports: [ + CommonModule, + FlexLayoutModule, + MatButtonModule, + MatCardModule, + MatDialogModule, + MatIconModule, + MatTooltipModule + ], selector: 'notebook-item', - styleUrls: ['notebook-item.component.scss'], + standalone: true, + styleUrl: 'notebook-item.component.scss', templateUrl: 'notebook-item.component.html' }) export class NotebookItemComponent { - canDelete: boolean; - canRevive: boolean; - color: string; + protected canDelete: boolean; + protected canRevive: boolean; + protected color: string; @Input() config: any; @Input() group: string; @Input() isChooseMode: boolean; - item: any; + protected item: any; @Input() itemId: string; - label: any; + protected label: any; @Input() note: any; - notebookUpdatedSubscription: Subscription; + private notebookUpdatedSubscription: Subscription; @Output() onSelect: EventEmitter = new EventEmitter(); - type: string; + private type: string; constructor( private configService: ConfigService, + private dialog: MatDialog, private notebookService: NotebookService, - private projectService: ProjectService, - private dialog: MatDialog + private projectService: ProjectService ) {} ngOnInit(): void { @@ -56,43 +72,19 @@ export class NotebookItemComponent { } ngOnChanges(): void { - this.label = this.config.itemTypes[this.type].label; + this.label = this.config.itemTypes[this.type]?.label; } ngOnDestroy(): void { this.notebookUpdatedSubscription.unsubscribe(); } - isItemInGroup(group: string): boolean { - return this.item.groups != null && this.item.groups.includes(group); - } - - getItemNodeId(): string { - if (this.item == null) { - return null; - } else { - return this.item.nodeId; - } + protected getItemNodePosition(): string { + return this.item == null ? '' : this.projectService.getNodePositionById(this.item.nodeId); } - getItemNodeLink(): string { - if (this.item == null) { - return ''; - } else { - return this.projectService.getNodePositionAndTitle(this.item.nodeId); - } - } - - getItemNodePosition(): string { - if (this.item == null) { - return ''; - } else { - return this.projectService.getNodePositionById(this.item.nodeId); - } - } - - doDelete(ev: any): void { - ev.stopPropagation(); + protected delete(event: Event): void { + event.stopPropagation(); this.dialog .open(DialogWithConfirmComponent, { data: { @@ -108,8 +100,8 @@ export class NotebookItemComponent { }); } - doRevive(ev: any): void { - ev.stopPropagation(); + protected revive(event: Event): void { + event.stopPropagation(); this.dialog .open(DialogWithConfirmComponent, { data: { @@ -125,45 +117,21 @@ export class NotebookItemComponent { }); } - doSelect(event: any): void { + protected select(event: any): void { if (this.onSelect) { this.onSelect.emit({ event: event, note: this.item }); } } - canShareNotebookItem(): boolean { - return ( - this.projectService.isSpaceExists('public') && - this.isMyNotebookItem() && - this.item.serverDeleteTime == null && - !this.isChooseMode && - !this.isItemInGroup('public') - ); - } - - canUnshareNotebookItem(): boolean { - return ( - this.projectService.isSpaceExists('public') && - this.isMyNotebookItem() && - this.item.serverDeleteTime == null && - !this.isChooseMode && - this.isItemInGroup('public') - ); - } - - canDeleteNotebookItem(): boolean { + private canDeleteNotebookItem(): boolean { return this.isMyNotebookItem() && this.item.serverDeleteTime == null && !this.isChooseMode; } - canReviveNotebookItem(): boolean { + private canReviveNotebookItem(): boolean { return this.item.serverDeleteTime != null && !this.isChooseMode; } private isMyNotebookItem(): boolean { return this.item.workgroupId === this.configService.getWorkgroupId(); } - - isNotebookItemActive(): boolean { - return this.item.serverDeleteTime == null; - } } diff --git a/src/app/notebook/notebook-notes/notebook-notes.component.html b/src/app/notebook/notebook-notes/notebook-notes.component.html index 2c1903a8d86..bd527492ade 100644 --- a/src/app/notebook/notebook-notes/notebook-notes.component.html +++ b/src/app/notebook/notebook-notes/notebook-notes.component.html @@ -14,8 +14,7 @@ (onSelect)="select($event)" fxFlex="100" fxFlex.gt-xs="50" - > - + /> @@ -97,8 +96,7 @@

- + /> diff --git a/src/app/notebook/notebook.module.ts b/src/app/notebook/notebook.module.ts index 74033740e20..8eb763e5d47 100644 --- a/src/app/notebook/notebook.module.ts +++ b/src/app/notebook/notebook.module.ts @@ -25,7 +25,6 @@ import { WiseTinymceEditorComponent } from '../../assets/wise5/directives/wise-t @NgModule({ declarations: [ NotebookParentComponent, - NotebookItemComponent, NotebookNotesComponent, NotebookReportComponent, NotebookReportAnnotationsComponent @@ -46,6 +45,7 @@ import { WiseTinymceEditorComponent } from '../../assets/wise5/directives/wise-t MatTabsModule, MatToolbarModule, MatTooltipModule, + NotebookItemComponent, NotebookLauncherComponent, WiseTinymceEditorComponent ], diff --git a/src/messages.xlf b/src/messages.xlf index 21a49bf752e..0993402c92a 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -6366,32 +6366,46 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.115 + + Delete + + src/app/notebook/notebook-item/notebook-item.component.html + 38 + + + + Revive + + src/app/notebook/notebook-item/notebook-item.component.html + 49 + + Are you sure you want to delete this ? src/app/notebook/notebook-item/notebook-item.component.ts - 99 + 91 Delete src/app/notebook/notebook-item/notebook-item.component.ts - 100 + 92 Are you sure you want to revive this ? src/app/notebook/notebook-item/notebook-item.component.ts - 116 + 108 Revive src/app/notebook/notebook-item/notebook-item.component.ts - 117 + 109 @@ -6405,21 +6419,21 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.Select item to insert src/app/notebook/notebook-notes/notebook-notes.component.html - 46 + 45 Add src/app/notebook/notebook-notes/notebook-notes.component.html - 71 + 70 Team hasn't created any yet. src/app/notebook/notebook-notes/notebook-notes.component.html - 83,85 + 82,84