Kitto.Rules.Wizard
Wizard rule support for KittoX. Provides a base class for wizard-specific business rules (step navigation, execute, cancel callbacks). Rules are associated to wizard views in a Rules subnode and are registered/invoked by name, like model rules.
Usage in YAML: Controller: Wizard Rules: MyWizardRules:
Usage in Delphi: type TMyWizardRules = class(TKXWizardRuleImpl) public procedure BeforeNextStep(const ARecord: TKRecord; const ACurrentStep: Integer; var AAllow: Boolean); override; procedure BeforeExecute(const ARecord: TKRecord); override; procedure AfterExecute(const ARecord: TKRecord); override; end;
initialization TKXWizardRuleRegistry.Instance.RegisterClass('MyWizardRules', TMyWizardRules); finalization TKXWizardRuleRegistry.Instance.UnregisterClass('MyWizardRules');
EKWizardRuleError class
Raised when a wizard rule cannot be created or applied (e.g. rule id not registered).
TKXWizardRuleImpl class
Base class for wizard rule implementations. Override the virtual methods you need. All methods have empty defaults.
property Config: TEFNode read FConfig write FConfig;The rule's configuration node from YAML (children of the rule name node).
procedure BeforeNextStep(const ARecord: TKRecord;Called before moving to the next step. Set AAllow := False to prevent the navigation. Raise an exception to show an error message. ACurrentStep is 0-based.
procedure AfterNextStep(const ARecord: TKRecord;Called after successfully moving to the next step. ANewStep is the step just navigated to (0-based).
procedure BeforePrevStep(const ARecord: TKRecord;Called before moving back to the previous step. Set AAllow := False to prevent navigation. ACurrentStep is 0-based.
procedure AfterPrevStep(const ARecord: TKRecord;Called after successfully moving to the previous step. ANewStep is the step just navigated to (0-based).
procedure BeforeExecute(const ARecord: TKRecord);Called before executing the wizard finish (saving the record). Raise an exception to prevent the save and show an error. The record contains the values from all steps.
procedure AfterExecute(const ARecord: TKRecord);Called after the record has been successfully saved to the database. Can perform additional operations (e.g. send notifications, create related records). Raise an exception to rollback the transaction.
procedure BeforeCancel(var AAllow: Boolean);Called before cancelling the wizard. Set AAllow := False to prevent cancellation (e.g. show "are you sure?" confirmation).
procedure AfterCancel;Called after the wizard has been cancelled. Can perform cleanup.
TKXWizardRuleRegistry class
Registry for wizard rule implementation classes. Register your classes in initialization sections.
constructor Create;Creates the registry and its internal class dictionary.
destructor Destroy;Frees the registry's internal class dictionary.
class destructor ClassDestroy;Frees the singleton registry instance.
procedure RegisterClass(const AId: string;Registers a wizard-rule implementation class under the given id.
procedure UnregisterClass(const AId: string);Removes the wizard-rule implementation class registered under the given id.
function HasClass(const AId: string): Boolean;Returns True if a wizard-rule class is registered under the given id.
function CreateObject(const AId: string): TKXWizardRuleImpl;Creates an instance of the wizard-rule class registered under the given id.
