Pull request #183: RED-1332

Merge in RED/ui from RED-1332 to master

* commit '6a65cef349e7a6e7200d133633b1b1e19bd8a329':
  use attributes from backend to get last opened file
  mark last opened file
This commit is contained in:
Timo Bejan 2021-05-14 12:26:21 +02:00
commit 3971855b0b
5 changed files with 52 additions and 14 deletions

View File

@ -37,6 +37,7 @@ import { AnnotationDrawService } from './services/annotation-draw.service';
import { AnnotationProcessingService } from './services/annotation-processing.service';
import { AnnotationRemoveActionsComponent } from './components/annotation-remove-actions/annotation-remove-actions.component';
import { DossierDictionaryDialogComponent } from './dialogs/dossier-dictionary-dialog/dossier-dictionary-dialog.component';
import { UserPreferenceControllerService } from '@redaction/red-ui-http';
const screens = [ProjectListingScreenComponent, ProjectOverviewScreenComponent, FilePreviewScreenComponent];
@ -79,7 +80,8 @@ const services = [
ManualAnnotationService,
PdfViewerDataService,
AnnotationDrawService,
AnnotationProcessingService
AnnotationProcessingService,
UserPreferenceControllerService
];
@NgModule({

View File

@ -22,7 +22,7 @@ import { handleFilterDelta, processFilters } from '@shared/components/filter/uti
import { UserPreferenceService } from '@services/user-preference.service';
import { UserService } from '@services/user.service';
import { FormBuilder, FormGroup } from '@angular/forms';
import { FileManagementControllerService, StatusControllerService } from '@redaction/red-ui-http';
import { FileManagementControllerService, StatusControllerService, UserPreferenceControllerService } from '@redaction/red-ui-http';
import { PdfViewerDataService } from '../../services/pdf-viewer-data.service';
import { download } from '@utils/file-download-utils';
import { ViewMode } from '@models/file/view-mode';
@ -71,6 +71,7 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach,
readonly permissionsService: PermissionsService,
readonly userPreferenceService: UserPreferenceService,
readonly userService: UserService,
private readonly _userPreferenceControllerService: UserPreferenceControllerService,
private readonly _changeDetectorRef: ChangeDetectorRef,
private readonly _activatedRoute: ActivatedRoute,
private readonly _dialogService: ProjectsDialogService,
@ -88,6 +89,16 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach,
this.reviewerForm = this._formBuilder.group({
reviewer: [this.appStateService.activeFile.currentReviewer]
});
this._loadFileData().subscribe(() => {
this._updateCanPerformActions();
});
document.documentElement.addEventListener('fullscreenchange', () => {
if (!document.fullscreenElement) {
this.fullScreen = false;
}
});
}
get singleUsersSelectOptions() {
@ -178,23 +189,15 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach,
}
ngOnAttach(previousRoute: ActivatedRouteSnapshot) {
this.displayPDFViewer = true;
this.ngOnInit();
this._lastPage = previousRoute.queryParams.page;
this._subscribeToFileUpdates();
}
ngOnInit(): void {
this.displayPDFViewer = true;
document.documentElement.addEventListener('fullscreenchange', () => {
if (!document.fullscreenElement) {
this.fullScreen = false;
}
});
this._loadFileData().subscribe(() => {
this._updateCanPerformActions();
});
const key = 'Project-Recent-' + this.projectId;
this._userPreferenceControllerService.savePreferences([this.fileId], key).toPromise().then();
this._subscribeToFileUpdates();
}

View File

@ -171,6 +171,7 @@
*cdkVirtualFor="let fileStatus of displayedEntities | sortBy: sortingOption.order:sortingOption.column; trackBy: fileId"
[class.disabled]="fileStatus.isExcluded"
[class.pointer]="permissionsService.canOpenFile(fileStatus)"
[class.last-opened]="isLastOpenedFile(fileStatus)"
[routerLink]="fileLink(fileStatus)"
class="table-item"
>

View File

@ -122,3 +122,23 @@ cdk-virtual-scroll-viewport {
.primary-attribute {
padding-top: 6px;
}
.last-opened {
> .selection-column {
padding-left: 6px !important;
border-left: 4px solid $red-1;
}
> div {
animation: red-fading-background 3s 1;
}
}
@keyframes red-fading-background {
0% {
background-color: rgba($red-1, 0.1);
}
100% {
background-color: inherit;
}
}

View File

@ -14,7 +14,7 @@ import { FileStatusWrapper } from '@models/file/file-status.wrapper';
import { annotationFilterChecker, keyChecker, processFilters } from '@shared/components/filter/utils/filter-utils';
import { PermissionsService } from '@services/permissions.service';
import { UserService } from '@services/user.service';
import { FileStatus } from '@redaction/red-ui-http';
import { FileStatus, UserPreferenceControllerService } from '@redaction/red-ui-http';
import { Subscription, timer } from 'rxjs';
import { filter, tap } from 'rxjs/operators';
import { RedactionFilterSorter } from '@utils/sorters/redaction-filter-sorter';
@ -50,6 +50,7 @@ export class ProjectOverviewScreenComponent extends BaseListingComponent<FileSta
private _routerEventsScrollPositionSub: Subscription;
private _fileChangedSub: Subscription;
private _lastScrollPosition: number;
private _lastOpenedFileId = '';
@ViewChild(CdkVirtualScrollViewport) private _scrollBar: CdkVirtualScrollViewport;
@ -68,6 +69,7 @@ export class ProjectOverviewScreenComponent extends BaseListingComponent<FileSta
private readonly _translateService: TranslateService,
private readonly _fileDropOverlayService: FileDropOverlayService,
private readonly _appStateService: AppStateService,
private readonly _userPreferenceControllerService: UserPreferenceControllerService,
protected readonly _injector: Injector
) {
super(_injector);
@ -78,6 +80,10 @@ export class ProjectOverviewScreenComponent extends BaseListingComponent<FileSta
return this._appStateService.activeProject;
}
isLastOpenedFile(fileStatus: FileStatusWrapper): boolean {
return this._lastOpenedFileId === fileStatus.fileId;
}
protected get _filterComponents(): FilterComponent[] {
return [this._statusFilterComponent, this._peopleFilterComponent, this._needsWorkFilterComponent];
}
@ -96,6 +102,12 @@ export class ProjectOverviewScreenComponent extends BaseListingComponent<FileSta
}
ngOnInit(): void {
this._userPreferenceControllerService.getAllUserAttributes().subscribe((attributes) => {
if (attributes === null || attributes === undefined) return;
const key = 'Project-Recent-' + this.activeProject.projectId;
this._lastOpenedFileId = attributes[key][0];
});
this._fileDropOverlayService.initFileDropHandling();
this.calculateData();