From ce798a834bc1d0b5d49e6cf83c3732af5fdf4a59 Mon Sep 17 00:00:00 2001 From: sunguangming Date: Tue, 2 Jul 2024 03:21:47 +0000 Subject: [PATCH] * [bug#51859,done,1h] fix bug. --- module/epic/control.php | 5 +++-- module/product/ui/browse.html.php | 4 ++-- module/requirement/control.php | 3 ++- module/story/control.php | 5 +++-- module/story/model.php | 5 ++++- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/module/epic/control.php b/module/epic/control.php index 9ff02fbeca..f27d4b8937 100644 --- a/module/epic/control.php +++ b/module/epic/control.php @@ -397,12 +397,13 @@ class epic extends control * Batch change grade. * * @param int $grade + * @param string $storyType * @access public * @return void */ - public function batchChangeGrade(int $grade) + public function batchChangeGrade(int $grade, string $storyType = 'epic') { - echo $this->fetch('story', 'batchChangeGrade', "grade=$grade&storyType=requirement"); + echo $this->fetch('story', 'batchChangeGrade', "grade=$grade&storyType=epic"); } /** diff --git a/module/product/ui/browse.html.php b/module/product/ui/browse.html.php index d655d70c14..1141ddd4de 100644 --- a/module/product/ui/browse.html.php +++ b/module/product/ui/browse.html.php @@ -246,7 +246,7 @@ $fnGenerateFootToolbar = function() use ($lang, $product, $productID, $project, $canBatchChangePlan = $canBeChanged && hasPriv($storyType, 'batchChangePlan') && $productID && $product && (($product->type != 'normal' && $branchID != 'all') || $product->type == 'normal'); } - $canBatchChangeGrade = $canBeChanged && hasPriv($storyType, 'batchChangeGrade'); + $canBatchChangeGrade = $canBeChanged && hasPriv($storyType, 'batchChangeGrade') && count($gradePairs) > 1 && $config->{$storyType}->gradeRule == 'cross'; $canBatchChangeStage = $canBeChanged && hasPriv('story', 'batchChangeStage') && $storyType == 'story'; $canBatchChangeBranch = $canBeChanged && hasPriv($storyType, 'batchChangeBranch') && $product && $product->type != 'normal' && $productID; $canBatchChangeModule = $canBeChanged && hasPriv($storyType, 'batchChangeModule') && $productID && (($product->type != 'normal' && $branchID != 'all') || $product->type == 'normal') && !$isProjectStory; @@ -266,7 +266,7 @@ $fnGenerateFootToolbar = function() use ($lang, $product, $productID, $project, $gradeItems = array(); $roadmapItems = array(); foreach($lang->story->reviewResultList as $key => $result) $reviewResultItems[$key] = array('text' => $result, 'class' => 'batch-btn', 'data-formaction' => $this->createLink($isProjectStory ? 'projectstory' : $storyType, 'batchReview', "result=$key")); - foreach($gradePairs as $key => $result) $gradeItems[] = array('text' => $result, 'class' => 'batch-btn', 'data-formaction' => $this->createLink($isProjectStory ? 'projectstory' : $storyType, 'batchChangeGrade', "result=$key")); + foreach($gradePairs as $key => $result) $gradeItems[] = array('text' => $result, 'class' => 'batch-btn', 'data-formaction' => $this->createLink($isProjectStory ? 'projectstory' : $storyType, 'batchChangeGrade', "result=$key&type=$storyType")); foreach($lang->story->reasonList as $key => $reason) $reviewRejectItems[] = array('text' => $reason, 'class' => 'batch-btn', 'data-formaction' => $this->createLink($isProjectStory ? 'projectstory' : $storyType, 'batchReview', "result=reject&reason=$key")); foreach($branchTagOption as $branchID => $branchName) $branchItems[] = array('text' => $branchName, 'class' => 'batch-btn', 'data-formaction' => $this->createLink($isProjectStory ? 'projectstory' : $storyType, 'batchChangeBranch', "branchID=$branchID")); foreach($modules as $moduleID => $moduleName) $moduleItems[] = array('text' => $moduleName, 'class' => 'batch-btn', 'data-formaction' => $this->createLink($isProjectStory ? 'projectstory' : $storyType, 'batchChangeModule', "moduleID=$moduleID")); diff --git a/module/requirement/control.php b/module/requirement/control.php index 020eddd668..7b2c77e93e 100644 --- a/module/requirement/control.php +++ b/module/requirement/control.php @@ -352,10 +352,11 @@ class requirement extends control * Batch change grade. * * @param int $grade + * @param string $storyType requirement|story|epic * @access public * @return void */ - public function batchChangeGrade(int $grade) + public function batchChangeGrade(int $grade, string $storyType = 'requirement') { echo $this->fetch('story', 'batchChangeGrade', "grade=$grade&storyType=requirement"); } diff --git a/module/story/control.php b/module/story/control.php index bd376f2ebe..f6fd8a3968 100755 --- a/module/story/control.php +++ b/module/story/control.php @@ -1199,15 +1199,16 @@ class story extends control * Batch change the grade of story. * * @param int $grade + * @param string $storyType story|requirement|epic * @access public * @return void */ - public function batchChangeGrade(int $grade) + public function batchChangeGrade(int $grade, string $storyType = 'story') { if(empty($_POST['storyIdList'])) return $this->send(array('result' => 'success', 'load' => true)); $storyIdList = array_unique($this->post->storyIdList); - $message = $this->story->batchChangeGrade($storyIdList, $grade); + $message = $this->story->batchChangeGrade($storyIdList, $grade, $storyType); $response = array(); $response['result'] = 'success'; diff --git a/module/story/model.php b/module/story/model.php index 5879b5b8d2..61c2d98ef3 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -1837,11 +1837,12 @@ class storyModel extends model * * @param array $storyIdList * @param int $grade + * @param string $storyType * * @access public * @return string|null */ - public function batchChangeGrade(array $storyIdList, int $grade): string|null + public function batchChangeGrade(array $storyIdList, int $grade, string $storyType = 'story'): string|null { $now = helper::now(); $account = $this->app->user->account; @@ -1861,10 +1862,12 @@ class storyModel extends model $sameRootList = ''; $gradeGtParentList = ''; $gradeOverflowList = ''; + foreach($storyIdList as $storyID) { $oldStory = $oldStories[$storyID]; if($grade == $oldStory->grade) continue; + if($oldStory->type != $storyType) continue; if($rootGroup[$oldStory->root] > 1) {