Skip to content

Commit 4a66caa

Browse files
committed
fix links and build alert cleanly
1 parent 65fa6e2 commit 4a66caa

2 files changed

Lines changed: 24 additions & 48 deletions

File tree

components/gui/alert/AlertContainer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ class AlertContainer extends HTMLElement {
8686
transition: all 0.3s ease-in-out;
8787
font-size: 14pt;
8888
}
89+
tpen-alert a {
90+
color: var(--primary-color);
91+
text-decoration: underline;
92+
}
8993
.alert-area tpen-alert {
9094
top: 0px;
9195
right: 0px;

interfaces/transcription/index.js

Lines changed: 20 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -424,62 +424,34 @@ export default class TranscriptionInterface extends HTMLElement {
424424
const alertContainer = document.querySelector('tpen-alert-container')
425425
if (!alertContainer) return
426426

427-
// Build URL with proper encoding
428427
const projectId = encodeURIComponent(TPEN.screen?.projectInQuery ?? '')
429428
const pageId = encodeURIComponent(TPEN.screen?.pageInQuery ?? '')
430-
const annotatorUrl = `/interfaces/annotator?projectId=${projectId}&pageId=${pageId}`
429+
const annotatorUrl = `/interfaces/annotator?projectID=${projectId}&pageID=${pageId}`
431430

432431
const alertElem = document.createElement('tpen-alert')
433-
434-
// Add styles for the alert content
435-
const style = document.createElement('style')
436-
style.textContent = `
437-
.no-lines-message p:first-child {
438-
margin-bottom: 1em;
439-
}
440-
.alert-link {
441-
color: #4fc3f7;
442-
text-decoration: underline;
443-
}
432+
alertElem.innerHTML = `
433+
<style>
434+
.no-lines-message p:first-child {
435+
margin-bottom: 1em;
436+
}
437+
.alert-link {
438+
color: var(--primary-color, #4fc3f7);
439+
text-decoration: underline;
440+
}
441+
</style>
442+
<div class="no-lines-message">
443+
<p>This page has no line annotations defined.</p>
444+
<p>To add lines, visit the <a href="${annotatorUrl}" class="alert-link">annotation interface</a>.</p>
445+
</div>
446+
<div class="button-container">
447+
<button id="no-lines-ok">Got it</button>
448+
</div>
444449
`
445-
alertElem.shadowRoot.appendChild(style)
446-
447-
// Create message with proper DOM elements
448-
const messageContainer = document.createElement('div')
449-
messageContainer.classList.add('no-lines-message')
450450

451-
const paragraph1 = document.createElement('p')
452-
paragraph1.textContent = 'This page has no line annotations defined.'
453-
454-
const paragraph2 = document.createElement('p')
455-
paragraph2.textContent = 'To add lines, visit the '
456-
457-
const link = document.createElement('a')
458-
link.href = annotatorUrl
459-
link.textContent = 'annotation interface'
460-
link.classList.add('alert-link')
461-
462-
paragraph2.appendChild(link)
463-
paragraph2.appendChild(document.createTextNode('.'))
464-
465-
messageContainer.appendChild(paragraph1)
466-
messageContainer.appendChild(paragraph2)
467-
468-
const okButton = document.createElement('button')
469-
const buttonContainer = document.createElement('div')
470-
buttonContainer.classList.add("button-container")
471-
okButton.textContent = 'Got it'
472-
473-
const handleOk = () => {
451+
alertElem.querySelector('#no-lines-ok').addEventListener('click', () => {
474452
alertElem.dismiss()
475-
}
476-
okButton.addEventListener('click', handleOk)
477-
478-
alertElem.appendChild(messageContainer)
479-
buttonContainer.appendChild(okButton)
480-
alertElem.appendChild(buttonContainer)
453+
})
481454

482-
// Use the container's method if available, otherwise access shadow DOM
483455
if (typeof alertContainer.addCustomAlert === 'function') {
484456
alertContainer.addCustomAlert(alertElem)
485457
} else {

0 commit comments

Comments
 (0)