* Add the ajax request when change parent stage for task #83955.

This commit is contained in:
hufangzhou
2023-02-07 01:08:03 +00:00
parent 3e1b5be66e
commit 9137ed1b83
3 changed files with 44 additions and 13 deletions
+25 -7
View File
@@ -212,8 +212,9 @@ class programplan extends control
*/
public function edit($planID = 0, $projectID = 0)
{
$this->app->loadLang('project');
$this->loadModel('project');
$this->app->loadLang('execution');
$this->app->loadLang('stage');
$plan = $this->programplan->getByID($planID);
global $lang;
@@ -234,12 +235,14 @@ class programplan extends control
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $locate));
}
$this->app->loadLang('stage');
$this->view->title = $this->lang->programplan->edit;
$this->view->position[] = $this->lang->programplan->edit;
$this->view->parentStage = $this->programplan->getParentStageList($this->session->project, $planID, $plan->product);
$this->view->isCreateTask = $this->programplan->isCreateTask($planID);
$this->view->plan = $plan;
$parentStage = $this->project->getByID($plan->parent, 'stage');
$this->view->title = $this->lang->programplan->edit;
$this->view->position[] = $this->lang->programplan->edit;
$this->view->isCreateTask = $this->programplan->isCreateTask($planID);
$this->view->plan = $plan;
$this->view->parentStageList = $this->programplan->getParentStageList($this->session->project, $planID, $plan->product);
$this->view->enableOptionalAttr = (empty($parentStage) or (!empty($parentStage) and $parentStage->attribute == 'mix'));
$this->display();
}
@@ -328,4 +331,19 @@ class programplan extends control
return $this->send(array('result' => 'success'));
}
}
public function ajaxGetAttribute($stageID)
{
$this->app->loadLang('stage');
$attribute = $this->dao->select('attribute')->from(TABLE_EXECUTION)->where('id')->eq($stageID)->fetch('attribute');
if(empty($attribute) or $attribute == 'mix')
{
return print(html::select('attribute', $this->lang->stage->typeList, $attribute, "class='form-control chosen'"));
}
else
{
return print(zget($this->lang->stage->typeList, $attribute));
}
}
}
+10
View File
@@ -0,0 +1,10 @@
function changeParentStage(stageID)
{
$.get(createLink('programplan', 'ajaxGetAttribute', 'stageID=' + stageID), function(attribute)
{
$('#attributeType td').html(attribute);
$("#attribute" + "_chosen").remove();
$("#attribute").next('.picker').remove();
$("#attribute").chosen();
})
}
+9 -6
View File
@@ -25,7 +25,7 @@
<tbody>
<tr>
<th class="w-100px"><?php echo $lang->programplan->parent;?></th>
<td colspan='2'><?php echo html::select('parent', $parentStage, $plan->parent, "class='form-control chosen '");?></td>
<td colspan='2'><?php echo html::select('parent', $parentStageList, $plan->parent, "class='form-control chosen '");?></td>
</tr>
<tr>
<th class='w-100px'><?php echo $lang->programplan->name;?> </th>
@@ -46,9 +46,11 @@
</div>
</td>
</tr>
<tr class="<?php if($plan->grade == 2) echo "hidden";?>" id="attributeType">
<th><?php echo $lang->programplan->attribute;?> </th>
<td colspan='2'><?php echo html::select('attribute', $lang->stage->typeList, $plan->attribute, "class='form-control'");?></td>
<tr id="attributeType">
<th><?php echo $lang->programplan->attribute;?></th>
<td colspan='2'>
<?php echo $enableOptionalAttr ? html::select('attribute', $lang->stage->typeList, $plan->attribute, "class='form-control'") : zget($lang->stage->typeList, $plan->attribute);?>
</td>
</tr>
<?php if($plan->setMilestone):?>
<tr>
@@ -101,16 +103,17 @@
$("#parent").change(function()
{
var parent = $(this).children("option:selected").val();
if(parent == 0)
{
$("#attributeType").removeClass('hidden');
$("#acl").attr('disabled', false);
}
else
{
$("#attributeType").addClass('hidden');
$("#acl").attr('disabled', true);
}
changeParentStage(parent);
});
</script>
<?php include '../../common/view/footer.html.php';?>