* add save action for prompt audit page.
This commit is contained in:
+25
-1
@@ -428,8 +428,32 @@ class ai extends control
|
||||
*/
|
||||
public function promptAudit($promptId, $objectId)
|
||||
{
|
||||
$prompt = $this->ai->getPromptByID($promptId);
|
||||
$prompt = $this->ai->getPromptByID($promptId);
|
||||
|
||||
if($_POST)
|
||||
{
|
||||
$data = fixer::input('post')->get();
|
||||
|
||||
$prompt->role = $data->role;
|
||||
$prompt->characterization = $data->characterization;
|
||||
$prompt->purpose = $data->purpose;
|
||||
$prompt->elaboration = $data->elaboration;
|
||||
|
||||
$this->ai->updatePrompt($prompt);
|
||||
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
if($data->backLocation == 1)
|
||||
{
|
||||
$response = array('result' => 'success', 'message' => $this->lang->saveSuccess, 'callback' => "reloadPrompt($promptId, $objectId)");
|
||||
}
|
||||
else
|
||||
{
|
||||
$response = array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true);
|
||||
}
|
||||
|
||||
$this->sendSuccess($response);
|
||||
}
|
||||
list($objectData, $object) = $this->ai->getObjectForPromptById($prompt, $objectId);
|
||||
|
||||
$this->view->prompt = $prompt;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
<?php include '../../common/view/header.lite.html.php'; ?>
|
||||
<div id='mainContent' class='main-content'>
|
||||
<form method="post" class="main-form form-ajax" target="hiddenwin">
|
||||
<form method="post" class="main-form form-ajax">
|
||||
<div class='center-block'>
|
||||
<div class="main-header">
|
||||
<p>
|
||||
@@ -120,5 +120,15 @@
|
||||
submitButton.disabled = !purpose.value;
|
||||
});
|
||||
})();
|
||||
|
||||
function reloadPrompt(promptId, objectId) {
|
||||
let link = createLink('ai', 'promptexecute', 'promptId=' + promptId + '&objectId=' + objectId);
|
||||
link = link.replace('onlybody=yes', '');
|
||||
const aTag = document.createElement('a');
|
||||
aTag.href = link;
|
||||
aTag.style.display = 'none';
|
||||
parent.document.body.appendChild(aTag);
|
||||
aTag.click();
|
||||
}
|
||||
</script>
|
||||
<?php include '../../common/view/footer.lite.html.php'; ?>
|
||||
|
||||
Reference in New Issue
Block a user