From 574ecd7bd32bd243034e421b108b6b620071fedc Mon Sep 17 00:00:00 2001 From: tianshujie98 Date: Fri, 16 Jul 2021 14:12:08 +0800 Subject: [PATCH] * Fix the issue #173. --- module/upgrade/css/mergeprogram.css | 2 +- module/upgrade/js/mergeprogram.js | 317 ++++++++++---------- module/upgrade/view/mergebyline.html.php | 4 +- module/upgrade/view/mergebyproduct.html.php | 4 +- module/upgrade/view/mergebysprint.html.php | 2 +- 5 files changed, 164 insertions(+), 165 deletions(-) diff --git a/module/upgrade/css/mergeprogram.css b/module/upgrade/css/mergeprogram.css index fdc6cb3c64..e04fac1821 100644 --- a/module/upgrade/css/mergeprogram.css +++ b/module/upgrade/css/mergeprogram.css @@ -14,7 +14,7 @@ div.divider {vertical-align: middle;} .main-row {margin-top: 20px; padding: 20px; background: #f1f1f1;} .main-row .side-col .nav li.active div a {background: #006af1; color: #fff; border-radius: 4px;} -.main-row .side-col .nav li div a {width: 80%; display: inline-block; padding: 8px 15px;} +.main-row .side-col .nav li div a {width: 80%; display: inline-block; padding: 5px 15px; margin-bottom: 5px;} #lineBox > .cell {height: 700px;} #source > .cell {padding: 0; position: relative; height: 700px;} diff --git a/module/upgrade/js/mergeprogram.js b/module/upgrade/js/mergeprogram.js index 1208c87462..556761523c 100644 --- a/module/upgrade/js/mergeprogram.js +++ b/module/upgrade/js/mergeprogram.js @@ -1,37 +1,5 @@ $(function() { - if($('[id^=productLines]').length > 0) - { - var checkedProduct = true; - var productLine = $('.nav li.active').attr('lineid'); - var productNum = $("[id^='products\[" + productLine + "\]']").length; - var checkedProductNum = $("[id^='products\[" + productLine + "\]']:checked").length; - - if(productNum > checkedProductNum) checkedProduct = false; - $("[id^='productLines\[" + productLine + "\]']").prop('checked', checkedProduct); - $('#checkAllProducts').prop('checked', checkedProduct); - $('#checkAllProjects').prop('checked', checkedProduct); - } - else if($('[id^=products]').length > 0) - { - var checkedProduct = true; - var productNum = $("[id^='products'").length; - var checkedProductNum = $("[id^='products']:checked").length; - - if(productNum > checkedProductNum) checkedProduct = false; - $('#checkAllProducts').prop('checked', checkedProduct); - $('#checkAllProjects').prop('checked', checkedProduct); - } - else if($('[id^=sprints]').length > 0) - { - var checkedProject = true; - var projectNum = $("[id^='sprints'").length; - var checkedProjectNum = $("[id^='sprints']:checked").length; - - if(projectNum > checkedProjectNum) checkedProject = false; - $('#checkAllProjects').prop('checked', checkedProject); - } - /* Define drag to select relevant parameters. */ var options = { selector: 'input', @@ -44,104 +12,119 @@ $(function() var checkedLines = true; var checkedProduct = true; var checkedProject = true; + var type = $('[data-id=' + e.id + ']').attr('name'); /* Select the product line of the current page. */ - if($('.nav li.active').find('[id^=productLines]').prop('checked')) + if(typeof(type) != 'undefined' && type.indexOf('productLines') > -1) { - var lineID = $('.nav li.active').attr('lineid'); - $('#checkAllProducts').prop('checked', true); - $('#checkAllProjects').prop('checked', true); - $("[id^='products\[" + lineID + "\]']").prop('checked', true); - $("[id^='sprints\[" + lineID + "\]'").prop('checked', true); + if($('.nav li.currentPage').find('[id^=productLines]').prop('checked')) + { + var lineID = $('.nav li.active').attr('lineid'); + $('#checkAllProducts').prop('checked', true); + $('#checkAllProjects').prop('checked', true); + $("[id^='products\[" + lineID + "\]']").prop('checked', true); + $("[id^='sprints\[" + lineID + "\]'").prop('checked', true); + } } /* All products selected. */ - if($('[id^=productLines]').length > 0) + if(typeof(type) != 'undefined' && type.indexOf('products') > -1) { - $("[id^='products\[" + lineID + "\]']").each(function() - { - if(!$(this).prop('checked')) - { - checkedProduct = false; - } - else - { - $('[data-product=' + $(this).val() +']').prop('checked', true); - } - }) - $("[id^='productLines\[" + lineID + "\]']").prop('checked', checkedProduct); - } - else - { - $("[id^=products]").each(function() - { - if(!$(this).prop('checked')) - { - checkedProduct = false; - } - else - { - $('[data-product=' + $(this).val() +']').prop('checked', true); - } - }) - } - $('#checkAllProducts').prop('checked', checkedProduct); - - /* All projects selected. */ - if($('[id^=productLines]').length > 0) - { - $("[id^='sprints\[" + lineID + "\]']").each(function() + if($('[id^=productLines]').length > 0) { - if(!$(this).prop('checked')) + $("[id^='products\[" + lineID + "\]']").each(function() { - checkedProject = false; - } - else - { - var productID = $(this).attr('data-product'); - if(productID && $('[data-productid=' + productID + ']').length > 0 && !$('[data-productid=' + productID + ']').prop('checked')) $('[data-productid=' + productID + ']').prop('checked', true); - } - }) - } - else if($('[id^=products]').length > 0) - { - $("[id^=sprints]").each(function() - { - if(!$(this).prop('checked')) - { - checkedProject = false; - } - else - { - var productID = $(this).attr('data-product'); - if(productID && $('[data-productid=' + productID + ']').length > 0 && !$('[data-productid=' + productID + ']').prop('checked')) $('[data-productid=' + productID + ']').prop('checked', true); - } - }) - } - else - { - var projectNum = $("[id^='sprints'").length; - var checkedProjectNum = $("[id^='sprints']:checked").length; - - if(projectNum > checkedProjectNum) checkedProject = false; - } - $('#checkAllProjects').prop('checked', checkedProject); - - /* All product lines selected. */ - $('[name^=productLines]').each(function() - { - if(!$(this).prop('checked')) - { - checkedLines = false; + if(!$(this).prop('checked')) + { + checkedProduct = false; + } + else + { + $('[data-product=' + $(this).val() +']').prop('checked', true); + $("[id^='productLines\[" + lineID + "\]']").prop('checked', true); + } + }) } else { - var productLine = $(this).val(); - $("[id^='products\[" + productLine + "\]']").prop('checked', true); - $("[id^='sprints\[" + productLine + "\]']").prop('checked', true); + $("[id^=products]").each(function() + { + if(!$(this).prop('checked')) + { + checkedProduct = false; + } + else + { + $('[data-product=' + $(this).val() +']').prop('checked', true); + } + }) } - }) - $('#checkAllLines').prop('checked', checkedLines); + $('#checkAllProducts').prop('checked', checkedProduct); + } + + /* All projects selected. */ + if(typeof(type) != 'undefined' && type.indexOf('sprints') > -1) + { + if($('[id^=productLines]').length > 0) + { + $("[id^='sprints\[" + lineID + "\]']").each(function() + { + if(!$(this).prop('checked')) + { + checkedProject = false; + } + else + { + var productID = $(this).attr('data-product'); + if(productID && $('[data-productid=' + productID + ']').length > 0 && !$('[data-productid=' + productID + ']').prop('checked')) $('[data-productid=' + productID + ']').prop('checked', true); + $("[id^='productLines\[" + lineID + "\]']").prop('checked', true); + } + }) + } + else if($('[id^=products]').length > 0) + { + $("[id^=sprints]").each(function() + { + if(!$(this).prop('checked')) + { + checkedProject = false; + } + else + { + var productID = $(this).attr('data-product'); + if(productID && $('[data-productid=' + productID + ']').length > 0 && !$('[data-productid=' + productID + ']').prop('checked')) $('[data-productid=' + productID + ']').prop('checked', true); + } + }) + } + else + { + var projectNum = $("[id^='sprints'").length; + var checkedProjectNum = $("[id^='sprints']:checked").length; + + if(projectNum > checkedProjectNum) checkedProject = false; + } + $('#checkAllProjects').prop('checked', checkedProject); + } + + /* All product lines selected. */ + if(typeof(type) != 'undefined' && type.indexOf('productLines') > -1) + { + $('[name^=productLines]').each(function() + { + if(!$(this).prop('checked')) + { + checkedLines = false; + } + else + { + var productLine = $(this).val(); + $('[lineid=' + productLine + ']').addClass('active'); + $("[id^='products\[" + productLine + "\]']").prop('checked', true); + $("[id^='sprints\[" + productLine + "\]']").prop('checked', true); + } + }) + $('#checkAllLines').prop('checked', checkedLines); + } /* If the project is checked, the relevant form will be displayed according to the selected mode. */ hiddenProject(); @@ -166,6 +149,7 @@ $(function() $('[name^=productLines]').prop('checked', true); $('[name^=products]').prop('checked', true); $('[name^=sprints]').prop('checked', true); + $('.main-row .side-col .nav li').addClass('active'); } else { @@ -174,6 +158,7 @@ $(function() $('[name^=productLines]').prop('checked', false); $('[name^=products]').prop('checked', false); $('[name^=sprints]').prop('checked', false); + $('.main-row .side-col .nav li').removeClass('active'); } /* If the project is checked, the relevant form will be displayed according to the selected mode. */ @@ -243,6 +228,7 @@ $(function() $('#checkAllProjects').prop('checked', true); } $('[data-line=' + value + ']').prop('checked', true); + $('[lineid=' + value + ']').addClass('active'); } else { @@ -253,6 +239,7 @@ $(function() $('#checkAllProjects').prop('checked', false); } $('[data-line=' + value + ']').prop('checked', false); + $('[lineid=' + value + ']').removeClass('active'); } /* Determine whether all product line buttons are selected. */ @@ -306,19 +293,29 @@ $(function() $('#end').removeAttr('disabled'); } + var currentLine = $(this).closest('li').attr('lineid'); + $(this).closest('li').addClass('currentPage'); + /* Active current li and remove active before li. */ - $(this).closest('ul').find('li').removeClass('active'); $(this).closest('li').addClass('active'); + $('[id^=productLines]').each(function() + { + var lineID = $(this).val(); + if($("[id^='productLines\[" + lineID +"\]'").prop('checked') || lineID == currentLine) + { + $(this).closest('li').addClass('active'); + } + else + { + $(this).closest('li').removeClass('currentPage'); + $(this).closest('li').removeClass('active'); + } + }) /* Show current data and hide before data. */ var target = $(this).attr('data-target'); $('.lineBox').addClass('hidden'); $(target).removeClass('hidden'); - $('#source').find('.lineBox :checkBox').prop('checked', false); - - /* The first group of products is selected by default. */ - var firstProduct = $(target).find(":checkbox:first").prop('checked', true); - $('[data-product=' + firstProduct.val() + ']').prop('checked', true); /* Replace program name. */ $('#programName').val($(this).text()); @@ -346,10 +343,15 @@ $(function() } else if($(this).closest("li").find('[id^=productLines]').prop('checked')) { - var productLine = $('.nav li.active').attr('lineid'); - $('#checkAllProducts').prop('checked', true); - $('#checkAllProjects').prop('checked', true); - $('[data-line=' + productLine + ']').prop('checked', true); + var productLine = $('.nav li.active').attr('lineid'); + var objectNum = $('[data-line='+ productLine +']').length; + var checkedObjectNum = $('[data-line='+ productLine +']:checked').length; + if(objectNum == checkedObjectNum) + { + $('#checkAllProducts').prop('checked', true); + $('#checkAllProjects').prop('checked', true); + $('[data-line=' + productLine + ']').prop('checked', true); + } } else { @@ -357,42 +359,30 @@ $(function() $('#checkAllProjects').prop('checked', false); } - /* Determine whether all products and all projects buttons are selected. */ - var checkedProduct = true; - var productLine = $('.nav li.active').attr('lineid'); - var productNum = $("[id^='products\[" + productLine + "\]'").length; - var checkedProductNum = $("[id^='products\[" + productLine + "\]']:checked").length; - - if(productNum > checkedProductNum) checkedProduct = false; - $('#checkAllProducts').prop('checked', checkedProduct); - $('#checkAllProjects').prop('checked', checkedProduct); - $("[id^='productLines\[" + productLine + "\]']").prop('checked', checkedProduct); - /* Determines whether to display an project related form control. */ hiddenProject(); - - /* If the product line is selected, the product and project are selected by default. */ - $('[id^=productLines]').each(function() - { - if($(this).prop('checked')) - { - $('[data-line=' + $(this).val() +']').prop('checked', true); - } - }) }) $('[name^=products]').change(function() { setProgramByProduct($(this)); - var checked = true; - var lineID = $(this).attr('data-line'); + var checked = true; + var checkedLine = true; + var lineID = $(this).attr('data-line'); if($('[id^=productLines]').length > 0) { var productNum = $("[id^='products\[" + lineID + "\]'").length; var checkedProductNum = $("[id^='products\[" + lineID + "\]']:checked").length; if(productNum > checkedProductNum) checked = false; + if(checkedProductNum > 0) $('[lineid=' + lineID + ']').addClass('active'); + if(checkedProductNum == 0) + { + $('[lineid=' + lineID + ']').removeClass('active'); + checkedLine = false; + } + $("[id^='productLines\[" + lineID + "\]']").prop('checked', checkedLine); } else if($('[id^=products]').length > 0) { @@ -403,7 +393,6 @@ $(function() } $('#checkAllProducts').prop('checked', checked); - $("[id^='productLines\[" + lineID + "\]']").prop('checked', checked); value = $(this).val(); if($(this).prop('checked')) @@ -443,6 +432,16 @@ $(function() $('[name^=sprints]').change(function() { + if($(this).prop('checked')) + { + if(lineID && $('[data-lineid=' + lineID + ']').length > 0 && !$('[data-lineid=' + lineID + ']').prop('checked')) $('[data-lineid=' + lineID + ']').prop('checked', true); + + var productID = $(this).attr('data-product'); + if(productID && $('[data-productid=' + productID + ']').length > 0 && !$('[data-productid=' + productID + ']').prop('checked')) $('[data-productid=' + productID + ']').prop('checked', true); + + setProgramByProduct($(':checkbox[data-productid=' + productID + ']')); + } + var checked = true; var checkedProduct = true; if($('[id^=productLines]').length > 0) @@ -456,6 +455,15 @@ $(function() var productNum = $("[id^='products\[" + lineID + "\]'").length; var checkedProductNum = $("[id^='products\[" + lineID + "\]']:checked").length; if(productNum > checkedProductNum) checkedProduct = false; + + var checkedLine = true; + if(checkedProductNum > 0) $('[lineid=' + lineID + ']').addClass('active'); + if(checkedProductNum == 0) + { + $('[lineid=' + lineID + ']').removeClass('active'); + checkedLine = false; + } + $("[id^='productLines\["+ lineID +"\]").prop('checked', checkedLine); } else if($('[id^=products]').length > 0) { @@ -480,15 +488,6 @@ $(function() $('#checkAllProjects').prop('checked', checked); $('#checkAllProducts').prop('checked', checkedProduct); - if($(this).prop('checked')) - { - if(lineID && $('[data-lineid=' + lineID + ']').length > 0 && !$('[data-lineid=' + lineID + ']').prop('checked')) $('[data-lineid=' + lineID + ']').prop('checked', true); - - var productID = $(this).attr('data-product'); - if(productID && $('[data-productid=' + productID + ']').length > 0 && !$('[data-productid=' + productID + ']').prop('checked')) $('[data-productid=' + productID + ']').prop('checked', true); - - setProgramByProduct($(':checkbox[data-productid=' + productID + ']')); - } setProgramBegin(programBegin); setProgramEnd(programEnd); setProjectPM(); diff --git a/module/upgrade/view/mergebyline.html.php b/module/upgrade/view/mergebyline.html.php index b245cecad0..d340171e8a 100644 --- a/module/upgrade/view/mergebyline.html.php +++ b/module/upgrade/view/mergebyline.html.php @@ -45,14 +45,14 @@ id] as $productID => $product):?>
- id]", array($productID => $product->name), $i == 0 ? $product->id : 0, "title='{$product->name}' data-productid='{$product->id}' data-line='{$line->id}' data-begin='{$product->createdDate}' data-programid='{$product->program}' class='tile'");?> + id]", array($productID => $product->name), '', "title='{$product->name}' data-productid='{$product->id}' data-line='{$line->id}' data-begin='{$product->createdDate}' data-programid='{$product->program}' class='tile'");?> id][$productID]", $productID);?>
- id][$productID]", array($sprint->id => $sprint->name), $i == 0 ? $sprint->id : 0, "title='{$sprint->name}' data-product='{$product->id}' data-line='{$line->id}' data-begin='{$sprint->begin}' data-end='{$sprint->end}' data-status='{$sprint->status}' data-pm='{$sprint->PM}' class='tile'");?> + id][$productID]", array($sprint->id => $sprint->name), '', "title='{$sprint->name}' data-product='{$product->id}' data-line='{$line->id}' data-begin='{$sprint->begin}' data-end='{$sprint->end}' data-status='{$sprint->status}' data-pm='{$sprint->PM}' class='tile'");?> id][$productID][$sprint->id]", $sprint->id);?> diff --git a/module/upgrade/view/mergebyproduct.html.php b/module/upgrade/view/mergebyproduct.html.php index 19739ac38c..00264ce5cf 100644 --- a/module/upgrade/view/mergebyproduct.html.php +++ b/module/upgrade/view/mergebyproduct.html.php @@ -24,13 +24,13 @@ $product):?>
- id => $product->name), $isChecked ? $product->id : '', "data-productid='{$product->id}' data-begin='{$product->createdDate}' data-programid='{$product->program}'");?> + id => $product->name), '', "data-productid='{$product->id}' data-begin='{$product->createdDate}' data-programid='{$product->program}'");?>
- id => $sprint->name), $isChecked ? $sprint->id : '', "data-product='{$productID}' data-begin='{$sprint->begin}' data-end='{$sprint->end}' data-status='{$sprint->status}' data-pm='{$sprint->PM}'");?> + id => $sprint->name), '', "data-product='{$productID}' data-begin='{$sprint->begin}' data-end='{$sprint->end}' data-status='{$sprint->status}' data-pm='{$sprint->PM}'");?> id]", $sprint->id);?> diff --git a/module/upgrade/view/mergebysprint.html.php b/module/upgrade/view/mergebysprint.html.php index 54a38be703..cb76631ebf 100644 --- a/module/upgrade/view/mergebysprint.html.php +++ b/module/upgrade/view/mergebysprint.html.php @@ -14,7 +14,7 @@
$sprint):?> - id => $sprint->name), $sprint->id, "data-begin='{$sprint->begin}' data-end='{$sprint->end}' data-status='{$sprint->status}' data-pm='{$sprint->PM}'");?> + id => $sprint->name), '', "data-begin='{$sprint->begin}' data-end='{$sprint->end}' data-status='{$sprint->status}' data-pm='{$sprint->PM}'");?>