* Code for task#77794. Edit productplan.

This commit is contained in:
xieqiyu
2022-11-30 09:30:44 +08:00
parent 996cc54961
commit 5095e566d8
4 changed files with 42 additions and 31 deletions
+10 -6
View File
@@ -917,7 +917,7 @@ class productplan extends control
{
foreach($planStories as $storyID => $story)
{
if($story->branch and $story->branch != $newBranch) $this->productplan->unlinkStory($storyID, $planID);
if($story->branch and strpos(",$newBranch,", ",$story->branch,") === false) $this->productplan->unlinkStory($storyID, $planID);
}
}
}
@@ -933,15 +933,17 @@ class productplan extends control
*/
public function ajaxGetConflictStory($planID, $newBranch)
{
$plan = $this->productplan->getByID($planID);
$oldBranch = $plan->branch;
$planStories = $this->loadModel('story')->getPlanStories($planID, 'all');
$conflictStoryIdList = '';
if(empty($newBranch)) return $conflictStoryIdList;
$plan = $this->productplan->getByID($planID);
$oldBranch = $plan->branch;
$planStories = $this->loadModel('story')->getPlanStories($planID, 'all');
if($oldBranch)
{
foreach($planStories as $storyID => $story)
{
if($story->branch and $story->branch != $newBranch) $conflictStoryIdList .= '[' . $storyID . ']';
if($story->branch and strpos(",$newBranch,", ",$story->branch,") === false) $conflictStoryIdList .= '[' . $storyID . ']';
}
}
if($conflictStoryIdList != '') printf($this->lang->story->confirmChangePlan, $conflictStoryIdList);
@@ -967,12 +969,14 @@ class productplan extends control
*
* @param int $productID
* @param int $branch
* @param int $planID
* @access public
* @return object
*/
public function ajaxGetTopPlan($productID, $branch = 0)
public function ajaxGetTopPlan($productID, $branch = 0, $planID = 0)
{
$parentPlanPairs = $this->productplan->getTopPlanPairs($productID, $branch);
if(isset($parentPlanPairs[$planID])) unset($parentPlanPairs[$planID]);
return print(html::select('parent', array(0 => '') + $parentPlanPairs, 0, 'class="form-control"'));
}
}
+10 -12
View File
@@ -17,34 +17,32 @@ function convertStringToDate(dateString)
* Get conflict stories.
*
* @param int $planID
* @param int $branch
* @access public
* @return void
*/
function getConflictStories(planID, branch)
function getConflictStories(planID)
{
$.get(createLink('productplan', 'ajaxGetConflictStory', 'planID=' + planID + '&newBranch=' + branch), function(conflictStories)
var newBranch = $('#branch').val() ? $('#branch').val().toString() : '';
$.get(createLink('productplan', 'ajaxGetConflictStory', 'planID=' + planID + '&newBranch=' + newBranch), function(conflictStories)
{
if(conflictStories != '')
{
var result = confirm(conflictStories) ? true : false;
if(!result)
{
newBranch = oldBranch[planID];
$('#branch').val(oldBranch[planID]);
$('#branch').trigger("chosen:updated");
}
}
if(conflictStories == '' || result)
var link = createLink('productplan', 'ajaxGetTopPlan', "productID=" + productID + "&branch=" + newBranch + "&planID=" + planID);
$.post(link, function(data)
{
var link = createLink('productplan', 'ajaxGetTopPlan', "productID=" + productID + "&branch=" + branch);
$.post(link, function(data)
{
$('#parent').replaceWith(data);
$('#parent_chosen').remove();
$('#parent').chosen();
})
}
$('#parent').replaceWith(data);
$('#parent_chosen').remove();
$('#parent').chosen();
})
});
}
+20 -11
View File
@@ -481,6 +481,13 @@ class productplanModel extends model
->remove('delta,uid,future')
->get();
$product = $this->loadModel('product')->getByID($plan->product);
if($product->type != 'normal' and !isset($_POST['branch']))
{
$this->lang->product->branch = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]);
dao::$errors['branch'] = sprintf($this->lang->error->notempty, $this->lang->product->branch);
}
if($plan->parent > 0)
{
$parentPlan = $this->getByID($plan->parent);
@@ -494,12 +501,6 @@ class productplanModel extends model
}
}
$product = $this->loadModel('product')->getByID($plan->product);
if($product->type != 'normal' and empty($plan->branch))
{
$this->lang->product->branch = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]);
dao::$errors['branch'] = sprintf($this->lang->error->notempty, $this->lang->product->branch);
}
if(!$this->post->future and strpos($this->config->productplan->create->requiredFields, 'begin') !== false and empty($_POST['begin']))
{
dao::$errors['begin'] = sprintf($this->lang->error->notempty, $this->lang->productplan->begin);
@@ -558,10 +559,19 @@ class productplanModel extends model
$plan = fixer::input('post')->stripTags($this->config->productplan->editor->edit['id'], $this->config->allowedTags)
->setIF($this->post->future or empty($_POST['begin']), 'begin', $this->config->productplan->future)
->setIF($this->post->future or empty($_POST['end']), 'end', $this->config->productplan->future)
->setDefault('branch', 0)
->join('branch', ',')
->add('id', $planID)
->remove('delta,uid,future')
->get();
$product = $this->loadModel('product')->getByID($oldPlan->product);
if($product->type != 'normal' and !isset($_POST['branch']))
{
$this->lang->product->branch = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]);
dao::$errors['branch'] = sprintf($this->lang->error->notempty, $this->lang->product->branch);
}
$parentPlan = $this->getByID($plan->parent);
$futureTime = $this->config->productplan->future;
@@ -578,9 +588,9 @@ class productplanModel extends model
}
elseif($oldPlan->parent == -1 and ($plan->begin != $futureTime or $plan->end != $futureTime))
{
$childPlans = $this->getChildren($planID);
$minBegin = $plan->begin;
$maxEnd = $plan->end;
$childPlans = $this->getChildren($planID);
$minBegin = $plan->begin;
$maxEnd = $plan->end;
foreach($childPlans as $childID => $childPlan)
{
$childPlan = isset($plans[$childID]) ? $plans[$childID] : $childPlan;
@@ -593,8 +603,7 @@ class productplanModel extends model
if(dao::isError()) return false;
$plan = $this->loadModel('file')->processImgURL($plan, $this->config->productplan->editor->edit['id'], $this->post->uid);
$this->dao->update(TABLE_PRODUCTPLAN)
->data($plan)
$this->dao->update(TABLE_PRODUCTPLAN)->data($plan)
->autoCheck()
->batchCheck($this->config->productplan->edit->requiredFields, 'notempty')
->checkIF(!$this->post->future && !empty($_POST['begin']) && !empty($_POST['end']), 'end', 'ge', $plan->begin)
+2 -2
View File
@@ -33,7 +33,7 @@
<?php if($product->type != 'normal' and $plan->parent != '-1'):?>
<tr>
<th><?php echo $lang->product->branch;?></th>
<td><?php echo html::select('branch[]', $branchTagOption, $plan->branch, "onchange='getConflictStories($plan->id, this.value); 'class='form-control chosen' multiple");?></td><td></td><td></td>
<td><?php echo html::select('branch[]', $branchTagOption, $plan->branch, "onchange='getConflictStories($plan->id);' class='form-control chosen' multiple");?></td><td></td><td></td>
</tr>
<?php endif;?>
<?php endif;?>
@@ -46,7 +46,7 @@
<?php else:?>
<tr>
<th><?php echo $lang->productplan->parent;?></th>
<td><?php echo html::select('parent', array('0' => '') + $parentPlanPairs, $plan->parent, "class='form-control chosen'");?>
<td><?php echo html::select('parent', array(0 => '') + $parentPlanPairs, $plan->parent, "class='form-control chosen'");?>
</tr>
<?php endif;?>
<tr>