Skip to content

Commit

Permalink
* fix for link bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyidong committed May 25, 2015
1 parent ef9a2e9 commit ae4cd7e
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 51 deletions.
2 changes: 1 addition & 1 deletion module/bug/control.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function browse($productID = 0, $browseType = 'unclosed', $param = 0, $or
elseif($browseType == 'longlifebugs') $bugs = $this->bug->getByLonglifebugs($productID, $projects, $sort, $pager);
elseif($browseType == 'postponedbugs') $bugs = $this->bug->getByPostponedbugs($productID, $projects, $sort, $pager);
elseif($browseType == 'needconfirm') $bugs = $this->bug->getByNeedconfirm($productID, $projects, $sort, $pager);
elseif($browseType == 'bysearch') $bugs = $this->bug->getBySearch($productID, $projects, $queryID, $sort, $pager);
elseif($browseType == 'bysearch') $bugs = $this->bug->getBySearch($productID, $queryID, $sort, $pager);

/* Process the sql, get the conditon partion, save it to session. */
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'bug', $browseType == 'needconfirm' ? false : true);
Expand Down
12 changes: 3 additions & 9 deletions module/bug/model.php
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ public function getProductBugPairs($productID)
*/
public function getReleaseBugs($buildID, $productID)
{
$project = $this->dao->select('t1.begin')
$project = $this->dao->select('t1.id,t1.begin')
->from(TABLE_PROJECT)->alias('t1')
->leftJoin(TABLE_BUILD)->alias('t2')
->on('t1.id = t2.project')
Expand All @@ -830,6 +830,7 @@ public function getReleaseBugs($buildID, $productID)
->where('resolvedDate')->ge($project->begin)
->andWhere('resolution')->ne('postponed')
->andWhere('product')->eq($productID)
->andWhere("(project != '$project->id' OR (project = '$project->id' and openedDate < '$project->begin'))")
->andWhere('deleted')->eq(0)
->orderBy('openedDate ASC')
->fetchAll();
Expand Down Expand Up @@ -1455,14 +1456,13 @@ public function getByNeedconfirm($productID, $projects, $orderBy, $pager)
* Get bugs by search.
*
* @param int $productID
* @param array $projects
* @param int $queryID
* @param string $orderBy
* @param object $pager
* @access public
* @return array
*/
public function getBySearch($productID, $projects, $queryID, $orderBy, $pager = null)
public function getBySearch($productID, $queryID, $orderBy, $pager = null)
{
if($queryID)
{
Expand All @@ -1482,12 +1482,6 @@ public function getBySearch($productID, $projects, $queryID, $orderBy, $pager =
if($this->session->bugQuery == false) $this->session->set('bugQuery', ' 1 = 1');
}

/* check the purview of projects.*/
if(strpos($this->session->bugQuery, '`project`') === false)
{
$var = $this->session->bugQuery . ' AND `project`' . helper::dbIN(array_keys($projects));
$this->session->set('bugQuery', "$var");
}
if(strpos($this->session->bugQuery, '`product`') === false)
{
$var = $this->session->bugQuery . ' AND `product` = ' . $productID;
Expand Down
4 changes: 2 additions & 2 deletions module/build/control.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public function linkBug($buildID = 0, $browseType = '', $param = 0)

/* Build the search form. */
$this->loadModel('bug');
$this->config->product->search['actionURL'] = $this->createLink('build', 'view', "buildID=$buildID&type=bug&link=true&param=" . helper::safe64Encode("&browseType=bySearch&queryID=myQueryID"));
$this->config->bug->search['actionURL'] = $this->createLink('build', 'view', "buildID=$buildID&type=bug&link=true&param=" . helper::safe64Encode("&browseType=bySearch&queryID=myQueryID"));
$this->config->bug->search['queryID'] = $queryID;
$this->config->bug->search['style'] = 'simple';
$this->config->bug->search['params']['plan']['values'] = $this->loadModel('productplan')->getForProducts(array($build->product => $build->product));
Expand All @@ -354,7 +354,7 @@ public function linkBug($buildID = 0, $browseType = '', $param = 0)

if($browseType == 'bySearch')
{
$allBugs = $this->bug->getBySearch($build->product, array($build->project => $build->project), $queryID, 'id_desc');
$allBugs = $this->bug->getBySearch($build->product, $queryID, 'id_desc');
}
else
{
Expand Down
1 change: 1 addition & 0 deletions module/build/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.red {color:red}
.green {color:green}
#unlinkBugList, #unlinkStoryList{margin-bottom:5px;}
input[type=checkbox].ml-10px{margin-left:10px;}
2 changes: 1 addition & 1 deletion module/productplan/control.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public function linkBug($planID = 0, $browseType = '', $param = 0, $orderBy = 'i

if($browseType == 'bySearch')
{
$allBugs = $this->bug->getBySearch($plan->product, $projects, $queryID, 'id_desc');
$allBugs = $this->bug->getBySearch($plan->product, $queryID, 'id_desc');
foreach($allBugs as $key => $bug)
{
if($bug->status != 'active') unset($allBugs[$key]);
Expand Down
1 change: 1 addition & 0 deletions module/productplan/css/view.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.tabs .tab-content .tab-pane #querybox form{padding-left:0px;}

#unlinkBugList, #unlinkStoryList{margin-bottom:5px;}
input[type=checkbox].ml-10px{margin-left:10px;}
2 changes: 1 addition & 1 deletion module/release/control.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ public function linkBug($releaseID = 0, $browseType = '', $param = 0)

if($browseType == 'bySearch')
{
$allBugs = $this->bug->getBySearch($release->product, $build->project ? array($build->project => $build->project) : array(), $queryID, 'id_desc');
$allBugs = $this->bug->getBySearch($release->product, $queryID, 'id_desc');
}
else
{
Expand Down
1 change: 1 addition & 0 deletions module/release/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.red {color:red}
.green {color:green}
#unlinkBugList, #unlinkStoryList{margin-bottom:5px;}
input[type=checkbox].ml-10px{margin-left:10px;}
1 change: 0 additions & 1 deletion module/release/css/view.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.tabs{position:relative;}
.tabs .tab-content .tab-pane .action{position: absolute; right: 110px; top: 0px;}
.tabs .tab-content .tab-pane #querybox{margin:0px}
.tabs .tab-content .tab-pane #querybox form{padding-left:0px;}
3 changes: 3 additions & 0 deletions module/release/view/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@
</div>
</div>
</div>
<style>
.tabs .tab-content .tab-pane .action{position: absolute; right: <?php echo ($countStories or $countBugs or $countNewBugs) ? '110px' : '0px'?>; top: 0px;}
</style>
<?php js::set('param', helper::safe64Decode($param))?>
<?php js::set('link', $link)?>
<?php js::set('releaseID', $release->id)?>
Expand Down
72 changes: 37 additions & 35 deletions module/search/view/buildform.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
setDateField('.date');
});

var params = <?php echo empty($fieldParams) ? '{}' : json_encode($fieldParams);?>;
var <?php echo $module . 'params'?> = <?php echo empty($fieldParams) ? '{}' : json_encode($fieldParams);?>;
var groupItems = <?php echo $config->search->groupItems;?>;
var setQueryTitle = '<?php echo $lang->search->setQueryTitle;?>';
var module = '<?php echo $module;?>';
Expand All @@ -100,11 +100,11 @@ function setDateField(query, fieldNO)
$period = $("<ul id='selectPeriod' class='dropdown-menu'><li class='dropdown-header'><?php echo $lang->datepicker->dpText->TEXT_OR . ' ' . $lang->datepicker->dpText->TEXT_DATE;?></li><li><a href='#lastWeek'><?php echo $lang->datepicker->dpText->TEXT_PREV_WEEK;?></a></li><li><a href='#thisWeek'><?php echo $lang->datepicker->dpText->TEXT_THIS_WEEK;?></a></li><li><a href='#yesterday'><?php echo $lang->datepicker->dpText->TEXT_YESTERDAY;?></a></li><li><a href='#today'><?php echo $lang->datepicker->dpText->TEXT_TODAY;?></a></li><li><a href='#lastMonth'><?php echo $lang->datepicker->dpText->TEXT_PREV_MONTH;?></a></li><li><a href='#thisMonth'><?php echo $lang->datepicker->dpText->TEXT_THIS_MONTH;?></a></li></ul>").appendTo('body');
$period.find('li > a').click(function(event)
{
var target = $('#' + $period.data('target'));
var target = $(query).parents('form').find('#' + $period.data('target'));
if(target.length)
{
target.val($(this).attr('href').replace('#', '$'));
$('#operator' + $period.data('fieldNO')).val('between');
$(query).parents('form').find('#operator' + $period.data('fieldNO')).val('between');
$period.hide();
}
event.stopPropagation();
Expand All @@ -119,7 +119,7 @@ function setDateField(query, fieldNO)
$period.find("li > a[href='" + $e.val().replace('$', '#') + "']").closest('li').addClass('active');
}).on('changeDate', function()
{
var opt = $('#operator' + $period.data('fieldNO'));
var opt = $(query).parents('form').find('#operator' + $period.data('fieldNO'));
if(opt.val() == 'between') opt.val('<=');
$period.hide();
}).on('hide', function(){setTimeout(function(){$period.hide();}, 200);});
Expand All @@ -128,33 +128,35 @@ function setDateField(query, fieldNO)
/**
* When the value of the fields select changed, set the operator and value of the new field.
*
* @param string $fieldName
* @param string $obj
* @param int $fieldNO
* @access public
* @return void
*/
function setField(fieldName, fieldNO)
function setField(obj, fieldNO, moduleparams)
{
$('#operator' + fieldNO).val(params[fieldName]['operator']); // Set the operator according the param setting.
$('#valueBox' + fieldNO).html($('#box' + fieldName).children().clone());
$('#valueBox' + fieldNO).children().attr({name : 'value' + fieldNO, id : 'value' + fieldNO});
var params = moduleparams;
var fieldName = $(obj).val();
$(obj).parents('form').find('#operator' + fieldNO).val(params[fieldName]['operator']); // Set the operator according the param setting.
$(obj).parents('form').find('#valueBox' + fieldNO).html($(obj).parents('form').find('#box' + fieldName).children().clone());
$(obj).parents('form').find('#valueBox' + fieldNO).children().attr({name : 'value' + fieldNO, id : 'value' + fieldNO});

if(typeof(params[fieldName]['class']) != undefined && params[fieldName]['class'] == 'date')
{
setDateField("#value" + fieldNO, fieldNO);
$("#value" + fieldNO).addClass('date'); // Shortcut the width of the datepicker to make sure align with others.
setDateField($(obj).parents('form').find("#value" + fieldNO), fieldNO);
$(obj).parents('form').find("#value" + fieldNO).addClass('date'); // Shortcut the width of the datepicker to make sure align with others.
var groupItems = <?php echo $config->search->groupItems?>;
var maxNO = 2 * groupItems;
var nextNO = fieldNO > groupItems ? fieldNO - groupItems + 1 : fieldNO + groupItems;
var nextValue = $('#value' + nextNO).val();
var nextValue = $(obj).parents('form').find('#value' + nextNO).val();
if(nextNO <= maxNO && fieldNO < maxNO && (nextValue == '' || nextValue == 0))
{
$('#field' + nextNO).val($('#field' + fieldNO).val());
$('#operator' + nextNO).val('<=');
$('#valueBox' + nextNO).html($('#box' + fieldName).children().clone());
$('#valueBox' + nextNO).children().attr({name : 'value' + nextNO, id : 'value' + nextNO});
setDateField("#value" + nextNO, nextNO);
$("#value" + nextNO).addClass('date');
$(obj).parents('form').find('#field' + nextNO).val($(obj).parents('form').find('#field' + fieldNO).val());
$(obj).parents('form').find('#operator' + nextNO).val('<=');
$(obj).parents('form').find('#valueBox' + nextNO).html($(obj).parents('form').find('#box' + fieldName).children().clone());
$(obj).parents('form').find('#valueBox' + nextNO).children().attr({name : 'value' + nextNO, id : 'value' + nextNO});
setDateField($(obj).parents('form').find("#value" + nextNO), nextNO);
$(obj).parents('form').find("#value" + nextNO).addClass('date');
}
}
}
Expand All @@ -165,11 +167,11 @@ function setField(fieldName, fieldNO)
* @access public
* @return void
*/
function resetForm()
function resetForm(obj)
{
for(i = 1; i <= groupItems * 2; i ++)
{
$('#value' + i).val('');
$(obj).parents('form').find('#value' + i).val('');
}
}

Expand All @@ -179,18 +181,18 @@ function resetForm()
* @access public
* @return void
*/
function showmore()
function showmore(obj)
{
for(i = 1; i <= groupItems * 2; i ++)
{
if(i != 1 && i != groupItems + 1 )
{
$('#searchbox' + i).removeClass('hidden');
$(obj).parents('form').find('#searchbox' + i).removeClass('hidden');
}
}

$('#formType').val('more');
$('#searchform').addClass('showmore');
$(obj).parents('form').find('#formType').val('more');
$(obj).parents('form').addClass('showmore');
}

/**
Expand All @@ -199,18 +201,18 @@ function showmore()
* @access public
* @return void
*/
function showlite()
function showlite(obj)
{
for(i = 1; i <= groupItems * 2; i ++)
{
if(i != 1 && i != groupItems + 1)
{
$('#value' + i).val('');
$('#searchbox' + i).addClass('hidden');
$(obj).parents('form').find('#value' + i).val('');
$(obj).parents('form').find('#searchbox' + i).addClass('hidden');
}
}
$('#searchform').removeClass('showmore');
$('#formType').val('lite');
$(obj).parents('form').removeClass('showmore');
$(obj).parents('form').find('#formType').val('lite');
}

/**
Expand Down Expand Up @@ -259,6 +261,7 @@ function deleteQuery()
}
</script>

<form method='post' action='<?php echo $this->createLink('search', 'buildQuery');?>' target='hiddenwin' id='searchform' class='form-condensed'>
<div class='hidden'>
<?php
/* Print every field as an html object, select or input. Thus when setFiled is called, copy it's html to build the search form. */
Expand All @@ -271,7 +274,6 @@ function deleteQuery()
}
?>
</div>
<form method='post' action='<?php echo $this->createLink('search', 'buildQuery');?>' target='hiddenwin' id='searchform' class='form-condensed'>
<table class='table table-condensed table-form' style='max-width: 1200px; margin: 0 auto'>
<tr>
<td class='w-400px'>
Expand All @@ -297,7 +299,7 @@ function deleteQuery()
echo '</td>';

/* Print field. */
echo "<td class='w-90px'>" . html::select("field$fieldNO", $searchFields, $formSession["field$fieldNO"], "onchange='setField(this.value, $fieldNO)' class='form-control'") . '</td>';
echo "<td class='w-90px'>" . html::select("field$fieldNO", $searchFields, $formSession["field$fieldNO"], "onchange='setField(this, $fieldNO, {$module}params)' class='form-control'") . '</td>';

/* Print operator. */
echo "<td class='w-70px'>" . html::select("operator$fieldNO", $lang->search->operators, $formSession["operator$fieldNO"], "class='form-control'") . '</td>';
Expand Down Expand Up @@ -339,7 +341,7 @@ function deleteQuery()
echo '</td>';

/* Print field. */
echo "<td class='w-90px'>" . html::select("field$fieldNO", $searchFields, $formSession["field$fieldNO"], "onchange='setField(this.value, $fieldNO)' class='form-control'") . '</td>';
echo "<td class='w-90px'>" . html::select("field$fieldNO", $searchFields, $formSession["field$fieldNO"], "onchange='setField(this, $fieldNO, {$module}param)' class='form-control'") . '</td>';

/* Print operator. */
echo "<td class='w-70px'>" . html::select("operator$fieldNO", $lang->search->operators, $formSession["operator$fieldNO"], "class='form-control'") . '</td>';
Expand Down Expand Up @@ -371,7 +373,7 @@ function deleteQuery()
echo html::submitButton($lang->search->common, '', 'btn-primary');
if($style != 'simple')
{
echo html::commonButton($lang->search->reset, 'onclick=resetForm(); class=btn');
echo html::commonButton($lang->search->reset, 'onclick=resetForm(this) class=btn');
echo html::commonButton($lang->save, 'onclick=saveQuery() class=btn');
}
echo '</div>';
Expand All @@ -390,8 +392,8 @@ function deleteQuery()
</tr>
</table>
<div id='moreOrLite'>
<a id="searchmore" href="javascript:showmore()"><i class="icon-double-angle-down icon-2x"></i></a>
<a id="searchlite" href="javascript:showlite()"><i class="icon-double-angle-up icon-2x"></i></a>
<a id="searchmore" href="javascript:;" onclick="showmore(this)"><i class="icon-double-angle-down icon-2x"></i></a>
<a id="searchlite" href="javascript:;" onclick="showlite(this)"><i class="icon-double-angle-up icon-2x"></i></a>
<?php echo html::hidden('formType', 'lite');?>
</div>
</form>
Expand Down
2 changes: 1 addition & 1 deletion www/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

/* Detect mobile. */
$mobile = $app->loadClass('mobile');
if(!$mobile->isTablet() and $mobile->isMobile())
if(!$mobile->isTablet() and $mobile->isMobile() and $config->default->view == 'html')
{
$config->default->view = 'mhtml';
helper::setViewType();
Expand Down

0 comments on commit ae4cd7e

Please sign in to comment.