* refactor prompt audit toolbar inject method.
This commit is contained in:
@@ -194,3 +194,15 @@ $config->ai->menuPrint->locations['doc']['view'] = (object)array(
|
||||
'injectMethod' => 'prepend',
|
||||
'targetContainer' => '#mainMenu>.btn-toolbar.pull-right',
|
||||
);
|
||||
|
||||
$config->ai->injectAuditButton = new stdclass();
|
||||
$config->ai->injectAuditButton->locations = array();
|
||||
$config->ai->injectAuditButton->locations['task']['edit']['toolbar'] = (object)array(
|
||||
'targetContainer' => '#mainContent .main-header',
|
||||
'injectMethod' => 'append',
|
||||
'class' => 'pull-right btn-toolbar',
|
||||
);
|
||||
$config->ai->injectAuditButton->locations['task']['edit']['action'] = (object)array(
|
||||
'targetContainer' => '#mainContent .form-actions',
|
||||
'injectMethod' => 'html',
|
||||
);
|
||||
|
||||
@@ -778,6 +778,7 @@ $lang->ai->audit = new stdclass();
|
||||
$lang->ai->audit->designPrompt = 'Prompt Design';
|
||||
$lang->ai->audit->afterSave = 'After saving,';
|
||||
$lang->ai->audit->regenerate = 'Regenerate';
|
||||
$lang->ai->audit->exit = 'Exit Audit';
|
||||
|
||||
$lang->ai->audit->backLocationList = array();
|
||||
$lang->ai->audit->backLocationList[0] = 'back to audit page.';
|
||||
|
||||
@@ -777,6 +777,7 @@ $lang->ai->audit = new stdclass();
|
||||
$lang->ai->audit->designPrompt = '提词设计';
|
||||
$lang->ai->audit->afterSave = '保存后';
|
||||
$lang->ai->audit->regenerate = '重新生成';
|
||||
$lang->ai->audit->exit = '退出调试';
|
||||
|
||||
$lang->ai->audit->backLocationList = array();
|
||||
$lang->ai->audit->backLocationList[0] = '返回调试页面';
|
||||
|
||||
@@ -97,30 +97,75 @@
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function()
|
||||
/* Set injected in oreder to cancel loading class on object view (see promptmenu.html.php). */
|
||||
sessionStorage.setItem('ai-prompt-data-injected', true);
|
||||
try
|
||||
{
|
||||
/* Set injected in oreder to cancel loading class on object view (see promptmenu.html.php). */
|
||||
sessionStorage.setItem('ai-prompt-data-injected', true);
|
||||
try
|
||||
{
|
||||
const data = JSON.parse(injectData);
|
||||
if(!data) return;
|
||||
const data = JSON.parse(injectData);
|
||||
if(!data) return;
|
||||
|
||||
inject(data);
|
||||
inject(data);
|
||||
|
||||
$.zui.messager.success('<?php echo $lang->ai->dataInject->success;?>');
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
$.zui.messager.danger('<?php echo $lang->ai->dataInject->fail;?>');
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
$.zui.messager.success('<?php echo $lang->ai->dataInject->success;?>');
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
$.zui.messager.danger('<?php echo $lang->ai->dataInject->fail;?>');
|
||||
console.error(e);
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
<?php endif;?>
|
||||
<?php
|
||||
$prompt = $_SESSION['aiPrompt']['prompt'];
|
||||
$objectId = $_SESSION['aiPrompt']['objectId'];
|
||||
$isAudit = isset($_SESSION['auditPrompt']) && time() - $_SESSION['auditPrompt']['time'] < 10 * 60;
|
||||
?>
|
||||
<script>
|
||||
$(function() {
|
||||
(function() {
|
||||
const isAudit = <?php echo $isAudit ? 'true' : 'false';?>;
|
||||
|
||||
<?php if(isset($config->ai->injectAuditButton->locations[$module][$method])) :?>
|
||||
function injectAuditAction()
|
||||
{
|
||||
<?php
|
||||
$htmlStr = html::commonButton($lang->ai->prompts->action->publish, "id='promptPublish' data-promptId=$prompt->id", 'btn btn-primary btn-wide');
|
||||
$htmlStr = $htmlStr . html::commonButton($lang->ai->audit->exit, "id='promptAuditExit'", 'btn btn-wide');
|
||||
$targetContainer = $config->ai->injectAuditButton->locations[$module][$method]['action']->targetContainer;
|
||||
$injectMethod = $config->ai->injectAuditButton->locations[$module][$method]['action']->injectMethod;
|
||||
?>
|
||||
const htmlStr = `<?php echo $htmlStr;?>`;
|
||||
$('<?php echo $targetContainer;?>')['<?php echo $injectMethod;?>'](htmlStr);
|
||||
}
|
||||
|
||||
function injectAuditToolbar()
|
||||
{
|
||||
<?php
|
||||
$htmlStr = html::a(helper::createLink('ai', 'promptexecute', "promptId=$prompt->id&objectId=$objectId"), '<i class="icon icon-refresh muted"></i> ' . $lang->ai->audit->regenerate, '', 'id="promptRegenerate" class="btn btn-link"');
|
||||
if($isAudit)
|
||||
{
|
||||
$htmlStr = $htmlStr . html::a(helper::createLink('ai', 'promptaudit', "promptId=$prompt->id&objectId=$objectId"), $lang->ai->audit->designPrompt, '', 'id="promptAudit" class="btn btn-info iframe"');
|
||||
}
|
||||
$targetContainer = $config->ai->injectAuditButton->locations[$module][$method]['toolbar']->targetContainer;
|
||||
$injectMethod = $config->ai->injectAuditButton->locations[$module][$method]['toolbar']->injectMethod;
|
||||
if(!empty($config->ai->injectAuditButton->locations[$module][$method]['toolbar']->class)) $htmlStr = '<div class="' . $config->ai->injectAuditButton->locations[$module][$method]['toolbar']->class . '">' . $htmlStr . '</div>';
|
||||
?>
|
||||
const targetContainer = `<?php echo $targetContainer;?>`;
|
||||
const injectMethod = `<?php echo $injectMethod;?>`;
|
||||
const htmlStr = `<?php echo $htmlStr;?>`;
|
||||
$(targetContainer)[injectMethod](htmlStr);
|
||||
}
|
||||
|
||||
if(isAudit)
|
||||
{
|
||||
injectAuditAction();
|
||||
}
|
||||
if(typeof injectData !== 'undefined')
|
||||
{
|
||||
injectAuditToolbar();
|
||||
}
|
||||
<?php endif;?>
|
||||
|
||||
const publishButton = document.getElementById('promptPublish');
|
||||
if(publishButton)
|
||||
{
|
||||
@@ -149,6 +194,6 @@
|
||||
$('body').addClass('load-indicator loading');
|
||||
});
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<?php endif;?>
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
<?php include '../../common/view/datepicker.html.php';?>
|
||||
<?php include '../../common/view/kindeditor.html.php';?>
|
||||
<?php include '../../common/view/sortable.html.php';?>
|
||||
<?php include '../../ai/view/inputinject.html.php';?>
|
||||
<?php js::set('oldStoryID', $task->story);?>
|
||||
<?php js::set('oldAssignedTo', $task->assignedTo);?>
|
||||
<?php js::set('oldExecutionID', $task->execution);?>
|
||||
@@ -45,20 +44,6 @@ foreach(explode(',', $config->task->edit->requiredFields) as $field)
|
||||
<?php echo html::a($this->createLink('task', 'view', "taskID=$task->id"), $task->name, '', "class='task-name'");?>
|
||||
<small><?php echo $lang->arrow . $lang->task->edit;?></small>
|
||||
</h2>
|
||||
<?php if(isset($_SESSION['aiInjectData'])): ?>
|
||||
<?php
|
||||
$this->app->loadLang('ai');
|
||||
$prompt = $_SESSION['aiPrompt']['prompt'];
|
||||
$objectId = $_SESSION['aiPrompt']['objectId'];
|
||||
$isAudit = isset($_SESSION['auditPrompt']) && time() - $_SESSION['auditPrompt']['time'] < 10 * 60;
|
||||
?>
|
||||
<div class="pull-right btn-toolbar">
|
||||
<?php echo html::a(helper::createLink('ai', 'promptexecute', "promptId=$prompt->id&objectId=$objectId"), '<i class="icon icon-refresh muted"></i> ' . $lang->ai->audit->regenerate, '', 'id="promptRegenerate" class="btn btn-link"');?>
|
||||
<?php if($isAudit): ?>
|
||||
<?php echo html::a(helper::createLink('ai', 'promptaudit', "promptId=$prompt->id&objectId=$objectId"), $lang->ai->audit->designPrompt, '', 'id="promptAudit" class="btn btn-info iframe"'); ?>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
<div class='main-row'>
|
||||
<div class='main-col col-8'>
|
||||
@@ -99,14 +84,10 @@ foreach(explode(',', $config->task->edit->requiredFields) as $field)
|
||||
</div>
|
||||
</div>
|
||||
<div class='detail text-center form-actions'>
|
||||
<?php if($isAudit && $prompt->status == 'draft'): ?>
|
||||
<?php echo html::commonButton($lang->ai->prompts->action->publish, "id='promptPublish' data-promptId=$prompt->id" ,'btn btn-primary btn-wide');?>
|
||||
<?php else:?>
|
||||
<?php echo html::hidden('lastEditedDate', $task->lastEditedDate);?>
|
||||
<?php echo html::hidden('consumed', $task->consumed);?>
|
||||
<?php echo html::submitButton();?>
|
||||
<?php echo html::backButton();?>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
<?php include '../../common/view/action.html.php';?>
|
||||
</div>
|
||||
@@ -326,4 +307,5 @@ foreach(explode(',', $config->task->edit->requiredFields) as $field)
|
||||
</form>
|
||||
</div>
|
||||
<?php js::set('executionID', $execution->id);?>
|
||||
<?php include '../../ai/view/inputinject.html.php';?>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
Reference in New Issue
Block a user