* code for task #49697.

This commit is contained in:
tanghucheng
2022-02-21 17:01:42 +08:00
parent 0cb4581eec
commit 422811bcbd
7 changed files with 324 additions and 6 deletions
+3
View File
@@ -0,0 +1,3 @@
<?php
$config->task->customBatchCreateFields .= ',lane,region';
$config->task->custom->batchCreateFields .= ',lane,region';
@@ -0,0 +1,47 @@
<?php
helper::importControl('task');
class myTask extends task
{
public function batchCreate($executionID = 0, $storyID = 0, $moduleID = 0, $taskID = 0, $iframe = 0, $extra = '')
{
$executions = $this->execution->getPairs();
if(empty($executions))
{
echo(js::alert($this->lang->task->kanbanDenied));
die(js::locate(helper::createLink('execution', 'create')));
}
$regionList = $this->loadModel('kanban')->getRegionPairs($executionID, 0, 'execution');
$this->view->regionList = $regionList;
$this->view->extra = $extra;
$extra = str_replace(array(',', ' '), array('&', ''), $extra);
parse_str($extra, $output);
$lanes = array();
if(isset($output['laneID']))
{
$regionID = $this->dao->select("*")->from(TABLE_KANBANLANE)->where('id')->eq($output['laneID'])->fetch('region');
$lanes = $this->kanban->getLanePairsByRegion($regionID, 'task');
$this->view->regionID = $regionID;
}
$this->view->lanes = $lanes;
if(!empty($_POST))
{
$laneIDList = $_POST['lane'];
foreach($laneIDList as $key => $lane)
{
$_POST['column'][$key] = $this->dao->select("t1.id")->from(TABLE_KANBANCOLUMN)->alias('t1')
->leftJoin(TABLE_KANBANLANE)->alias('t2')
->on("t2.group = t1.group")
->where('t1.deleted')->eq('0')
->andWhere('t2.id')->eq($lane)
->andWhere('t1.type')->eq('wait')
->fetch('id');
}
}
return parent::batchCreate($executionID, $storyID, $moduleID, $taskID, $iframe, $extra);
}
}
@@ -0,0 +1,252 @@
<?php
/**
* The batch create view of task module of ZenTaoPMS.
*
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
* @license ZPL (http://zpl.pub/page/zplv12.html)
* @author Yangyang Shi <shiyangyang@cnezsoft.com>
* @package task
* @version $Id$
* @link http://www.zentao.net
*/
?>
<?php include $this->app->getModuleRoot() . '/common/view/header.html.php';?>
<?php include $this->app->getModuleRoot() . '/common/view/datepicker.html.php';?>
<?php js::set('taskConsumed', $taskConsumed);?>
<?php js::set('addChildTask', $lang->task->addChildTask);?>
<style>.c-lane,.c-region{width:150px;}</style>
<div id="mainContent" class="main-content fade">
<div class="main-header clearfix">
<h2 class="pull-left">
<?php if($parent):?>
<span class='pull-left'><?php echo $parentTitle . $this->lang->colon;?></span>
<?php echo $lang->task->batchCreateChildren;?>
<?php else:?>
<?php echo $lang->task->batchCreate;?>
<?php endif;?>
</h2>
<?php if($execution->type != 'ops'):?>
<a class="checkbox-primary pull-left" id='zeroTaskStory' href='javascript:toggleZeroTaskStory();'>
<label><?php echo $lang->story->zeroTask;?></label>
</a>
<?php endif;?>
<div class="pull-right btn-toolbar">
<button type='button' data-toggle='modal' data-target="#importLinesModal" class="btn btn-primary"><?php echo $lang->pasteText;?></button>
<?php $customLink = $this->createLink('custom', 'ajaxSaveCustomFields', 'module=task&section=custom&key=batchCreateFields')?>
<?php include $this->app->getModuleRoot() . '/common/view/customfield.html.php';?>
</div>
</div>
<?php
$visibleFields = array();
$requiredFields = array();
foreach(explode(',', $showFields) as $field)
{
if($field)$visibleFields[$field] = '';
}
foreach(explode(',', $config->task->create->requiredFields) as $field)
{
if($field)
{
$requiredFields[$field] = '';
if(strpos(",{$config->task->customBatchCreateFields},", ",{$field},") !== false) $visibleFields[$field] = '';
}
}
$colspan = count($visibleFields) + 3;
?>
<form method='post' class='load-indicator batch-actions-form form-ajax' enctype='multipart/form-data' id="batchCreateForm">
<div class="table-responsive">
<table class="table table-form" id="tableBody">
<thead>
<tr>
<th class='c-id'><?php echo $lang->idAB;?></th>
<th class='c-module<?php echo zget($visibleFields, 'module', ' hidden') . zget($requiredFields, 'module', '', ' required');?>'><?php echo $lang->task->module?></th>
<?php if($execution->type != 'ops'):?>
<th class='c-story<?php echo zget($visibleFields, 'story', ' hidden') . zget($requiredFields, 'story', '', ' required');?>'><?php echo $lang->task->story;?></th>
<?php endif;?>
<th class='c-name required has-btn'><?php echo $lang->task->name;?></span></th>
<th class='c-region required<?php echo zget($visibleFields, 'region', ' hidden');?>'><?php echo $lang->task->region;?></th>
<th class='c-lane required<?php echo zget($visibleFields, 'lane', ' hidden');?>'><?php echo $lang->task->lane;?></th>
<th class='c-type required'><?php echo $lang->typeAB;?></span></th>
<th class='c-assigned<?php echo zget($visibleFields, 'assignedTo', ' hidden') . zget($requiredFields, 'assignedTo', '', ' required');?>'><?php echo $lang->task->assignedTo;?></th>
<th class='c-estimate<?php echo zget($visibleFields, 'estimate', ' hidden') . zget($requiredFields, 'estimate', '', ' required');?>'><?php echo $lang->task->estimateAB;?></th>
<th class='c-date<?php echo zget($visibleFields, 'estStarted', ' hidden') . zget($requiredFields, 'estStarted', '', ' required');?>'><?php echo $lang->task->estStarted;?></th>
<th class='c-date<?php echo zget($visibleFields, 'deadline', ' hidden') . zget($requiredFields, 'deadline', '', ' required');?>'><?php echo $lang->task->deadline;?></th>
<th class='c-desc<?php echo zget($visibleFields, 'desc', ' hidden') . zget($requiredFields, 'desc', '', ' required');?>'><?php echo $lang->task->desc;?></th>
<th class='c-pri<?php echo zget($visibleFields, 'pri', ' hidden') . zget($requiredFields, 'pri', '', ' required');?>'><?php echo $lang->task->pri;?></th>
<?php
$extendFields = $this->task->getFlowExtendFields();
foreach($extendFields as $extendField) echo "<th class='w-100px'>{$extendField->name}</th>";
?>
</tr>
</thead>
<tbody>
<?php
$stories['ditto'] = $lang->task->ditto;
$lang->task->typeList['ditto'] = $lang->task->ditto;
$members['ditto'] = $lang->task->ditto;
$modules['ditto'] = $lang->task->ditto;
if($execution->type == 'ops') $colspan = $colspan - 1;
?>
<?php for($i = 1; $i <= $config->task->batchCreate; $i++):?>
<?php
if($i == 1)
{
$currentStory = $storyID;
$type = '';
$member = '';
}
else
{
$currentStory = $type = $member = $moduleID = 'ditto';
}
?>
<?php $pri = 3;?>
<tr>
<td class='text-center'><?php echo $i;?></td>
<td <?php echo zget($visibleFields, 'module', "class='hidden'")?> style='overflow:visible'>
<?php echo html::select("module[$i]", $modules, $moduleID, "class='form-control chosen' onchange='setStories(this.value, $execution->id, $i)'")?>
<?php echo html::hidden("parent[$i]", $parent);?>
</td>
<?php if($execution->type != 'ops'):?>
<td <?php echo zget($visibleFields, 'story', "class='hidden'");?> style='overflow: visible'>
<div class='input-group'>
<?php echo html::select("story[$i]", $stories, $currentStory, "class='form-control chosen' onchange='setStoryRelated($i)'");?>
<span class='input-group-btn'>
<a id='preview<?php echo $i;?>' href='#' class='btn iframe btn-link btn-icon btn-copy' disabled='disabled' title='<?php echo $lang->preview; ?>'><i class='icon-search'></i></a>
<a href='javascript:copyStoryTitle(<?php echo $i;?>)' class='btn btn-link btn-icon btn-copy' title='<?php echo $lang->task->copyStoryTitle; ?>'><i class='icon-arrow-right'></i></a>
<?php echo html::hidden("storyEstimate$i") . html::hidden("storyDesc$i") . html::hidden("storyPri$i");?>
</span>
</div>
</td>
<?php endif;?>
<td style='overflow:visible'>
<div class="input-control has-icon-right">
<?php echo html::input("name[$i]", '', "class='form-control title-import'");?>
<div class="colorpicker">
<button type="button" class="btn btn-link dropdown-toggle" data-toggle="dropdown"><span class="cp-title"></span><span class="color-bar"></span><i class="ic"></i></button>
<ul class="dropdown-menu clearfix pull-right">
<li class="heading"><?php echo $lang->task->colorTag;?><i class="icon icon-close"></i></li>
</ul>
<?php echo html::hidden("color[$i]", '', "data-provide='colorpicker' data-icon='color' data-wrapper='input-control-icon-right' data-update-color='#name\\[$i\\]'");?>
</div>
</div>
</td>
<td <?php echo zget($visibleFields, 'region', "class='hidden'")?> style='overflow:visible'><?php echo html::select("region[$i]", $regionList, isset($regionID) ? $regionID : '', "class='form-control chosen' onchange='loadLaneGroup(this.value, $i)'");?></td>
<td <?php echo zget($visibleFields, 'lane', "class='hidden'")?> style='overflow:visible'><?php echo html::select("lane[$i]", $lanes, '', "class='form-control chosen'");?></td>
<td><?php echo html::select("type[$i]", $lang->task->typeList, $type, 'class=form-control');?></td>
<td <?php echo zget($visibleFields, 'assignedTo', "class='hidden'")?> style='overflow:visible'><?php echo html::select("assignedTo[$i]", $members, $member, "class='form-control chosen'");?></td>
<td <?php echo zget($visibleFields, 'estimate', "class='hidden'")?>><?php echo html::input("estimate[$i]", '', "class='form-control text-center'");?></td>
<td <?php echo zget($visibleFields, 'estStarted', "class='hidden'")?>>
<div class='input-group'>
<?php
echo html::input("estStarted[$i]", '', "class='form-control text-center form-date' onkeyup='toggleCheck(this)'");
if($i != 0) echo "<span class='input-group-addon estStartedBox'><input type='checkbox' name='estStartedDitto[$i]' id='estStartedDitto$i' " . ($i> 0 ? "checked" : '') . " /> {$lang->task->ditto}</span>";
?>
</div>
</td>
<td <?php echo zget($visibleFields, 'deadline', "class='hidden'")?>>
<div class='input-group'>
<?php
echo html::input("deadline[$i]", '', "class='form-control text-center form-date' onkeyup='toggleCheck(this)'");
if($i != 0) echo "<span class='input-group-addon deadlineBox'><input type='checkbox' name='deadlineDitto[$i]' id='deadlineDitto$i' " . ($i> 0 ? "checked" : '') . " /> {$lang->task->ditto}</span>";
?>
</div>
</td>
<td <?php echo zget($visibleFields, 'desc', "class='hidden'")?>><?php echo html::textarea("desc[$i]", '', "rows='1' class='form-control autosize'");?></td>
<td <?php echo zget($visibleFields, 'pri', "class='hidden'")?>><?php echo html::select("pri[$i]", (array)$lang->task->priList, $pri, 'class=form-control');?></td>
<?php foreach($extendFields as $extendField) echo "<td" . (($extendField->control == 'select' or $extendField->control == 'multi-select') ? " style='overflow:visible'" : '') . ">" . $this->loadModel('flow')->getFieldControl($extendField, '', $extendField->field . "[$i]") . "</td>";?>
</tr>
<?php endfor;?>
</tbody>
<tfoot>
<tr>
<td colspan='<?php echo $colspan?>' class='text-center form-actions'>
<?php echo html::submitButton();?>
<?php echo html::backButton();?>
</td>
</tr>
</tfoot>
</table>
</div>
</form>
</div>
<table class='template' id='trTemp'>
<tbody>
<tr>
<td class='text-center'>%s</td>
<td <?php echo zget($visibleFields, 'module', "class='hidden'")?> style='overflow:visible'>
<?php echo html::select("module[%s]", $modules, $moduleID, "class='form-control chosen' onchange='setStories(this.value, $execution->id, \"%s\")'")?>
<?php echo html::hidden("parent[%s]", $parent);?>
</td>
<td <?php echo zget($visibleFields, 'story', "class='hidden'");?> style='overflow: visible'>
<div class='input-group'>
<?php echo html::select("story[%s]", $stories, $currentStory, "class='form-control chosen' onchange='setStoryRelated(\"%s\")'");?>
<span class='input-group-btn'>
<a id="preview%s" href='#' class='btn iframe btn-link btn-icon btn-copy' disabled='disabled' title='<?php echo $lang->preview; ?>'><i class='icon-search'></i></a>
<a href='javascript:copyStoryTitle("%s")' class='btn btn-link btn-icon btn-copy' title='<?php echo $lang->task->copyStoryTitle; ?>'><i class='icon-arrow-right'></i></a>
</span>
</div>
</td>
<td style='overflow:visible'>
<div class="input-control has-icon-right">
<?php echo html::input("name[%s]", '', "class='form-control title-import'");?>
<div class="colorpicker">
<button type="button" class="btn btn-link dropdown-toggle" data-toggle="dropdown"><span class="cp-title"></span><span class="color-bar"></span><i class="ic"></i></button>
<ul class="dropdown-menu clearfix pull-right">
<li class="heading"><?php echo $lang->task->colorTag;?><i class="icon icon-close"></i></li>
</ul>
<?php echo html::hidden("color[%s]", '', "data-provide='colorpicker-later' data-icon='color' data-wrapper='input-control-icon-right' data-update-color='#name\\[%s\\]'");?>
</div>
</div>
</div>
</td>
<td <?php echo zget($visibleFields, 'region', "class='hidden'")?> style='overflow:visible'><?php echo html::select("region[%s]", $regionList, isset($regionID) ? $regionID : '', "class='form-control chosen' onchange='loadLaneGroup(this.value, $i)'");?></td>
<td <?php echo zget($visibleFields, 'lane', "class='hidden'")?> style='overflow:visible'><?php echo html::select("lane[%s]", $lanes, '', "class='form-control chosen'");?></td>
<td><?php echo html::select("type[%s]", $lang->task->typeList, $type, 'class="form-control"');?></td>
<td <?php echo zget($visibleFields, 'assignedTo', "class='hidden'")?> style='overflow:visible'><?php echo html::select("assignedTo[%s]", $members, $member, "class='form-control chosen'");?></td>
<td <?php echo zget($visibleFields, 'estimate', "class='hidden'")?>><?php echo html::input("estimate[%s]", '', "class='form-control text-center'");?></td>
<td <?php echo zget($visibleFields, 'estStarted', "class='hidden'")?>>
<div class='input-group'>
<?php
echo html::input("estStarted[%s]", '', "class='form-control text-center form-date' onkeyup='toggleCheck(this)'");
echo "<span class='input-group-addon estStartedBox'><input type='checkbox' name='estStartedDitto[%s]' id='estStartedDitto%s' checked/>{$lang->task->ditto}</span>";
?>
</div>
</td>
<td <?php echo zget($visibleFields, 'deadline', "class='hidden'")?>>
<div class='input-group'>
<?php
echo html::input("deadline[%s]", '', "class='form-control text-center form-date' onkeyup='toggleCheck(this)'");
echo "<span class='input-group-addon deadlineBox'><input type='checkbox' name='deadlineDitto[%s]' id='deadlineDitto%s' checked/>{$lang->task->ditto}</span>";
?>
</div>
<td <?php echo zget($visibleFields, 'desc', "class='hidden'")?>><?php echo html::textarea("desc[%s]", '', "rows='1' class='form-control autosize'");?></td>
<td <?php echo zget($visibleFields, 'pri', "class='hidden'")?>><?php echo html::select("pri[%s]", (array)$lang->task->priList, $pri, 'class=form-control');?></td>
<?php foreach($extendFields as $extendField) echo "<td" . (($extendField->control == 'select' or $extendField->control == 'multi-select') ? " style='overflow:visible'" : '') . ">" . $this->loadModel('flow')->getFieldControl($extendField, '', $extendField->field . "[%s]") . "</td>";?>
</tr>
</tbody>
</table>
<?php js::set('executionType', $execution->type);?>
<?php js::set('storyTasks', $storyTasks);?>
<?php js::set('mainField', 'name');?>
<?php js::set('ditto', $lang->task->ditto);?>
<?php js::set('storyID', $storyID);?>
<script>
function loadLaneGroup(regionID, num)
{
var link = createLink('kanban', 'ajaxGetLanes', 'regionID=' + regionID + '&type=task&field=lane&i=' + num);
$.post(link, function(data)
{
$('#lane' + num).replaceWith(data);
$('#lane' + num + '_chosen').remove();
$('#lane' + num).chosen();
})
console.log($('#lane' + num).val());
}
$(function()
{
$("select[id^='region']").change();
})
</script>
<?php include $this->app->getModuleRoot() . '/common/view/pastetext.html.php';?>
<?php include $this->app->getModuleRoot() . '/common/view/footer.html.php';?>
@@ -1,6 +1,6 @@
<script>
$(function()
{
for(var index = 0; index <= 9; index++) $('#batchCreateForm').append(`<input type="hidden" name="vision[${index}]" id="vision[${index}]" value="lite">`);
for(var index = 1; index <= 10; index++) $('#batchCreateForm').append(`<input type="hidden" name="vision[${index}]" id="vision[${index}]" value="lite">`);
});
</script>
+4 -2
View File
@@ -1695,12 +1695,14 @@ class kanban extends control
* @access public
* @return string
*/
public function ajaxGetLanes($regionID, $type = 'all')
public function ajaxGetLanes($regionID, $type = 'all', $field = 'otherLane', $i = 0)
{
$lanes = $this->kanban->getLanePairsByRegion($regionID, $type);
if(empty($lanes)) return;
return print(html::select('otherLane', $lanes, '', "class='form-control'"));
if($i) return print(html::select($field . "[$i]", $lanes, '', "class='form-control'"));
return print(html::select($field, $lanes, '', "class='form-control'"));
}
/**
+1 -1
View File
@@ -1825,7 +1825,7 @@ class kanbanModel extends model
{
return $this->dao->select('id, name')->from(TABLE_KANBANLANE)
->where('deleted')->eq('0')
->andWhere('region')->eq($regionID)
->andWhere('region')->in($regionID)
->beginIF($type != 'all')->andWhere('type')->eq($type)->fi()
->fetchPairs();
}
+16 -2
View File
@@ -247,6 +247,13 @@ class taskModel extends model
$preStory = 0;
$tasks = fixer::input('post')->get();
if($this->config->vision == 'lite')
{
$lanes = $tasks->lane;
$columns = $tasks->column;
unset($tasks->lane);
unset($tasks->column);
}
$extra = str_replace(array(',', ' '), array('&', ''), $extra);
parse_str($extra, $output);
@@ -405,7 +412,14 @@ class taskModel extends model
$this->executeHooks($taskID);
if(isset($output['laneID']) and isset($output['columnID'])) $this->kanban->addKanbanCell($executionID, $output['laneID'], $output['columnID'], 'task', $taskID);
if($this->config->vision == 'lite')
{
$this->kanban->addKanbanCell($executionID, $lanes[$i], $columns[$i], 'task', $taskID);
}
else
{
if(isset($output['laneID']) and isset($output['columnID'])) $this->kanban->addKanbanCell($executionID, $output['laneID'], $output['columnID'], 'task', $taskID);
}
$actionID = $this->action->create('task', $taskID, 'Opened', '');
if(!dao::isError()) $this->loadModel('score')->create('task', 'create', $taskID);
@@ -459,7 +473,7 @@ class taskModel extends model
if(!empty($changes)) $this->action->logHistory($actionID, $changes);
}
if(!isset($output['laneID']) or !isset($output['columnID'])) $this->kanban->updateLane($executionID, 'task');
if(!isset($output['laneID']) or !isset($output['columnID']) or !isset($lanes)) $this->kanban->updateLane($executionID, 'task');
return $mails;
}