diff --git a/src/app/doubtfire.states.ts b/src/app/doubtfire.states.ts index 9f3da83c84..488b5c68e2 100644 --- a/src/app/doubtfire.states.ts +++ b/src/app/doubtfire.states.ts @@ -263,7 +263,10 @@ const AdministerUnits: NgHybridStateDeclaration = { const ProjectDashboardState: NgHybridStateDeclaration = { name: 'dashboard2', parent: 'projects2', - url: '/dashboard2', + url: '/dashboard2/:taskAbbreviation?', + params: { + taskAbbreviation: {value: null, squash: true, dynamic: true}, + }, views: { projectView: { component: ProjectDashboardComponent, diff --git a/src/app/projects/states/dashboard/directives/task-dashboard/task-dashboard.component.html b/src/app/projects/states/dashboard/directives/task-dashboard/task-dashboard.component.html index fa43b725b3..7cf2f4d94e 100644 --- a/src/app/projects/states/dashboard/directives/task-dashboard/task-dashboard.component.html +++ b/src/app/projects/states/dashboard/directives/task-dashboard/task-dashboard.component.html @@ -1,17 +1,50 @@
- + + + + + + +
+ + + + + + +
+
+ - + @if (task.definition.hasTaskSheet) { + + } @else { +
+ subtitles_off +
+ + }
- + @if (task.hasPdf) { + + } @else { +
+ subtitles_off +
+ + }
@@ -20,9 +53,9 @@
- + diff --git a/src/app/projects/states/dashboard/directives/task-dashboard/task-dashboard.component.ts b/src/app/projects/states/dashboard/directives/task-dashboard/task-dashboard.component.ts index 2373546356..c83b823681 100644 --- a/src/app/projects/states/dashboard/directives/task-dashboard/task-dashboard.component.ts +++ b/src/app/projects/states/dashboard/directives/task-dashboard/task-dashboard.component.ts @@ -17,6 +17,8 @@ import {DoubtfireConstants} from 'src/app/config/constants/doubtfire-constants'; import {SelectedTaskService} from '../../selected-task.service'; import {DashboardViews} from '../../selected-task.service'; import {TooltipService} from '@swimlane/ngx-charts'; +import {SelectionChange} from '@angular/cdk/collections'; +import {MatTabChangeEvent} from '@angular/material/tabs'; @Component({ selector: 'f-task-dashboard', @@ -42,6 +44,27 @@ export class TaskDashboardComponent implements OnInit, OnChanges { public overseerEnabledObs = this.doubtfire.IsOverseerEnabled; public currentView: DashboardViews; + public currentIndex; + + onTabChange(event: MatTabChangeEvent) { + switch (event.index) { + case 0: + this.currentView = DashboardViews.details; + break; + case 1: + this.currentView = DashboardViews.task; + break; + case 2: + this.currentView = DashboardViews.submission; + break; + case 3: + this.currentView = DashboardViews.similarity; + break; + } + + console.log(this.currentView); + } + constructor( private doubtfire: DoubtfireConstants, private taskService: TaskService, @@ -49,11 +72,10 @@ export class TaskDashboardComponent implements OnInit, OnChanges { private fileDownloader: FileDownloaderService, private router: UIRouter, public selectedTaskService: SelectedTaskService, - ) { - } + ) {} ngOnInit(): void { - this.selectedTaskService.currentView$.next(DashboardViews.submission); + this.selectedTaskService.currentView$.next(DashboardViews.details); this.selectedTaskService.currentView$.subscribe((view) => { this.currentView = view; }); diff --git a/src/app/projects/states/dashboard/project-dashboard/project-dashboard.component.html b/src/app/projects/states/dashboard/project-dashboard/project-dashboard.component.html index 5207f2c725..5a6459d3c9 100644 --- a/src/app/projects/states/dashboard/project-dashboard/project-dashboard.component.html +++ b/src/app/projects/states/dashboard/project-dashboard/project-dashboard.component.html @@ -1,32 +1,44 @@ -
-
- - +
+
@if (subs$ | async) { +
} - + @if (selectedTaskDefinition$.value) { +
+ +
+
+ + +
+ } @else { +
+ +
+ }
diff --git a/src/app/projects/states/dashboard/project-dashboard/project-dashboard.component.ts b/src/app/projects/states/dashboard/project-dashboard/project-dashboard.component.ts index ac792b582e..a24e44b340 100644 --- a/src/app/projects/states/dashboard/project-dashboard/project-dashboard.component.ts +++ b/src/app/projects/states/dashboard/project-dashboard/project-dashboard.component.ts @@ -12,7 +12,7 @@ import { withLatestFrom, } from 'rxjs'; import {ProjectService} from 'src/app/api/services/project.service'; -import {GlobalStateService} from '../../index/global-state.service'; +import {GlobalStateService, ViewType} from '../../index/global-state.service'; import {UserService} from 'src/app/api/services/user.service'; import {Project, TaskDefinition} from 'src/app/api/models/doubtfire-model'; @@ -65,6 +65,7 @@ export class ProjectDashboardComponent implements OnInit { // projectTasks = this.projectService.loadProject this.project$.subscribe((project) => { console.log(project); + this.globalStateService.setView(ViewType.PROJECT, project); }); this.dragMoveAudited$ = this.dragMove$.pipe( diff --git a/src/app/projects/states/dashboard/selected-task.service.ts b/src/app/projects/states/dashboard/selected-task.service.ts index 6a6684c81c..e50a4b673a 100644 --- a/src/app/projects/states/dashboard/selected-task.service.ts +++ b/src/app/projects/states/dashboard/selected-task.service.ts @@ -5,6 +5,7 @@ import {TaskService} from 'src/app/api/services/task.service'; import {GlobalStateService} from '../index/global-state.service'; export enum DashboardViews { + details, submission, task, similarity, diff --git a/src/app/units/states/tasks/inbox/inbox.component.html b/src/app/units/states/tasks/inbox/inbox.component.html index b948c196ec..1192eaaced 100644 --- a/src/app/units/states/tasks/inbox/inbox.component.html +++ b/src/app/units/states/tasks/inbox/inbox.component.html @@ -26,6 +26,9 @@ }
+ + +
-
+
- @if (filteredTaskDefinitions.length === 0) { -
No tasks to display
- } @for (taskDef of filteredTaskDefinitions; track taskDef) { - + @if (taskDef) { -
-
-
+
+
+
-
-

{{ taskDef.name }}

+
+
{{ taskDef.name }}
- +
@if (taskDef.isGroupTask()) { group + } @else { + person }
{{ gradeNames[taskDef.targetGrade] }} Task
- @if (hasTasks && taskForTaskDef(taskDef)) { -

{{ taskForTaskDef(taskDef).status }}

- } - - -
+
+ @if (hasTasks && taskForTaskDef(taskDef)) { + + }
} + } @empty { +
No tasks to display
}
diff --git a/src/app/units/task-viewer/directives/unit-task-list/unit-task-list.component.scss b/src/app/units/task-viewer/directives/unit-task-list/unit-task-list.component.scss index 635ffef224..9914e6c47c 100644 --- a/src/app/units/task-viewer/directives/unit-task-list/unit-task-list.component.scss +++ b/src/app/units/task-viewer/directives/unit-task-list/unit-task-list.component.scss @@ -72,7 +72,7 @@ $my-palette: mat.m2-define-palette($md-formatif); cursor: pointer; } -.mat-mdc-list-item .item-content.selected { +.mat-mdc-list-item.selected { background-color: var(--background-gray); } diff --git a/src/app/units/task-viewer/directives/unit-task-list/unit-task-list.component.ts b/src/app/units/task-viewer/directives/unit-task-list/unit-task-list.component.ts index 9ff21d0c78..7e314da9d2 100644 --- a/src/app/units/task-viewer/directives/unit-task-list/unit-task-list.component.ts +++ b/src/app/units/task-viewer/directives/unit-task-list/unit-task-list.component.ts @@ -3,6 +3,7 @@ import {Grade} from 'src/app/api/models/grade'; import {TaskDefinition, Task} from 'src/app/api/models/doubtfire-model'; import {TaskDefinitionNamePipe} from 'src/app/common/filters/task-definition-name.pipe'; import {BehaviorSubject} from 'rxjs'; +import {StateService, UIRouter} from '@uirouter/core'; @Component({ selector: 'f-unit-task-list', @@ -25,6 +26,11 @@ export class FUnitTaskListComponent implements OnInit { taskDefinitionNamePipe = new TaskDefinitionNamePipe(); protected gradeNames: string[] = Grade.GRADES; + constructor( + private router: UIRouter, + private stateService: StateService, + ) {} + applyFilters() { this.filteredTaskDefinitions = this.taskDefinitionNamePipe.transform( this.taskDefinitions, @@ -44,6 +50,12 @@ export class FUnitTaskListComponent implements OnInit { return this.tasks.find((task) => task.definition.id === taskDef?.id); } + /* + TODO: There's still an issue where loading the route for the first time will cause child components (like task-dashboard) to load trigger OnInit and OnChanges twice... + Causing duplicate queries to submission_details and task comments. + One hack would be to always keep the task-dashboard rendered using [hidden]. + */ + ngOnInit(): void { this.applyFilters(); @@ -65,13 +77,31 @@ export class FUnitTaskListComponent implements OnInit { // if (this.taskDefinitions.length > 0) { // this.setSelectedTaskDefinition(this.taskDefinitions[0]); // } + + // Load selected task from URL + const current = this.selectedTaskDefinition$.value; + const param = this.router.globals.params.taskAbbreviation; + + if (param) { + const taskDef = this.taskDefinitions.find((t) => t.abbreviation === param); + + if (taskDef !== current) { + this.selectedTaskDefinition$.next(taskDef); + } + } else { + if (current !== null) { + this.selectedTaskDefinition$.next(null); + } + } } setSelectedTaskDefinition(taskDef: TaskDefinition) { if (this.isSelectedTaskDefinition(taskDef)) { this.selectedTaskDefinition$.next(null); + this.stateService.go('.', {taskAbbreviation: null}, {location: 'replace'}); } else { this.selectedTaskDefinition$.next(taskDef); + this.stateService.go('.', {taskAbbreviation: taskDef.abbreviation}, {location: 'replace'}); } // this.selectedTaskDefinition.emit(taskDef);