|
| 1 | +-- ============================================================================ |
| 2 | +-- Button Confirmation Examples - Confirmation / ConfirmProceed / ConfirmCancel |
| 3 | +-- ============================================================================ |
| 4 | +-- |
| 5 | +-- A button that calls a microflow or nanoflow can ask "are you sure?" first. |
| 6 | +-- Mendix stores the dialog on the ACTION (Forms$ConfirmationInfo: Question, |
| 7 | +-- ProceedButtonCaption, CancelButtonCaption), so only those two action kinds |
| 8 | +-- take it; anything else is refused as MDL-WIDGET32. |
| 9 | +-- |
| 10 | +-- The captions default to Proceed / Cancel. DESCRIBE PAGE omits a caption |
| 11 | +-- equal to its default, so describe -> exec -> describe is stable. |
| 12 | +-- |
| 13 | +-- Run: mxcli exec mdl-examples/doctype-tests/button-confirmation.mdl -p app.mpr |
| 14 | +-- ============================================================================ |
| 15 | + |
| 16 | +create module ConfirmTest; |
| 17 | + |
| 18 | +create microflow ConfirmTest.ACT_Purge () |
| 19 | +begin |
| 20 | + log info 'purge'; |
| 21 | +end; |
| 22 | +/ |
| 23 | + |
| 24 | +create nanoflow ConfirmTest.NAV_Reset () |
| 25 | +begin |
| 26 | + log info 'reset'; |
| 27 | +end; |
| 28 | +/ |
| 29 | + |
| 30 | +-- ---------------------------------------------------------------------------- |
| 31 | +-- CREATE PAGE: default captions, custom captions, nanoflow action, link button |
| 32 | +-- ---------------------------------------------------------------------------- |
| 33 | + |
| 34 | +create or replace page ConfirmTest.Maintenance ( |
| 35 | + Title: 'Maintenance', |
| 36 | + Layout: Atlas_Core.Atlas_Default |
| 37 | +) { |
| 38 | + container cMain { |
| 39 | + actionbutton btnPurge (Caption: 'Purge', Action: microflow ConfirmTest.ACT_Purge, |
| 40 | + Confirmation: 'Delete all archived orders?', ButtonStyle: Danger) |
| 41 | + actionbutton btnPurgeCustom (Caption: 'Purge (custom)', Action: microflow ConfirmTest.ACT_Purge, |
| 42 | + Confirmation: 'Really purge?', ConfirmProceed: 'Purge', ConfirmCancel: 'Keep') |
| 43 | + actionbutton btnReset (Caption: 'Reset', Action: nanoflow ConfirmTest.NAV_Reset, |
| 44 | + Confirmation: 'Reset the filters?') |
| 45 | + linkbutton lnkPurge (Caption: 'Purge', Action: microflow ConfirmTest.ACT_Purge, |
| 46 | + Confirmation: 'Delete all archived orders?', ConfirmProceed: 'Yes') |
| 47 | + actionbutton btnPlain (Caption: 'No dialog', Action: microflow ConfirmTest.ACT_Purge) |
| 48 | + } |
| 49 | +} |
| 50 | + |
| 51 | +describe page ConfirmTest.Maintenance; |
| 52 | + |
| 53 | +-- ---------------------------------------------------------------------------- |
| 54 | +-- ALTER PAGE: add, edit, remove |
| 55 | +-- ---------------------------------------------------------------------------- |
| 56 | + |
| 57 | +alter page ConfirmTest.Maintenance { |
| 58 | + -- add a dialog to a button that had none |
| 59 | + set (Confirmation = 'Run it now?', ConfirmCancel = 'Not now') on btnPlain; |
| 60 | + -- edit one caption; the question and the other caption are kept |
| 61 | + set ConfirmProceed = 'Go' on btnPurgeCustom; |
| 62 | + -- remove the dialog |
| 63 | + set Confirmation = '' on btnReset; |
| 64 | +}; |
| 65 | + |
| 66 | +describe page ConfirmTest.Maintenance; |
| 67 | + |
| 68 | +-- ---------------------------------------------------------------------------- |
| 69 | +-- Refused (MDL-WIDGET32) — uncomment to see the errors: |
| 70 | +-- |
| 71 | +-- actionbutton b1 (Caption: 'Save', Action: save_changes, Confirmation: 'Sure?') |
| 72 | +-- -- the dialog lives on a microflow/nanoflow action; save has no slot |
| 73 | +-- actionbutton b2 (Caption: 'Go', Action: microflow ConfirmTest.ACT_Purge, ConfirmProceed: 'Yes') |
| 74 | +-- -- a caption without a question |
| 75 | +-- ---------------------------------------------------------------------------- |
0 commit comments