+ add the feature of custom fields.

This commit is contained in:
wangchunsheng
2010-07-28 06:14:58 +00:00
parent 8fad508b0f
commit 9b0ab2ed18
7 changed files with 216 additions and 0 deletions

View File

@@ -59,3 +59,16 @@ $config->bug->search['params']['assignedDate'] = array('operator' => '>=',
$config->bug->create->requiredFields = 'title,openedBuild';
$config->bug->edit->requiredFields = $config->bug->create->requiredFields;
$config->bug->resolve->requiredFields = 'resolution';
$config->bug->list->allFields = 'id, module, project, story, task,
title, keywords, severity, pri, type, os, browser, hardware,
found, steps, status, mailto,
openedBy, openedDate, openedBuild,
assignedTo, assignedDate,
resolvedBy, resolution, resolvedBuild, resolvedDate,
closedBy, closedDate,
duplicateBug, linkBug,
case,
lastEditedBy,
lastEditedDate';
$config->bug->list->defaultFields = 'id,severity,pri,title,openedBy,assignedTo,resolvedBy,resolution';

View File

@@ -163,6 +163,10 @@ class bug extends control
$this->view->searchForm = $this->fetch('search', 'buildForm', $this->config->bug->search);
$users = $this->user->getPairs('noletter');
/* 设置自定义字段。*/
$customFields = $this->cookie->bugFields != false ? $this->cookie->bugFields : $this->config->bug->list->defaultFields;
$customed = !($customFields == $this->config->bug->list->defaultFields);
$header['title'] = $this->products[$productID] . $this->lang->colon . $this->lang->bug->common;
$position[] = html::a($this->createLink('bug', 'browse', "productID=$productID"), $this->products[$productID]);
@@ -180,6 +184,8 @@ class bug extends control
$this->view->param = $param;
$this->view->orderBy = $orderBy;
$this->view->moduleID = $moduleID;
$this->view->customed = $customed;
$this->view->customFields= explode(',', str_replace(' ', '', trim($customFields)));
$this->display();
}
@@ -545,6 +551,25 @@ class bug extends control
die();
}
/* 自定义显示字段。*/
public function customFields()
{
if($_POST)
{
$customFields = $this->post->customFields;
$customFields = join(',', $customFields);
setcookie('bugFields', $customFields);
die(js::reload('parent'));
}
/* 设定自定义字段列表。*/
$customFields = $this->cookie->bugFields ? $this->cookie->bugFields : $this->config->bug->list->defaultFields;
$this->view->allFields = $this->bug->getFieldPairs($this->config->bug->list->allFields);
$this->view->customFields = $this->bug->getFieldPairs($customFields);
$this->view->defaultFields = $this->bug->getFieldPairs($this->config->bug->list->defaultFields);
die($this->display());
}
/* 获得用户的bug列表。*/
public function ajaxGetUserBugs($account = '')
{

View File

@@ -37,6 +37,7 @@ $lang->bug->severityAB = '级别';
$lang->bug->pri = '优先级';
$lang->bug->type = 'Bug类型';
$lang->bug->os = '操作系统';
$lang->bug->hardware = '硬件平台';
$lang->bug->browser = '浏览器';
$lang->bug->machine = '机器硬件';
$lang->bug->found = '如何发现';
@@ -77,6 +78,8 @@ $lang->bug->close = '关闭Bug';
$lang->bug->activate = '激活Bug';
$lang->bug->reportChart = '报表统计';
$lang->bug->delete = '删除Bug';
$lang->bug->customFields = '自定义字段';
$lang->bug->restoreDefault = '恢复默认';
$lang->bug->ajaxGetUserBugs = '接口:我的Bug';
$lang->bug->confirmStoryChange = '确认需求变动';
@@ -105,6 +108,8 @@ $lang->bug->lblAssignedTo = '当前指派';
$lang->bug->lblMailto = '抄送给';
$lang->bug->lblLastEdited = '最后修改';
$lang->bug->lblResolved = '由谁解决';
$lang->bug->lblAllFields = '所有字段';
$lang->bug->lblCustomFields = '自定义字段';
/* legend列表。*/
$lang->bug->legendBasicInfo = '基本信息';

View File

@@ -460,4 +460,17 @@ class bugModel extends model
->get();
$this->dao->insert(TABLE_USERTPL)->data($template)->autoCheck('title, content', 'notempty')->check('title', 'unique')->exec();
}
/* 给一个字段的列表,返回字段和相应语言解释的键值对。*/
public function getFieldPairs($fields)
{
$fields = explode(',', $fields);
foreach($fields as $key => $field)
{
$field = trim($field);
$fields[$field] = $this->lang->bug->$field;
unset($fields[$key]);
}
return $fields;
}
}

View File

@@ -0,0 +1,82 @@
<div class='yui-d0 <?php if($browseType == 'bymodule') echo 'yui-t1';?>' id='mainbox'>
<table class='table-1 bd-none'>
<tr valign='top'>
<td class='bd-none <?php if($browseType != 'bymodule') echo 'hidden';?>' id='treebox'>
<nobr>
<div class='box-title'><?php echo $productName;?></div>
<div class='box-content'>
<?php echo $moduleTree;?>
<div class='a-right'>
<?php if(common::hasPriv('tree', 'browse')) echo html::a($this->createLink('tree', 'browse', "productID=$productID&view=bug"), $lang->tree->manage);?>
</div>
</div>
</nobr>
</td>
<td class='bd-none'>
<?php $vars = "productID=$productID&browseType=$browseType&param=$param&orderBy=%s&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}"; ?>
<table class='table-1 colored tablesorter datatable'>
<thead>
<tr class='colhead'>
<?php foreach($customFields as $fieldName):?>
<th><nobr><?php common::printOrderLink($fieldName, $orderBy, $vars, $lang->bug->$fieldName);?></nobr></th>
<?php endforeach;?>
<th class='{sorter:false}'><nobr><?php echo $lang->actions;?></nobr></th>
</tr>
</thead>
<tbody>
<?php foreach($bugs as $bug):?>
<?php $bugLink = inlink('view', "bugID=$bug->id");?>
<tr>
<?php foreach($customFields as $fieldName):?>
<td><nobr>
<?php
if(preg_match('/^(id|title)$/i', $fieldName))
{
echo html::a($bugLink, $bug->$fieldName);
}
elseif(preg_match('/assignedTo|by/i', $fieldName))
{
echo $users[$bug->$fieldName];
}
elseif(preg_match('/^(severity|pri|resolution|os|type|browse|status)$/i', $fieldName))
{
$key = $fieldName . 'List';
$list = $lang->bug->$key;
echo $list[$bug->$fieldName];
}
else
{
echo $bug->$fieldName;
}
?>
</nobr></td>
<?php endforeach;?>
<td><nobr>
<?php
$params = "bugID=$bug->id";
if(!($bug->status == 'active' and common::printLink('bug', 'resolve', $params, $lang->bug->buttonResolve))) echo $lang->bug->buttonResolve . ' ';
if(!($bug->status == 'resolved' and common::printLink('bug', 'close', $params, $lang->bug->buttonClose))) echo $lang->bug->buttonClose . ' ';
common::printLink('bug', 'edit', $params, $lang->bug->buttonEdit);
?>
</nobr>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
<?php $pager->show();?>
</td>
</tr>
</table>
<script language='javascript'>
$("#<?php echo $browseType;?>Tab").addClass('active');
$("#module<?php echo $moduleID;?>").addClass('active');
if($.browser.msie && Math.floor(parseInt($.browser.version)) == 6)
{
$("#browsecss").attr('href', '');
}
</script>
<iframe frameborder='0' name='hiddenwin' class='<?php $config->debug ? print("debugwin") : print('hiddenwin')?>'></iframe>
</body>
</html>

View File

@@ -47,6 +47,10 @@ function browseBySearch(active)
$('#bysearchTab').addClass('active');
}
$(document).ready(function()
{
$("a.iframe").colorbox({width:640, height:420, iframe:true, transition:'none'});
});
</script>
<div class='yui-d0'>
@@ -66,6 +70,7 @@ function browseBySearch(active)
?>
</div>
<div class='f-right'>
<?php common::printLink('bug', 'customFields', '', $lang->bug->customFields, '', "class='iframe'"); ?>
<?php echo html::export2csv($lang->exportCSV, $lang->setFileName);?>
<?php common::printLink('bug', 'report', "productID=$productID&browseType=$browseType&moduleID=$moduleID", $lang->bug->report->common); ?>
<?php common::printLink('bug', 'create', "productID=$productID&extra=moduleID=$moduleID", $lang->bug->create); ?>
@@ -74,6 +79,7 @@ function browseBySearch(active)
<div id='querybox' class='<?php if($browseType !='bysearch') echo 'hidden';?>'><?php echo $searchForm;?></div>
</div>
<?php if($customed){include 'browse.custom.html.php'; exit;}?>
<div class='yui-d0 <?php if($browseType == 'bymodule') echo 'yui-t1';?>' id='mainbox'>
<div class="yui-main">

View File

@@ -0,0 +1,72 @@
<?php
/**
* The custom seting fields view of bug module of ZenTaoMS.
*
* ZenTaoMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ZenTaoMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ZenTaoMS. If not, see <http://www.gnu.org/licenses/>.
*
* @copyright Copyright 2009-2010 青岛易软天创网络科技有限公司(www.cnezsoft.com)
* @author Chunsheng Wang <chunsheng@cnezsoft.com>
* @package product
* @version $Id$
* @link http://www.zentaoms.com
*/
?>
<?php include '../../common/view/header.lite.html.php';?>
<style>
body{background:white}
.button-c {width:60px}
</style>
<script language='Javascript'>
function restoreDefault()
{
$('#customFields option').remove();
$('#defaultFields option').clone().appendTo('#customFields');
}
</script>
<div id='yui-d0' style='margin-top:20px'>
<form method='post'>
<table class='table-1'>
<caption class='caption-tl'><?php echo $lang->bug->customFields;?></caption>
<tr class='colhead'>
<th><?php echo $lang->bug->lblAllFields;?></th>
<th></th>
<th><?php echo $lang->bug->lblCustomFields;?></th>
<th></th>
</tr>
<tr>
<td>
<?php
echo html::select('allFields[]', $allFields, '', 'class=select-2 size=10 multiple');
echo html::select('defaultFields[]', $defaultFields, '', 'class=hidden');
?>
</td>
<td>
<?php
echo html::commonButton('>', "onclick=\"addItem('allFields', 'customFields')\"") . '<br />';
echo html::commonButton('<', "onclick=delItem('customFields')") . '<br />';
?>
</td>
<td><?php echo html::select('customFields[]', $customFields, '', 'class=select-2 size=10 multiple');?></td>
<td>
<?php
echo html::commonButton('+', "onclick=upItem('customFields')") . '<br />';
echo html::commonButton('-', "onclick=downItem('customFields')") . '<br />';
echo html::commonButton($lang->bug->restoreDefault, "onclick=restoreDefault()") . '<br />';
?>
</td>
</tr>
<tr><td colspan='4' class='a-center'><?php echo html::submitButton('', 'onclick=selectItem("customFields")');?></td></tr>
</table>
</form>
</div>