From 8f924a7f0571126b8d213d8d820ed702221bcf62 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Tue, 18 Jan 2022 17:23:54 +0800 Subject: [PATCH 1/5] * Fix bug #18481. --- module/execution/control.php | 1 + module/execution/js/common.js | 9 +++++++++ module/execution/js/create.js | 8 ++++++++ module/execution/js/edit.js | 9 +++++++++ module/execution/model.php | 12 +++++++++--- module/execution/view/create.html.php | 1 + module/execution/view/edit.html.php | 1 + 7 files changed, 38 insertions(+), 3 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index dd8f36353c..4f66c86ea1 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1604,6 +1604,7 @@ class execution extends control $this->view->rdUsers = $rdUsers; $this->view->users = $this->user->getPairs('nodeleted|noclosed'); $this->view->allProjects = $this->project->getPairsByModel('all', 0, 'noclosed'); + $this->view->project = $this->project->getById($execution->project); $this->view->groups = $this->loadModel('group')->getPairs(); $this->view->allProducts = $allProducts; $this->view->linkedProducts = $linkedProducts; diff --git a/module/execution/js/common.js b/module/execution/js/common.js index 9e61566158..cdbddd71ba 100644 --- a/module/execution/js/common.js +++ b/module/execution/js/common.js @@ -166,6 +166,15 @@ function loadBranches(product) var branchID = $('#branch' + index).val(); loadPlans(product, branchID); }); + if(projectModel == 'kanban' || projectModel == 'waterfall') + { + $('#productsBox .input-group').removeClass('required'); + $('#productsBox .input-group').each(function() + { + $(this).addClass('required'); + return false; + } ); + } } /** diff --git a/module/execution/js/create.js b/module/execution/js/create.js index 2e76285f06..8ff041d6dc 100644 --- a/module/execution/js/create.js +++ b/module/execution/js/create.js @@ -17,6 +17,14 @@ $(function() $("input:radio[name='delta']").attr("checked", false); }) + if(projectModel == 'kanban' || projectModel == 'waterfall') + { + if($('#productsBox .input-group').length == 1) + { + $('#productsBox .input-group').addClass('required'); + } + } + if(typeof(currentPlanID) == 'undefined') { $('#productsBox select[id^="products"]').each(function() diff --git a/module/execution/js/edit.js b/module/execution/js/edit.js index 0c09b6bfe8..8ade87ef49 100644 --- a/module/execution/js/edit.js +++ b/module/execution/js/edit.js @@ -64,6 +64,15 @@ $(function() } }); + if(projectModel == 'kanban' || projectModel == 'waterfall') + { + $('#productsBox .input-group').each(function() + { + $(this).addClass('required'); + return false; + } ); + } + oldProject = $("#project").val(); $('#project').change(function() { diff --git a/module/execution/model.php b/module/execution/model.php index 4114d2dc0e..69cc47c87b 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -302,13 +302,13 @@ class executionModel extends model if($project) $type = zget($this->config->execution->modelList, $project->model, 'sprint'); /* If the execution model is a stage, determine whether the product is linked. */ - if($type == 'stage' and empty($this->post->products[0])) + if($type == 'stage' and empty(array_filter($this->post->products))) { dao::$errors['message'][] = $this->lang->execution->noLinkProduct; return false; } - if($type == 'kanban' and empty($this->post->products[0])) + if($type == 'kanban' and empty(array_filter($this->post->products))) { dao::$errors['message'][] = $this->lang->execution->kanbanNoLinkProduct; return false; @@ -470,12 +470,18 @@ class executionModel extends model return false; } - if($oldExecution->type == 'stage' and empty($this->post->products[0])) + if($oldExecution->type == 'stage' and empty(array_filter($this->post->products))) { dao::$errors['message'][] = $this->lang->execution->noLinkProduct; return false; } + if($oldExecution->type == 'kanban' and empty(array_filter($this->post->products))) + { + dao::$errors['message'][] = $this->lang->execution->kanbanNoLinkProduct; + return false; + } + /* Get the data from the post. */ $execution = fixer::input('post') ->setDefault('lastEditedBy', $this->app->user->account) diff --git a/module/execution/view/create.html.php b/module/execution/view/create.html.php index d9738e31ab..941fc72b81 100644 --- a/module/execution/view/create.html.php +++ b/module/execution/view/create.html.php @@ -43,6 +43,7 @@ systemMode);?> +model) ? $project->model : '');?>
diff --git a/module/execution/view/edit.html.php b/module/execution/view/edit.html.php index 0316288f4f..f7b7aa54b0 100644 --- a/module/execution/view/edit.html.php +++ b/module/execution/view/edit.html.php @@ -14,6 +14,7 @@ +model) ? $project->model : '');?>
From eb31aac6a1da02670a68d58822e0a2b7efd8c559 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Tue, 18 Jan 2022 17:29:52 +0800 Subject: [PATCH 2/5] * Encapsulation function for bug #18481. --- module/execution/js/common.js | 26 +++++++++++++++++--------- module/execution/js/create.js | 8 +------- module/execution/js/edit.js | 9 +-------- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/module/execution/js/common.js b/module/execution/js/common.js index cdbddd71ba..214e5cdf51 100644 --- a/module/execution/js/common.js +++ b/module/execution/js/common.js @@ -1,3 +1,19 @@ +/** + * Add link products required class. + * + * @access public + * @return void + */ +function addProductsRequiredClass() +{ + $('#productsBox .input-group').removeClass('required'); + $('#productsBox .input-group').each(function() + { + $(this).addClass('required'); + return false; + } ); +} + function switchStatus(projectID, status) { if(status) location.href = createLink('project', 'task', 'project=' + projectID + '&type=' + status); @@ -166,15 +182,7 @@ function loadBranches(product) var branchID = $('#branch' + index).val(); loadPlans(product, branchID); }); - if(projectModel == 'kanban' || projectModel == 'waterfall') - { - $('#productsBox .input-group').removeClass('required'); - $('#productsBox .input-group').each(function() - { - $(this).addClass('required'); - return false; - } ); - } + if(projectModel == 'kanban' || projectModel == 'waterfall') addProductsRequiredClass(); } /** diff --git a/module/execution/js/create.js b/module/execution/js/create.js index 8ff041d6dc..a16676955d 100644 --- a/module/execution/js/create.js +++ b/module/execution/js/create.js @@ -17,13 +17,7 @@ $(function() $("input:radio[name='delta']").attr("checked", false); }) - if(projectModel == 'kanban' || projectModel == 'waterfall') - { - if($('#productsBox .input-group').length == 1) - { - $('#productsBox .input-group').addClass('required'); - } - } + if(projectModel == 'kanban' || projectModel == 'waterfall') addProductsRequiredClass(); if(typeof(currentPlanID) == 'undefined') { diff --git a/module/execution/js/edit.js b/module/execution/js/edit.js index 8ade87ef49..3f8016dc3b 100644 --- a/module/execution/js/edit.js +++ b/module/execution/js/edit.js @@ -64,14 +64,7 @@ $(function() } }); - if(projectModel == 'kanban' || projectModel == 'waterfall') - { - $('#productsBox .input-group').each(function() - { - $(this).addClass('required'); - return false; - } ); - } + if(projectModel == 'kanban' || projectModel == 'waterfall') addProductsRequiredClass(); oldProject = $("#project").val(); $('#project').change(function() From a1c6cfadccf9274fcd8b5f179c985ec053c76b3e Mon Sep 17 00:00:00 2001 From: liumengyi Date: Wed, 19 Jan 2022 09:01:29 +0800 Subject: [PATCH 3/5] * Modify required item judgment method. --- module/execution/js/common.js | 19 +------------------ module/execution/js/create.js | 2 -- module/execution/js/edit.js | 2 -- module/execution/view/create.html.php | 2 +- module/execution/view/edit.html.php | 2 +- 5 files changed, 3 insertions(+), 24 deletions(-) diff --git a/module/execution/js/common.js b/module/execution/js/common.js index 214e5cdf51..8bb7171a8d 100644 --- a/module/execution/js/common.js +++ b/module/execution/js/common.js @@ -1,19 +1,3 @@ -/** - * Add link products required class. - * - * @access public - * @return void - */ -function addProductsRequiredClass() -{ - $('#productsBox .input-group').removeClass('required'); - $('#productsBox .input-group').each(function() - { - $(this).addClass('required'); - return false; - } ); -} - function switchStatus(projectID, status) { if(status) location.href = createLink('project', 'task', 'project=' + projectID + '&type=' + status); @@ -155,7 +139,7 @@ function loadBranches(product) if($('#productsBox .input-group:last select:first').val() != 0) { var length = $('#productsBox .input-group').size(); - $('#productsBox .row').append('
' + $('#productsBox .col-sm-4:last').html() + '
'); + $('#productsBox .row').append('
' + $('#productsBox .col-sm-4:last').html().replace('required', '') + '
'); if($('#productsBox .input-group:last select').size() >= 2) $('#productsBox .input-group:last select:last').remove(); $('#productsBox .input-group:last .chosen-container').remove(); $('#productsBox .input-group:last select:first').attr('name', 'products[' + length + ']').attr('id', 'products' + length); @@ -182,7 +166,6 @@ function loadBranches(product) var branchID = $('#branch' + index).val(); loadPlans(product, branchID); }); - if(projectModel == 'kanban' || projectModel == 'waterfall') addProductsRequiredClass(); } /** diff --git a/module/execution/js/create.js b/module/execution/js/create.js index a16676955d..2e76285f06 100644 --- a/module/execution/js/create.js +++ b/module/execution/js/create.js @@ -17,8 +17,6 @@ $(function() $("input:radio[name='delta']").attr("checked", false); }) - if(projectModel == 'kanban' || projectModel == 'waterfall') addProductsRequiredClass(); - if(typeof(currentPlanID) == 'undefined') { $('#productsBox select[id^="products"]').each(function() diff --git a/module/execution/js/edit.js b/module/execution/js/edit.js index 3f8016dc3b..0c09b6bfe8 100644 --- a/module/execution/js/edit.js +++ b/module/execution/js/edit.js @@ -64,8 +64,6 @@ $(function() } }); - if(projectModel == 'kanban' || projectModel == 'waterfall') addProductsRequiredClass(); - oldProject = $("#project").val(); $('#project').change(function() { diff --git a/module/execution/view/create.html.php b/module/execution/view/create.html.php index 941fc72b81..f013ee46ef 100644 --- a/module/execution/view/create.html.php +++ b/module/execution/view/create.html.php @@ -145,7 +145,7 @@
-
+
diff --git a/module/execution/view/edit.html.php b/module/execution/view/edit.html.php index f7b7aa54b0..900467ecd7 100644 --- a/module/execution/view/edit.html.php +++ b/module/execution/view/edit.html.php @@ -142,7 +142,7 @@ type != 'normal' and isset($branchGroups[$product->id]);?> id] as $branchID => $branch):?>
-
+
"> id, "class='form-control chosen' $class onchange='loadBranches(this)' data-last='" . $product->id . "' data-type='". $product->type ."'");?> id], $branchID, "class='form-control chosen' $class onchange=\"loadPlans('#products{$i}', this.value)\" data-last='" . $branchID . "'");?> From 2d10aedf4b40b77afa946b0dfc1a53297986f5ef Mon Sep 17 00:00:00 2001 From: liumengyi Date: Wed, 19 Jan 2022 09:04:11 +0800 Subject: [PATCH 4/5] * Remove useless code. --- module/execution/view/edit.html.php | 1 - 1 file changed, 1 deletion(-) diff --git a/module/execution/view/edit.html.php b/module/execution/view/edit.html.php index 900467ecd7..d78120ecc3 100644 --- a/module/execution/view/edit.html.php +++ b/module/execution/view/edit.html.php @@ -14,7 +14,6 @@ -model) ? $project->model : '');?>
From 361d245ac638f74215034da16416f0f728f18105 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Wed, 19 Jan 2022 11:13:43 +0800 Subject: [PATCH 5/5] * Remove useless variables. --- module/execution/view/create.html.php | 1 - 1 file changed, 1 deletion(-) diff --git a/module/execution/view/create.html.php b/module/execution/view/create.html.php index f013ee46ef..7cc9de664d 100644 --- a/module/execution/view/create.html.php +++ b/module/execution/view/create.html.php @@ -43,7 +43,6 @@ systemMode);?> -model) ? $project->model : '');?>