Skip to content

Add validation mode to UiUtil.DialogSaveCancel#6

Open
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1776950014-dialog-save-cancel-validation
Open

Add validation mode to UiUtil.DialogSaveCancel#6
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1776950014-dialog-save-cancel-validation

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Enhances UiUtil.DialogSaveCancel in lib/UiUtil.js with an optional aValidationOption parameter that enables a validation + data-preservation flow, matching the pattern already used by DialogWithDateRange and DialogWithCustomBody.

When aValidationOption is provided, the dialog:

  • Deep-clones jsonObject into cloneObject once (persisted across re-opens on validation failure).
  • Builds the dialog body via createBody(cloneObject) on every open.
  • On Save, reads widgets into cloneObject via UiUtil.PopulateJsonFromDialog BEFORE the swal is destroyed.
  • Runs onValidate(cloneObject, callback). If callback is called with a non-empty fail message, DialogError is shown and DialogSaveCancel is re-invoked recursively with the same aValidationOption (preserving cloneObject).
  • On pass, invokes jsOk(cloneObject) with the validated data.
  • Optionally invokes onFailValidation() before the error dialog.

Without aValidationOption, behavior is identical to the previous implementation (backward compatible).

Review & Testing Checklist for Human

  • Confirm existing call sites of DialogSaveCancel (no aValidationOption) still behave exactly as before — the original DialogTwoButton pass-through path is preserved.
  • Exercise a new call site that supplies aValidationOption with divBodyName, jsonObject, createBody, and onValidate: verify that failed validation re-opens the dialog with user input preserved, and that successful validation invokes jsOk(cloneObject) with the populated data.
  • Verify that onFailValidation (if provided) runs before the DialogError is shown when validation fails.

Notes

  • File uses CRLF line endings; line endings were preserved.
  • node --check lib/UiUtil.js passes syntax check.
  • No other files modified.

Link to Devin session: https://app.devin.ai/sessions/e9806690a79842e9964a7e2baf9c4e93
Requested by: @shujutech

Adds optional aValidationOption parameter to DialogSaveCancel that
enables a validation + data-preservation flow matching the pattern
used by DialogWithDateRange and DialogWithCustomBody.

When aValidationOption is provided, the dialog:
- Deep-clones jsonObject into cloneObject once, preserved across reopens
- Builds the body via createBody(cloneObject) on every open
- On Save, reads widgets into cloneObject via PopulateJsonFromDialog
- Runs onValidate; on fail, shows DialogError and re-opens preserving data
- On pass, invokes jsOk(cloneObject)

Without aValidationOption the behavior is identical to before.

Co-Authored-By: shujutech <shujutech@gmail.com>
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.

0 participants