fix delete annotation
This commit is contained in:
parent
5d7849be45
commit
9317f55d81
@ -1,7 +1,9 @@
|
||||
import { AsyncPipe, NgIf } from '@angular/common';
|
||||
import { Component, computed, Input, OnChanges } from '@angular/core';
|
||||
import { CircleButtonComponent, getConfig, HelpModeService, IqserAllowDirective, IqserPermissionsService } from '@iqser/common-ui';
|
||||
import { AnnotationPermissions } from '@models/file/annotation.permissions';
|
||||
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { Roles } from '@users/roles';
|
||||
import { REDAnnotationManager } from '../../../pdf-viewer/services/annotation-manager.service';
|
||||
@ -9,10 +11,8 @@ import { AnnotationActionsService } from '../../services/annotation-actions.serv
|
||||
import { AnnotationReferencesService } from '../../services/annotation-references.service';
|
||||
import { FilePreviewStateService } from '../../services/file-preview-state.service';
|
||||
import { MultiSelectService } from '../../services/multi-select.service';
|
||||
import { ViewModeService } from '../../services/view-mode.service';
|
||||
import { SkippedService } from '../../services/skipped.service';
|
||||
import { AsyncPipe, NgIf } from '@angular/common';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { ViewModeService } from '../../services/view-mode.service';
|
||||
|
||||
export const AnnotationButtonTypes = {
|
||||
default: 'default',
|
||||
@ -62,10 +62,6 @@ export class AnnotationActionsComponent implements OnChanges {
|
||||
return this.#annotations;
|
||||
}
|
||||
|
||||
get isImageHint(): boolean {
|
||||
return this.annotations.every(annotation => annotation.IMAGE_HINT);
|
||||
}
|
||||
|
||||
@Input()
|
||||
set annotations(annotations: AnnotationWrapper[]) {
|
||||
this.#annotations = annotations.filter(a => a !== undefined);
|
||||
@ -73,6 +69,10 @@ export class AnnotationActionsComponent implements OnChanges {
|
||||
this._annotationId = this.#annotations[0]?.id;
|
||||
}
|
||||
|
||||
get isImageHint(): boolean {
|
||||
return this.annotations.every(annotation => annotation.IMAGE_HINT);
|
||||
}
|
||||
|
||||
get canEdit(): boolean {
|
||||
const canEditRedactions =
|
||||
this.annotationPermissions.canChangeLegalBasis ||
|
||||
@ -132,6 +132,14 @@ export class AnnotationActionsComponent implements OnChanges {
|
||||
return this.annotations.every(a => a.superType === type);
|
||||
}
|
||||
|
||||
get #annotationChangesAllowed() {
|
||||
return (!this.#isDocumine || !this._state.file().excludedFromAutomaticAnalysis) && !this.#somePending;
|
||||
}
|
||||
|
||||
get #somePending() {
|
||||
return this.#annotations.some(a => a.pending);
|
||||
}
|
||||
|
||||
ngOnChanges(): void {
|
||||
this.#setPermissions();
|
||||
}
|
||||
@ -183,12 +191,4 @@ export class AnnotationActionsComponent implements OnChanges {
|
||||
this._state.file().excludedFromAutomaticAnalysis,
|
||||
);
|
||||
}
|
||||
|
||||
get #annotationChangesAllowed() {
|
||||
return (!this.#isDocumine || !this._state.file().excludedFromAutomaticAnalysis) && !this.#somePending;
|
||||
}
|
||||
|
||||
get #somePending() {
|
||||
return this.#annotations.some(a => a.pending);
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,7 +75,14 @@ export class FileDataService extends EntitiesService<AnnotationWrapper, Annotati
|
||||
) {
|
||||
super();
|
||||
const localStorageKey = this.#tenantsService.activeTenantId + '-annotations-' + this._state.fileId;
|
||||
this.#annotations = signal<AnnotationWrapper[]>(JSON.parse(localStorage.getItem(localStorageKey) || '[]'));
|
||||
const storedAnnotations = JSON.parse(localStorage.getItem(localStorageKey) || '[]') as [];
|
||||
this.#annotations = signal<AnnotationWrapper[]>(
|
||||
storedAnnotations.map(a => {
|
||||
const newAnn = new AnnotationWrapper();
|
||||
Object.assign(newAnn, a);
|
||||
return newAnn;
|
||||
}),
|
||||
);
|
||||
this.annotations$ = toObservable(this.#annotations);
|
||||
this.annotations = this.#annotations.asReadonly();
|
||||
this.earmarks = this.#earmarks.asReadonly();
|
||||
@ -226,7 +233,8 @@ export class FileDataService extends EntitiesService<AnnotationWrapper, Annotati
|
||||
continue;
|
||||
}
|
||||
|
||||
const canBeMappedToASuperType = !!SuperTypeMapper[entry.entryType][entry.state](entry);
|
||||
const isRemoved = entry.state === EntryStates.REMOVED;
|
||||
const canBeMappedToASuperType = !!SuperTypeMapper[entry.entryType][entry.state](entry) || isRemoved;
|
||||
if (!canBeMappedToASuperType) {
|
||||
if (this.#isIqserDevMode) {
|
||||
this.#logger.warn(
|
||||
|
||||
@ -201,6 +201,7 @@ export class REDAnnotationManager {
|
||||
}
|
||||
|
||||
#getByIds(annotations: List | List<AnnotationWrapper>) {
|
||||
annotations = annotations ?? [];
|
||||
return annotations.map((item: string | AnnotationWrapper) => this.#getById(item)).filter(a => !!a);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user