Some cleanup

This commit is contained in:
Adina Țeudan 2022-03-01 12:47:23 +02:00
parent 976cde9f5b
commit 3c4c5c5f70
12 changed files with 113 additions and 89 deletions

View File

@ -1,30 +1,6 @@
<ng-container *ngFor="let annotation of annotations; let idx = index">
<div *ngIf="showHighlightGroup(idx) as highlightGroup" class="workload-separator">
<div>
<redaction-type-annotation-icon [annotation]="annotation" class="mr-8"></redaction-type-annotation-icon>
<span [translateParams]="highlightGroup" [translate]="'highlights'" class="all-caps-label"></span>
</div>
<div *ngIf="state.isWritable$ | async">
<iqser-circle-button
(action)="convertHighlights(highlightGroup)"
[size]="28"
[tooltip]="'file-preview.highlights.convert' | translate"
[type]="circleButtonTypes.dark"
class="mr-2"
icon="red:convert"
tooltipPosition="above"
></iqser-circle-button>
<iqser-circle-button
(action)="removeHighlights(highlightGroup)"
[size]="28"
[tooltip]="'file-preview.highlights.remove' | translate"
[type]="circleButtonTypes.dark"
icon="iqser:trash"
tooltipPosition="above"
></iqser-circle-button>
</div>
<redaction-highlights-separator [annotation]="annotation" [highlightGroup]="highlightGroup"></redaction-highlights-separator>
</div>
<div

View File

@ -76,7 +76,3 @@
}
}
}
.workload-separator > div {
display: flex;
}

View File

@ -1,20 +1,13 @@
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output, SimpleChanges, TemplateRef } from '@angular/core';
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { CircleButtonTypes, FilterService, IqserEventTarget } from '@iqser/common-ui';
import { FilterService, IqserEventTarget } from '@iqser/common-ui';
import { MultiSelectService } from '../../services/multi-select.service';
import { AnnotationReferencesService } from '../../services/annotation-references.service';
import { FilePreviewStateService } from '../../services/file-preview-state.service';
import { UserPreferenceService } from '@services/user-preference.service';
import { ViewModeService } from '../../services/view-mode.service';
import { BehaviorSubject } from 'rxjs';
import { DossiersDialogService } from '../../../../services/dossiers-dialog.service';
import { TextHighlightOperation } from '@red/domain';
interface HighlightGroup {
startIdx: number;
color: string;
length: number;
}
import { TextHighlightsGroup } from '@red/domain';
@Component({
selector: 'redaction-annotations-list',
@ -23,8 +16,6 @@ interface HighlightGroup {
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AnnotationsListComponent implements OnChanges {
readonly circleButtonTypes = CircleButtonTypes;
@Input() annotations: AnnotationWrapper[];
@Input() selectedAnnotations: AnnotationWrapper[];
@Input() annotationActionsTemplate: TemplateRef<unknown>;
@ -34,28 +25,17 @@ export class AnnotationsListComponent implements OnChanges {
@Output() readonly selectAnnotations = new EventEmitter<AnnotationWrapper[]>();
@Output() readonly deselectAnnotations = new EventEmitter<AnnotationWrapper[]>();
highlightGroups$ = new BehaviorSubject<HighlightGroup[]>([]);
highlightGroups$ = new BehaviorSubject<TextHighlightsGroup[]>([]);
constructor(
readonly multiSelectService: MultiSelectService,
readonly annotationReferencesService: AnnotationReferencesService,
readonly state: FilePreviewStateService,
private readonly _filterService: FilterService,
private readonly _userPreferenceService: UserPreferenceService,
private readonly _viewModeService: ViewModeService,
private readonly _dialogService: DossiersDialogService,
) {}
convertHighlights(highlightGroup: HighlightGroup): void {
const data = this._getActionData(highlightGroup, TextHighlightOperation.CONVERT);
this._dialogService.openDialog('highlightAction', null, data);
}
removeHighlights(highlightGroup: HighlightGroup): void {
const data = this._getActionData(highlightGroup, TextHighlightOperation.REMOVE);
this._dialogService.openDialog('highlightAction', null, data);
}
ngOnChanges(changes: SimpleChanges): void {
if (changes.annotations && this.annotations && !this._viewModeService.isTextHighlights) {
this.annotations = this.annotations.sort(this.annotationsPositionCompare);
@ -109,25 +89,16 @@ export class AnnotationsListComponent implements OnChanges {
}
}
showHighlightGroup(idx: number): HighlightGroup {
showHighlightGroup(idx: number): TextHighlightsGroup {
return this._viewModeService.isTextHighlights && this.highlightGroups$.value.find(h => h.startIdx === idx);
}
private _getActionData(highlightGroup: HighlightGroup, operation: TextHighlightOperation) {
return {
dossierId: this.state.dossierId,
fileId: this.state.fileId,
color: highlightGroup.color,
operation,
};
}
private _updateHighlightGroups(): void {
if (!this.annotations?.length) {
return;
}
const highlightGroups: HighlightGroup[] = [];
let lastGroup: HighlightGroup;
const highlightGroups: TextHighlightsGroup[] = [];
let lastGroup: TextHighlightsGroup;
for (let idx = 0; idx < this.annotations.length; ++idx) {
if (idx === 0 || this.annotations[idx].color !== this.annotations[idx - 1].color) {
if (lastGroup) {

View File

@ -0,0 +1,25 @@
<div>
<redaction-type-annotation-icon [annotation]="annotation" class="mr-8"></redaction-type-annotation-icon>
<span [translateParams]="highlightGroup" [translate]="'highlights'" class="all-caps-label"></span>
</div>
<div *ngIf="isWritable$ | async">
<iqser-circle-button
(action)="convertHighlights(highlightGroup)"
[size]="28"
[tooltip]="'file-preview.highlights.convert' | translate"
[type]="circleButtonTypes.dark"
class="mr-2"
icon="red:convert"
tooltipPosition="above"
></iqser-circle-button>
<iqser-circle-button
(action)="removeHighlights(highlightGroup)"
[size]="28"
[tooltip]="'file-preview.highlights.remove' | translate"
[type]="circleButtonTypes.dark"
icon="iqser:trash"
tooltipPosition="above"
></iqser-circle-button>
</div>

View File

@ -0,0 +1,7 @@
:host {
display: contents;
> div {
display: flex;
}
}

View File

@ -0,0 +1,41 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { CircleButtonTypes } from '@iqser/common-ui';
import { TextHighlightOperation, TextHighlightsGroup } from '@red/domain';
import { DossiersDialogService } from '../../../../services/dossiers-dialog.service';
import { FilePreviewStateService } from '../../services/file-preview-state.service';
import { AnnotationWrapper } from '@models/file/annotation.wrapper';
@Component({
selector: 'redaction-highlights-separator [highlightGroup] [annotation]',
templateUrl: './highlights-separator.component.html',
styleUrls: ['./highlights-separator.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class HighlightsSeparatorComponent {
@Input() highlightGroup: TextHighlightsGroup;
@Input() annotation: AnnotationWrapper;
readonly circleButtonTypes = CircleButtonTypes;
readonly isWritable$ = this._state.isWritable$;
constructor(private readonly _dialogService: DossiersDialogService, private readonly _state: FilePreviewStateService) {}
convertHighlights(highlightGroup: TextHighlightsGroup): void {
const data = this._getActionData(highlightGroup, TextHighlightOperation.CONVERT);
this._dialogService.openDialog('highlightAction', null, data);
}
removeHighlights(highlightGroup: TextHighlightsGroup): void {
const data = this._getActionData(highlightGroup, TextHighlightOperation.REMOVE);
this._dialogService.openDialog('highlightAction', null, data);
}
private _getActionData(highlightGroup: TextHighlightsGroup, operation: TextHighlightOperation) {
return {
dossierId: this._state.dossierId,
fileId: this._state.fileId,
color: highlightGroup.color,
operation,
};
}
}

View File

@ -175,7 +175,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
const nonStandardEntries = annotations.filter(a => a.getCustomData('changeLogRemoved') === 'true');
this._setAnnotationsOpacity(standardEntries, true);
this._show(standardEntries);
this._hide([...nonStandardEntries]);
this._hide(nonStandardEntries);
break;
}
case 'DELTA': {
@ -184,7 +184,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
this._setAnnotationsColor(redactions, 'annotationColor');
this._setAnnotationsOpacity(changeLogEntries, true);
this._show(changeLogEntries);
this._hide([...nonChangeLogEntries]);
this._hide(nonChangeLogEntries);
break;
}
case 'REDACTED': {
@ -192,7 +192,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
this._setAnnotationsOpacity(redactions);
this._setAnnotationsColor(redactions, 'redactionColor');
this._show(redactions);
this._hide([...nonRedactionEntries]);
this._hide(nonRedactionEntries);
break;
}
case 'TEXT_HIGHLIGHTS': {
@ -725,7 +725,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
}
}
private _getAnnotations(predicate: (value) => unknown) {
private _getAnnotations(predicate: (value) => boolean) {
const annotations = this._instance.Core.annotationManager.getAnnotationsList();
return predicate ? annotations.filter(predicate) : annotations;
}

View File

@ -23,6 +23,7 @@ import { AnnotationReferencesListComponent } from './components/annotation-refer
import { AcceptRecommendationDialogComponent } from './dialogs/accept-recommendation-dialog/accept-recommendation-dialog.component';
import { AnnotationCardComponent } from './components/annotation-card/annotation-card.component';
import { AnnotationReferencesPageIndicatorComponent } from './components/annotation-references-page-indicator/annotation-references-page-indicator.component';
import { HighlightsSeparatorComponent } from './components/highlights-separator/highlights-separator.component';
const routes: Routes = [
{
@ -33,26 +34,28 @@ const routes: Routes = [
},
];
const components = [
FileWorkloadComponent,
AnnotationDetailsComponent,
AnnotationsListComponent,
PageIndicatorComponent,
PageExclusionComponent,
PdfViewerComponent,
AnnotationActionsComponent,
CommentsComponent,
DocumentInfoComponent,
TypeAnnotationIconComponent,
ViewSwitchComponent,
UserManagementComponent,
AcceptRecommendationDialogComponent,
AnnotationReferencesListComponent,
AnnotationCardComponent,
AnnotationReferencesPageIndicatorComponent,
HighlightsSeparatorComponent,
];
@NgModule({
declarations: [
FilePreviewScreenComponent,
FileWorkloadComponent,
AnnotationDetailsComponent,
AnnotationsListComponent,
PageIndicatorComponent,
PageExclusionComponent,
PdfViewerComponent,
AnnotationActionsComponent,
CommentsComponent,
DocumentInfoComponent,
TypeAnnotationIconComponent,
ViewSwitchComponent,
UserManagementComponent,
AcceptRecommendationDialogComponent,
AnnotationReferencesListComponent,
AnnotationCardComponent,
AnnotationReferencesPageIndicatorComponent,
],
declarations: [FilePreviewScreenComponent, ...components],
imports: [
RouterModule.forChild(routes),
CommonModule,

View File

@ -222,7 +222,6 @@ export class AnnotationDrawService {
annotationWrapper.hidden;
annotation.setCustomData('redact-manager', 'true');
annotation.setCustomData('redaction', String(annotationWrapper.previewAnnotation));
annotation.setCustomData('highlight', String(annotationWrapper.isHighlight));
annotation.setCustomData('skipped', String(annotationWrapper.isSkipped));
annotation.setCustomData('changeLog', String(annotationWrapper.isChangeLogEntry));
annotation.setCustomData('changeLogRemoved', String(annotationWrapper.isChangeLogRemoved));

View File

@ -1,4 +1,4 @@
import { IRectangle } from '../geometry/rectangle';
import { IRectangle } from '../geometry';
export interface ImportedRedaction {
id: string;

View File

@ -2,3 +2,4 @@ export * from './imported-redaction';
export * from './text-highlight-operation';
export * from './text-highlight.response';
export * from './text-highlight.request';
export * from './text-highlights-group';

View File

@ -0,0 +1,5 @@
export interface TextHighlightsGroup {
startIdx: number;
color: string;
length: number;
}