From 6750bed4544d4ef03977dfaf0fed603e8ab68c3c Mon Sep 17 00:00:00 2001 From: daitingting Date: Thu, 20 Oct 2022 01:41:01 +0000 Subject: [PATCH] * Finish task #71572. --- module/execution/js/common.js | 2 +- module/execution/js/edit.js | 63 ++++++++++++++++++++--------- module/execution/view/edit.html.php | 2 +- module/project/js/manageproducts.js | 8 ++-- module/project/model.php | 2 +- 5 files changed, 49 insertions(+), 28 deletions(-) diff --git a/module/execution/js/common.js b/module/execution/js/common.js index 2011db324c..c49d678d02 100644 --- a/module/execution/js/common.js +++ b/module/execution/js/common.js @@ -142,7 +142,7 @@ function loadBranches(product) if(typeof(projectID) == 'undefined') projectID = 0; var index = $inputgroup.find('select:first').attr('id').replace('products' , ''); - $.get(createLink('branch', 'ajaxGetBranches', "productID=" + $(product).val() + "&oldBranch=¶m=active&projectID=" + projectID + "&withMainBranch=true"), function(data) + $.get(createLink('branch', 'ajaxGetBranches', "productID=" + $(product).val() + "&oldBranch=0¶m=active&projectID=" + projectID + "&withMainBranch=true"), function(data) { if(data) { diff --git a/module/execution/js/edit.js b/module/execution/js/edit.js index 87b8d8de54..820c795f5e 100644 --- a/module/execution/js/edit.js +++ b/module/execution/js/edit.js @@ -37,33 +37,56 @@ $().ready(function() $(function() { - /* 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"); + var current = $(this).val(); + var last = $(this).attr('data-last'); + var lastBranch = $(this).attr('data-lastBranch'); - var productTip = tip.replace('%s', linkedStoryIDList[$(this).attr('data-last')][0]); - $(this).siblings('div').find('span').attr('title', productTip); + $(this).attr('data-last', current); + + var $branch = $(this).closest('.has-branch').find("[name^='branch']"); + if($branch.length) + { + var branchID = $branch.val(); + $(this).attr('data-lastBranch', branchID); + } + else + { + $(this).removeAttr('data-lastBranch'); + } + + if(current != last && $.inArray(last, unmodifiableProducts) != -1) + { + if(lastBranch) + { + if($.inArray(lastBranch, unmodifiableBranches) != -1) + { + if(linkedStoryIDList[last][lastBranch]) bootbox.alert(tip.replace('%s', linkedStoryIDList[last][lastBranch])); + } + } + else + { + bootbox.alert(tip.replace('%s', linkedStoryIDList[last][0])); + } } }); - $("#productsBox select[name^='branch']").each(function() + $(document).on('change', '[name*=branch]', function() { - var isExistedBranch = $.inArray($(this).attr('data-last'), unmodifiableBranches); - if(isExistedBranch != -1) - { - var $product = $(this).closest('.has-branch').find("[name^='products']"); - if($.inArray($product.val(), unmodifiableProducts) != -1 && linkedStoryIDList[$product.val()][$(this).attr('data-last')]) - { - $(this).prop('disabled', true).trigger("chosen:updated"); - $product.prop('disabled', true).trigger("chosen:updated"); + var current = $(this).val(); + var last = $(this).attr('data-last'); + $(this).attr('data-last', current); - var productTip = tip.replace('%s', linkedStoryIDList[$product.val()][$(this).attr('data-last')]); - $product.siblings('div').find('span').attr('title', productTip); + 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 && linkedStoryIDList[productID][last]) + { + bootbox.alert(tip.replace('%s', linkedStoryIDList[productID][last])); } } }); diff --git a/module/execution/view/edit.html.php b/module/execution/view/edit.html.php index 9256687b37..4e9cf0df9d 100644 --- a/module/execution/view/edit.html.php +++ b/module/execution/view/edit.html.php @@ -152,7 +152,7 @@ id] as $branchID => $branch):?>
- id, "class='form-control chosen' $class onchange='loadBranches(this)' data-last='" . $product->id . "' data-type='". $product->type ."'");?> + id, "class='form-control chosen' $class onchange='loadBranches(this)' data-last='" . $product->id . "' data-type='". $product->type ."' data-lastBranch='" . $branchID . "'");?> id], $branchID, "class='form-control chosen' $class onchange=\"loadPlans('#products{$i}', this.value)\" data-last='" . $branchID . "'");?>
diff --git a/module/project/js/manageproducts.js b/module/project/js/manageproducts.js index 5fb05d3dfc..cff7f15591 100644 --- a/module/project/js/manageproducts.js +++ b/module/project/js/manageproducts.js @@ -11,18 +11,16 @@ $(function() var $cb = $(this); $cb.closest('.product').toggleClass('checked', $cb.prop('checked')); + if($cb.prop('checked')) return true; + var productID = String($cb.val()); if($.inArray(productID, unmodifiableProducts) != -1) { var $branch = $cb.closest('.product').find('[name^=branch]'); - if($branch) + if($branch.length) { var branchID = String($branch.val()); - console.log(productID); - console.log(unmodifiableMainBranches); - console.log($.inArray(productID, unmodifiableMainBranches)); - if((branchID == BRANCH_MAIN && unmodifiableMainBranches[productID]) || (branchID != BRANCH_MAIN && $.inArray(branchID, unmodifiableBranches) != -1)) { bootbox.alert(unLinkProductTip.replace("%s", branchGroups[productID][branchID])); diff --git a/module/project/model.php b/module/project/model.php index b06821c42f..0f6f1a3343 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -916,7 +916,7 @@ class projectModel extends model */ public function getProjectExecutionPairs() { - return $this->dao->select('project, id')->from(TABLE_PROJECT)->where('type')->eq('sprint')->andWhere('multiple')->eq('0')->andWhere('deleted')->eq('0')->fetchPairs(); + return $this->dao->select('project, id')->from(TABLE_PROJECT)->andWhere('multiple')->eq('0')->andWhere('deleted')->eq('0')->fetchPairs(); } /**