diff --git a/module/ai/control.php b/module/ai/control.php index 193df678b8..b496de10ae 100644 --- a/module/ai/control.php +++ b/module/ai/control.php @@ -428,7 +428,8 @@ class ai extends control */ public function promptAudit($promptId, $objectId) { - $prompt = $this->ai->getPromptByID($promptId); + $prompt = $this->ai->getPromptByID($promptId); + list($objectData, $object) = $this->ai->getObjectForPromptById($prompt, $objectId); $this->view->prompt = $prompt; @@ -437,4 +438,34 @@ class ai extends control $this->display(); } + + /** + * Publish prompt, set status to active. + * + * @param int $id + * @access public + * @return void + */ + public function promptPublish($id) + { + $this->ai->togglePromptStatus($id, 'active'); + + if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); + return $this->send(array('result' => 'success')); + } + + /** + * Unpublish prompt, set status to draft. + * + * @param int $id + * @access public + * @return void + */ + public function promptUnpublish($id) + { + $this->ai->togglePromptStatus($id, 'draft'); + + if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); + return $this->send(array('result' => 'success')); + } } diff --git a/module/ai/lang/de.php b/module/ai/lang/de.php index 6ed1e60250..a47dda6452 100644 --- a/module/ai/lang/de.php +++ b/module/ai/lang/de.php @@ -49,6 +49,8 @@ $lang->ai->prompts->action->test = 'Test'; $lang->ai->prompts->action->edit = 'Edit'; $lang->ai->prompts->action->publish = 'Publish'; $lang->ai->prompts->action->unpublish = 'Unpublish'; +$lang->ai->prompts->action->delete = 'Delete'; +$lang->ai->prompts->action->deleteConfirm = 'Are you sure to delete this prompt?'; /* Steps of prompt creation. */ $lang->ai->prompts->assignRole = 'Assign Role'; diff --git a/module/ai/lang/en.php b/module/ai/lang/en.php index 1d216f4768..88334d2378 100644 --- a/module/ai/lang/en.php +++ b/module/ai/lang/en.php @@ -49,6 +49,8 @@ $lang->ai->prompts->action->test = 'Test'; $lang->ai->prompts->action->edit = 'Edit'; $lang->ai->prompts->action->publish = 'Publish'; $lang->ai->prompts->action->unpublish = 'Unpublish'; +$lang->ai->prompts->action->delete = 'Delete'; +$lang->ai->prompts->action->deleteConfirm = 'Are you sure to delete this prompt?'; /* Steps of prompt creation. */ $lang->ai->prompts->assignRole = 'Assign Role'; diff --git a/module/ai/lang/fr.php b/module/ai/lang/fr.php index e611f05f79..c97b3c61fc 100644 --- a/module/ai/lang/fr.php +++ b/module/ai/lang/fr.php @@ -49,6 +49,8 @@ $lang->ai->prompts->action->test = 'Test'; $lang->ai->prompts->action->edit = 'Edit'; $lang->ai->prompts->action->publish = 'Publish'; $lang->ai->prompts->action->unpublish = 'Unpublish'; +$lang->ai->prompts->action->delete = 'Delete'; +$lang->ai->prompts->action->deleteConfirm = 'Are you sure to delete this prompt?'; /* Steps of prompt creation. */ $lang->ai->prompts->assignRole = 'Assign Role'; diff --git a/module/ai/lang/zh-cn.php b/module/ai/lang/zh-cn.php index f849ab9845..5cca48c82a 100644 --- a/module/ai/lang/zh-cn.php +++ b/module/ai/lang/zh-cn.php @@ -49,6 +49,8 @@ $lang->ai->prompts->action->test = '调试'; $lang->ai->prompts->action->edit = '编辑'; $lang->ai->prompts->action->publish = '发布'; $lang->ai->prompts->action->unpublish = '下架'; +$lang->ai->prompts->action->delete = '删除'; +$lang->ai->prompts->action->deleteConfirm = '您确定要执行删除操作吗?'; /* Steps of prompt creation. */ $lang->ai->prompts->assignRole = '指定角色'; diff --git a/module/ai/view/prompts.html.php b/module/ai/view/prompts.html.php index 60864783c7..91f7b665c0 100644 --- a/module/ai/view/prompts.html.php +++ b/module/ai/view/prompts.html.php @@ -30,7 +30,7 @@ $html .= html::a($executable ? $this->ai->getTestingLocation($prompt) : '#', '', '', "class='btn" . ($executable && !$published ? '' : ' disabled') . "' title='{$lang->ai->prompts->action->test}'" . ($executable ? '' : " data-toggle='modal' data-target='#designConfirmModal'")); /* Edit button. */ - $html .= html::a(helper::createLink('ai', '', "prompt=$prompt->id"), '', '', "class='btn' title='{$lang->ai->prompts->action->edit}'"); + $html .= html::a(helper::createLink('ai', 'promptedit', "prompt=$prompt->id"), '', '', "class='btn' title='{$lang->ai->prompts->action->edit}'"); /* Divider. */ $html .= '
'; diff --git a/module/ai/view/promptview.html.php b/module/ai/view/promptview.html.php index 8f4ead8d52..197f720eef 100644 --- a/module/ai/view/promptview.html.php +++ b/module/ai/view/promptview.html.php @@ -26,4 +26,43 @@ +
+
+
+
+ ' . $lang->goback, '', "class='btn'");?> +
+ status == 'draft') echo html::a(helper::createLink('ai', 'promptassignrole', "prompt=$prompt->id"), ' ' . $lang->ai->prompts->action->design, '', "class='btn'");?> + status == 'draft' && $this->ai->isExecutable($prompt)) echo html::a($this->ai->getTestingLocation($prompt), ' ' . $lang->ai->prompts->action->test, '', "class='btn'");?> + status == 'draft' && $this->ai->isExecutable($prompt)) echo html::a(helper::createLink('ai', 'promptpublish', "id={$prompt->id}"), ' ' . $lang->ai->prompts->action->publish, '', "class='btn'");?> + status == 'active') echo html::a(helper::createLink('ai', 'promptunpublish', "id={$prompt->id}"), ' ' . $lang->ai->prompts->action->unpublish, '', "class='btn'");?> +
+ id"), '', '', "class='btn' title='{$lang->ai->prompts->action->edit}'");?> + ', '', "class='btn deleter' title='{$lang->ai->prompts->action->delete}'");?> +
+
+
+
+ +
+
+ + +