Beispiel #1
0
        private async Task <IActionResult> HandlePhysicalViewNode(GraphNode <Key, FormNode> viewNode,
                                                                  bool returnToSummary = false,
                                                                  IDictionary <string, Answer> inFlightAnswers = null,
                                                                  IDictionary <string, string> inFlightErrors  = null)
        {
            var viewData = await _physicalNodeHandlerStrategy.Handle(GetFormTypeFromFormId(), GetFormId(), viewNode);

            viewData.CurrentNodeId = viewNode.Key.Value;
            ViewData[FormConstants.TempDataErrors]          = inFlightErrors;
            ViewData[FormConstants.TempDataAnswers]         = inFlightAnswers;
            ViewData[FormConstants.TempDataReturnToSummary] = returnToSummary;
            ViewData[FormConstants.BackButtonProps]         = new BackButtonProps(viewNode.Key.Value, viewData.ShowBackButton);
            ViewData[FormConstants.ViewDataFormTitle]       = _staticFormProvider.GetFormName(GetFormTypeFromFormId());

            return(viewData switch
            {
                TaskListResponse taskListResponse => View("TaskList", taskListResponse),
                TaskPageResponse taskQuestionResponse => View("TaskQuestionPage", taskQuestionResponse),
                TaskSummaryResponse taskSummaryResponse => View("TaskSummary", taskSummaryResponse),
                RepeatTaskResponse repeatTaskResponse => View("RepeatTask", repeatTaskResponse),
                ConsentPageResponse consentPageResponse => View("ConsentPage", consentPageResponse),
                PreTaskResponse preTaskResponse => View("PreTask", preTaskResponse),
                RepeatSubTaskResponse repeatSubTaskResponse => View("RepeatSubTask", repeatSubTaskResponse),
                _ => throw new NotImplementedException()
            });
Beispiel #2
0
        public IActionResult Index(string form)
        {
            if (!Enum.TryParse(form, true, out FormType formType))
            {
                return(View("QuestionnaireNotRecognised"));
            }

            AddCookie(FormConstants.RequestedFormCookieName, form);

            var startPage = _staticFormProvider.GetStartPage(formType);

            ViewData[FormConstants.ViewDataFormTitle] = _staticFormProvider.GetFormName(formType);

            return(View(startPage));
        }
Beispiel #3
0
        public Task <PhysicalResponse> Handle(FormType formType, string formKey, GraphNode <Key, FormNode> node)
        {
            node.AssertType <TaskListFormNode>();

            var taskRouters = node.Neighbors.Where(GraphNodePredicates.IsTaskRouterNode);

            var tasks = new List <TaskListTask>();

            foreach (var taskRouter in taskRouters)
            {
                var taskNode = taskRouter.AssertType <TaskRouterFormNode>();

                var staticTask = _staticFormProvider.GetTask(formType, StaticKey.ForTaskNode(taskNode.TaskId));

                var taskListTask = new TaskListTask
                {
                    Name = staticTask.Name,
                    TaskRouterNodeKey = taskRouter.Key.Value,
                    TaskId            = staticTask.Id,
                    GroupNameIndex    = staticTask.GroupNameIndex,
                    IsComplete        = IsTaskComplete(taskRouter),
                };

                tasks.Add(taskListTask);
            }

            var isTaskCompleteList = tasks.Select(x => (x.TaskId, x.IsComplete)).ToList();

            foreach (var task in tasks)
            {
                var staticTask = _staticFormProvider.GetTask(formType, StaticKey.ForTaskNode(task.TaskId));
                task.IsHidden = staticTask.HiddenWhen?.Invoke(isTaskCompleteList) ?? false;
            }

            return(Task.FromResult(new TaskListResponse
            {
                FormName = _staticFormProvider.GetFormName(formType),
                Tasks = tasks,
                TaskGroupNames = _staticFormProvider.GetTaskGroups(formType)
            } as PhysicalResponse));
        }