@@ -589,19 +589,95 @@ export const schedulePane = {
589589 }
590590
591591 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' )
592+ const controls = slide . appendChild ( dom . createElement ( 'div' ) )
593+ controls . setAttribute ( 'style' , 'margin: 0.5em 0;' )
594+
595+ const label = controls . appendChild ( dom . createElement ( 'label' ) )
596+ label . textContent = 'Time proposal mode: '
597+
598+ const modeSelector = controls . appendChild ( dom . createElement ( 'select' ) )
599+ modeSelector . setAttribute ( 'style' , inputStyle )
600+
601+ const allDayOption = modeSelector . appendChild ( dom . createElement ( 'option' ) )
602+ allDayOption . setAttribute ( 'value' , 'true' )
603+ allDayOption . textContent = 'All day'
604+
605+ const specificTimesOption = modeSelector . appendChild (
606+ dom . createElement ( 'option' )
595607 )
596- UI . widgets . appendForm (
597- document ,
598- slide ,
599- { } ,
600- subject ,
601- fallbackForm ,
602- detailsDoc ,
603- complainIfBad
608+ specificTimesOption . setAttribute ( 'value' , 'false' )
609+ specificTimesOption . textContent = 'Specific times'
610+
611+ const fallbackContainer = slide . appendChild ( dom . createElement ( 'div' ) )
612+
613+ const renderChosenFallbackForm = function ( ) {
614+ clearElement ( fallbackContainer )
615+ const allDayValue = asBoolean ( kb . any ( subject , ns . sched ( 'allDay' ) ) , true )
616+ const fallbackForm = kb . sym (
617+ formsURI + ( allDayValue ? '#AllDayForm2' : '#NotAllDayForm2' )
618+ )
619+ UI . widgets . appendForm (
620+ document ,
621+ fallbackContainer ,
622+ { } ,
623+ subject ,
624+ fallbackForm ,
625+ detailsDoc ,
626+ complainIfBad
627+ )
628+ }
629+
630+ const setAllDayAndRender = function ( nextAllDayValue ) {
631+ const existing = kb . statementsMatching (
632+ subject ,
633+ ns . sched ( 'allDay' ) ,
634+ undefined ,
635+ detailsDoc
636+ )
637+ const replacement = [
638+ $rdf . st (
639+ subject ,
640+ ns . sched ( 'allDay' ) ,
641+ $rdf . literal (
642+ nextAllDayValue ? 'true' : 'false' ,
643+ undefined ,
644+ $rdf . sym ( 'http://www.w3.org/2001/XMLSchema#boolean' )
645+ ) ,
646+ detailsDoc
647+ )
648+ ]
649+
650+ if ( kb . updater && kb . updater . editable ( detailsDoc . uri , kb ) ) {
651+ kb . updater . update ( existing , replacement , function (
652+ _uri ,
653+ success ,
654+ body
655+ ) {
656+ if ( ! success ) {
657+ complainIfBad ( false , body )
658+ return
659+ }
660+ renderChosenFallbackForm ( )
661+ } )
662+ } else {
663+ existing . forEach ( st => kb . remove ( st ) )
664+ replacement . forEach ( st => kb . add ( st . subject , st . predicate , st . object , st . why ) )
665+ renderChosenFallbackForm ( )
666+ }
667+ }
668+
669+ modeSelector . value =
670+ asBoolean ( kb . any ( subject , ns . sched ( 'allDay' ) ) , true ) ? 'true' : 'false'
671+
672+ modeSelector . addEventListener (
673+ 'change' ,
674+ function ( ) {
675+ setAllDayAndRender ( modeSelector . value === 'true' )
676+ } ,
677+ false
604678 )
679+
680+ renderChosenFallbackForm ( )
605681 }
606682
607683 if ( wizard ) {
0 commit comments