diff --git a/module/branch/control.php b/module/branch/control.php index 6f497f7abb..fed3f32882 100644 --- a/module/branch/control.php +++ b/module/branch/control.php @@ -280,7 +280,7 @@ class branch extends control $branchTagOption[$oldBranch] = $oldBranch == BRANCH_MAIN ? $branch : ($branch->name . ($branch->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : '')); } - return print(html::select('branch', $branchTagOption, $oldBranch, "class='form-control' onchange='loadBranch(this)'")); + return print(html::select('branch', $branchTagOption, $oldBranch, "class='form-control' onchange='loadBranch(this)' data-last='{$oldBranch}'")); } /** diff --git a/module/program/model.php b/module/program/model.php index 887ba28a02..6bda90a163 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -76,16 +76,15 @@ class programModel extends model if($programID) { $program = $this->getByID($programID); - $path = explode(',', $program->path); - $path = array_filter($path); + $path = array_filter(explode(',', $program->path)); $programID = current($path); } /* When mode equals assign and programID equals 0, you can query the standalone product. */ if(!empty($append) and is_array($append)) $append = implode(',', $append); + $views = empty($append) ? $this->app->user->view->products : $this->app->user->view->products . ",$append"; - $views = empty($append) ? $this->app->user->view->products : $this->app->user->view->products . ",$append"; - $products = $this->dao->select('*')->from(TABLE_PRODUCT) + return $this->dao->select('*')->from(TABLE_PRODUCT) ->where('deleted')->eq(0) ->andWhere('vision')->eq($this->config->vision) ->beginIF($shadow !== 'all')->andWhere('shadow')->eq((int)$shadow)->fi() @@ -93,7 +92,6 @@ class programModel extends model ->beginIF(strpos($status, 'noclosed') !== false)->andWhere('status')->ne('closed')->fi() ->beginIF(!$this->app->user->admin)->andWhere('id')->in($views)->fi() ->fetchPairs('id', 'name'); - return $products; } /** diff --git a/module/project/control.php b/module/project/control.php index 3ccde8ccd3..0498d41b64 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -280,7 +280,7 @@ class project extends control $data['selectedProgramPath'] = explode(',', $selectedProgram->path); } - $allProducts = array(0 => '') + $this->program->getProductPairs($selectedProgramID, 'assign', 'noclosed'); + $allProducts = array(0 => '') + $this->program->getProductPairs(0, 'all', 'noclosed'); $data['allProducts'] = html::select("products[0]", $allProducts, '', "class='form-control chosen' onchange='loadBranches(this)'"); $data['plans'] = html::select('plans[][][]', '', '', 'class=\'form-control chosen\' multiple'); @@ -540,25 +540,24 @@ class project extends control } } - if($this->app->tab == 'program' and $programID) $this->loadModel('program')->setMenu($programID); - if($this->app->tab == 'doc') unset($this->lang->doc->menu->project['subMenu']); + if($this->app->tab == 'program' and $programID) $this->loadModel('program')->setMenu($programID); if($this->app->tab == 'product' and !empty($output['productID'])) $this->loadModel('product')->setMenu($output['productID']); + if($this->app->tab == 'doc') unset($this->lang->doc->menu->project['subMenu']); $this->session->set('projectModel', $model); $extra = str_replace(array(',', ' '), array('&', ''), $extra); parse_str($extra, $output); - $name = ''; - $code = ''; - $team = ''; - $whitelist = ''; - $acl = 'private'; - $auth = 'extend'; - $hasProduct = 1; - + $name = ''; + $code = ''; + $team = ''; + $whitelist = ''; + $acl = 'private'; + $auth = 'extend'; + $hasProduct = 1; + $shadow = 0; $products = array(); $productPlans = array(); - $shadow = 0; $parentProgram = $this->loadModel('program')->getByID($programID); if($copyProjectID) @@ -567,12 +566,12 @@ class project extends control $name = $copyProject->name; $code = $copyProject->code; $team = $copyProject->team; + $whitelist = $copyProject->whitelist; $acl = $copyProject->acl; $auth = $copyProject->auth; - $whitelist = $copyProject->whitelist; + $hasProduct = $copyProject->hasProduct; $programID = $copyProject->parent; $model = $copyProject->model; - $hasProduct = $copyProject->hasProduct; $products = $this->product->getProducts($copyProjectID); if(!$copyProject->hasProduct) $shadow = 1; @@ -598,14 +597,13 @@ class project extends control $this->config->executionCommonList[$this->app->getClientLang()][0] : $this->config->executionCommonList[$this->app->getClientLang()][1]; - $this->view->title = $this->lang->project->create; - + $this->view->title = $this->lang->project->create; $this->view->gobackLink = (isset($output['from']) and $output['from'] == 'global') ? $this->createLink('project', 'browse') : ''; $this->view->pmUsers = $this->loadModel('user')->getPairs('noclosed|nodeleted|pmfirst'); $this->view->users = $this->user->getPairs('noclosed|nodeleted'); $this->view->copyProjects = $this->project->getPairsByModel($model); $this->view->products = $products; - $this->view->allProducts = array('0' => '') + $this->program->getProductPairs($programID, 'assign', 'noclosed', '', $shadow); + $this->view->allProducts = array('0' => '') + $this->program->getProductPairs(0, 'all', 'noclosed', '', $shadow); $this->view->productPlans = array('0' => '') + $productPlans; $this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products), 'noclosed'); $this->view->programID = $programID; @@ -713,7 +711,7 @@ class project extends control $productPlans = array(0 => ''); $branches = $this->project->getBranchesByProject($projectID); $linkedProductIdList = empty($branches) ? '' : array_keys($branches); - $allProducts = $this->program->getProductPairs($project->parent, 'assign', 'noclosed', $linkedProductIdList); + $allProducts = $this->program->getProductPairs(0, 'all', 'noclosed', $linkedProductIdList); $linkedProducts = $this->loadModel('product')->getProducts($projectID, 'all', '', true, $linkedProductIdList); $parentProject = $this->program->getByID($project->parent); $plans = $this->productplan->getGroupByProduct(array_keys($linkedProducts), 'skipParent|unexpired'); diff --git a/module/project/js/edit.js b/module/project/js/edit.js index 20ea121d62..b6118eca99 100644 --- a/module/project/js/edit.js +++ b/module/project/js/edit.js @@ -66,37 +66,66 @@ $(function() adjustProductBoxMargin(); adjustPlanBoxMargin(); - /* If the story of the product which linked the execution under the project, you don't allow to remove the product. */ - $("#productsBox select[name^='products']").each(function() + $(document).on('change', '[name*=products]', function() { - var isExistedProduct = $.inArray($(this).attr('data-last'), unmodifiableProducts); - var productType = $(this).attr('data-type'); - if(isExistedProduct != -1 && productType == 'normal') - { - $(this).prop('disabled', true).trigger("chosen:updated"); - $(this).siblings('div').find('span').attr('title', tip); - } - }); + var current = $(this).val(); + var last = $(this).attr('data-last'); + var lastBranch = $(this).attr('data-lastBranch'); - $("#productsBox select[name^='branch']").each(function() - { - var branchID = $(this).attr('data-last'); - var isExistedBranch = $.inArray(branchID, unmodifiableBranches); - if(isExistedBranch != -1) + $(this).attr('data-last', current); + + var $branch = $(this).closest('.has-branch').find("[name^='branch']"); + if($branch !== undefined) { - var $product = $(this).closest('.has-branch').find("[name^='products']"); - if($.inArray($product.val(), unmodifiableProducts) != -1) + var branchID = $branch.val(); + $(this).attr('data-lastBranch', branchID); + } + else + { + $(this).removeAttr('data-lastBranch'); + } + + if(current != last && $.inArray(last, unmodifiableProducts) != -1) + { + if(lastBranch) { - if((branchID == 0 && unmodifiableMainBranches[$product.val()]) || branchID != 0) + if($.inArray(lastBranch, unmodifiableBranches) != -1) { - $(this).prop('disabled', true).trigger("chosen:updated"); - $product.prop('disabled', true).trigger("chosen:updated"); - $product.siblings('div').find('span').attr('title', tip); + if((lastBranch == 0 && unmodifiableMainBranches[last]) || lastBranch != 0) + { + bootbox.alert(unLinkProductTip.replace("%s", allProducts[last])); + } } } + else + { + bootbox.alert(unLinkProductTip.replace("%s", allProducts[last])); + } } }); + $(document).on('change', '[name*=branch]', function() + { + var current = $(this).val(); + var last = $(this).attr('data-last'); + $(this).attr('data-last', current); + + var $product = $(this).closest('.has-branch').find("[name^='products']"); + $product.attr('data-lastBranch', current); + + if($.inArray(last, unmodifiableBranches) != -1) + { + var productID = $product.val(); + if($.inArray(productID, unmodifiableProducts) != -1) + { + if((last == 0 && unmodifiableMainBranches[productID]) || last != 0) + { + bootbox.alert(unLinkProductTip.replace("%s", branchGroups[productID][last])); + } + } + } + }) + /* If end is longtime, set the default date to today */ var today = $.zui.formatDate(new Date(), 'yyyy-MM-dd'); if($('#end').val() == longTime) $('#end').val(today).datetimepicker('update').val(longTime); diff --git a/module/project/lang/de.php b/module/project/lang/de.php index e501303e59..6821428ae0 100644 --- a/module/project/lang/de.php +++ b/module/project/lang/de.php @@ -211,6 +211,7 @@ $lang->project->noDevStage = 'There is no R&D stage under this proje $lang->project->budgetOverrun = "The project's budget exceeds the remaining budget of the parent program:"; $lang->project->disabledInputTip = 'Please cancel %s first'; $lang->project->linkRepoFailed = 'Failed to link projects and code repositories.'; +$lang->project->unLinkProductTip = 'Are you sure you want to unlink %s? (Does not affect linked requirements)'; $lang->project->tenThousand = ''; $lang->project->hundredMillion = 'Hundred Million'; diff --git a/module/project/lang/en.php b/module/project/lang/en.php index 2197ff2083..f174343745 100644 --- a/module/project/lang/en.php +++ b/module/project/lang/en.php @@ -211,6 +211,7 @@ $lang->project->noDevStage = 'There is no R&D stage under this proje $lang->project->budgetOverrun = "The project's budget exceeds the remaining budget of the parent program:"; $lang->project->disabledInputTip = 'Please cancel %s first'; $lang->project->linkRepoFailed = 'Failed to link projects and code repositories.'; +$lang->project->unLinkProductTip = 'Are you sure you want to unlink %s? (Does not affect linked requirements)'; $lang->project->tenThousand = 'Ten Thousand'; $lang->project->hundredMillion = 'Hundred Million'; diff --git a/module/project/lang/fr.php b/module/project/lang/fr.php index 0c9044919b..c718a93124 100644 --- a/module/project/lang/fr.php +++ b/module/project/lang/fr.php @@ -210,6 +210,7 @@ $lang->project->noDevStage = "Il n'y a pas de phase R&D dans ce proj $lang->project->budgetOverrun = "Le budget du projet a dépassé le budget restant du programme parent:"; $lang->project->disabledInputTip = 'Please cancel %s first'; $lang->project->linkRepoFailed = 'Failed to link projects and code repositories.'; +$lang->project->unLinkProductTip = 'Are you sure you want to unlink %s? (Does not affect linked requirements)'; $lang->project->tenThousand = ''; $lang->project->hundredMillion = 'Hundred Million'; diff --git a/module/project/lang/zh-cn.php b/module/project/lang/zh-cn.php index ee902eaa1b..4144a5d604 100644 --- a/module/project/lang/zh-cn.php +++ b/module/project/lang/zh-cn.php @@ -211,6 +211,7 @@ $lang->project->noDevStage = '该项目下没有研发类型的阶 $lang->project->budgetOverrun = '项目的预算超出了父项目集的剩余预算:'; $lang->project->disabledInputTip = '请先取消%s'; $lang->project->linkRepoFailed = '关联代码库失败'; +$lang->project->unLinkProductTip = "您确认要取消与%s的关联关系吗?(不影响已关联的需求)"; $lang->project->tenThousand = '万'; $lang->project->hundredMillion = '亿'; diff --git a/module/project/view/edit.html.php b/module/project/view/edit.html.php index 684714d013..eefb607f35 100755 --- a/module/project/view/edit.html.php +++ b/module/project/view/edit.html.php @@ -37,6 +37,9 @@ project->beginLetterParent);?> project->endGreaterParent);?> project->ignore);?> + + +project->unLinkProductTip);?>