Skip to content

feat: implement SAVE_AS_DRAFT and TraderSavedAsDraft state#189

Open
ginaxu1 wants to merge 1 commit intoOpenNSW:mainfrom
ginaxu1:102-save-draft
Open

feat: implement SAVE_AS_DRAFT and TraderSavedAsDraft state#189
ginaxu1 wants to merge 1 commit intoOpenNSW:mainfrom
ginaxu1:102-save-draft

Conversation

@ginaxu1
Copy link
Contributor

@ginaxu1 ginaxu1 commented Feb 26, 2026

Screen.Recording.2026-02-25.at.22.57.30.mov

Summary

Add "Save as Draft" functionality for tasks by establishing the SAVE_AS_DRAFT Task command structure spanning both the React frontend and the backend workflow engine

Changes

Frontend

  • add a "Save as Draft" button alongside the submit button in SimpleForm.tsx
  • refactor form submission logic into a shared sendCommand helper to eliminate code duplication between handleSubmit and handleSaveAsDraft
  • standardize the API action and local frontend Task Command to SAVE_AS_DRAFT across task.ts + preConsignment.ts

Backend

  • rename the internal action in simple_form.go from DRAFT_FORM to SAVE_AS_DRAFT to map with the frontend command
  • add new test swuite TestSimpleForm_Execute_SaveAsDraft in simple_form_test.go to cover draft execution paths including success, WriteToLocalStore failures, and invalid transition handling.
  • handle out of sync testing environments: sync core test SQL mocks in consignment_service_test.go + workflow_node_service_test.go to properly account for new schema fields (outcome, unlock_configuration, end_node_id) introduced from the main branch

Related Issues

Closes #102

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ginaxu1, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new "Save as Draft" feature for the simple form plugin, allowing users to save their progress on a form without immediate submission. This enhancement improves the user experience by preventing data loss and enabling partial completion of forms. The changes involve updates to both the backend, where a key action constant was renamed and new tests were added, and the frontend, where the UI and logic for saving drafts were implemented.

Highlights

  • Backend Constant Renaming: Renamed the backend constant SimpleFormActionDraft from "DRAFT_FORM" to "SAVE_AS_DRAFT" for improved clarity and consistency.
  • New Unit Tests for Draft Functionality: Introduced comprehensive unit tests for the SimpleForm plugin's "Save as Draft" functionality, covering successful draft saving, error handling during local store writes, and scenarios with invalid state transitions.
  • Frontend 'Save as Draft' Implementation: Implemented a new handleSaveAsDraft function in the frontend TraderForm component, enabling users to save their current form data as a draft and providing appropriate navigation upon success or error feedback.
  • UI Integration of 'Save as Draft': Added a dedicated "Save as Draft" button to the TraderForm user interface, allowing users to easily trigger the new draft saving functionality.
  • Frontend Type Definition Update: Updated the TaskAction type definition in the frontend task.ts service to reflect the new SAVE_AS_DRAFT action, ensuring type safety and consistency across the application.
Changelog
  • backend/internal/task/plugin/simple_form.go
    • Renamed the SimpleFormActionDraft constant from "DRAFT_FORM" to "SAVE_AS_DRAFT".
  • backend/internal/task/plugin/simple_form_test.go
    • Added a new test file for the simple_form plugin.
    • Implemented MockAPI for testing plugin interactions.
    • Included test cases for TestSimpleForm_Execute_SaveAsDraft covering successful draft saving, failure during local store write, and invalid state transitions.
  • portals/apps/trader-app/src/plugins/SimpleForm.tsx
    • Adjusted destructuring of useParams for consistency.
    • Implemented handleSaveAsDraft asynchronous function to send a 'DRAFT' command to the backend, handle success/failure, and navigate the user.
    • Added a "Save as Draft" button to the form's action area, linked to handleSaveAsDraft.
    • Made minor formatting adjustments to SVG path attributes in SubmissionResponseForm and OgaReviewForm.
    • Made minor formatting adjustments to component rendering in SimpleForm default export.
  • portals/apps/trader-app/src/services/task.ts
    • Updated the TaskAction type definition to change 'DRAFT' to 'SAVE_AS_DRAFT'.
    • Modified the sendTaskCommand function to use 'SAVE_AS_DRAFT' when the command is 'DRAFT'.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

gemini-code-assist[bot]

This comment was marked as resolved.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements the 'Save as Draft' functionality for simple forms. The changes span across the backend, frontend, and service layer to introduce the new SAVE_AS_DRAFT action and TraderSavedAsDraft state. New tests have been added for the backend plugin logic, which is great.

My review includes a couple of suggestions to improve maintainability and clarity:

  • In SimpleForm.tsx, I've suggested refactoring to reduce code duplication between handleSubmit and the new handleSaveAsDraft function.
  • In task.ts, I've pointed out a naming inconsistency between the UI-level TaskCommand ('DRAFT') and the API-level TaskAction ('SAVE_AS_DRAFT') and suggested aligning them for better readability.

Overall, this is a solid implementation of the new feature.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for this change in the save as draft PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Task Manager] SimpleForm Logics not fully implemented

3 participants