mark last opened file

This commit is contained in:
Dan Percic 2021-05-10 15:18:26 +03:00
parent 4b73b4cc5d
commit b44d9c9d0c
5 changed files with 40 additions and 12 deletions

View File

@ -88,6 +88,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 annotations(): AnnotationWrapper[] {
@ -178,23 +188,13 @@ 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();
});
this.userPreferenceService.lastOpenedFileId = this.fileId;
this._subscribeToFileUpdates();
}

View File

@ -170,6 +170,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,16 @@ cdk-virtual-scroll-viewport {
.primary-attribute {
padding-top: 6px;
}
.last-opened {
> .selection-column {
padding-left: 6px !important;
border-left: 4px solid $red-1;
}
&:hover {
> div {
background-color: rgba($red-1, 0.1);
}
}
}

View File

@ -26,6 +26,7 @@ import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
import { BaseListingComponent } from '@shared/base/base-listing.component';
import { ProjectWrapper } from '@state/model/project.wrapper';
import { OnAttach, OnDetach } from '@utils/custom-route-reuse.strategy';
import { UserPreferenceService } from '@services/user-preference.service';
@Component({
selector: 'redaction-project-overview-screen',
@ -68,6 +69,7 @@ export class ProjectOverviewScreenComponent extends BaseListingComponent<FileSta
private readonly _translateService: TranslateService,
private readonly _fileDropOverlayService: FileDropOverlayService,
private readonly _appStateService: AppStateService,
private readonly _userPreferencesService: UserPreferenceService,
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._userPreferencesService.lastOpenedFileId === fileStatus.fileId;
}
protected get _filterComponents(): FilterComponent[] {
return [this._statusFilterComponent, this._peopleFilterComponent, this._needsWorkFilterComponent];
}

View File

@ -12,6 +12,14 @@ export class UserPreferenceService {
return false;
}
set lastOpenedFileId(value: string) {
sessionStorage.setItem('redaction.last-opened-file', value);
}
get lastOpenedFileId(): string {
return sessionStorage.getItem('redaction.last-opened-file') || '';
}
toggleDevFeatures() {
sessionStorage.setItem('redaction.enable-dev-features', `${!this.areDevFeaturesEnabled}`);
window.location.reload();