From 9e59413f9ffcf76d2ca26f94987550705f3644c3 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 10 Jan 2024 09:39:59 +0800 Subject: [PATCH] * Fix bug #42514. --- module/execution/ui/create.html.php | 2 +- module/file/ui/export.html.php | 2 +- module/project/js/create.ui.js | 24 +++++++++++++++--------- module/project/ui/create.html.php | 11 ++++++----- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/module/execution/ui/create.html.php b/module/execution/ui/create.html.php index a1dc74217e..240edaaf42 100644 --- a/module/execution/ui/create.html.php +++ b/module/execution/ui/create.html.php @@ -82,7 +82,7 @@ if((empty($project) || $project->model != 'kanban') && $execution->type != 'kanb } $productsBox = null; -if(!empty($project->hasProduct) && $products && $copyExecutionID > 0) +if(!empty($project->hasProduct) && ($products || $copyExecutionID > 0)) { $i = 0; foreach($products as $product) diff --git a/module/file/ui/export.html.php b/module/file/ui/export.html.php index 28d000f1dd..93aa9bb72c 100644 --- a/module/file/ui/export.html.php +++ b/module/file/ui/export.html.php @@ -123,7 +123,7 @@ formPanel ( set::width('full'), set::label($lang->file->fileName), - set::control('inputControl'), + set::control('text'), set::name('fileName'), set::value(isset($fileName) ? $fileName : $lang->file->untitled), on::change('onChangeFileName'), diff --git a/module/project/js/create.ui.js b/module/project/js/create.ui.js index 3f4f6d5e41..94a68b8600 100644 --- a/module/project/js/create.ui.js +++ b/module/project/js/create.ui.js @@ -49,25 +49,25 @@ window.addProduct = function(e) } } -window.productChange = function(e) +window.productChange = function(target) { - loadBranches(e.target); + loadBranches(target); - let current = $(e.target).val(); - let last = $(e.target).attr('last'); - let lastBranch = $(e.target).attr('data-lastBranch'); + let current = $(target).val(); + let last = $(target).attr('last'); + let lastBranch = $(target).attr('data-lastBranch'); - $(e.target).attr('data-last', current); + $(target).attr('data-last', current); - let $branch = $(e.target).closest('.has-branch').find("[name^='branch']"); + let $branch = $(target).closest('.has-branch').find("[name^='branch']"); if($branch.length) { let branchID = $branch.val(); - $(e.target).attr('data-lastBranch', branchID); + $(target).attr('data-lastBranch', branchID); } else { - $(e.target).removeAttr('data-lastBranch'); + $(target).removeAttr('data-lastBranch'); } let chosenProducts = 0; @@ -148,3 +148,9 @@ window.setParentProgram = function() loadPage(link, '#aclList'); $('select[name^=whitelist]').closest('.form-row').removeClass('hidden') } + +/* Init product. */ +window.waitDom('[name^=products]', function() +{ + if($('.newProductBox').length > 0) productChange($('[name^=products]').eq(0)); +}); diff --git a/module/project/ui/create.html.php b/module/project/ui/create.html.php index 197ec308a2..bdca2b5fb2 100644 --- a/module/project/ui/create.html.php +++ b/module/project/ui/create.html.php @@ -54,7 +54,7 @@ if(!empty($products)) div ( setClass('grow'), - select + picker ( set::name("products[$i]"), set::value($product->id), @@ -73,7 +73,7 @@ if(!empty($products)) inputGroup ( $lang->product->branchName['branch'], - select + picker ( set::name("branch[$i][]"), set::items($branches), @@ -88,7 +88,7 @@ if(!empty($products)) ( set::id("plan{$i}"), $lang->project->associatePlan, - select + picker ( set::name("plans[$product->id][]"), set::items($plans), @@ -165,7 +165,7 @@ formPanel on::change('#parent, #budget', 'checkBudget(0)'), on::change('#begin, [name=delta]', 'computeEndDate'), on::change('#begin, #end', 'computeWorkDays'), - on::change('[name^=products]', 'productChange'), + on::change('[name^=products]', 'productChange(e.target)'), on::change('[name^=branch]', 'branchChange'), on::change('[name=multiple]', 'toggleMultiple'), on::change('[name=future]', 'toggleBudget'), @@ -411,7 +411,8 @@ formPanel picker ( set::name('products[0]'), - set::items($allProducts) + set::items($allProducts), + set::value($productID) ) ), div