@@ -85,7 +85,9 @@ export function Component() {
8585 statusResponse,
8686 actionDivRef,
8787 refetchStatusResponse,
88+ readOnly,
8889 } = useOutletContext < PerProcessOutletContext > ( ) ;
90+
8991 const { per_overviewassessmentmethods } = useGlobalEnums ( ) ;
9092 const userMe = useUserMe ( ) ;
9193
@@ -101,6 +103,7 @@ export function Component() {
101103 validate,
102104 } = useForm (
103105 overviewSchema ,
106+ // FIXME: use value from enum
104107 { value : { assessment_method : 'per' } } ,
105108 isSettingUpProcess ,
106109 ) ;
@@ -338,10 +341,10 @@ export function Component() {
338341 const error = getErrorObject ( formError ) ;
339342
340343 const currentPerStep = statusResponse ?. phase ;
341- const submissionDisabled = isDefined ( currentPerStep )
342- && currentPerStep !== PER_PHASE_OVERVIEW ;
344+ const submissionDisabled = readOnly
345+ || ( isDefined ( currentPerStep ) && currentPerStep !== PER_PHASE_OVERVIEW ) ;
343346
344- const partialReadonlyMode = value ?. is_draft === false ;
347+ const partialReadOnly = value ?. is_draft === false ;
345348
346349 const dataPending = fetchingPerOverview ;
347350 const savePerPending = createPerPending || updatePerPending ;
@@ -367,7 +370,7 @@ export function Component() {
367370 < Container
368371 headerElementRef = { formContentRef }
369372 className = { styles . overviewForm }
370- heading = { partialReadonlyMode
373+ heading = { partialReadOnly
371374 ? strings . overviewEditHeading
372375 : strings . overviewSetupHeading }
373376 headingLevel = { 2 }
@@ -394,7 +397,7 @@ export function Component() {
394397 name = { undefined }
395398 variant = "secondary"
396399 onClick = { handleSave }
397- disabled = { savePerPending }
400+ disabled = { savePerPending || readOnly }
398401 >
399402 { strings . saveButtonLabel }
400403 </ Button >
@@ -420,7 +423,7 @@ export function Component() {
420423 onChange = { setFieldValue }
421424 value = { value ?. country }
422425 error = { getErrorString ( error ?. country ) }
423- readOnly = { partialReadonlyMode }
426+ readOnly = { partialReadOnly || readOnly }
424427 disabled = { disabled }
425428 regions = { ! userMe ?. is_superuser
426429 ? userMe ?. is_per_admin_for_regions : undefined }
@@ -449,7 +452,7 @@ export function Component() {
449452 onChange = { setFieldValue }
450453 value = { value ?. date_of_orientation }
451454 error = { error ?. date_of_orientation }
452- readOnly = { partialReadonlyMode }
455+ readOnly = { partialReadOnly || readOnly }
453456 disabled = { disabled }
454457 />
455458 </ InputSection >
@@ -467,6 +470,7 @@ export function Component() {
467470 setFileIdToUrlMap = { setFileIdToUrlMap }
468471 error = { getErrorString ( error ?. orientation_documents ) }
469472 disabled = { disabled }
473+ readOnly = { readOnly }
470474 >
471475 { strings . uploadButtonLabel }
472476 </ GoMultiFileInput >
@@ -491,7 +495,7 @@ export function Component() {
491495 onChange = { setFieldValue }
492496 value = { value ?. date_of_assessment }
493497 error = { error ?. date_of_assessment }
494- readOnly = { partialReadonlyMode }
498+ readOnly = { partialReadOnly || readOnly }
495499 disabled = { disabled }
496500 />
497501 </ InputSection >
@@ -509,7 +513,7 @@ export function Component() {
509513 onChange = { setFieldValue }
510514 value = { value ?. type_of_assessment }
511515 error = { error ?. type_of_assessment }
512- readOnly = { partialReadonlyMode }
516+ readOnly = { partialReadOnly || readOnly }
513517 disabled = { disabled || perOptionsPending }
514518 />
515519 </ InputSection >
@@ -554,7 +558,7 @@ export function Component() {
554558 value = { value ?. branches_involved }
555559 onChange = { setFieldValue }
556560 error = { error ?. branches_involved }
557- readOnly = { partialReadonlyMode }
561+ readOnly = { partialReadOnly || readOnly }
558562 disabled = { disabled }
559563 />
560564 </ InputSection >
@@ -571,7 +575,7 @@ export function Component() {
571575 labelSelector = { stringValueSelector }
572576 onChange = { setFieldValue }
573577 error = { error ?. assessment_method }
574- readOnly = { partialReadonlyMode }
578+ readOnly = { partialReadOnly || readOnly }
575579 disabled = { disabled }
576580 />
577581 </ InputSection >
@@ -585,7 +589,7 @@ export function Component() {
585589 value = { value ?. assess_preparedness_of_country }
586590 onChange = { setFieldValue }
587591 error = { error ?. assess_preparedness_of_country }
588- readOnly = { partialReadonlyMode }
592+ readOnly = { partialReadOnly || readOnly }
589593 disabled = { disabled }
590594 />
591595 </ InputSection >
@@ -599,7 +603,7 @@ export function Component() {
599603 value = { value . assess_urban_aspect_of_country }
600604 onChange = { setFieldValue }
601605 error = { error ?. assess_urban_aspect_of_country }
602- readOnly = { partialReadonlyMode }
606+ readOnly = { partialReadOnly || readOnly }
603607 disabled = { disabled }
604608 />
605609 </ InputSection >
@@ -614,7 +618,7 @@ export function Component() {
614618 value = { value ?. assess_climate_environment_of_country }
615619 onChange = { setFieldValue }
616620 error = { error ?. assess_climate_environment_of_country }
617- readOnly = { partialReadonlyMode }
621+ readOnly = { partialReadOnly || readOnly }
618622 disabled = { disabled }
619623 />
620624 </ InputSection >
@@ -660,6 +664,7 @@ export function Component() {
660664 error = { error ?. workplan_development_date }
661665 onChange = { setFieldValue }
662666 disabled = { disabled }
667+ readOnly = { readOnly }
663668 />
664669 </ InputSection >
665670 < InputSection
@@ -673,6 +678,7 @@ export function Component() {
673678 value = { value ?. workplan_revision_date }
674679 error = { error ?. workplan_revision_date }
675680 disabled = { disabled }
681+ readOnly = { readOnly }
676682 />
677683 </ InputSection >
678684 </ Container >
@@ -696,6 +702,7 @@ export function Component() {
696702 onChange = { setFieldValue }
697703 error = { error ?. ns_focal_point_name }
698704 disabled = { disabled }
705+ readOnly = { readOnly }
699706 />
700707 < TextInput
701708 label = { strings . focalPointEmailInputLabel }
@@ -704,6 +711,7 @@ export function Component() {
704711 onChange = { setFieldValue }
705712 error = { error ?. ns_focal_point_email }
706713 disabled = { disabled }
714+ readOnly = { readOnly }
707715 />
708716 < TextInput
709717 label = { strings . focalPointPhoneNumberInputLabel }
@@ -712,6 +720,7 @@ export function Component() {
712720 onChange = { setFieldValue }
713721 error = { error ?. ns_focal_point_phone }
714722 disabled = { disabled }
723+ readOnly = { readOnly }
715724 />
716725 </ InputSection >
717726 < InputSection
@@ -727,6 +736,7 @@ export function Component() {
727736 onChange = { setFieldValue }
728737 error = { error ?. ns_second_focal_point_name }
729738 disabled = { disabled }
739+ readOnly = { readOnly }
730740 />
731741 < TextInput
732742 label = { strings . focalPointEmailInputLabel }
@@ -735,6 +745,7 @@ export function Component() {
735745 onChange = { setFieldValue }
736746 error = { error ?. ns_second_focal_point_email }
737747 disabled = { disabled }
748+ readOnly = { readOnly }
738749 />
739750 < TextInput
740751 label = { strings . focalPointPhoneNumberInputLabel }
@@ -743,6 +754,7 @@ export function Component() {
743754 onChange = { setFieldValue }
744755 error = { error ?. ns_second_focal_point_phone }
745756 disabled = { disabled }
757+ readOnly = { readOnly }
746758 />
747759 </ InputSection >
748760 < InputSection
@@ -757,6 +769,7 @@ export function Component() {
757769 onChange = { setFieldValue }
758770 error = { error ?. partner_focal_point_name }
759771 disabled = { disabled }
772+ readOnly = { readOnly }
760773 />
761774 < TextInput
762775 label = { strings . focalPointEmailInputLabel }
@@ -765,6 +778,7 @@ export function Component() {
765778 onChange = { setFieldValue }
766779 error = { error ?. partner_focal_point_email }
767780 disabled = { disabled }
781+ readOnly = { readOnly }
768782 />
769783 < TextInput
770784 label = { strings . focalPointPhoneNumberInputLabel }
@@ -773,6 +787,7 @@ export function Component() {
773787 onChange = { setFieldValue }
774788 error = { error ?. partner_focal_point_phone }
775789 disabled = { disabled }
790+ readOnly = { readOnly }
776791 />
777792 < TextInput
778793 label = { strings . focalPointOrganizationInputLabel }
@@ -781,6 +796,7 @@ export function Component() {
781796 onChange = { setFieldValue }
782797 error = { error ?. partner_focal_point_organization }
783798 disabled = { disabled }
799+ readOnly = { readOnly }
784800 />
785801 </ InputSection >
786802 < InputSection
@@ -795,6 +811,7 @@ export function Component() {
795811 onChange = { setFieldValue }
796812 error = { error ?. facilitator_name }
797813 disabled = { disabled }
814+ readOnly = { readOnly }
798815 />
799816 < TextInput
800817 label = { strings . focalPointEmailInputLabel }
@@ -803,6 +820,7 @@ export function Component() {
803820 onChange = { setFieldValue }
804821 error = { error ?. facilitator_email }
805822 disabled = { disabled }
823+ readOnly = { readOnly }
806824 />
807825 < TextInput
808826 label = { strings . focalPointPhoneNumberInputLabel }
@@ -811,6 +829,7 @@ export function Component() {
811829 onChange = { setFieldValue }
812830 error = { error ?. facilitator_phone }
813831 disabled = { disabled }
832+ readOnly = { readOnly }
814833 />
815834 < TextInput
816835 label = { strings . otherContactMethodInputLabel }
@@ -819,6 +838,7 @@ export function Component() {
819838 onChange = { setFieldValue }
820839 error = { error ?. facilitator_contact }
821840 disabled = { disabled }
841+ readOnly = { readOnly }
822842 />
823843 </ InputSection >
824844 </ Container >
0 commit comments