+ prompt delete.
This commit is contained in:
@@ -209,6 +209,21 @@ class ai extends control
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a prompt.
|
||||
*
|
||||
* @param int $prompt
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function promptDelete($prompt)
|
||||
{
|
||||
$result = $this->ai->deletePrompt($prompt);
|
||||
|
||||
if(dao::isError() || $result === false) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
return $this->send(array('result' => 'success'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit role of prompt, prompt editing step 2.
|
||||
*
|
||||
|
||||
+29
-7
@@ -374,7 +374,7 @@ class aiModel extends model
|
||||
public function getPrompts($module = '', $status = '', $order = 'id_desc', $pager = null)
|
||||
{
|
||||
$prompts = $this->dao->select('*')->from(TABLE_PROMPT)
|
||||
->where('1=1')
|
||||
->where('deleted')->eq(0)
|
||||
->beginIF(!empty($module))->andWhere('module')->eq($module)->fi()
|
||||
->beginIF(!empty($status))->andWhere('status')->eq($status)->fi()
|
||||
->orderBy($order)
|
||||
@@ -484,6 +484,29 @@ class aiModel extends model
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a prompt.
|
||||
*
|
||||
* @param int $id
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function deletePrompt($id)
|
||||
{
|
||||
$prompt = $this->getPromptById($id);
|
||||
if(empty($prompt)) return false;
|
||||
|
||||
$this->dao->update(TABLE_PROMPT)
|
||||
->set('deleted')->eq(1)
|
||||
->where('id')->eq($id)
|
||||
->exec();
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$this->loadModel('action')->create('prompt', $id, 'deleted');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle prompt status.
|
||||
*
|
||||
@@ -688,10 +711,8 @@ class aiModel extends model
|
||||
break;
|
||||
case 'release':
|
||||
if(isset($sourceGroups['release'])) $object->release = $this->loadModel('release')->getById($objectId);
|
||||
$stories = array_filter(explode(',', $object->release->stories));
|
||||
if(isset($sourceGroups['stories'])) $object->stories = $this->loadModel('story')->getByList($stories);
|
||||
$bugs = array_filter(explode(',', $object->release->bugs));
|
||||
if(isset($sourceGroups['bugs'])) $object->bugs = $this->loadModel('bug')->getByList($bugs);
|
||||
if(isset($sourceGroups['stories'])) $object->stories = $this->loadModel('story')->getByList(array_filter(explode(',', $object->release->stories)));
|
||||
if(isset($sourceGroups['bugs'])) $object->bugs = $this->loadModel('bug')->getByList(array_filter(explode(',', $object->release->bugs)));
|
||||
break;
|
||||
case 'productplan':
|
||||
if(isset($sourceGroups['productplan'])) $object->productplan = $this->loadModel('productplan')->getByID($objectId);
|
||||
@@ -702,7 +723,7 @@ class aiModel extends model
|
||||
if(isset($sourceGroups['task'])) $object->task = $this->loadModel('task')->getById($objectId);
|
||||
break;
|
||||
case 'case':
|
||||
if(isset($sourceGroups['case'])) $object->case = $this->loadModel('testcase')->getById($objectId);
|
||||
if(isset($sourceGroups['case'])) $object->case = $this->loadModel('testcase')->getById($objectId);
|
||||
if(isset($sourceGroups['steps'])) $object->steps = $object->case->steps;
|
||||
break;
|
||||
case 'bug':
|
||||
@@ -1015,7 +1036,8 @@ class aiModel extends model
|
||||
public function getPromptsForUser($module)
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_PROMPT)
|
||||
->where('module')->eq($module)
|
||||
->where('deleted')->eq(0)
|
||||
->andWhere('module')->eq($module)
|
||||
->andWhere('status', true)->eq('active')->orWhere('createdBy')->eq($this->app->user->account)->markRight(1)
|
||||
->orderBy('id_desc')
|
||||
->fetchAll();
|
||||
|
||||
@@ -64,14 +64,16 @@
|
||||
<div class='main-actions'>
|
||||
<div class="btn-toolbar">
|
||||
<?php echo html::a(helper::createLink('ai', 'prompts'), '<i class="icon icon-back icon-sm"></i> ' . $lang->goback, '', "class='btn'");?>
|
||||
<div class='divider'></div>
|
||||
<?php if($prompt->status == 'draft') echo html::a(helper::createLink('ai', 'promptassignrole', "prompt=$prompt->id"), '<i class="icon icon-design icon-sm"></i> ' . $lang->ai->prompts->action->design, '', "class='btn'");?>
|
||||
<?php if($prompt->status == 'draft' && $this->ai->isExecutable($prompt)) echo html::a($this->ai->getTestingLocation($prompt), '<i class="icon icon-bug icon-sm"></i> ' . $lang->ai->prompts->action->test, '', "class='btn'");?>
|
||||
<?php if($prompt->status == 'draft' && $this->ai->isExecutable($prompt)) echo html::a(helper::createLink('ai', 'promptpublish', "id={$prompt->id}"), '<i class="icon icon-publish icon-sm"></i> ' . $lang->ai->prompts->action->publish, '', "class='btn'");?>
|
||||
<?php if($prompt->status == 'active') echo html::a(helper::createLink('ai', 'promptunpublish', "id={$prompt->id}"), '<i class="icon icon-ban icon-sm"></i> ' . $lang->ai->prompts->action->unpublish, '', "class='btn' id='unpublish-btn'");?>
|
||||
<div class='divider'></div>
|
||||
<?php echo html::a(helper::createLink('ai', 'promptedit', "prompt=$prompt->id"), '<i class="icon icon-edit icon-sm"></i>', '', "class='btn' title='{$lang->ai->prompts->action->edit}'");?>
|
||||
<?php echo html::a(helper::createLink('ai', 'promptdelete'), '<i class="icon icon-trash icon-sm"></i>', '', "class='btn deleter' title='{$lang->ai->prompts->action->delete}'");?>
|
||||
<?php if(!$prompt->deleted):?>
|
||||
<div class='divider'></div>
|
||||
<?php if($prompt->status == 'draft') echo html::a(helper::createLink('ai', 'promptassignrole', "prompt=$prompt->id"), '<i class="icon icon-design icon-sm"></i> ' . $lang->ai->prompts->action->design, '', "class='btn'");?>
|
||||
<?php if($prompt->status == 'draft' && $this->ai->isExecutable($prompt)) echo html::a($this->ai->getTestingLocation($prompt), '<i class="icon icon-bug icon-sm"></i> ' . $lang->ai->prompts->action->test, '', "class='btn'");?>
|
||||
<?php if($prompt->status == 'draft' && $this->ai->isExecutable($prompt)) echo html::a(helper::createLink('ai', 'promptpublish', "id={$prompt->id}"), '<i class="icon icon-publish icon-sm"></i> ' . $lang->ai->prompts->action->publish, '', "class='btn'");?>
|
||||
<?php if($prompt->status == 'active') echo html::a(helper::createLink('ai', 'promptunpublish', "id={$prompt->id}"), '<i class="icon icon-ban icon-sm"></i> ' . $lang->ai->prompts->action->unpublish, '', "class='btn' id='unpublish-btn'");?>
|
||||
<div class='divider'></div>
|
||||
<?php echo html::a(helper::createLink('ai', 'promptedit', "prompt=$prompt->id"), '<i class="icon icon-edit icon-sm"></i>', '', "class='btn' title='{$lang->ai->prompts->action->edit}'");?>
|
||||
<?php echo html::a(helper::createLink('ai', 'promptdelete', "prompt=$prompt->id"), '<i class="icon icon-trash icon-sm"></i>', '', "class='btn deleter' title='{$lang->ai->prompts->action->delete}'");?>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user