* Finish task#8735.

This commit is contained in:
leiyong
2020-12-22 15:24:31 +08:00
parent 1a79fda207
commit 853fd8609f
12 changed files with 81 additions and 40 deletions
+29 -1
View File
@@ -557,6 +557,32 @@ class program extends control
$this->display();
}
/**
* Ajax get projects.
*
* @param string $name
* @param int $copyProjectID
* @access public
* @return void
*/
public function ajaxGetCopyProjects($name = '', $copyProjectID = 0)
{
$projects = $this->dao->select('id, name')->from(TABLE_PROJECT)
->where('type')->eq('project')
->andWhere('deleted')->eq(0)
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->projects)->fi()
->beginIF($name)->andWhere('name')->like("%$name%")->fi()
->fetchPairs();
$html = empty($projects) ? "<div class='text-center'>{$this->lang->noData}</div>" : '';
foreach($projects as $id => $name)
{
$active = $copyProjectID == $id ? 'active' : '';
$html .= "<div class='col-md-4 col-sm-6'><a href='javascript:;' data-id=$id class='nobr $active'>" . html::icon($this->lang->icons['project'], 'text-muted') . $name . "</a></div>";
}
echo $html;
}
/**
* Update program order.
*
@@ -728,6 +754,8 @@ class program extends control
$acl = $copyProject->acl;
$auth = $copyProject->auth;
$whitelist = $copyProject->whitelist;
$programID = $copyProject->parent;
$model = $copyProject->model;
$products = $this->project->getProducts($copyProjectID);
foreach($products as $product)
@@ -743,7 +771,7 @@ class program extends control
$this->view->pmUsers = $this->loadModel('user')->getPairs('noclosed|nodeleted|pmfirst');
$this->view->users = $this->user->getPairs('noclosed|nodeleted');
$this->view->copyProjects = array('' => '') + $this->program->getPRJPairsByModel($model, $programID);
$this->view->copyProjects = $this->program->getPRJPairsByModel();
$this->view->products = $products;
$this->view->allProducts = array('0' => '') + $allProducts;
$this->view->productPlans = array('0' => '') + $productPlans;
+1
View File
@@ -8,3 +8,4 @@
#copyProjectModal a.active:after {position: absolute; content: '\e92f'; font-family: ZentaoIcon; font-size: 20px; right: 25px;}
#copyProjectModal a.cancel {color: #ff5d5d}
#budget {border-right:0px;}
#projectName{display: inline-block; width: 32%}
+28 -2
View File
@@ -1,6 +1,11 @@
$(function()
{
$('#copyProjects a').click(function(){setCopyProject($(this).data('id')); $('#copyProjectModal').modal('hide')});
$('#copyProjects a').click(function()
{
setCopyProject($(this).data('id'));
$('#copyProjectModal').modal('hide')
});
setAclList($("#parent").val());
if(typeof(currentPlanID) == 'undefined')
@@ -28,7 +33,7 @@ $(function()
function setParentProgram()
{
var parentProgram = $("#parent").val();
location.href = createLink('program', 'PRJCreate', 'model=' + model + '&programID=' + parentProgram + '&from=' + from + '&copyProjectID=' + copyProjectID);
location.href = createLink('program', 'PRJCreate', 'model=' + model + '&programID=' + parentProgram + '&from=' + from);
}
/**
@@ -209,3 +214,24 @@ function adjustPlanBoxMargin()
}
}
}
/**
* Fuzzy search projects by project name.
*
* @access public
* @return void
*/
$('#projectName').on('keyup', function()
{
var name = $(this).val();
name = name.replace(/\s+/g, '');
link = createLink('program', 'ajaxGetCopyProjects', 'name=' + name + '&cpoyProjectID=' + copyProjectID);
$.post(link, function(data)
{
$('#copyProjects').html(data);
$('#copyProjects a').click(function()
{
setCopyProject($(this).data('id')); $('#copyProjectModal').modal('hide')
});
})
})
+1 -2
View File
@@ -38,8 +38,7 @@ $lang->program->copyTitle = 'Please select an project to copy';
$lang->program->errorSameProducts = 'Project cannot be associated with multiple identical products.';
$lang->program->errorNoProducts = 'At least one product is associated';
$lang->program->copyNoProject = 'There are no items available to copy.';
$lang->program->PRJSource = 'Project source:';
$lang->program->PRJStandalone = 'Projects that do not belong to a program.';
$lang->project->searchByName = 'Enter the project name to retrieve';
/* Fields. */
$lang->program->common = 'Program';
+1 -2
View File
@@ -38,8 +38,7 @@ $lang->program->copyTitle = 'Please select an project to copy';
$lang->program->errorSameProducts = 'Project cannot be associated with multiple identical products.';
$lang->program->errorNoProducts = 'At least one product is associated';
$lang->program->copyNoProject = 'There are no items available to copy.';
$lang->program->PRJSource = 'Project source:';
$lang->program->PRJStandalone = 'Projects that do not belong to a program.';
$lang->project->searchByName = 'Enter the project name to retrieve';
/* Fields. */
$lang->program->common = 'Program';
+1 -2
View File
@@ -38,8 +38,7 @@ $lang->program->copyTitle = 'Please select an project to copy';
$lang->program->errorSameProducts = 'Project cannot be associated with multiple identical products.';
$lang->program->errorNoProducts = 'At least one product is associated';
$lang->program->copyNoProject = 'There are no items available to copy.';
$lang->program->PRJSource = 'Project source:';
$lang->program->PRJStandalone = 'Projects that do not belong to a program.';
$lang->project->searchByName = 'Enter the project name to retrieve';
/* Fields. */
$lang->program->common = 'Program';
+1 -2
View File
@@ -38,8 +38,7 @@ $lang->program->copyTitle = 'Please select an project to copy';
$lang->program->errorSameProducts = 'Project cannot be associated with multiple identical products.';
$lang->program->errorNoProducts = 'At least one product is associated';
$lang->program->copyNoProject = 'There are no items available to copy.';
$lang->program->PRJSource = 'Project source:';
$lang->program->PRJStandalone = 'Projects that do not belong to a program.';
$lang->project->searchByName = 'Enter the project name to retrieve';
/* Fields. */
$lang->program->common = 'Program';
+2 -3
View File
@@ -34,12 +34,11 @@ $lang->program->PRJStoryConcept = '需求概念组合';
$lang->program->unbindWhielist = '项目删除白名单';
$lang->program->PRJManageProducts = '关联产品';
$lang->program->view = '项目集详情';
$lang->program->copyTitle = '请选择一个项目来复制';
$lang->program->copyTitle = '请选择要复制的项目';
$lang->program->errorSameProducts = '项目不能关联多个相同的产品。';
$lang->program->errorNoProducts = '最少关联一个产品';
$lang->program->copyNoProject = '没有可用的项目来复制';
$lang->program->PRJSource = '项目来源:';
$lang->program->PRJStandalone = '没有所属项目集的项目';
$lang->project->searchByName = '输入项目名称进行检索';
/* Fields. */
$lang->program->common = '项目集';
+4 -4
View File
@@ -1116,17 +1116,17 @@ class programModel extends model
/**
* Get project pairs by model and program.
*
* @param string $model
* @param string $model scrum|waterfall
* @param int $programID
* @access public
* @return void
*/
public function getPRJPairsByModel($model, $programID = 0)
public function getPRJPairsByModel($model = 'all', $programID = 0)
{
return $this->dao->select('id, name')->from(TABLE_PROJECT)
->where('type')->eq('project')
->andWhere('parent')->eq($programID)
->andWhere('model')->eq($model)
->beginIF($programID)->andWhere('parent')->eq($programID)->fi()
->beginIF($model != 'all')->andWhere('model')->eq($model)->fi()
->andWhere('deleted')->eq('0')
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->projects)->fi()
->orderBy('id_desc')
@@ -13,9 +13,6 @@ $programsPinYin = common::convert2Pinyin($programNames);
?>
</div>
<div class="col-footer">
<div class='pull-left'>
<?php echo html::a(helper::createLink('program', 'pgmbrowse', 'status=all'), '<i class="icon icon-cards-view muted"></i> ' . $lang->project->all, '', 'class="not-list-item"'); ?>
</div>
<div class='pull-right'>
<?php echo html::checkbox('showClosed', array('1' => $lang->program->PGMShowClosed), '', $this->cookie->showClosed ? 'checked=checked' : '');?>
</div>
@@ -46,9 +43,9 @@ $programsPinYin = common::convert2Pinyin($programNames);
#programTree li.open > .list-toggle:before {border: none; height: 2px; width: 6px; left: 0; top: 2px; background: #fff;}
#programTree li.open > .list-toggle:hover {background: #006AF1;}
#programTree ul > li:after {display: block; position: absolute; content: ' '; border-top: 2px solid #cbd0db; top: 14px; left: -12px; z-index: 1; width: 10px;}
#programTree ul > li:after {display: block; position: absolute; content: ' '; border-top: 1px dashed #cbd0db; top: 14px; left: -12px; z-index: 1; width: 10px;}
#programTree ul > li:before,
#programTree ul > li.has-list:before {background: none; content: ' '; display: block; position: absolute; width: auto; height: auto; border: none; border-left: 2px solid #cbd0db; top: -13px; bottom: 12px; left: -12px;}
#programTree ul > li.has-list:before {background: none; content: ' '; display: block; position: absolute; width: auto; height: auto; border: none; border-left: 1px dashed #cbd0db; top: -13px; bottom: 12px; left: -12px;}
#programTree ul > li:last-child:before {bottom: auto; height: 29px;}
#programTree ul > li:first-child:before {top: -9px;}
#programTree ul > li.has-list:first-child:before {top: -13px;}
@@ -61,11 +58,11 @@ $programsPinYin = common::convert2Pinyin($programNames);
$('#programTree').tree();
$(function()
{
$('input[name^="showClosed"]').click(function()
{
$('#showClosed1').click(function()
{
var showClosed = $(this).is(':checked') ? 1 : 0;
$.cookie('showClosed', showClosed, {expires:config.cookieLife, path:config.webRoot});
window.location.reload();
});
});
});
</script>
@@ -8,7 +8,7 @@
</div>
<div class="col-footer">
<?php echo html::a(helper::createLink('program', 'PRJBrowse', 'programID=0&status=all'), '<i class="icon icon-cards-view muted"></i> ' . $lang->project->all, '', 'class="not-list-item"'); ?>
<a class='pull-right toggle-right-col not-list-item'><?php echo $lang->project->doneProjects?><i class='icon icon-angle-right'></i></a>
<a class='pull-right toggle-right-col not-list-item'><?php echo $lang->project->doneProjects;?><i class='icon icon-angle-right'></i></a>
</div>
</div>
<div class="table-col col-right">
@@ -41,9 +41,9 @@
#projectTree li.open > .list-toggle:before {border: none; height: 2px; width: 6px; left: 0; top: 2px; background: #fff;}
#projectTree li.open > .list-toggle:hover {background: #006AF1;}
#projectTree ul > li:after {display: block; position: absolute; content: ' '; border-top: 2px solid #cbd0db; top: 14px; left: -12px; z-index: 1; width: 10px;}
#projectTree ul > li:after {display: block; position: absolute; content: ' '; border-top: 1px dashed #cbd0db; top: 14px; left: -12px; z-index: 1; width: 10px;}
#projectTree ul > li:before,
#projectTree ul > li.has-list:before {background: none; content: ' '; display: block; position: absolute; width: auto; height: auto; border: none; border-left: 2px solid #cbd0db; top: -13px; bottom: 12px; left: -12px;}
#projectTree ul > li.has-list:before {background: none; content: ' '; display: block; position: absolute; width: auto; height: auto; border: none; border-left: 1px dashed #cbd0db; top: -13px; bottom: 12px; left: -12px;}
#projectTree ul > li:last-child:before {bottom: auto; height: 29px;}
#projectTree ul > li:first-child:before {top: -9px;}
#projectTree ul > li.has-list:first-child:before {top: -13px;}
+5 -11
View File
@@ -53,7 +53,7 @@
<div class='row'>
<?php $i = 0;?>
<?php foreach($products as $product):?>
<div class="col-sm-4">
<div class="col-sm-4" style="margin-bottom: 10px;">
<?php $hasBranch = $product->type != 'normal' and isset($branchGroups[$product->id]);?>
<div class="input-group<?php if($hasBranch) echo ' has-branch';?>">
<?php echo html::select("products[$i]", $allProducts, $product->id, "class='form-control chosen' onchange='loadBranches(this)' data-last='" . $product->id . "'");?>
@@ -176,9 +176,8 @@
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal'><i class="icon icon-close"></i></button>
<h4 class='modal-title' id='myModalLabel'>
<?php echo $lang->program->copyTitle;?>
<?php if($programID) $lang->program->PRJStandalone = zget($programList, $programID, $lang->noData);?>
<span class="label label-primary label-outline"><?php echo $lang->program->PRJSource . $lang->program->PRJStandalone;?></span>
<?php echo $lang->program->copyTitle;?>
<?php echo html::input('projectName', '', "class='form-control' placeholder={$lang->project->searchByName}");?>
</h4>
</div>
<div class='modal-body'>
@@ -190,13 +189,8 @@
<?php else:?>
<div id='copyProjects' class='row'>
<?php foreach ($copyProjects as $id => $name):?>
<?php if(empty($id)):?>
<?php if($copyProjectID != 0):?>
<div class='col-md-4 col-sm-6'><a href='javascript:;' data-id='' class='cancel'><?php echo html::icon($lang->icons['cancel']) . ' ' . $lang->project->cancelCopy;?></a></div>
<?php endif;?>
<?php else: ?>
<div class='col-md-4 col-sm-6'><a href='javascript:;' data-id='<?php echo $id;?>' class='nobr <?php echo ($copyProjectID == $id) ? ' active' : '';?>'><?php echo html::icon($lang->icons['project'], 'text-muted') . ' ' . $name;?></a></div>
<?php endif; ?>
<?php $active = ($copyProjectID == $id) ? ' active' : '';?>
<div class='col-md-4 col-sm-6'><a href='javascript:;' data-id='<?php echo $id;?>' class='nobr <?php echo $active;?>'><?php echo html::icon($lang->icons['project'], 'text-muted') . ' ' . $name;?></a></div>
<?php endforeach;?>
</div>
<?php endif;?>