Skip to content

Commit 504ed5c

Browse files
committed
fix: schedulePane render
1 parent 7082a83 commit 504ed5c

1 file changed

Lines changed: 51 additions & 1 deletion

File tree

src/schedule/schedulePane.js

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,9 +557,53 @@ export const schedulePane = {
557557
const showForms = function () {
558558
clearElement(naviCenter) // Remove refresh button if nec
559559
const div = naviMain
560+
561+
// form2 depends on sched:allDay; seed a local default for new polls
562+
if (!kb.any(subject, ns.sched('allDay'))) {
563+
kb.add(
564+
subject,
565+
ns.sched('allDay'),
566+
$rdf.literal(
567+
'true',
568+
undefined,
569+
$rdf.sym('http://www.w3.org/2001/XMLSchema#boolean')
570+
),
571+
detailsDoc
572+
)
573+
}
574+
560575
const wizard = true
561576
let currentSlide = 0
562577
let gotDoneButton = false
578+
579+
const hasFormControls = function (container) {
580+
return !!container.querySelector('input, select, textarea, button')
581+
}
582+
583+
const asBoolean = function (term, fallback) {
584+
if (!term) return fallback
585+
const value = (term.value || '').toLowerCase()
586+
if (value === 'true' || value === '1') return true
587+
if (value === 'false' || value === '0') return false
588+
return fallback
589+
}
590+
591+
const renderTimeProposalFallback = function (slide) {
592+
const allDayValue = asBoolean(kb.any(subject, ns.sched('allDay')), true)
593+
const fallbackForm = kb.sym(
594+
formsURI + (allDayValue ? '#AllDayForm2' : '#NotAllDayForm2')
595+
)
596+
UI.widgets.appendForm(
597+
document,
598+
slide,
599+
{},
600+
subject,
601+
fallbackForm,
602+
detailsDoc,
603+
complainIfBad
604+
)
605+
}
606+
563607
if (wizard) {
564608
const forms = [form1, form2, form3]
565609
const slides = []
@@ -575,6 +619,12 @@ export const schedulePane = {
575619
detailsDoc,
576620
complainIfBad
577621
)
622+
623+
// Some stores end up with form2's ui:Options unresolved; force a usable input form.
624+
if (f === 1 && !hasFormControls(slide)) {
625+
renderTimeProposalFallback(slide)
626+
}
627+
578628
slides.push(slide)
579629
}
580630

@@ -882,7 +932,7 @@ export const schedulePane = {
882932

883933
// Read or create empty results file
884934
function getResults () {
885-
fetcher.nowOrWhenFetched(resultsDoc.uri, (ok, body, response) => {
935+
fetcher.nowOrWhenFetched(resultsDoc.uri, undefined, (ok, body, response) => {
886936
if (!ok) {
887937
if (response.status === 404) {
888938
// / Check explicitly for 404 error

0 commit comments

Comments
 (0)