* [perf] refactor: enhance task search form building functionality
- Add productID parameter to buildTaskSearchForm method to support better filtering - Introduce module parameter to handle different search contexts (task, programplanTask, projectTask) - Refactor search configuration to be more modular and context-aware - Remove hardcoded search module configurations and pass them as parameters - Simplify search form initialization across execution, programplan, and project modules - Improve code reusability by centralizing search configuration logic - Add conditional field filtering based on execution type and search context
This commit is contained in:
@@ -197,9 +197,7 @@ class execution extends control
|
||||
/* Build the search form. */
|
||||
$modules = $this->loadModel('tree')->getTaskOptionMenu($executionID, 0, $showModule);
|
||||
$actionURL = $this->createLink('execution', 'task', "executionID=$executionID&status=bySearch¶m=myQueryID&orderBy=$orderBy&recTotal=0&recPerPage=100&pageID=1&from=$from&blockID=$blockID");
|
||||
$this->config->execution->search['onMenuBar'] = 'yes';
|
||||
if(!$execution->multiple) unset($this->config->execution->search['fields']['execution']);
|
||||
$this->execution->buildTaskSearchForm($executionID, $this->executions, $queryID, $actionURL);
|
||||
$this->execution->buildTaskSearchForm($executionID, $productID, $this->executions, $queryID, $actionURL);
|
||||
|
||||
$this->view->title = $execution->name . $this->lang->hyphen . $this->lang->execution->task;
|
||||
$this->view->tasks = $tasks;
|
||||
|
||||
+41
-14
@@ -4169,6 +4169,7 @@ class executionModel extends model
|
||||
* Build task search form.
|
||||
*
|
||||
* @param int $executionID
|
||||
* @param int $productID
|
||||
* @param array $executions
|
||||
* @param int $queryID
|
||||
* @param string $actionURL
|
||||
@@ -4176,12 +4177,16 @@ class executionModel extends model
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function buildTaskSearchForm(int $executionID, array $executions, int $queryID, string $actionURL, bool $cacheSearchParams = true)
|
||||
public function buildTaskSearchForm(int $executionID, int $productID, array $executions, int $queryID, string $actionURL, string $module = 'task', bool $cacheSearchParams = true)
|
||||
{
|
||||
$module = $this->config->execution->search['module'];
|
||||
if($cacheSearchParams) return $this->cacheSearchParams($module, __METHOD__, func_get_args());
|
||||
|
||||
$showAll = empty($executionID) && empty($executions) ? true : false;
|
||||
$searchConfig = $this->config->execution->search;
|
||||
$searchConfig['module'] = $module;
|
||||
$searchConfig['actionURL'] = $actionURL;
|
||||
$searchConfig['queryID'] = $queryID;
|
||||
|
||||
$showAll = empty($executionID) && empty($executions);
|
||||
if($showAll)
|
||||
{
|
||||
$executions = $this->getPairs(0, 'all', "nocode,noprefix,multiple");
|
||||
@@ -4189,27 +4194,49 @@ class executionModel extends model
|
||||
}
|
||||
$execution = $this->getByID($executionID);
|
||||
|
||||
$this->config->execution->search['actionURL'] = $actionURL;
|
||||
$this->config->execution->search['queryID'] = $queryID;
|
||||
$this->config->execution->search['params']['story']['values'] = $this->loadModel('story')->getExecutionStoryPairs($executionID, 0, 'all', '', 'full', 'unclosed', 'story', false);
|
||||
$searchConfig['params']['story']['values'] = $this->loadModel('story')->getExecutionStoryPairs($executionID, 0, 'all', '', 'full', 'unclosed', 'story', false);
|
||||
|
||||
if($module == 'task')
|
||||
{
|
||||
$searchConfig['onMenuBar'] = 'yes';
|
||||
if(!$execution->multiple) unset($searchConfig['fields']['execution']);
|
||||
}
|
||||
elseif($module == 'programplanTask')
|
||||
{
|
||||
unset($searchConfig['fields']['project']);
|
||||
$executions = $this->loadModel('programplan')->getPairs($projectID, $productID, 'all');
|
||||
}
|
||||
elseif($module == 'projectTask')
|
||||
{
|
||||
unset($searchConfig['fields']['project']);
|
||||
unset($searchConfig['fields']['module']);
|
||||
}
|
||||
|
||||
if(isset($execution->type) && $execution->type == 'project')
|
||||
{
|
||||
unset($this->config->execution->search['fields']['project']);
|
||||
$this->config->execution->search['params']['execution']['values'] = array('' => '') + $executions;
|
||||
unset($searchConfig['fields']['project']);
|
||||
if(isset($searchConfig['fields']['execution'])) $searchConfig['params']['execution']['values'] = array('' => '') + $executions;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->config->execution->search['params']['execution']['values'] = $showAll ? $executions : array(''=>'', $executionID => zget($executions, $executionID, ''), 'all' => $this->lang->execution->allExecutions);
|
||||
if(isset($searchConfig['fields']['execution'])) $searchConfig['params']['execution']['values'] = $showAll ? $executions : array(''=>'', $executionID => zget($executions, $executionID, ''), 'all' => $this->lang->execution->allExecutions);
|
||||
}
|
||||
|
||||
$projects = $this->loadModel('project')->getPairsByProgram();
|
||||
$this->config->execution->search['params']['project']['values'] = $projects + array('all' => $this->lang->project->allProjects);
|
||||
if(isset($searchConfig['fields']['project']))
|
||||
{
|
||||
$projects = $this->loadModel('project')->getPairsByProgram();
|
||||
$searchConfig['params']['project']['values'] = $projects + array('all' => $this->lang->project->allProjects);
|
||||
}
|
||||
|
||||
$showAllModule = isset($this->config->execution->task->allModule) ? $this->config->execution->task->allModule : '';
|
||||
$this->config->execution->search['params']['module']['values'] = $this->loadModel('tree')->getTaskOptionMenu($executionID, 0, $showAllModule ? 'allModule' : '');
|
||||
if(isset($searchConfig['fields']['module']))
|
||||
{
|
||||
$showAllModule = $this->config->execution->task->allModule ?? '';
|
||||
$searchConfig['params']['module']['values'] = $this->loadModel('tree')->getTaskOptionMenu($executionID, 0, $showAllModule ? 'allModule' : '');
|
||||
}
|
||||
|
||||
$this->loadModel('search')->setSearchParams($this->config->execution->search);
|
||||
$this->loadModel('search')->setSearchParams($searchConfig);
|
||||
|
||||
return $searchConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -441,12 +441,8 @@ class programplanZen extends programplan
|
||||
if($hasSearch)
|
||||
{
|
||||
/* Build the search form. */
|
||||
$this->config->execution->search['module'] = 'projectTask';
|
||||
|
||||
$actionURL = $this->createLink('programplan', 'browse', "projectID=$projectID&productID=$productID&type=$type&orderBy=$orderBy&baselineID=$baselineID&browseType=bysearch&queryID=myQueryID");
|
||||
unset($this->config->execution->search['fields']['project']);
|
||||
$executions = $this->programplan->getPairs($projectID, $productID, 'all');
|
||||
$this->loadModel('execution')->buildTaskSearchForm($projectID, $executions, $queryID, $actionURL);
|
||||
$this->loadModel('execution')->buildTaskSearchForm($projectID, $productID, $executions, $queryID, $actionURL, 'programplanTask');
|
||||
}
|
||||
|
||||
$this->view->title = $this->lang->programplan->browse;
|
||||
|
||||
@@ -870,15 +870,10 @@ class project extends control
|
||||
if($this->cookie->showTask)
|
||||
{
|
||||
/* Build the search form. */
|
||||
$this->config->execution->search['module'] = 'projectTask';
|
||||
|
||||
$actionURL = $this->createLink('project', 'execution', "status=bysearch&projectID=$projectID&orderBy=$orderBy&productID=$productID&recTotal=$recTotal&recPerPage=$recPerPage&pageID=$pageID&queryID=myQueryID");
|
||||
unset($this->config->execution->search['fields']['project']);
|
||||
unset($this->config->execution->search['fields']['module']);
|
||||
$actionURL = $this->createLink('project', 'execution', "status=bysearch&projectID=$projectID&orderBy=$orderBy&productID=$productID&recTotal=$recTotal&recPerPage=$recPerPage&pageID=$pageID&queryID=myQueryID");
|
||||
$executions = $this->execution->fetchExecutionList($projectID, 'all', $productID);
|
||||
$executions = $this->execution->getPairsByList(array_keys($executions));
|
||||
|
||||
$this->execution->buildTaskSearchForm($projectID, $executions, $queryID, $actionURL);
|
||||
$this->execution->buildTaskSearchForm($projectID, $productID, $executions, $queryID, $actionURL, 'projectTask');
|
||||
}
|
||||
|
||||
$this->view->title = $this->lang->execution->allExecutions;
|
||||
|
||||
Reference in New Issue
Block a user