Skip to content

Commit ab582e5

Browse files
Copilotcubap
andcommitted
Add dismissible modal for pages without lines
Shows an alert when a page has no line annotations with a link to the annotation interface where users can manually define lines. The alert is dismissible by clicking the "Got it" button. Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>
1 parent 182d6ce commit ab582e5

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

interfaces/transcription/index.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import '../../components/line-image/index.js'
77
import CheckPermissions from "../../components/check-permissions/checkPermissions.js"
88
import { orderPageItemsByColumns } from "../../utilities/columnOrdering.js"
99
import { renderPermissionError } from "../../utilities/renderPermissionError.js"
10+
import '../../components/gui/alert/AlertContainer.js'
1011
export default class TranscriptionInterface extends HTMLElement {
1112
#page
1213
#canvas
@@ -419,6 +420,38 @@ export default class TranscriptionInterface extends HTMLElement {
419420
})
420421
}
421422

423+
showNoLinesAlert() {
424+
const alertContainer = document.querySelector('tpen-alert-container')
425+
if (!alertContainer) return
426+
427+
const alertElem = document.createElement('tpen-alert')
428+
const message = document.createElement('div')
429+
message.innerHTML = `
430+
<p style="margin-bottom: 1em;">This page has no line annotations defined.</p>
431+
<p>To add lines, visit the <a href="/interfaces/annotator?projectId=${TPEN.screen?.projectInQuery ?? ''}&pageId=${TPEN.screen?.pageInQuery ?? ''}" style="color: #4fc3f7; text-decoration: underline;">annotation interface</a>.</p>
432+
`
433+
434+
const okButton = document.createElement('button')
435+
const buttonContainer = document.createElement('div')
436+
buttonContainer.classList.add("button-container")
437+
okButton.textContent = 'Got it'
438+
439+
const handleOk = () => {
440+
alertElem.dismiss()
441+
}
442+
okButton.addEventListener('click', handleOk)
443+
444+
alertElem.appendChild(message)
445+
buttonContainer.appendChild(okButton)
446+
alertElem.appendChild(buttonContainer)
447+
448+
const screenLockingSection = alertContainer.shadowRoot.querySelector('.alert-area')
449+
if (screenLockingSection) {
450+
screenLockingSection.appendChild(alertElem)
451+
alertElem.show()
452+
}
453+
}
454+
422455
updateLines() {
423456
if (TPEN.activeLineIndex < 0 || !this.#page) return
424457
const topImage = this.shadowRoot.querySelector('#topImage')
@@ -530,6 +563,8 @@ export default class TranscriptionInterface extends HTMLElement {
530563
topImage.canvas = canvasID
531564
bottomImage.canvas = canvas
532565
topImage.setAttribute('region', regionValue)
566+
// Show alert to inform user about missing lines
567+
this.showNoLinesAlert()
533568
return
534569
}
535570

0 commit comments

Comments
 (0)