Compare commits
2 Commits
b13c10936b
...
feat/issue
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
379bc84e11 | ||
|
|
110da9b8b0 |
@@ -260,13 +260,6 @@ class TranscriptionBlockControllerTest {
|
|||||||
.andExpect(status().isForbidden());
|
.andExpect(status().isForbidden());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@WithMockUser(authorities = "READ_ALL")
|
|
||||||
void deleteBlock_returns403_whenUserHasOnlyReadAllPermission() throws Exception {
|
|
||||||
mockMvc.perform(delete(URL_BLOCK))
|
|
||||||
.andExpect(status().isForbidden());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@WithMockUser(authorities = "WRITE_ALL")
|
@WithMockUser(authorities = "WRITE_ALL")
|
||||||
void deleteBlock_returns204_whenAuthorised() throws Exception {
|
void deleteBlock_returns204_whenAuthorised() throws Exception {
|
||||||
|
|||||||
@@ -40,6 +40,26 @@ export default defineConfig(
|
|||||||
parser: ts.parser,
|
parser: ts.parser,
|
||||||
svelteConfig
|
svelteConfig
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
// text-accent resolves to #a1dcd8 in light mode (1.52:1 on white — WCAG fail).
|
||||||
|
// layout.css documents it as decorative-only (borders, icon tints, bg fills).
|
||||||
|
// For any text label use text-primary or text-ink instead. This rule catches
|
||||||
|
// the pattern where text-accent appears inside a JavaScript string literal
|
||||||
|
// (e.g. conditional ternary class expressions in Svelte templates).
|
||||||
|
'no-restricted-syntax': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
selector: 'Literal[value=/\\btext-accent\\b/]',
|
||||||
|
message:
|
||||||
|
'text-accent is decorative-only (#a1dcd8 in light mode = 1.52:1 contrast — WCAG fail). Use text-primary or text-ink-2 for text labels.'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
selector: 'TemplateLiteral > TemplateElement[value.raw=/\\btext-accent\\b/]',
|
||||||
|
message:
|
||||||
|
'text-accent is decorative-only (#a1dcd8 in light mode = 1.52:1 contrast — WCAG fail). Use text-primary or text-ink-2 for text labels.'
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ let {
|
|||||||
dimmed = false,
|
dimmed = false,
|
||||||
flashAnnotationId = null,
|
flashAnnotationId = null,
|
||||||
onDraw,
|
onDraw,
|
||||||
onAnnotationClick,
|
onAnnotationClick
|
||||||
onDeleteRequest
|
|
||||||
}: {
|
}: {
|
||||||
annotations: Annotation[];
|
annotations: Annotation[];
|
||||||
canDraw: boolean;
|
canDraw: boolean;
|
||||||
@@ -30,7 +29,6 @@ let {
|
|||||||
flashAnnotationId?: string | null;
|
flashAnnotationId?: string | null;
|
||||||
onDraw: (rect: DrawRect) => void;
|
onDraw: (rect: DrawRect) => void;
|
||||||
onAnnotationClick?: (id: string) => void;
|
onAnnotationClick?: (id: string) => void;
|
||||||
onDeleteRequest?: (annotationId: string) => void;
|
|
||||||
} = $props();
|
} = $props();
|
||||||
|
|
||||||
let drawStart = $state<{ x: number; y: number } | null>(null);
|
let drawStart = $state<{ x: number; y: number } | null>(null);
|
||||||
@@ -114,8 +112,6 @@ const containerStyle = $derived(
|
|||||||
dimmed={dimmed}
|
dimmed={dimmed}
|
||||||
blockNumber={blockNumbers[annotation.id]}
|
blockNumber={blockNumbers[annotation.id]}
|
||||||
isFlashing={flashAnnotationId === annotation.id}
|
isFlashing={flashAnnotationId === annotation.id}
|
||||||
showDelete={canDraw}
|
|
||||||
onDeleteRequest={() => onDeleteRequest?.(annotation.id)}
|
|
||||||
onclick={() => onAnnotationClick?.(annotation.id)}
|
onclick={() => onAnnotationClick?.(annotation.id)}
|
||||||
onpointerenter={() => (hoveredId = annotation.id)}
|
onpointerenter={() => (hoveredId = annotation.id)}
|
||||||
onpointerleave={() => (hoveredId = null)}
|
onpointerleave={() => (hoveredId = null)}
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ describe('AnnotationLayer', () => {
|
|||||||
expect(el2.style.opacity).toBe('1');
|
expect(el2.style.opacity).toBe('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not show delete button when annotation is not hovered or active', async () => {
|
it('does not show delete buttons (annotations owned by blocks)', async () => {
|
||||||
render(AnnotationLayer, {
|
render(AnnotationLayer, {
|
||||||
annotations: [makeAnnotation('ann-1')],
|
annotations: [makeAnnotation('ann-1')],
|
||||||
canDraw: true,
|
canDraw: true,
|
||||||
@@ -107,19 +107,6 @@ describe('AnnotationLayer', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await expect.element(page.getByTestId('annotation-ann-1')).toBeInTheDocument();
|
await expect.element(page.getByTestId('annotation-ann-1')).toBeInTheDocument();
|
||||||
expect(page.getByTestId('annotation-delete-ann-1').query()).toBeNull();
|
expect(page.getByRole('button', { name: /löschen/i }).query()).toBeNull();
|
||||||
});
|
|
||||||
|
|
||||||
it('does not show delete button when canDraw is false even if annotation is active', async () => {
|
|
||||||
render(AnnotationLayer, {
|
|
||||||
annotations: [makeAnnotation('ann-1')],
|
|
||||||
canDraw: false,
|
|
||||||
color: '#00C7B1',
|
|
||||||
activeAnnotationId: 'ann-1',
|
|
||||||
onDraw: () => {}
|
|
||||||
});
|
|
||||||
|
|
||||||
await expect.element(page.getByTestId('annotation-ann-1')).toBeInTheDocument();
|
|
||||||
expect(page.getByTestId('annotation-delete-ann-1').query()).toBeNull();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ let {
|
|||||||
blockNumber = undefined,
|
blockNumber = undefined,
|
||||||
isFlashing = false,
|
isFlashing = false,
|
||||||
isResizable = false,
|
isResizable = false,
|
||||||
showDelete = false,
|
|
||||||
onDeleteRequest,
|
|
||||||
onclick,
|
onclick,
|
||||||
onpointerenter,
|
onpointerenter,
|
||||||
onpointerleave
|
onpointerleave
|
||||||
@@ -25,15 +23,11 @@ let {
|
|||||||
blockNumber?: number | undefined;
|
blockNumber?: number | undefined;
|
||||||
isFlashing?: boolean;
|
isFlashing?: boolean;
|
||||||
isResizable?: boolean;
|
isResizable?: boolean;
|
||||||
showDelete?: boolean;
|
|
||||||
onDeleteRequest?: () => void;
|
|
||||||
onclick: () => void;
|
onclick: () => void;
|
||||||
onpointerenter: () => void;
|
onpointerenter: () => void;
|
||||||
onpointerleave: () => void;
|
onpointerleave: () => void;
|
||||||
} = $props();
|
} = $props();
|
||||||
|
|
||||||
const deleteVisible = $derived(showDelete && (isHovered || isActive));
|
|
||||||
|
|
||||||
function hexToRgba(hex: string, alpha: number): string {
|
function hexToRgba(hex: string, alpha: number): string {
|
||||||
const r = parseInt(hex.slice(1, 3), 16);
|
const r = parseInt(hex.slice(1, 3), 16);
|
||||||
const g = parseInt(hex.slice(3, 5), 16);
|
const g = parseInt(hex.slice(3, 5), 16);
|
||||||
@@ -89,7 +83,6 @@ let shapeStyle = $derived(
|
|||||||
onclick={onclick}
|
onclick={onclick}
|
||||||
onkeydown={(e) => {
|
onkeydown={(e) => {
|
||||||
if (e.key === 'Enter' || e.key === ' ') onclick();
|
if (e.key === 'Enter' || e.key === ' ') onclick();
|
||||||
if (e.key === 'Delete' && showDelete) onDeleteRequest?.();
|
|
||||||
}}
|
}}
|
||||||
onpointerenter={onpointerenter}
|
onpointerenter={onpointerenter}
|
||||||
onpointerleave={onpointerleave}
|
onpointerleave={onpointerleave}
|
||||||
@@ -119,51 +112,6 @@ let shapeStyle = $derived(
|
|||||||
{blockNumber}
|
{blockNumber}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if deleteVisible}
|
|
||||||
<button
|
|
||||||
data-testid="annotation-delete-{annotation.id}"
|
|
||||||
type="button"
|
|
||||||
aria-label="Löschen"
|
|
||||||
onclick={(e) => {
|
|
||||||
e.stopPropagation();
|
|
||||||
onDeleteRequest?.();
|
|
||||||
}}
|
|
||||||
style="
|
|
||||||
position: absolute;
|
|
||||||
top: -8px;
|
|
||||||
right: -8px;
|
|
||||||
min-width: 44px;
|
|
||||||
min-height: 44px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
border-radius: 50%;
|
|
||||||
background-color: #fff;
|
|
||||||
border: 1px solid var(--color-error, #e53e3e);
|
|
||||||
color: var(--color-error, #e53e3e);
|
|
||||||
cursor: pointer;
|
|
||||||
pointer-events: auto;
|
|
||||||
box-shadow: 0 1px 4px rgba(0,0,0,0.2);
|
|
||||||
z-index: 10;
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
width="16"
|
|
||||||
height="16"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
fill="none"
|
|
||||||
stroke="currentColor"
|
|
||||||
stroke-width="1.5"
|
|
||||||
aria-hidden="true"
|
|
||||||
>
|
|
||||||
<path
|
|
||||||
stroke-linecap="round"
|
|
||||||
stroke-linejoin="round"
|
|
||||||
d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"
|
|
||||||
/>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
{/if}
|
|
||||||
{#if isResizable}
|
{#if isResizable}
|
||||||
<AnnotationEditOverlay annotation={annotation} />
|
<AnnotationEditOverlay annotation={annotation} />
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -1,155 +0,0 @@
|
|||||||
import { describe, it, expect, vi, afterEach } from 'vitest';
|
|
||||||
import { cleanup, render } from 'vitest-browser-svelte';
|
|
||||||
import { page } from 'vitest/browser';
|
|
||||||
import AnnotationShape from './AnnotationShape.svelte';
|
|
||||||
|
|
||||||
afterEach(cleanup);
|
|
||||||
|
|
||||||
function makeAnnotation(id = 'ann-1') {
|
|
||||||
return {
|
|
||||||
id,
|
|
||||||
documentId: 'doc-1',
|
|
||||||
pageNumber: 1,
|
|
||||||
x: 0.1,
|
|
||||||
y: 0.1,
|
|
||||||
width: 0.3,
|
|
||||||
height: 0.2,
|
|
||||||
color: '#00C7B1',
|
|
||||||
createdAt: new Date().toISOString()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('AnnotationShape', () => {
|
|
||||||
it('renders the annotation element', async () => {
|
|
||||||
render(AnnotationShape, {
|
|
||||||
annotation: makeAnnotation(),
|
|
||||||
isHovered: false,
|
|
||||||
isActive: false,
|
|
||||||
onclick: () => {},
|
|
||||||
onpointerenter: () => {},
|
|
||||||
onpointerleave: () => {}
|
|
||||||
});
|
|
||||||
|
|
||||||
await expect.element(page.getByTestId('annotation-ann-1')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not show delete button when showDelete is false', async () => {
|
|
||||||
render(AnnotationShape, {
|
|
||||||
annotation: makeAnnotation(),
|
|
||||||
isHovered: true,
|
|
||||||
isActive: false,
|
|
||||||
showDelete: false,
|
|
||||||
onDeleteRequest: vi.fn(),
|
|
||||||
onclick: () => {},
|
|
||||||
onpointerenter: () => {},
|
|
||||||
onpointerleave: () => {}
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(page.getByTestId('annotation-delete-ann-1').query()).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not show delete button when showDelete is true but neither hovered nor active', async () => {
|
|
||||||
render(AnnotationShape, {
|
|
||||||
annotation: makeAnnotation(),
|
|
||||||
isHovered: false,
|
|
||||||
isActive: false,
|
|
||||||
showDelete: true,
|
|
||||||
onDeleteRequest: vi.fn(),
|
|
||||||
onclick: () => {},
|
|
||||||
onpointerenter: () => {},
|
|
||||||
onpointerleave: () => {}
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(page.getByTestId('annotation-delete-ann-1').query()).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('shows delete button when showDelete is true and isHovered is true', async () => {
|
|
||||||
render(AnnotationShape, {
|
|
||||||
annotation: makeAnnotation(),
|
|
||||||
isHovered: true,
|
|
||||||
isActive: false,
|
|
||||||
showDelete: true,
|
|
||||||
onDeleteRequest: vi.fn(),
|
|
||||||
onclick: () => {},
|
|
||||||
onpointerenter: () => {},
|
|
||||||
onpointerleave: () => {}
|
|
||||||
});
|
|
||||||
|
|
||||||
await expect.element(page.getByTestId('annotation-delete-ann-1')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('shows delete button when showDelete is true and isActive is true', async () => {
|
|
||||||
render(AnnotationShape, {
|
|
||||||
annotation: makeAnnotation(),
|
|
||||||
isHovered: false,
|
|
||||||
isActive: true,
|
|
||||||
showDelete: true,
|
|
||||||
onDeleteRequest: vi.fn(),
|
|
||||||
onclick: () => {},
|
|
||||||
onpointerenter: () => {},
|
|
||||||
onpointerleave: () => {}
|
|
||||||
});
|
|
||||||
|
|
||||||
await expect.element(page.getByTestId('annotation-delete-ann-1')).toBeInTheDocument();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('calls onDeleteRequest when delete button is clicked', async () => {
|
|
||||||
const onDeleteRequest = vi.fn();
|
|
||||||
|
|
||||||
render(AnnotationShape, {
|
|
||||||
annotation: makeAnnotation(),
|
|
||||||
isHovered: true,
|
|
||||||
isActive: false,
|
|
||||||
showDelete: true,
|
|
||||||
onDeleteRequest,
|
|
||||||
onclick: () => {},
|
|
||||||
onpointerenter: () => {},
|
|
||||||
onpointerleave: () => {}
|
|
||||||
});
|
|
||||||
|
|
||||||
const deleteBtn = page.getByTestId('annotation-delete-ann-1');
|
|
||||||
await deleteBtn.click();
|
|
||||||
|
|
||||||
expect(onDeleteRequest).toHaveBeenCalledOnce();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('calls onDeleteRequest when Delete key is pressed on the annotation', async () => {
|
|
||||||
const onDeleteRequest = vi.fn();
|
|
||||||
|
|
||||||
render(AnnotationShape, {
|
|
||||||
annotation: makeAnnotation(),
|
|
||||||
isHovered: false,
|
|
||||||
isActive: true,
|
|
||||||
showDelete: true,
|
|
||||||
onDeleteRequest,
|
|
||||||
onclick: () => {},
|
|
||||||
onpointerenter: () => {},
|
|
||||||
onpointerleave: () => {}
|
|
||||||
});
|
|
||||||
|
|
||||||
const annotationEl = page.getByTestId('annotation-ann-1').element() as HTMLElement;
|
|
||||||
annotationEl.dispatchEvent(new KeyboardEvent('keydown', { key: 'Delete', bubbles: true }));
|
|
||||||
|
|
||||||
expect(onDeleteRequest).toHaveBeenCalledOnce();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not call onDeleteRequest on Delete key when showDelete is false', async () => {
|
|
||||||
const onDeleteRequest = vi.fn();
|
|
||||||
|
|
||||||
render(AnnotationShape, {
|
|
||||||
annotation: makeAnnotation(),
|
|
||||||
isHovered: false,
|
|
||||||
isActive: true,
|
|
||||||
showDelete: false,
|
|
||||||
onDeleteRequest,
|
|
||||||
onclick: () => {},
|
|
||||||
onpointerenter: () => {},
|
|
||||||
onpointerleave: () => {}
|
|
||||||
});
|
|
||||||
|
|
||||||
const annotationEl = page.getByTestId('annotation-ann-1').element() as HTMLElement;
|
|
||||||
annotationEl.dispatchEvent(new KeyboardEvent('keydown', { key: 'Delete', bubbles: true }));
|
|
||||||
|
|
||||||
expect(onDeleteRequest).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -24,7 +24,6 @@ type Props = {
|
|||||||
flashAnnotationId?: string | null;
|
flashAnnotationId?: string | null;
|
||||||
onAnnotationClick: (id: string) => void;
|
onAnnotationClick: (id: string) => void;
|
||||||
onTranscriptionDraw?: (rect: DrawRect) => void;
|
onTranscriptionDraw?: (rect: DrawRect) => void;
|
||||||
onDeleteAnnotationRequest?: (annotationId: string) => void;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let {
|
let {
|
||||||
@@ -39,8 +38,7 @@ let {
|
|||||||
annotationsDimmed = false,
|
annotationsDimmed = false,
|
||||||
flashAnnotationId = null,
|
flashAnnotationId = null,
|
||||||
onAnnotationClick,
|
onAnnotationClick,
|
||||||
onTranscriptionDraw,
|
onTranscriptionDraw
|
||||||
onDeleteAnnotationRequest
|
|
||||||
}: Props = $props();
|
}: Props = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -100,7 +98,6 @@ let {
|
|||||||
flashAnnotationId={flashAnnotationId}
|
flashAnnotationId={flashAnnotationId}
|
||||||
onAnnotationClick={onAnnotationClick}
|
onAnnotationClick={onAnnotationClick}
|
||||||
onTranscriptionDraw={onTranscriptionDraw}
|
onTranscriptionDraw={onTranscriptionDraw}
|
||||||
onDeleteAnnotationRequest={onDeleteAnnotationRequest}
|
|
||||||
documentFileHash={doc.fileHash ?? null}
|
documentFileHash={doc.fileHash ?? null}
|
||||||
/>
|
/>
|
||||||
{:else if fileUrl}
|
{:else if fileUrl}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ let {
|
|||||||
aria-label={showAnnotations ? m.pdf_annotations_hide() : m.pdf_annotations_show()}
|
aria-label={showAnnotations ? m.pdf_annotations_hide() : m.pdf_annotations_show()}
|
||||||
class="flex items-center gap-1.5 rounded px-2 py-1 font-sans text-xs transition {showAnnotations
|
class="flex items-center gap-1.5 rounded px-2 py-1 font-sans text-xs transition {showAnnotations
|
||||||
? 'text-ink-2 hover:bg-surface/10'
|
? 'text-ink-2 hover:bg-surface/10'
|
||||||
: 'bg-surface/10 text-accent'}"
|
: 'bg-surface/10 text-primary'}"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
class="h-3.5 w-3.5 shrink-0"
|
class="h-3.5 w-3.5 shrink-0"
|
||||||
|
|||||||
67
frontend/src/lib/components/PdfControls.svelte.spec.ts
Normal file
67
frontend/src/lib/components/PdfControls.svelte.spec.ts
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
import { vi, describe, it, expect, afterEach } from 'vitest';
|
||||||
|
import { cleanup, render } from 'vitest-browser-svelte';
|
||||||
|
import { page } from 'vitest/browser';
|
||||||
|
|
||||||
|
import PdfControls from './PdfControls.svelte';
|
||||||
|
|
||||||
|
afterEach(cleanup);
|
||||||
|
|
||||||
|
const defaultProps = {
|
||||||
|
currentPage: 1,
|
||||||
|
totalPages: 3,
|
||||||
|
isLoaded: true,
|
||||||
|
showAnnotations: false,
|
||||||
|
annotationCount: 0,
|
||||||
|
onPrev: vi.fn(),
|
||||||
|
onNext: vi.fn(),
|
||||||
|
onZoomIn: vi.fn(),
|
||||||
|
onZoomOut: vi.fn(),
|
||||||
|
onToggleAnnotations: vi.fn()
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('PdfControls — annotation toggle visibility', () => {
|
||||||
|
it('renders annotation toggle when annotationCount is greater than zero', async () => {
|
||||||
|
render(PdfControls, { ...defaultProps, annotationCount: 3 });
|
||||||
|
await expect
|
||||||
|
.element(page.getByRole('button', { name: /annotierungen anzeigen/i }))
|
||||||
|
.toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not render annotation toggle when annotationCount is zero', async () => {
|
||||||
|
render(PdfControls, { ...defaultProps, annotationCount: 0 });
|
||||||
|
await expect
|
||||||
|
.element(page.getByRole('button', { name: /annotierungen/i }))
|
||||||
|
.not.toBeInTheDocument();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('PdfControls — annotation toggle label', () => {
|
||||||
|
it('shows "Annotierungen anzeigen" label when annotations are hidden', async () => {
|
||||||
|
render(PdfControls, { ...defaultProps, annotationCount: 2, showAnnotations: false });
|
||||||
|
const btn = page.getByRole('button', { name: /annotierungen anzeigen/i });
|
||||||
|
await expect.element(btn).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('shows "Annotierungen verbergen" label when annotations are visible', async () => {
|
||||||
|
render(PdfControls, { ...defaultProps, annotationCount: 2, showAnnotations: true });
|
||||||
|
const btn = page.getByRole('button', { name: /annotierungen verbergen/i });
|
||||||
|
await expect.element(btn).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('PdfControls — annotation toggle contrast (WCAG 2.1 AA)', () => {
|
||||||
|
it('uses text-primary class on annotation toggle button when annotations are hidden', async () => {
|
||||||
|
const { container } = render(PdfControls, {
|
||||||
|
...defaultProps,
|
||||||
|
annotationCount: 2,
|
||||||
|
showAnnotations: false
|
||||||
|
});
|
||||||
|
const allButtons = container.querySelectorAll('button');
|
||||||
|
const annotationBtn = Array.from(allButtons).find((b) =>
|
||||||
|
b.getAttribute('aria-label')?.toLowerCase().includes('annotierungen')
|
||||||
|
);
|
||||||
|
expect(annotationBtn).not.toBeNull();
|
||||||
|
expect(annotationBtn!.className).toContain('text-primary');
|
||||||
|
expect(annotationBtn!.className).not.toContain('text-accent');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -18,7 +18,6 @@ let {
|
|||||||
activeAnnotationId = $bindable<string | null>(null),
|
activeAnnotationId = $bindable<string | null>(null),
|
||||||
onAnnotationClick,
|
onAnnotationClick,
|
||||||
onTranscriptionDraw,
|
onTranscriptionDraw,
|
||||||
onDeleteAnnotationRequest,
|
|
||||||
documentFileHash,
|
documentFileHash,
|
||||||
annotationsDimmed = false,
|
annotationsDimmed = false,
|
||||||
flashAnnotationId = null
|
flashAnnotationId = null
|
||||||
@@ -31,7 +30,6 @@ let {
|
|||||||
activeAnnotationId?: string | null;
|
activeAnnotationId?: string | null;
|
||||||
onAnnotationClick?: (id: string) => void;
|
onAnnotationClick?: (id: string) => void;
|
||||||
onTranscriptionDraw?: (rect: DrawRect) => void;
|
onTranscriptionDraw?: (rect: DrawRect) => void;
|
||||||
onDeleteAnnotationRequest?: (annotationId: string) => void;
|
|
||||||
documentFileHash?: string | null;
|
documentFileHash?: string | null;
|
||||||
annotationsDimmed?: boolean;
|
annotationsDimmed?: boolean;
|
||||||
flashAnnotationId?: string | null;
|
flashAnnotationId?: string | null;
|
||||||
@@ -266,7 +264,6 @@ function handleAnnotationClick(id: string) {
|
|||||||
flashAnnotationId={flashAnnotationId}
|
flashAnnotationId={flashAnnotationId}
|
||||||
onDraw={handleDraw}
|
onDraw={handleDraw}
|
||||||
onAnnotationClick={handleAnnotationClick}
|
onAnnotationClick={handleAnnotationClick}
|
||||||
onDeleteRequest={onDeleteAnnotationRequest}
|
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ let { percentage }: { percentage: number } = $props();
|
|||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
<span
|
<span
|
||||||
class="block text-center font-sans text-xs font-bold {percentage > 0 ? 'text-accent' : 'text-gray-400'}"
|
class="block text-center font-sans text-xs font-bold {percentage > 0 ? 'text-primary' : 'text-gray-400'}"
|
||||||
>
|
>
|
||||||
{percentage}%
|
{percentage}%
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ describe('ProgressRing', () => {
|
|||||||
expect(el.className).toContain('text-gray-400');
|
expect(el.className).toContain('text-gray-400');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders a mint-colored label when percentage is > 0', async () => {
|
it('renders a primary-colored label when percentage is > 0', async () => {
|
||||||
render(ProgressRing, { percentage: 75 });
|
render(ProgressRing, { percentage: 75 });
|
||||||
const label = page.getByText('75%');
|
const label = page.getByText('75%');
|
||||||
await expect.element(label).toBeInTheDocument();
|
await expect.element(label).toBeInTheDocument();
|
||||||
const el = (await label.element()) as HTMLElement;
|
const el = (await label.element()) as HTMLElement;
|
||||||
expect(el.className).toContain('text-accent');
|
expect(el.className).toContain('text-primary');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders a fully filled arc for 100%', async () => {
|
it('renders a fully filled arc for 100%', async () => {
|
||||||
|
|||||||
@@ -13,12 +13,9 @@ import { getErrorMessage } from '$lib/errors';
|
|||||||
import { translateOcrProgress } from '$lib/ocr/translateOcrProgress';
|
import { translateOcrProgress } from '$lib/ocr/translateOcrProgress';
|
||||||
import { createFileLoader } from '$lib/hooks/useFileLoader.svelte';
|
import { createFileLoader } from '$lib/hooks/useFileLoader.svelte';
|
||||||
import { scrollToCommentFromQuery } from '$lib/utils/deepLinkScroll';
|
import { scrollToCommentFromQuery } from '$lib/utils/deepLinkScroll';
|
||||||
import { getConfirmService } from '$lib/services/confirm.svelte.js';
|
|
||||||
|
|
||||||
let { data } = $props();
|
let { data } = $props();
|
||||||
|
|
||||||
const { confirm } = getConfirmService();
|
|
||||||
|
|
||||||
const doc = $derived(data.document);
|
const doc = $derived(data.document);
|
||||||
const canWrite = $derived(data.canWrite ?? false);
|
const canWrite = $derived(data.canWrite ?? false);
|
||||||
const currentUserId = $derived((data.user?.id as string | undefined) ?? null);
|
const currentUserId = $derived((data.user?.id as string | undefined) ?? null);
|
||||||
@@ -108,23 +105,6 @@ async function deleteBlock(blockId: string) {
|
|||||||
annotationReloadKey++;
|
annotationReloadKey++;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleAnnotationDeleteRequest(annotationId: string) {
|
|
||||||
const confirmed = await confirm({
|
|
||||||
title: m.transcription_block_delete_confirm(),
|
|
||||||
destructive: true
|
|
||||||
});
|
|
||||||
if (!confirmed) return;
|
|
||||||
|
|
||||||
const block = transcriptionBlocks.find((b) => b.annotationId === annotationId);
|
|
||||||
if (block) {
|
|
||||||
await deleteBlock(block.id);
|
|
||||||
} else {
|
|
||||||
// Annotation has no linked block — delete the annotation directly
|
|
||||||
await fetch(`/api/documents/${doc.id}/annotations/${annotationId}`, { method: 'DELETE' });
|
|
||||||
annotationReloadKey++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function reviewToggle(blockId: string) {
|
async function reviewToggle(blockId: string) {
|
||||||
const res = await fetch(`/api/documents/${doc.id}/transcription-blocks/${blockId}/review`, {
|
const res = await fetch(`/api/documents/${doc.id}/transcription-blocks/${blockId}/review`, {
|
||||||
method: 'PUT'
|
method: 'PUT'
|
||||||
@@ -401,7 +381,6 @@ onMount(() => {
|
|||||||
bind:activeAnnotationId={activeAnnotationId}
|
bind:activeAnnotationId={activeAnnotationId}
|
||||||
onAnnotationClick={handleAnnotationClick}
|
onAnnotationClick={handleAnnotationClick}
|
||||||
onTranscriptionDraw={createBlockFromDraw}
|
onTranscriptionDraw={createBlockFromDraw}
|
||||||
onDeleteAnnotationRequest={handleAnnotationDeleteRequest}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user