Add validation mode to UiUtil.DialogSaveCancel#6
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Add validation mode to UiUtil.DialogSaveCancel#6devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enhances
UiUtil.DialogSaveCancelinlib/UiUtil.jswith an optionalaValidationOptionparameter that enables a validation + data-preservation flow, matching the pattern already used byDialogWithDateRangeandDialogWithCustomBody.When
aValidationOptionis provided, the dialog:jsonObjectintocloneObjectonce (persisted across re-opens on validation failure).createBody(cloneObject)on every open.cloneObjectviaUiUtil.PopulateJsonFromDialogBEFORE the swal is destroyed.onValidate(cloneObject, callback). Ifcallbackis called with a non-empty fail message,DialogErroris shown andDialogSaveCancelis re-invoked recursively with the sameaValidationOption(preservingcloneObject).jsOk(cloneObject)with the validated data.onFailValidation()before the error dialog.Without
aValidationOption, behavior is identical to the previous implementation (backward compatible).Review & Testing Checklist for Human
DialogSaveCancel(noaValidationOption) still behave exactly as before — the originalDialogTwoButtonpass-through path is preserved.aValidationOptionwithdivBodyName,jsonObject,createBody, andonValidate: verify that failed validation re-opens the dialog with user input preserved, and that successful validation invokesjsOk(cloneObject)with the populated data.onFailValidation(if provided) runs before theDialogErroris shown when validation fails.Notes
node --check lib/UiUtil.jspasses syntax check.Link to Devin session: https://app.devin.ai/sessions/e9806690a79842e9964a7e2baf9c4e93
Requested by: @shujutech