From 16e24ac37aa15f71dc8bb5ba3b538565162dd114 Mon Sep 17 00:00:00 2001 From: sunjun Date: Wed, 8 Jun 2022 07:08:25 +0000 Subject: [PATCH 1/3] sprint_201_56459 --- module/my/control.php | 26 +++++----- module/my/lang/en.php | 1 + module/my/lang/zh-cn.php | 1 + module/my/model.php | 84 ++++++++++++++++++++++++++++++++ module/my/view/testcase.html.php | 11 ++++- 5 files changed, 111 insertions(+), 12 deletions(-) diff --git a/module/my/control.php b/module/my/control.php index 42e999364f..42b29e1a58 100755 --- a/module/my/control.php +++ b/module/my/control.php @@ -219,11 +219,11 @@ EOF; * @access public * @return void */ - public function contribute($mode = 'task', $type = 'openedBy', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function contribute($mode = 'task', $type = 'openedBy', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1, $param = 0) { if(($mode == 'issue' or $mode == 'risk') and $type == 'openedBy') $type = 'createdBy'; - echo $this->fetch('my', $mode, "type=$type&orderBy=$orderBy&recTotal=$recTotal&recPerPage=$recPerPage&pageID=$pageID"); + echo $this->fetch('my', $mode, "type=$type&orderBy=$orderBy&recTotal=$recTotal&recPerPage=$recPerPage&pageID=$pageID¶m=$param"); } /** @@ -604,7 +604,7 @@ EOF; * @access public * @return void */ - public function testcase($type = 'assigntome', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function testcase($type = 'assigntome', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1, $param = 0) { $this->loadModel('testcase'); $this->loadModel('testtask'); @@ -620,20 +620,24 @@ EOF; /* Append id for secend sort. */ $sort = common::appendOrder($orderBy); + $queryID = ($type == 'bysearch') ? (int)$param : 0; $cases = array(); - if($type == 'assigntome') - { - $cases = $this->testcase->getByAssignedTo($this->app->user->account, $sort, $pager, 'skip'); - } - elseif($type == 'openedbyme') - { - $cases = $this->testcase->getByOpenedBy($this->app->user->account, $sort, $pager, 'skip'); - } + if($type == 'assigntome') $cases = $this->testcase->getByAssignedTo($this->app->user->account, $sort, $pager, 'skip'); + if($type == 'openedbyme') $cases = $this->testcase->getByOpenedBy($this->app->user->account, $sort, $pager, 'skip'); + if($type == 'bysearch' and $this->app->rawMethod == 'contribute') $cases = $this->my->getTestcasesBySearch($queryID, 'openedbyme', $orderBy, $pager); + if($type == 'bysearch' and $this->app->rawMethod == 'work') $cases = $this->my->getTestcasesBySearch($queryID, 'assigntome', $orderBy, $pager); + $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'testcase', $type == 'assigntome' ? false : true); $cases = $this->testcase->appendData($cases, $type == 'assigntome' ? 'run' : 'case'); + /* Build the search form. */ + $method = $this->app->rawMethod; + $actionURL = $this->createLink('my', $method, "mode=testcase&type=bysearch&orderBy={$orderBy}&recTotal={$recTotal}&recPerPage={$recPerPage}&pageID={$pageID}¶m=myQueryID"); + $this->config->testcase->search['onMenuBar'] = 'yes'; + $this->my->buildTestcaseSearchForm($queryID, $actionURL, $method); + /* Assign. */ $this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->myTestCase; $this->view->position[] = $this->lang->my->myTestCase; diff --git a/module/my/lang/en.php b/module/my/lang/en.php index 344033dd8f..5aa236aa2a 100644 --- a/module/my/lang/en.php +++ b/module/my/lang/en.php @@ -43,6 +43,7 @@ $lang->my->testcase = 'My Case'; $lang->my->storyConcept = 'Story Concept'; $lang->my->pri = 'Priority'; $lang->my->alert = 'You can click on your profile at the top right and select "Preference" to modify your information. '; +$lang->my->assignedToMe = 'AssignedToMe'; $lang->my->indexAction = 'My Index'; $lang->my->calendarAction = 'My Calendar'; diff --git a/module/my/lang/zh-cn.php b/module/my/lang/zh-cn.php index a0a4e36334..265f0899b7 100644 --- a/module/my/lang/zh-cn.php +++ b/module/my/lang/zh-cn.php @@ -43,6 +43,7 @@ $lang->my->testcase = '我的用例'; $lang->my->storyConcept = $config->URAndSR ? '默认需求概念组合' : '默认需求概念'; $lang->my->pri = '优先级'; $lang->my->alert = '后续您可以点击右上方的头像,选择“个性化设置”修改信息。'; +$lang->my->assignedToMe = '指派给我'; $lang->my->indexAction = '地盘仪表盘'; $lang->my->calendarAction = '我的日程'; diff --git a/module/my/model.php b/module/my/model.php index 280f51d2c3..e3aaec1027 100644 --- a/module/my/model.php +++ b/module/my/model.php @@ -374,4 +374,88 @@ class myModel extends model } return $objectList; } + + /** + * Build search form. + * + * @param int $queryID + * @param string $actionURL + * @param string $type + * @access public + * @return void + */ + public function buildTestCaseSearchForm($queryID, $actionURL, $type) + { + $products = $this->dao->select('id,name')->from(TABLE_PRODUCT) + ->where('deleted')->eq(0) + ->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->products)->fi() + ->orderBy('order_asc') + ->fetchPairs(); + + $queryName = $type == 'contribute' ? 'contributeTestcase' : 'workTestcase'; + $this->app->loadConfig('testcase'); + $this->config->testcase->search['module'] = $queryName; + $this->config->testcase->search['queryID'] = $queryID; + $this->config->testcase->search['actionURL'] = $actionURL; + $this->config->testcase->search['params']['product']['values'] = $products; + $this->config->testcase->search['params']['lib']['values'] = $this->loadModel('caselib')->getLibraries(); + + unset($this->config->testcase->search['fields']['module']); + + $this->loadModel('search')->setSearchParams($this->config->testcase->search); + } + + /** + * Get testcases by search. + * + * @param int $queryID + * @param string $type + * @param string $orderBy + * @param int $pager + * @access public + * @return array + */ + public function getTestcasesBySearch($queryID, $type, $orderBy, $pager) + { + $queryName = $type == 'contribute' ? 'contributeTestcaseQuery' : 'workTestcaseQuery'; + if($queryID) + { + $query = $this->loadModel('search')->getQuery($queryID); + if($query) + { + $this->session->set($queryName, $query->sql); + $this->session->set($queryName . 'Form', $query->form); + } + else + { + $this->session->set($queryName, ' 1 = 1'); + } + } + else + { + if($this->session->$queryName == false) $this->session->set($queryName, ' 1 = 1'); + } + + $myTestcaseQuery = $this->session->$queryName; + $myTestcaseQuery = preg_replace('/`(\w+)`/', 't1.`$1`', $myTestcaseQuery); + + if($type == 'openedbyme') + { + $cases = $this->dao->select('*')->from(TABLE_CASE)->alias('t1') + ->where($myTestcaseQuery) + ->andWhere('t1.openedBy')->eq($this->app->user->account) + ->andWhere('t1.deleted')->eq(0) + ->orderBy($orderBy)->page($pager)->fetchAll('id'); + } + else + { + $cases = $this->dao->select('t1.*')->from(TABLE_CASE)->alias('t1') + ->leftJoin(TABLE_TESTRUN)->alias('t2')->on('t1.id = t2.case') + ->where($myTestcaseQuery) + ->andWhere('t2.assignedTo')->eq($this->app->user->account) + ->andWhere('t1.deleted')->eq(0) + ->orderBy($orderBy)->page($pager)->fetchAll('id'); + } + return $cases; + } } diff --git a/module/my/view/testcase.html.php b/module/my/view/testcase.html.php index 604a4c0236..e36ad95c8c 100644 --- a/module/my/view/testcase.html.php +++ b/module/my/view/testcase.html.php @@ -19,11 +19,20 @@
{$pager->recTotal}"; - if($app->rawMethod == 'contribute') echo html::a(inlink($app->rawMethod, "mode=$mode&type=openedbyme"), "{$lang->testcase->openedByMe}" . ($type == 'openedbyme' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'openedbyme' ? ' btn-active-text' : '') . "'"); + if($app->rawMethod == 'contribute') + { + echo html::a(inlink($app->rawMethod, "mode=$mode&type=openedbyme"), "{$lang->testcase->openedByMe}" . ($type == 'openedbyme' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'openedbyme' ? ' btn-active-text' : '') . "'"); + } + else + { + echo html::a(inlink($app->rawMethod, "mode=$mode&type=assigntome"), "{$lang->my->assignedToMe}" . ($type == 'assigntome' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'assigntome' ? ' btn-active-text' : '') . "'"); + } ?> + loadModel('search');echo $lang->search->common;?>
+
rawMethod == 'contribute' ? 'contributeTestcase' : 'workTestcase');?>>

testcase->noCase;?>

From 305c6ee54344bff802830ef45fbf21db1f2cab59 Mon Sep 17 00:00:00 2001 From: sunjun Date: Wed, 8 Jun 2022 08:59:25 +0000 Subject: [PATCH 2/3] sprint_201_56459 --- module/my/control.php | 53 +++++++++++++++++++++------------------ module/my/model.php | 2 +- module/testcase/model.php | 2 +- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/module/my/control.php b/module/my/control.php index 42b29e1a58..c27455b3dc 100755 --- a/module/my/control.php +++ b/module/my/control.php @@ -75,18 +75,19 @@ class my extends control /** * My work view. * - * @param string $mode - * @param string $type - * @param string $orderBy - * @param int $recTotal - * @param int $recPerPage - * @param int $pageID + * @param string $mode + * @param string $type + * @param string|int $param + * @param string $orderBy + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID * @access public * @return void */ - public function work($mode = 'task', $type = 'assignedTo', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function work($mode = 'task', $type = 'assignedTo', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { - echo $this->fetch('my', $mode, "type=$type&orderBy=$orderBy&recTotal=$recTotal&recPerPage=$recPerPage&pageID=$pageID"); + echo $this->fetch('my', $mode, "type=$type¶m=$param&orderBy=$orderBy&recTotal=$recTotal&recPerPage=$recPerPage&pageID=$pageID"); $this->showWorkCount($recTotal, $recPerPage, $pageID); } @@ -210,20 +211,21 @@ EOF; /** * My contribute view. * - * @param string $mode - * @param string $type - * @param string $orderBy - * @param int $recTotal - * @param int $recPerPage - * @param int $pageID + * @param string $mode + * @param string $type + * @param string|int $param + * @param string $orderBy + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID * @access public * @return void */ - public function contribute($mode = 'task', $type = 'openedBy', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1, $param = 0) + public function contribute($mode = 'task', $type = 'openedBy', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { if(($mode == 'issue' or $mode == 'risk') and $type == 'openedBy') $type = 'createdBy'; - echo $this->fetch('my', $mode, "type=$type&orderBy=$orderBy&recTotal=$recTotal&recPerPage=$recPerPage&pageID=$pageID¶m=$param"); + echo $this->fetch('my', $mode, "type=$type¶m=$param&orderBy=$orderBy&recTotal=$recTotal&recPerPage=$recPerPage&pageID=$pageID"); } /** @@ -596,15 +598,16 @@ EOF; /** * My test case. * - * @param string $type assigntome|openedbyme - * @param string $orderBy - * @param int $recTotal - * @param int $recPerPage - * @param int $pageID + * @param string $type assigntome|openedbyme + * @param string|int $param + * @param string $orderBy + * @param int $recTotal + * @param int $recPerPage + * @param int $pageID * @access public * @return void */ - public function testcase($type = 'assigntome', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1, $param = 0) + public function testcase($type = 'assigntome', $param = 0, $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { $this->loadModel('testcase'); $this->loadModel('testtask'); @@ -633,10 +636,10 @@ EOF; $cases = $this->testcase->appendData($cases, $type == 'assigntome' ? 'run' : 'case'); /* Build the search form. */ - $method = $this->app->rawMethod; - $actionURL = $this->createLink('my', $method, "mode=testcase&type=bysearch&orderBy={$orderBy}&recTotal={$recTotal}&recPerPage={$recPerPage}&pageID={$pageID}¶m=myQueryID"); + $currentMethod = $this->app->rawMethod; + $actionURL = $this->createLink('my', $currentMethod, "mode=testcase&type=bysearch¶m=myQueryID&orderBy={$orderBy}&recTotal={$recTotal}&recPerPage={$recPerPage}&pageID={$pageID}"); $this->config->testcase->search['onMenuBar'] = 'yes'; - $this->my->buildTestcaseSearchForm($queryID, $actionURL, $method); + $this->my->buildTestcaseSearchForm($queryID, $actionURL, $currentMethod); /* Assign. */ $this->view->title = $this->lang->my->common . $this->lang->colon . $this->lang->my->myTestCase; diff --git a/module/my/model.php b/module/my/model.php index e3aaec1027..b2982a275a 100644 --- a/module/my/model.php +++ b/module/my/model.php @@ -417,7 +417,7 @@ class myModel extends model */ public function getTestcasesBySearch($queryID, $type, $orderBy, $pager) { - $queryName = $type == 'contribute' ? 'contributeTestcaseQuery' : 'workTestcaseQuery'; + $queryName = $type == 'openedbyme' ? 'contributeTestcaseQuery' : 'workTestcaseQuery'; if($queryID) { $query = $this->loadModel('search')->getQuery($queryID); diff --git a/module/testcase/model.php b/module/testcase/model.php index ba07b6894d..bca32dc7d4 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -607,7 +607,7 @@ class testcaseModel extends model */ public function getByAssignedTo($account, $orderBy = 'id_desc', $pager = null, $auto = 'no') { - return $this->dao->select('t1.*,t2.project,t2.pri,t2.title,t2.type,t2.openedBy,t2.color,t2.product,t2.branch,t2.module,t2.status,t3.name as taskName')->from(TABLE_TESTRUN)->alias('t1') + return $this->dao->select('t1.task,t1.case,t1.version,t1.assignedTo,t1.lastRunner,t1.lastRunDate,t1.lastRunResult,t1.status,t2.id as id,t2.project,t2.pri,t2.title,t2.type,t2.openedBy,t2.color,t2.product,t2.branch,t2.module,t2.status,t3.name as taskName')->from(TABLE_TESTRUN)->alias('t1') ->leftJoin(TABLE_CASE)->alias('t2')->on('t1.case = t2.id') ->leftJoin(TABLE_TESTTASK)->alias('t3')->on('t1.task = t3.id') ->where('t1.assignedTo')->eq($account) From 283df0a7b81dea1a0cf520f92f2e5804e152549f Mon Sep 17 00:00:00 2001 From: sunjun Date: Wed, 8 Jun 2022 13:50:36 +0000 Subject: [PATCH 3/3] sprint_201_56459 --- module/my/control.php | 2 +- module/my/model.php | 2 +- module/my/view/testcase.html.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/module/my/control.php b/module/my/control.php index c27455b3dc..16f8d0fcac 100755 --- a/module/my/control.php +++ b/module/my/control.php @@ -637,7 +637,7 @@ EOF; /* Build the search form. */ $currentMethod = $this->app->rawMethod; - $actionURL = $this->createLink('my', $currentMethod, "mode=testcase&type=bysearch¶m=myQueryID&orderBy={$orderBy}&recTotal={$recTotal}&recPerPage={$recPerPage}&pageID={$pageID}"); + $actionURL = $this->createLink('my', $currentMethod, "mode=testcase&type=bysearch¶m=myQueryID&orderBy={$orderBy}&recTotal={$recTotal}&recPerPage={$recPerPage}&pageID={$pageID}"); $this->config->testcase->search['onMenuBar'] = 'yes'; $this->my->buildTestcaseSearchForm($queryID, $actionURL, $currentMethod); diff --git a/module/my/model.php b/module/my/model.php index b2982a275a..efcb0ad662 100644 --- a/module/my/model.php +++ b/module/my/model.php @@ -424,7 +424,7 @@ class myModel extends model if($query) { $this->session->set($queryName, $query->sql); - $this->session->set($queryName . 'Form', $query->form); + $this->session->set($queryName . 'Form', $query->form); } else { diff --git a/module/my/view/testcase.html.php b/module/my/view/testcase.html.php index e36ad95c8c..9401f4bd0b 100644 --- a/module/my/view/testcase.html.php +++ b/module/my/view/testcase.html.php @@ -28,7 +28,7 @@ echo html::a(inlink($app->rawMethod, "mode=$mode&type=assigntome"), "{$lang->my->assignedToMe}" . ($type == 'assigntome' ? $recTotalLabel : ''), '', "class='btn btn-link" . ($type == 'assigntome' ? ' btn-active-text' : '') . "'"); } ?> - loadModel('search');echo $lang->search->common;?> + loadModel('search');echo $lang->search->common;?>