protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData) { ThrowIfMustFail(contextData, ScreenLifecycleStage.CreatingStepData); var result = new InitialScreenScreenModel(); return(result); }
protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData) { var initData = contextData.GetStepData <FlowInitializer.StartScreenModel>(ScreenName.PreStart); var screenStepData = contextData.GetStepData <InitialScreen.InitialScreenScreenModel>(); return(new ExitReturnToCaller(initData, screenStepData.StringValue)); }
protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData) { return(new StepBScreenScreenModel { //TODO: rest }); }
protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData) { var result = await base.OnCreateModelAsync(contextData); result.SetContainedFlow("GreenFlow"); return(result); }
protected override IScreenFlowConfigurator OnRegisterUserActions( IScreenFlowConfigurator screenConfiguration, IUiFlowContextData contextData) { return(screenConfiguration .OnEventReentriesCurrent(ScreenEvent.ErrorOccurred) .OnEventNavigatesTo(ScreenInputEvent.Submit, ModelTesterFlowStep.FlowCompletedScreen)); }
public async Task <UiFlowScreenModel> RefreshStepDataAsync(IUiFlowContextData contextData, UiFlowScreenModel originalScreenModel, IDictionary <string, object> stepViewCustomizations = null) { TraceBegin(nameof(RefreshStepDataAsync), contextData); var result = originalScreenModel; if (!_stepDataLoaded) { await _syncLock.AsyncCriticalSection(async() => { if (!_stepDataLoaded) { LifecycleStage = ScreenLifecycleStage.RefreshingStepData; _stepDataLoaded = true; var onRefreshStepDataAsync = await OnRefreshModelAsync(contextData, originalScreenModel, stepViewCustomizations); await OnScreenLoadCompletedAsync(contextData); result = onRefreshStepDataAsync; LifecycleStage = ScreenLifecycleStage.RefreshStepDataCompleted; } } ); } TraceEnd(nameof(RefreshStepDataAsync), contextData); return(result); }
protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData) { return(new StepAScreenScreenModel() { ScreenTitle = "Green Flow -Step A" }); }
protected override IScreenFlowConfigurator OnRegisterUserActions( IScreenFlowConfigurator screenConfiguration, IUiFlowContextData contextData) { var prestart = contextData.GetStepData <FlowInitializer.StartScreenModel>(ScreenName.PreStart); return(screenConfiguration.OnEventReentriesCurrent(ScreenEvent.ErrorOccurred) .OnEventNavigatesTo(ScreenInputEvent.Reset, BlueFlowScreenName.Step0Screen) .OnEventNavigatesTo(ScreenInputEvent.FlowTransitionCompleted, BlueFlowScreenName.FlowCompletedScreen, () => !prestart.MustReturnToCaller, "Not Called from another flow expecting result") .OnEventNavigatesTo(ScreenInputEvent.FlowTransitionCompleted, BlueFlowScreenName.EndAndReturnToCaller, () => prestart.MustReturnToCaller, "Called from another flow expecting result") .OnEventNavigatesTo(ScreenInputEvent.Previous, BlueFlowScreenName.FillDataStep_StepBScreen, () => !ByPassedStepAandB(), "Comes from B") .OnEventNavigatesTo(ScreenInputEvent.Previous, BlueFlowScreenName.Step0Screen, ByPassedStepAandB, "Comes from step0") .OnEventExecutes(ScreenInputEvent.Reset, (e, ctx) => ctx.Reset())); bool ByPassedStepAandB() { var stepValue1 = contextData .GetStepData <InitialScreen.InitialScreenScreenModel>(BlueFlowScreenName.Step0Screen).StepValue1; return(stepValue1 != null && stepValue1.StartsWith('a')); } }
protected override Task <UiFlowScreenModel> OnRefreshModelAsync(IUiFlowContextData contextData, UiFlowScreenModel originalScreenModel, IDictionary <string, object> stepViewCustomizations = null) { ThrowIfMustFail(contextData, ScreenLifecycleStage.RefreshingStepData); return(base.OnRefreshModelAsync(contextData, originalScreenModel, stepViewCustomizations)); }
protected override async Task <UiFlowScreenModel> OnRefreshModelAsync(IUiFlowContextData contextData, UiFlowScreenModel originalScreenModel, IDictionary <string, object> stepViewCustomizations = null) { await SetTitle(contextData, (Number2ContainerScreenModel)originalScreenModel); return(originalScreenModel); }
private async Task OnHandlingStepEvent(ScreenEvent triggeredEvent, IUiFlowContextData contextData) { if (_eventHandlers.ContainsKey(triggeredEvent)) { var eventHandler = _eventHandlers[triggeredEvent]; await eventHandler(triggeredEvent, contextData); } }
protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData) { var model = new Number2ContainerScreenModel(); await SetTitle(contextData, model); return(model); }
protected override async Task <UiFlowScreenModel> OnRefreshModelAsync(IUiFlowContextData contextData, UiFlowScreenModel originalScreenModel, IDictionary <string, object> stepViewCustomizations = null) { var result = Map(contextData.GetStepData <InputScreen.ScreenModel>(ModelTesterFlowStep.InputScreen), contextData.GetCurrentStepData <ScreenModel>()); return(result); }
protected override bool OnValidate(ScreenEvent transitionTrigger, IUiFlowContextData contextData, out string errorMessage) { var result = true; errorMessage = null; return(result); }
protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData) { return(new StepData("BlueFlow", new BlueFlow.Steps.FlowInitializer.StartScreenModel { CallbackFlowHandler = contextData.FlowHandler, CallbackFlowEvent = ScreenInputEvent.ToStep2, }, asContained: true)); }
private void ThrowIfMustFail(IUiFlowContextData contextData, ScreenLifecycleStage stage) { var root = contextData.GetStepData <FlowInitializer.StartScreenModel>(); if (root != null && (ScreenName)root.FailOnStep == ScreenNameId && root.FailOnEvent == stage) { throw new Exception($"Failing on {ScreenNameId}.{stage}"); } }
protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData) { return(new StepData("BlueFlow", new BlueFlow.Steps.FlowInitializer.StartScreenModel { GreenFlowData = contextData.GetStepData <InitialScreen.InitialScreenScreenModel>().StepValue1, CallbackFlowHandler = contextData.FlowHandler, CallbackFlowEvent = ScreenInputEvent.BlueFlowCompleted })); }
protected override IScreenFlowConfigurator OnRegisterUserActions( IScreenFlowConfigurator screenConfiguration, IUiFlowContextData contextData) { return(screenConfiguration .OnEventNavigatesTo(ScreenInputEvent.BlueFlowCompleted, GreenFlowScreenName.FlowCompletedScreen) .OnEventExecutes(ScreenInputEvent.BlueFlowCompleted, (e, ctx) => ctx.GetCurrentStepData <StepData>().BlueFlowCompletedEventHandled = true)); }
protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData) { var a = contextData.GetStepData <Number1ContainerScreen.StepData>(ContainersFlow3ScreenName.Number1ContainerScreen); return(new ScreenModel() { BlueFlowSelectedInput = a.CalledFlowResult, Step1Loaded = a.InitialLoad }); }
protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData) { return(new StepCScreenScreenModel { FlowInputData = contextData.GetStepData <FlowInitializer.StartScreenModel>(ScreenName.PreStart).SampleParameter, InitialValue = contextData.GetStepData <InitialScreen.InitialScreenScreenModel>(GreenFlowScreenName.Step0Screen).StepValue1, StepAValue = contextData.GetStepData <StepAScreen.StepAScreenScreenModel>(GreenFlowScreenName.StepAScreen)?.StepAValue1, StepBValue = contextData.GetStepData <StepBScreen.StepBScreenScreenModel>(GreenFlowScreenName.StepBScreen)?.StepBValue1, }); }
protected override IScreenFlowConfigurator OnRegisterUserActions( IScreenFlowConfigurator screenConfiguration, IUiFlowContextData contextData) { return(screenConfiguration.OnEventReentriesCurrent(ScreenEvent.ErrorOccurred) .OnEventNavigatesTo(ScreenInputEvent.Reset, GreenFlowScreenName.Step0Screen) .OnEventNavigatesTo(ScreenInputEvent.Next, GreenFlowScreenName.StepCScreen) .OnEventNavigatesTo(ScreenInputEvent.Previous, GreenFlowScreenName.StepAScreen) .OnEventExecutes(ScreenInputEvent.Reset, (e, ctx) => ctx.Reset()) .OnEventExecutes(ScreenInputEvent.Previous, (e, ctx) => ctx.GetCurrentStepData <StepBScreenScreenModel>().StepBValue1 = null)); }
protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData) { var result = new ErrorScreenModel(); result.Error = contextData.LastError.ExceptionMessage; result.OnStep = contextData.LastError.OccurredOnStep; result.OnLifecycleEvent = contextData.LastError.LifecycleStage.ToString(); //error handled contextData.LastError = null; return(result); }
public bool ValidateTransitionAttempt(ScreenEvent triggeredEvent, IUiFlowContextData contextData, out string errorMessage) { TraceBegin(nameof(HandleStepEvent), contextData, triggeredEvent); LifecycleStage = ScreenLifecycleStage.ValidatingTransition; var isValid = OnValidate(triggeredEvent, contextData, out errorMessage); LifecycleStage = isValid ? ScreenLifecycleStage.ValidateTransitionCompleted : ScreenLifecycleStage.ValidateTransitionCompletedWithErrors; TraceEnd(nameof(HandleStepEvent), contextData, triggeredEvent); return(isValid); }
public async Task <UiFlowScreenModel> CreateStepDataAsync(IUiFlowContextData contextData) { TraceBegin(nameof(CreateStepDataAsync), contextData); LifecycleStage = ScreenLifecycleStage.CreatingStepData; var result = await OnCreateModelAsync(contextData); _stepDataLoaded = true; await OnScreenLoadCompletedAsync(contextData); LifecycleStage = ScreenLifecycleStage.CreateStepDataCompleted; TraceEnd(nameof(CreateStepDataAsync), contextData); return(result); }
public IScreenFlowConfigurator DefineActionHandlersOnCurrentScreen(IScreenFlowConfigurator screenConfiguration, IUiFlowContextData contextData) { TraceBegin(nameof(DefineActionHandlersOnCurrentScreen), contextData); LifecycleStage = ScreenLifecycleStage.DefiningTransitionsFromCurrentScreen; var cfg = OnRegisterUserActions(screenConfiguration, contextData); var internalScreenFlowConfigurator = ((IInternalScreenFlowConfigurator)cfg); internalScreenFlowConfigurator.AddErrorTransitionIfUndefined(); this.Transitions = internalScreenFlowConfigurator.Transitions; this._eventHandlers = internalScreenFlowConfigurator.Handlers; LifecycleStage = ScreenLifecycleStage.DefineTransitionsFromCurrentScreenCompleted; TraceEnd(nameof(DefineActionHandlersOnCurrentScreen), contextData); return(cfg); }
protected override bool OnValidate(ScreenEvent transitionTrigger, IUiFlowContextData contextData, out string errorMessage) { var result = true; errorMessage = null; if (transitionTrigger == ScreenInputEvent.Next) { var viewModel = contextData.GetCurrentStepData <InitialScreenScreenModel>(); var b = int.TryParse(viewModel.StepValue1, out var value); errorMessage = b ? "Numeric only value are not allowed" : string.Empty; result = !b; } return(result); }
public async Task HandleStepEvent(ScreenEvent triggeredEvent, IUiFlowContextData contextData) { TraceBegin(nameof(HandleStepEvent), contextData, triggeredEvent); LifecycleStage = ScreenLifecycleStage.HandlingEvent; //TDO: inline next await OnHandlingStepEvent(triggeredEvent, contextData); var uiFlowStepData = contextData.GetCurrentStepData <UiFlowScreenModel>(); if (uiFlowStepData != null) { uiFlowStepData.Errors = new List <UiFlowUserInputError>(); } LifecycleStage = ScreenLifecycleStage.HandleEventCompleted; TraceEnd(nameof(HandleStepEvent), contextData, triggeredEvent); }
protected override async Task <UiFlowScreenModel> OnCreateModelAsync(IUiFlowContextData contextData) { var stepData = new FlowCompletedScreenScreenModel { }; var runBlueFlowStep = contextData.GetStepData <RunBlueFlowScreen.StepData>(GreenFlowScreenName.RunBlueFlow); if (contextData.CurrentEvents.Any(x => x == RunBlueFlowScreen.ScreenInputEvent.BlueFlowCompleted) || contextData.EventsLog.Any(x => x.Event == RunBlueFlowScreen.ScreenInputEvent.BlueFlowCompleted)) { stepData.BlueFlowInitialScreenValue = runBlueFlowStep.CalledFlowResult; } stepData.BlueFlowEventHandled = runBlueFlowStep != null && runBlueFlowStep.BlueFlowCompletedEventHandled; return(stepData); }
protected override async Task <UiFlowScreenModel> OnRefreshModelAsync(IUiFlowContextData contextData, UiFlowScreenModel originalScreenModel, IDictionary <string, object> stepViewCustomizations = null) { var result = (StepCScreenScreenModel)originalScreenModel; result.FlowInputData = contextData.GetStepData <FlowInitializer.StartScreenModel>(ScreenName.PreStart).SampleParameter; result.InitialValue = contextData .GetStepData <InitialScreen.InitialScreenScreenModel>(GreenFlowScreenName.Step0Screen).StepValue1; result.StepAValue = contextData .GetStepData <StepAScreen.StepAScreenScreenModel>(GreenFlowScreenName.StepAScreen) ?.StepAValue1; result.StepBValue = contextData .GetStepData <StepBScreen.StepBScreenScreenModel>(GreenFlowScreenName.StepBScreen) ?.StepBValue1; return(result); }
protected override bool OnValidate(ScreenEvent transitionTrigger, IUiFlowContextData contextData, out string errorMessage) { var result = true; errorMessage = null; if (transitionTrigger == ScreenInputEvent.Next) { var viewModel = contextData.GetCurrentStepData <StepBScreenScreenModel>(); result = !string.IsNullOrEmpty(viewModel.StepBValue1); if (!result) { errorMessage = "Value cannot be empty"; } } return(result); }