diff --git a/apps/red-ui/src/app/models/file/annotation.wrapper.ts b/apps/red-ui/src/app/models/file/annotation.wrapper.ts index de9d41047..b0a76be8c 100644 --- a/apps/red-ui/src/app/models/file/annotation.wrapper.ts +++ b/apps/red-ui/src/app/models/file/annotation.wrapper.ts @@ -40,7 +40,7 @@ export class AnnotationWrapper implements IListable { typeLabel?: string; color: string; numberOfComments = 0; - firstTopLeftPoint: IPoint; + firstBottomLeftPoint: IPoint; shortContent: string; content: AnnotationContent; value: string; @@ -199,11 +199,11 @@ export class AnnotationWrapper implements IListable { } get x() { - return this.firstTopLeftPoint.x; + return this.firstBottomLeftPoint.x; } get y() { - return this.firstTopLeftPoint.y; + return this.firstBottomLeftPoint.y; } get legalBasis() { @@ -228,7 +228,7 @@ export class AnnotationWrapper implements IListable { annotationWrapper.value = 'Imported'; annotationWrapper.color = earmark.hexColor; annotationWrapper.positions = earmark.positions; - annotationWrapper.firstTopLeftPoint = earmark.positions[0]?.topLeft; + annotationWrapper.firstBottomLeftPoint = earmark.positions[0]?.topLeft; annotationWrapper.superTypeLabel = annotationTypesTranslations[annotationWrapper.superType]; return annotationWrapper; @@ -249,7 +249,7 @@ export class AnnotationWrapper implements IListable { annotationWrapper.isChangeLogEntry = logEntry.state === EntryStates.REMOVED || !!changeLogType; annotationWrapper.type = logEntry.type; annotationWrapper.value = logEntry.value; - annotationWrapper.firstTopLeftPoint = { x: logEntry.positions[0].rectangle[0], y: logEntry.positions[0].rectangle[1] }; + annotationWrapper.firstBottomLeftPoint = { x: logEntry.positions[0].rectangle[0], y: logEntry.positions[0].rectangle[1] }; annotationWrapper.pageNumber = logEntry.positions[0].pageNumber; annotationWrapper.positions = logEntry.positions.map(p => ({ page: p.pageNumber, diff --git a/apps/red-ui/src/app/modules/file-preview/utils/sort-by-page-rotation.utils.ts b/apps/red-ui/src/app/modules/file-preview/utils/sort-by-page-rotation.utils.ts index 580b12147..355abde3d 100644 --- a/apps/red-ui/src/app/modules/file-preview/utils/sort-by-page-rotation.utils.ts +++ b/apps/red-ui/src/app/modules/file-preview/utils/sort-by-page-rotation.utils.ts @@ -1,18 +1,18 @@ import { AnnotationWrapper } from '@models/file/annotation.wrapper'; export const sortTopLeftToBottomRight = (a1: AnnotationWrapper, a2: AnnotationWrapper): number => { - const top = Math.min(a1.y, a2.y); - const bottom = Math.max(a1.y - a1.height, a2.y - a2.height); + const top = Math.min(a1.y + a1.height, a2.y + a2.height); + const bottom = Math.max(a1.y, a2.y); const intersectionHeight = Math.max(0, top - bottom); const a1IntersectionPercentage = (intersectionHeight / a1.height) * 100; const a2IntersectionPercentage = (intersectionHeight / a2.height) * 100; - if (a1IntersectionPercentage || a2IntersectionPercentage) { + if (a1IntersectionPercentage > 10 || a2IntersectionPercentage > 10) { return a1.x < a2.x ? -1 : 1; } - if (a1.y > a2.y) { + if (a1.y + a1.height > a2.y + a2.height) { return -1; } - if (a1.y < a2.y) { + if (a1.y + a1.height < a2.y + a2.height) { return 1; } return a1.x < a2.x ? -1 : 1; @@ -24,8 +24,8 @@ export const sortBottomLeftToTopRight = (a1: AnnotationWrapper, a2: AnnotationWr const intersectionHeight = Math.max(0, bottom - top); const a1IntersectionPercentage = (intersectionHeight / a1.width) * 100; const a2IntersectionPercentage = (intersectionHeight / a2.width) * 100; - if (a1IntersectionPercentage || a2IntersectionPercentage) { - return a1.y < a2.y ? -1 : 1; + if (a1IntersectionPercentage > 10 || a2IntersectionPercentage > 10) { + return a1.y + a1.height < a2.y + a2.height ? -1 : 1; } if (a1.x < a2.x) { return -1; @@ -33,7 +33,7 @@ export const sortBottomLeftToTopRight = (a1: AnnotationWrapper, a2: AnnotationWr if (a1.x > a2.x) { return 1; } - return a1.y < a2.y ? -1 : 1; + return a1.y + a1.height < a2.y + a2.height ? -1 : 1; }; export const sortBottomRightToTopLeft = (a1: AnnotationWrapper, a2: AnnotationWrapper): number => { @@ -42,8 +42,8 @@ export const sortBottomRightToTopLeft = (a1: AnnotationWrapper, a2: AnnotationWr const intersectionHeight = Math.max(0, bottom - top); const a1IntersectionPercentage = (intersectionHeight / a1.height) * 100; const a2IntersectionPercentage = (intersectionHeight / a2.height) * 100; - if (a1IntersectionPercentage || a2IntersectionPercentage) { - return a1.x > a2.x ? -1 : 1; + if (a1IntersectionPercentage > 10 || a2IntersectionPercentage > 10) { + return a1.x + a1.width > a2.x + a2.width ? -1 : 1; } if (a1.y < a2.y) { return -1; @@ -51,7 +51,7 @@ export const sortBottomRightToTopLeft = (a1: AnnotationWrapper, a2: AnnotationWr if (a1.y > a2.y) { return 1; } - return a1.x > a2.x ? -1 : 1; + return a1.x + a1.width > a2.x + a2.width ? -1 : 1; }; export const sortTopRightToBottomLeft = (a1: AnnotationWrapper, a2: AnnotationWrapper): number => { const top = Math.min(a1.x + a1.width, a2.x + a2.width); @@ -59,14 +59,14 @@ export const sortTopRightToBottomLeft = (a1: AnnotationWrapper, a2: AnnotationWr const intersectionHeight = Math.max(0, top - bottom); const a1IntersectionPercentage = (intersectionHeight / a1.width) * 100; const a2IntersectionPercentage = (intersectionHeight / a2.width) * 100; - if (a1IntersectionPercentage || a2IntersectionPercentage) { - return a1.y > a2.y ? -1 : 1; + if (a1IntersectionPercentage > 10 || a2IntersectionPercentage > 10) { + return a1.y + a1.height > a2.y + a2.height ? -1 : 1; } - if (a1.x > a2.x) { + if (a1.x + a1.width > a2.x + a2.width) { return -1; } - if (a1.x < a2.x) { + if (a1.x + a1.width < a2.x + a2.width) { return 1; } - return a1.y > a2.y ? -1 : 1; + return a1.y + a1.height > a2.y + a2.height ? -1 : 1; };