From 5c24b6f81e0dae0ac8d5f782ac0ce39faae29d79 Mon Sep 17 00:00:00 2001 From: Dillon Date: Sun, 1 Oct 2023 00:32:40 +0800 Subject: [PATCH 1/5] Relocate help menu and make dynamic questionnaire set generation --- .../FetchFirstQuestionQAProcessor.php | 2 +- .../FetchNextQuestionQAProcessor.php | 9 ++- .../general/elements/HelpMenuComponent.vue | 68 +++++++++++++++++++ .../general/forms/HelpMenuFormComponent.vue | 18 ++--- .../sections/OrderProfileSectionComponent.vue | 2 +- .../OrderProfileV2SectionComponent.vue | 2 +- resources/views/layouts/base_portal.blade.php | 1 + resources/views/partials/helpmenu.blade.php | 1 + routes/help_menu.php | 2 +- 9 files changed, 84 insertions(+), 21 deletions(-) create mode 100644 resources/assets/vue/components/general/elements/HelpMenuComponent.vue create mode 100644 resources/views/partials/helpmenu.blade.php diff --git a/app/Classes/Modules/HelpMenu/Processors/FetchFirstQuestionQAProcessor.php b/app/Classes/Modules/HelpMenu/Processors/FetchFirstQuestionQAProcessor.php index 9f463418..c4f81f27 100644 --- a/app/Classes/Modules/HelpMenu/Processors/FetchFirstQuestionQAProcessor.php +++ b/app/Classes/Modules/HelpMenu/Processors/FetchFirstQuestionQAProcessor.php @@ -23,7 +23,7 @@ class FetchFirstQuestionQAProcessor public function execute(Request $request){ try { - $query = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => 1]); + $query = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => $request->route('set_id')]); return $query; } catch (\Exception $exception){ throw new ErrorException($exception->getMessage(), $exception->getCode()); diff --git a/app/Classes/Modules/HelpMenu/Processors/FetchNextQuestionQAProcessor.php b/app/Classes/Modules/HelpMenu/Processors/FetchNextQuestionQAProcessor.php index d9fc9a0a..39188cf5 100644 --- a/app/Classes/Modules/HelpMenu/Processors/FetchNextQuestionQAProcessor.php +++ b/app/Classes/Modules/HelpMenu/Processors/FetchNextQuestionQAProcessor.php @@ -38,6 +38,7 @@ class FetchNextQuestionQAProcessor $nextQuestionNumber = 0; $nextNestedQuestion = 0; $nextMainQuestion= 0; + $questionnaireSetId = 0; $currentQuestion = $request->question; $questionType = QAType::DEFAULT; $returnQuestion = null; @@ -48,7 +49,9 @@ class FetchNextQuestionQAProcessor $questionType = $currentQuestion['question_type']; $nextNestedQuestion = $currentQuestion['next_nested_question']; $nextMainQuestion = $currentQuestion['next_main_question']; + $questionnaireSetId = $currentQuestion['questionnaire_set_id']; } + if ($request->has('answerObj')) { $nextQuestionNumber = $request->answerObj['next_question_number']; } @@ -58,7 +61,7 @@ class FetchNextQuestionQAProcessor $previousAnswer = $this->listsHelpMenuUserAnswerSelected->execute(['user_id' => $userId, 'order_by' => (object)['column' => 'id','DESC' => true]])[0]; //Get previous question - $previousQuestion = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => 1, 'id' => $previousAnswer['question_id']]); + $previousQuestion = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => $questionnaireSetId, 'id' => $previousAnswer['question_id']]); $returnQuestion = $previousQuestion; } else{ @@ -79,11 +82,11 @@ class FetchNextQuestionQAProcessor $returnQuestion = null; } else if($question_number != 0){ - $nextQuestion = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => 1, 'question_number' => $question_number]); + $nextQuestion = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => $questionnaireSetId, 'question_number' => $question_number]); $returnQuestion = $nextQuestion; } else if (array_key_exists('id', $request->input('question'))) { - $nextQuestion = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => 1, 'id_next' => $questionId, 'next_main_question' => null]); + $nextQuestion = $this->fetchesHelpMenuQuestion->execute(['questionnaire_set_id' => $questionnaireSetId, 'id_next' => $questionId, 'next_main_question' => null]); $returnQuestion = $nextQuestion; } } diff --git a/resources/assets/vue/components/general/elements/HelpMenuComponent.vue b/resources/assets/vue/components/general/elements/HelpMenuComponent.vue new file mode 100644 index 00000000..2f1a6e34 --- /dev/null +++ b/resources/assets/vue/components/general/elements/HelpMenuComponent.vue @@ -0,0 +1,68 @@ + + + + + diff --git a/resources/assets/vue/components/general/forms/HelpMenuFormComponent.vue b/resources/assets/vue/components/general/forms/HelpMenuFormComponent.vue index bef90475..e27851a5 100644 --- a/resources/assets/vue/components/general/forms/HelpMenuFormComponent.vue +++ b/resources/assets/vue/components/general/forms/HelpMenuFormComponent.vue @@ -77,16 +77,6 @@