diff --git a/module/ai/control.php b/module/ai/control.php index 467e443a98..80dcf86119 100644 --- a/module/ai/control.php +++ b/module/ai/control.php @@ -170,10 +170,11 @@ class ai extends control return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->inlink('promptAssignRole', "promptID=$promptID") . '#app=admin')); } - $this->view->prompt = $prompt; - $this->view->promptID = $promptID; - $this->view->title = $this->lang->ai->prompts->assignRole . " {$this->lang->colon} " . $this->lang->ai->prompts->common; - $this->view->position[] = $this->lang->ai->prompts->common; + $this->view->prompt = $prompt; + $this->view->promptID = $promptID; + $this->view->lastActiveStep = $this->ai->getLastActiveStep($prompt); + $this->view->title = $this->lang->ai->prompts->assignRole . " {$this->lang->colon} " . $this->lang->ai->prompts->common; + $this->view->position[] = $this->lang->ai->prompts->common; $this->display(); } @@ -214,6 +215,7 @@ class ai extends control $this->view->dataSource = $this->config->ai->dataSource; $this->view->prompt = $prompt; $this->view->promptID = $promptID; + $this->view->lastActiveStep = $this->ai->getLastActiveStep($prompt); $this->view->title = $this->lang->ai->prompts->selectDataSource . " {$this->lang->colon} " . $this->lang->ai->prompts->common; $this->view->position[] = $this->lang->ai->prompts->common; $this->display(); @@ -251,11 +253,12 @@ class ai extends control return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->inlink('promptSetPurpose', "promptID=$promptID") . '#app=admin')); } - $this->view->dataPreview = $this->ai->generateDemoDataPrompt($prompt->module, $prompt->source); - $this->view->prompt = $prompt; - $this->view->promptID = $promptID; - $this->view->title = $this->lang->ai->prompts->setPurpose . " {$this->lang->colon} " . $this->lang->ai->prompts->common; - $this->view->position[] = $this->lang->ai->prompts->common; + $this->view->dataPreview = $this->ai->generateDemoDataPrompt($prompt->module, $prompt->source); + $this->view->prompt = $prompt; + $this->view->promptID = $promptID; + $this->view->lastActiveStep = $this->ai->getLastActiveStep($prompt); + $this->view->title = $this->lang->ai->prompts->setPurpose . " {$this->lang->colon} " . $this->lang->ai->prompts->common; + $this->view->position[] = $this->lang->ai->prompts->common; $this->display(); } @@ -297,11 +300,12 @@ class ai extends control return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->inlink('promptSetTargetForm', "promptID=$promptID") . '#app=admin')); } - $this->view->dataPreview = $this->ai->generateDemoDataPrompt($prompt->module, $prompt->source); - $this->view->prompt = $prompt; - $this->view->promptID = $promptID; - $this->view->title = $this->lang->ai->prompts->setTargetForm . " {$this->lang->colon} " . $this->lang->ai->prompts->common; - $this->view->position[] = $this->lang->ai->prompts->common; + $this->view->dataPreview = $this->ai->generateDemoDataPrompt($prompt->module, $prompt->source); + $this->view->prompt = $prompt; + $this->view->promptID = $promptID; + $this->view->lastActiveStep = $this->ai->getLastActiveStep($prompt); + $this->view->title = $this->lang->ai->prompts->setTargetForm . " {$this->lang->colon} " . $this->lang->ai->prompts->common; + $this->view->position[] = $this->lang->ai->prompts->common; $this->display(); } @@ -337,10 +341,11 @@ class ai extends control return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->inlink('promptFinalize', "promptID=$promptID") . '#app=admin')); } - $this->view->prompt = $prompt; - $this->view->promptID = $promptID; - $this->view->title = $this->lang->ai->prompts->finalize . " {$this->lang->colon} " . $this->lang->ai->prompts->common; - $this->view->position[] = $this->lang->ai->prompts->common; + $this->view->prompt = $prompt; + $this->view->promptID = $promptID; + $this->view->lastActiveStep = $this->ai->getLastActiveStep($prompt); + $this->view->title = $this->lang->ai->prompts->finalize . " {$this->lang->colon} " . $this->lang->ai->prompts->common; + $this->view->position[] = $this->lang->ai->prompts->common; $this->display(); } } diff --git a/module/ai/model.php b/module/ai/model.php index e023dcbb3c..bd26eb00f4 100644 --- a/module/ai/model.php +++ b/module/ai/model.php @@ -745,4 +745,26 @@ class aiModel extends model return false; } + + /** + * Get the last active step of prompt by id. + * + * @param object $prompt + * @access public + * @return string + */ + public function getLastActiveStep($prompt) + { + if(empty($prompt)) return 'assignrole'; + + if($prompt->status == 'active') return 'finalize'; + + if(!empty($prompt->targetForm)) return 'settargetform'; + + if(!empty($prompt->purpose)) return 'setpurpose'; + + if(!empty($prompt->source)) return 'selectdatasource'; + + return 'assignrole'; + } } diff --git a/module/ai/view/promptdesignprogressbar.html.php b/module/ai/view/promptdesignprogressbar.html.php index 49cb0ba7b5..fe5d863f56 100644 --- a/module/ai/view/promptdesignprogressbar.html.php +++ b/module/ai/view/promptdesignprogressbar.html.php @@ -17,6 +17,7 @@ $stepSequence = array('assignrole', 'selectdatasource', 'setpurpose', 'settargetform', 'finalize'); $currentStepIndex = array_search($step, $stepSequence); + $lastActiveStepIndex = array_search($lastActiveStep, $stepSequence); $stepstatus = array(); @@ -26,11 +27,7 @@ { $stepstatus[$stepName] = 'active'; } - elseif($index == $currentStepIndex) - { - $stepstatus[$stepName] = 'current'; - } - elseif($index == $currentStepIndex + 1) + elseif($index > $currentStepIndex && $index <= $lastActiveStepIndex + 1) { $stepstatus[$stepName] = 'clickable'; } @@ -38,6 +35,11 @@ { $stepstatus[$stepName] = 'disabled'; } + + if($index == $currentStepIndex) + { + $stepstatus[$stepName] = 'current'; + } } foreach($lang->ai->designStepNav as $stepKey => $stepLang)