* finish task#1514.

This commit is contained in:
chencongzhi520@gmail.com
2013-07-15 06:37:03 +00:00
parent a6c59896b8
commit 04b22c74f9
5 changed files with 74 additions and 26 deletions
+3 -9
View File
@@ -149,6 +149,7 @@ class product extends control
$this->view->productName = $this->products[$productID];
$this->view->moduleID = $moduleID;
$this->view->stories = $stories;
$this->view->plans = $this->loadModel('productplan')->getPairs($productID);
$this->view->summary = $this->product->summary($stories);
$this->view->moduleTree = $this->tree->getTreeMenu($productID, $viewType = 'story', $startModuleID = 0, array('treeModel', 'createStoryLink'));
$this->view->parentModules = $this->tree->getParents($moduleID);
@@ -465,17 +466,10 @@ class product extends control
* @access public
* @return void
*/
public function ajaxGetPlans($productID, $planID = 0, $dropMenu = false)
public function ajaxGetPlans($productID, $planID = 0)
{
$plans = $this->loadModel('productplan')->getPairs($productID);
if(!$dropMenu) die(html::select('plan', $plans, $planID));
echo "<ul>";
foreach($plans as $plan)
{
echo "<li><a>" . $plan . "</a></li>";
}
echo "</ul>";
die(html::select('plan', $plans, $planID));
}
/**
+5 -11
View File
@@ -11,15 +11,15 @@ function browseByModule()
/**
* Change form action.
*
* @param formName $formName
* @param actionName $actionName
* @param actionLink $actionLink
* @param url $actionLink
* @param bool $hiddenwin
* @access public
* @return void
*/
function changeAction(formName, actionName, actionLink)
function changeAction(actionLink, hiddenwin)
{
$('#' + formName).attr('action', actionLink).submit();
if(hiddenwin) $('form').attr('target', 'hiddenwin');
$('form').attr('action', actionLink).submit();
}
/**
@@ -84,12 +84,6 @@ function toggleSubMenu(currentID, position, menuIndex)
$('#' + currentID + 'Menu').toggle();
}
function ajaxShowMenu(currentID, productID)
{
$.get(createLink('product', 'ajaxGetPlans', "productID=" + productID + "&plan=0&showMenu=true"), function(data){ $('#' + currentID + 'Menu').html(data);});
toggleSubMenu(currentID);
}
$(function()
{
if(browseType == 'bysearch') ajaxGetSearchForm();
+18 -6
View File
@@ -63,7 +63,7 @@
$actionLink = $this->createLink('story', 'batchEdit', "productID=$productID&projectID=0");
echo "<div class='groupButton'>";
echo html::commonButton($lang->edit, "onclick=\"changeAction('productStoryForm', 'batchEdit', '$actionLink')\" $disabled");
echo html::commonButton($lang->edit, "onclick=\"changeAction('$actionLink')\" $disabled");
echo html::commonButton($lang->more, "onclick=\"toggleSubMenu(this.id, 'top', 0)\" id='moreAction'");
echo "</div>";
}
@@ -83,9 +83,9 @@
$canBatchClose = common::hasPriv('story', 'batchClose') and strtolower($browseType) != 'closedbyme' and strtolower($browseType) != 'closedstory';
$disabled = $canBatchClose ? '' : 'disabled';
$actionLink = $this->createLink('story', 'batchClose', "productID=$productID&projectID=0");
echo "<li>" . html::a('#', $lang->close, '', "onclick=\"changeAction('productStoryForm', 'batchClose', '$actionLink')\" $disabled") . "</li>";
echo "<li>" . html::a('#', $lang->close, '', "onclick=\"changeAction('$actionLink',true)\" $disabled") . "</li>";
echo "<li>" . html::a('#', $lang->story->review, '', "onmouseover='toggleSubMenu(this.id)' onmouseout='toggleSubMenu(this.id)' id='reviewItem'") . "</li>";
echo "<li>" . html::a('#', $lang->story->planAB, '', "onmouseover='ajaxShowMenu(this.id, $productID)' onmouseout='toggleSubMenu(this.id)' id='planItem'") . "</li>";
echo "<li>" . html::a('#', $lang->story->planAB, '', "onmouseover='toggleSubMenu(this.id)' onmouseout='toggleSubMenu(this.id)' id='planItem'") . "</li>";
echo "<li>" . html::a('#', $lang->story->stageAB, '', "onmouseover='toggleSubMenu(this.id)' onmouseout='toggleSubMenu(this.id)' id='stageItem'") . "</li>";
?>
</ul>
@@ -106,7 +106,7 @@
}
else
{
echo html::a('#', $result, '', "onclick=\"changeAction('productStoryForm', 'batchReview', '$actionLink')\"");
echo html::a('#', $result, '', "onclick=\"changeAction('$actionLink',true)\"");
}
echo "</li>";
}
@@ -125,14 +125,26 @@
{
$actionLink = $this->createLink('story', 'batchReview', "result=reject&reason=$key");
echo "<li>";
echo html::a('#', $reason, '', "onclick=\"changeAction('productStoryForm', 'batchReview', '$actionLink')\"");
echo html::a('#', $reason, '', "onclick=\"changeAction('$actionLink',true)\"");
echo "</li>";
}
?>
</ul>
</div>
<div id='planItemMenu' class='hidden listMenu'></div>
<div id='planItemMenu' class='hidden listMenu'>
<ul>
<?php
unset($plans['']);
$plans = array(0 => '&nbsp;') + $plans;
foreach($plans as $planID => $plan)
{
$actionLink = $this->createLink('story', 'batchChangePlan', "planID=$planID");
echo "<li>" . html::a('#', $plan, '', "onclick=\"changeAction('$actionLink',true)\"") . "</li>";
}
?>
</ul>
</div>
<div id='stageItemMenu' class='hidden listMenu'>
<ul>
+21
View File
@@ -702,6 +702,27 @@ class story extends control
$this->display();
}
/**
* Batch change the plan of story.
*
* @param int $planID
* @access public
* @return void
*/
public function batchChangePlan($planID)
{
$storyIDList = $this->post->storyIDList ? $this->post->storyIDList : die(js::locate($this->session->storyList, 'parent'));
$allChanges = $this->story->batchChangePlan($storyIDList, $planID);
if(dao::isError()) die(js::error(dao::getError()));
foreach($allChanges as $storyID => $changes)
{
$actionID = $this->action->create('story', $storyID, 'Edited');
$this->action->logHistory($actionID, $changes);
$this->sendMail($storyID, $actionID);
}
die(js::locate($this->session->storyList, 'parent'));
}
/**
* Tasks of a story.
*
+27
View File
@@ -623,6 +623,33 @@ class storyModel extends model
return $allChanges;
}
/**
* Batch change the plan of story.
*
* @param array $storyIDList
* @param int $planID
* @access public
* @return array
*/
public function batchChangePlan($storyIDList, $planID)
{
$now = helper::now();
$allChanges = array();
foreach($storyIDList as $storyID)
{
$oldStory = $this->getById($storyID);
$story = new stdclass();
$story->lastEditedBy = $this->app->user->account;
$story->lastEditedDate = $now;
$story->plan = $planID;
$this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq((int)$storyID)->exec();
if(!dao::isError()) $allChanges[$storyID] = common::createChanges($oldStory, $story);
}
return $allChanges;
}
/**
* Activate a story.
*