+ add the search feature to story.

This commit is contained in:
wangchunsheng
2010-01-08 07:56:17 +00:00
parent 6b2c0ba37a
commit 2cce363ffb
6 changed files with 71 additions and 29 deletions

View File

@@ -1,5 +1,6 @@
<?php
/*
global $lang, $app;
$app->loadLang('story');
$config->product->search['module'] = 'story';
$config->product->search['fields']['id'] = $lang->story->id;
$config->product->search['fields']['title'] = $lang->story->title;
@@ -20,4 +21,3 @@ $config->product->search['params']['lastEditedBy'] = array('operator' => '=',
$config->product->search['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => $lang->story->statusList);
$config->product->search['params']['pri'] = array('operator' => '=', 'control' => 'select', 'values' => $lang->story->priList);
$config->product->search['params']['mailto'] = array('operator' => 'include', 'control' => 'select', 'values' => 'users');
*/

View File

@@ -49,46 +49,58 @@ class product extends control
}
/* 浏览某一个产品。*/
public function browse($productID = 0, $moduleID = 0, $orderBy = 'id|desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
public function browse($productID = 0, $queryType = 'byModule', $param = 0, $orderBy = 'id|desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
{
//$this->config->product->search['actionURL'] = $this->createLink('product', 'browse', "productID=$productID&type=byQuery");
//$this->assign('searchForm', $this->fetch('search', 'buildForm', $this->config->product->search));
/* 设置搜索条件。*/
$this->config->product->search['actionURL'] = $this->createLink('product', 'browse', "productID=$productID&type=bySearch");
$this->view->searchForm = $this->fetch('search', 'buildForm', $this->config->product->search);
/* 设置查询格式。*/
$queryType = strtolower($queryType);
/* 设置当前的产品id和模块id。*/
$this->session->set('storyList', $this->app->getURI(true));
$productID = common::saveProductState($productID, key($this->products));
$moduleID = (int)$moduleID;
$childModuleIds = $this->tree->getAllChildID($moduleID);
$moduleID = ($queryType == 'bymodule') ? (int)$param : 0;
/* 设置菜单。*/
$this->product->setMenu($this->products, $productID);
/* 设置header和导航条信息。*/
$header['title'] = $this->lang->product->index . $this->lang->colon . $this->products[$productID];
$position[] = $this->products[$productID];
$this->view->header->title = $this->lang->product->index . $this->lang->colon . $this->products[$productID];
$this->view->position[] = $this->products[$productID];
/* 加载分页类并查询stories列表。*/
$this->app->loadClass('pager', $static = true);
$pager = new pager($recTotal, $recPerPage, $pageID);
$stories = $this->story->getProductStories($productID, $childModuleIds, 'all', $orderBy, $pager);
/* 设置浏览模式。*/
$browseType = $moduleID > 0 ? 'module' : 'all';
$stories = array();
if($queryType == 'all')
{
$stories = $this->story->getProductStories($productID, 0, 'all', $orderBy, $pager);
}
elseif($queryType == 'bymodule')
{
$childModuleIds = $this->tree->getAllChildID($moduleID);
$stories = $this->story->getProductStories($productID, $childModuleIds, 'all', $orderBy, $pager);
}
elseif($queryType == 'bysearch')
{
if($this->session->storyQuery == false) $this->session->set('storyQuery', ' 1 = 1');
$stories = $this->story->getByQuery($this->session->storyQuery, $orderBy, $pager);
}
$this->assign('header', $header);
$this->assign('position', $position);
$this->assign('productID', $productID);
$this->assign('productName', $this->products[$productID]);
$this->assign('moduleID', $moduleID);
$this->assign('stories', $stories);
$this->assign('moduleTree', $this->tree->getTreeMenu($productID, $viewType = 'product', $rooteModuleID = 0, array('treeModel', 'createStoryLink')));
$this->assign('parentModules', $this->tree->getParents($moduleID));
$this->assign('pager', $pager->get());
$this->assign('recTotal', $pager->recTotal);
$this->assign('recPerPage', $pager->recPerPage);
$this->assign('pager', $pager);
$this->assign('users', $this->user->getPairs($this->app->company->id, 'noletter'));
$this->assign('orderBy', $orderBy);
$this->assign('browseType', $browseType);
$this->assign('queryType', $queryType);
$this->assign('moduleID', $moduleID);
$this->display();
}

View File

@@ -48,4 +48,5 @@ $lang->product->status = '状态';
$lang->product->desc = '产品描述';
$lang->product->moduleStory = '按模块浏览';
$lang->product->searchStory = '搜索';
$lang->product->allStory = '全部需求';

View File

@@ -31,25 +31,39 @@ function browseByModule()
{
$('#mainbox').addClass('yui-t7');
$('#treebox').removeClass('hidden');
$('#featuremodule').addClass('active');
$('#featureall').removeClass('active');
$('#bymoduleTab').addClass('active');
$('#allTab').removeClass('active');
$('#bysearchTab').removeClass('active');
$('#querybox').addClass('hidden');
}
function search(active)
{
$('#mainbox').removeClass('yui-t7');
$('#treebox').addClass('hidden');
$('#querybox').removeClass('hidden');
$('#bymoduleTab').removeClass('active');
$('#' + active + 'Tab').removeClass('active');
$('#bysearchTab').addClass('active');
}
</script>
<div class='yui-d0'>
<div id='featurebar'>
<div class='f-left'>
<span id='featureall'><?php echo html::a($this->createLink('product', 'browse', "productID=$productID"), $lang->product->allStory);?></span>
<span id='featuremodule' onclick='browseByModule()'><?php echo $lang->product->moduleStory;?></span>
<span id='bymoduleTab' onclick='browseByModule()'><?php echo $lang->product->moduleStory;?></span>
<span id='bysearchTab' onclick='search("<?php echo $queryType;?>")'><?php echo $lang->product->searchStory;?></span>
<span id='allTab'><?php echo html::a($this->createLink('product', 'browse', "productID=$productID&type=all"), $lang->product->allStory);?></span>
</div>
<div class='f-right'>
<?php if(common::hasPriv('story', 'create')) echo html::a($this->createLink('story', 'create', "productID=$productID&moduleID=$moduleID"), $lang->story->create); ?>
</div>
</div>
<div id='querybox' class='<?php if($queryType !='bysearch') echo 'hidden';?>'><?php echo $searchForm;?></div>
</div>
<div class='yui-d0 <?php if($browseType == 'module') echo 'yui-t7';?>' id='mainbox'>
<div class='yui-b <?php if($browseType != 'module') echo 'hidden';?>' id='treebox'>
<div class='yui-d0 <?php if($queryType == 'bymodule') echo 'yui-t7';?>' id='mainbox'>
<div class='yui-b <?php if($queryType != 'bymodule') echo 'hidden';?>' id='treebox'>
<div class='box-title'><?php echo $productName;?></div>
<div class='box-content'>
<?php echo $moduleTree;?>
@@ -66,7 +80,7 @@ function browseByModule()
<table class='table-1 fixed colored'>
<thead>
<tr class='colhead'>
<?php $vars = "productID=$productID&moduleID=$moduleID&orderBy=%s&recTotal=$recTotal&recPerPage=$recPerPage";?>
<?php $vars = "productID=$productID&moduleID=$moduleID&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}";?>
<th><?php common::printOrderLink('id', $orderBy, $vars, $lang->story->id);?></th>
<th><?php common::printOrderLink('pri', $orderBy, $vars, $lang->story->pri);?></th>
<th class='w-p40'><?php common::printOrderLink('title', $orderBy, $vars, $lang->story->title);?></th>
@@ -75,7 +89,7 @@ function browseByModule()
<th><?php common::printOrderLink('openedBy', $orderBy, $vars, $lang->story->openedBy);?></th>
<th><?php common::printOrderLink('estimate', $orderBy, $vars, $lang->story->estimate);?></th>
<th><?php common::printOrderLink('status', $orderBy, $vars, $lang->story->status);?></th>
<th><?php common::printOrderLink('lastEditedDate', $orderBy, $vars, $lang->story->lastEditedDate);?></th>
<th class='w-100px'><?php common::printOrderLink('lastEditedDate', $orderBy, $vars, $lang->story->lastEditedDate);?></th>
<th><?php echo $lang->action;?></th>
</tr>
</thead>
@@ -103,12 +117,12 @@ function browseByModule()
<?php endforeach;?>
</tbody>
</table>
<?php echo $pager;?>
<?php $pager->show();?>
</div>
</div>
</div>
<script language='javascript'>
$('#module<?php echo $moduleID;?>').addClass('active')
$('#feature<?php echo $browseType;?>').addClass('active')
$('#<?php echo $queryType;?>Tab').addClass('active')
</script>
<?php include '../../common/footer.html.php';?>

View File

@@ -101,6 +101,21 @@ class storyModel extends model
return $this->formatStories($stories);
}
/* 按照某一个查询条件获取列表。*/
public function getByQuery($query, $orderBy, $pager = null)
{
$tmpStories = $this->dao->select('*')->from(TABLE_STORY)->where($query)->orderBy($orderBy)->page($pager)->fetchGroup('plan');
if(!$tmpStories) return array();
$plans = $this->dao->select('id,title')->from(TABLE_PRODUCTPLAN)->where('id')->in(array_keys($tmpStories))->fetchPairs();
$stories = array();
foreach($tmpStories as $planID => $planStories)
{
foreach($planStories as $story) $story->planTitle = isset($plans[$planID]) ? $plans[$planID] : '';
$stories[] = $story;
}
return $stories;
}
/* 获得某一个项目相关的所有需求列表。*/
function getProjectStories($projectID = 0, $orderBy='id|desc', $pager = null)
{

View File

@@ -137,7 +137,7 @@ class treeModel extends model
/* 生成需求链接。*/
function createStoryLink($module)
{
$linkHtml = html::a(helper::createLink('product', 'browse', "product={$module->product}&module={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
$linkHtml = html::a(helper::createLink('product', 'browse', "product={$module->product}&type=byModule&param={$module->id}"), $module->name, '_self', "id='module{$module->id}'");
return $linkHtml;
}