From 56ded707e638ae769665a863ce65acffea5a588a Mon Sep 17 00:00:00 2001 From: jakerenzella Date: Tue, 11 Oct 2022 18:31:47 +1100 Subject: [PATCH] feat: add mobile inbox view --- .../states/dashboard/selected-task.service.ts | 8 +++++ .../states/tasks/inbox/inbox.component.html | 35 ++++++++++++++++++- .../states/tasks/inbox/inbox.component.scss | 16 +++++++-- .../states/tasks/inbox/inbox.component.ts | 11 ++++-- 4 files changed, 64 insertions(+), 6 deletions(-) diff --git a/src/app/projects/states/dashboard/selected-task.service.ts b/src/app/projects/states/dashboard/selected-task.service.ts index abdfc18bf..7b02cf44c 100644 --- a/src/app/projects/states/dashboard/selected-task.service.ts +++ b/src/app/projects/states/dashboard/selected-task.service.ts @@ -12,6 +12,12 @@ export class SelectedTaskService { private task$ = new BehaviorSubject(null); public currentPdfUrl$ = new BehaviorSubject(null); + private _showingTask: boolean; + + public get showingTaskSheet() { + return this._showingTask; + } + public setSelectedTask(task: number | Task) { if (typeof task === 'number') { this.taskService.get(task).subscribe(this.task$); @@ -23,10 +29,12 @@ export class SelectedTaskService { public showTaskSheet() { this.currentPdfUrl$.next(this.task$.value?.definition?.getTaskPDFUrl(false)); + this._showingTask = true; } public showSubmission() { this.currentPdfUrl$.next(this.task$.value.submissionUrl(false)); + this._showingTask = false; } public get selectedTask$(): Subject { diff --git a/src/app/units/states/tasks/inbox/inbox.component.html b/src/app/units/states/tasks/inbox/inbox.component.html index 84b968dc4..90f238b63 100644 --- a/src/app/units/states/tasks/inbox/inbox.component.html +++ b/src/app/units/states/tasks/inbox/inbox.component.html @@ -1,4 +1,4 @@ -
+
+ +
+
+ +
+
+
+ +

{{ taskData?.selectedTask?.project.student.nickname }}

+
+ + +
+ +
+ +
+
+
diff --git a/src/app/units/states/tasks/inbox/inbox.component.scss b/src/app/units/states/tasks/inbox/inbox.component.scss index a2e4fa2b8..7728cf89f 100644 --- a/src/app/units/states/tasks/inbox/inbox.component.scss +++ b/src/app/units/states/tasks/inbox/inbox.component.scss @@ -1,15 +1,20 @@ -.staff-task-list { -} +.staff-task-list {} .task-comment-panel { padding-left: 12px; padding-bottom: 0px; + + &.mobile { + padding-left: 0px; + padding-bottom: 0px; + margin-bottom: 10px; + } } .resizer { background-color: #f5f5f5; z-index: 200; - width: 15px //css on hover + width: 10px //css on hover } .resizer:hover, @@ -24,4 +29,9 @@ padding: 8px; min-width: 60px; width: 350px; + + &.mobile { + max-width: 100%; + width: 100%; + } } \ No newline at end of file diff --git a/src/app/units/states/tasks/inbox/inbox.component.ts b/src/app/units/states/tasks/inbox/inbox.component.ts index 82a2aec03..9b4b3b7d3 100644 --- a/src/app/units/states/tasks/inbox/inbox.component.ts +++ b/src/app/units/states/tasks/inbox/inbox.component.ts @@ -1,6 +1,6 @@ import { CdkDragEnd, CdkDragStart, CdkDragMove } from '@angular/cdk/drag-drop'; import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core'; -import { StateService, UIRouter } from '@uirouter/core'; +import { MediaObserver } from '@angular/flex-layout'; import { auditTime, merge, Observable, of, Subject, tap, withLatestFrom } from 'rxjs'; import { Unit } from 'src/app/api/models/unit'; import { UnitRole } from 'src/app/api/models/unit-role'; @@ -25,16 +25,22 @@ export class InboxComponent implements OnInit { private dragMove$ = new Subject<{ event: CdkDragMove; div: HTMLDivElement }>(); private dragMoveAudited$; + public taskSelected = false; + visiblePdfUrl: string; get narrowTaskInbox(): boolean { return this.inboxPanel?.nativeElement.getBoundingClientRect().width < 150; } - constructor(private router: UIRouter, private state: StateService, private selectedTask: SelectedTaskService) { + constructor(private selectedTask: SelectedTaskService, public mediaObserver: MediaObserver) { this.selectedTask.currentPdfUrl$.subscribe((url) => { this.visiblePdfUrl = url; }); + + this.selectedTask.selectedTask$.subscribe((task) => { + this.taskSelected = task != null; + }); } ngOnInit(): void { @@ -66,6 +72,7 @@ export class InboxComponent implements OnInit { }) ); this.subs$ = merge(this.dragMoveAudited$, of(true)); + window.dispatchEvent(new Event('resize')); } startedDragging(event: CdkDragStart, div: HTMLDivElement) {