Skip to content

Reporting/LFO: Display warning when user deselects activity with filled form #4773

Description

@zoeyli-46

Describe the task

If a user tries to deselect an activity from the review facility information page or the review operation information page, and that activity form is not empty, show a warning

Acceptance Criteria

Given I am on the Review Operation Information page,
If I deselect an activity AND this activity in any of my facility reports is NOT empty,

  • Then I see a warning
    Wireframe
  • Given I click cancel, it keeps the activity selected
  • Given I click "remove activity" it will deselect the activity

Dev checklist

  • Update getReviewOperationInformationPageData api to include activities_with_data
activities_with_data = list(
      ReportActivity.objects.filter(
          facility_report__report_version_id=version_id
      ).values_list('activity_id', flat=True).distinct()
  )
  • Add prop: activitiesWithData: number[] to OperationReviewForm
  • Update onChangeHandler to Detect deselected activities
  • Check if any deselected activity has data
    - If has data: show modal, don't update state
    - If no data: update state normally
  • Reuse SimpleModal component (already imported) for Warning
<SimpleModal
   title="Confirmation"
   open={pendingDeselectionActivity !== undefined}
   onCancel={cancelActivityDeselection}
   onConfirm={confirmActivityDeselection}
   confirmText="Remove Activity"
 >
   Are you sure you want to remove this activity? If you proceed, all of the form data you have entered will be lost.
 </SimpleModal>

Definition of Done

  • first
  • second
  • third

Additional context

  • Add any other context about the task here.
  • Or here

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions