From e1e2f7adad389a57a60d8f9b60ab7d5078b1a5e2 Mon Sep 17 00:00:00 2001 From: liugang Date: Thu, 29 Jun 2023 09:54:45 +0800 Subject: [PATCH] * testcase: display diffferent batch actions based on the $browseType parameter. --- module/testcase/ui/browse.html.php | 25 +++++++++++++------------ module/testcase/ui/header.html.php | 3 ++- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/module/testcase/ui/browse.html.php b/module/testcase/ui/browse.html.php index 8182c6437d..0cc3be81a8 100644 --- a/module/testcase/ui/browse.html.php +++ b/module/testcase/ui/browse.html.php @@ -18,17 +18,18 @@ jsVar('checkedSummary', $lang->testcase->checkedSummary); include 'header.html.php'; -$canBatchRun = hasPriv('testtask', 'batchRun'); -$canBatchEdit = hasPriv('testcase', 'batchEdit'); -$canBatchReview = hasPriv('testcase', 'batchReview') && ($config->testcase->needReview || !empty($config->testcase->forceReview)); -$canBatchDelete = hasPriv('testcase', 'batchDelete'); -$canBatchCaseTypeChange = hasPriv('testcase', 'batchCaseTypeChange'); -$canBatchConfirmStoryChange = hasPriv('testcase', 'batchConfirmStoryChange'); -$canBatchChangeBranch = hasPriv('testcase', 'batchChangeBranch') && $this->session->currentProductType && $this->session->currentProductType != 'normal'; +$canBatchRun = hasPriv('testtask', 'batchRun') && !$isOnlyScene; +$canBatchEdit = hasPriv('testcase', 'batchEdit') && !$isOnlyScene; +$canBatchReview = hasPriv('testcase', 'batchReview') && !$isOnlyScene && ($config->testcase->needReview || !empty($config->testcase->forceReview)); +$canBatchDelete = hasPriv('testcase', 'batchDelete') && !$isOnlyScene; +$canBatchCaseTypeChange = hasPriv('testcase', 'batchCaseTypeChange') && !$isOnlyScene; +$canBatchConfirmStoryChange = hasPriv('testcase', 'batchConfirmStoryChange') && !$isOnlyScene; +$canBatchChangeBranch = hasPriv('testcase', 'batchChangeBranch') && !$isOnlyScene && $this->session->currentProductType && $this->session->currentProductType != 'normal'; $canBatchChangeModule = hasPriv('testcase', 'batchChangeModule') && !empty($productID) && ($product->type == 'normal' || $branch !== 'all'); -$canBatchChangeScene = hasPriv('testcase', 'batchChangeScene'); -$canImportToLib = hasPriv('testcase', 'importToLib'); -$canBatchAction = ($canBatchRun || $canBatchEdit || $canBatchReview || $canBatchDelete || $canBatchCaseTypeChange || $canBatchConfirmStoryChange || $canBatchChangeBranch || $canBatchChangeModule || $canBatchChangeScene || $canImportToLib); +$canBatchChangeScene = hasPriv('testcase', 'batchChangeScene') && !$isOnlyScene; +$canImportToLib = hasPriv('testcase', 'importToLib') && !$isOnlyScene; +$canGroupBatch = ($canBatchRun || $canBatchEdit || $canBatchReview || $canBatchDelete || $canBatchCaseTypeChange || $canBatchConfirmStoryChange); +$canBatchAction = ($canGroupBatch || $canBatchChangeBranch || $canBatchChangeModule || $canBatchChangeScene || $canImportToLib); $caseProductIds = array(); foreach($cases as $case) $caseProductIds[$case->product] = $case->product; @@ -36,12 +37,12 @@ $caseProductID = count($caseProductIds) > 1 ? 0 : $productID; $footToolbar = $canBatchAction ? array('items' => array ( - array('type' => 'btn-group', 'items' => array + $canGroupBatch ? array('type' => 'btn-group', 'items' => array ( $canBatchRun ? array('text' => $lang->testtask->runCase, 'className' => 'batch-btn', 'data-url' => helper::createLink('testtask', 'batchRun', "productID=$productID&orderBy=$orderBy")) : null, $canBatchEdit ? array('text' => $lang->edit, 'className' => 'batch-btn', 'data-url' => helper::createLink('testcase', 'batchEdit', "productID=$caseProductID&branch=$branch")) : null, ($canBatchReview || $canBatchDelete || $canBatchCaseTypeChange || $canBatchConfirmStoryChange) ? array('caret' => 'up', 'btnType' => 'secondary', 'url' => '#navActions', 'data-toggle' => 'dropdown', 'data-placement' => 'top-start') : null, - )), + )) : null, $canBatchChangeBranch ? array('caret' => 'up', 'text' => $lang->product->branchName[$this->session->currentProductType], 'btnType' => 'secondary', 'url' => '#navBranch', 'data-toggle' => 'dropdown', 'data-placement' => 'top-start') : null, $canBatchChangeModule ? array('caret' => 'up', 'text' => $lang->testcase->moduleAB, 'btnType' => 'secondary', 'url' => '#navModule', 'data-toggle' => 'dropdown', 'data-placement' => 'top-start') : null, $canBatchChangeScene ? array('caret' => 'up', 'text' => $lang->testcase->scene, 'btnType' => 'secondary', 'url' => '#navScene','data-toggle' => 'dropdown', 'data-placement' => 'top-start') : null, diff --git a/module/testcase/ui/header.html.php b/module/testcase/ui/header.html.php index 15dbe76bea..e9ea748415 100644 --- a/module/testcase/ui/header.html.php +++ b/module/testcase/ui/header.html.php @@ -10,6 +10,7 @@ declare(strict_types=1); */ namespace zin; +$isOnlyScene = strtolower($browseType) == 'onlyscene'; $isProjectApp = $this->app->tab == 'project'; $currentModule = $isProjectApp ? 'project' : 'testcase'; $currentMethod = $isProjectApp ? 'testcase' : 'browse'; @@ -134,7 +135,7 @@ featureBar a ( set::href(str_replace('{key}', 'onlyScene', $browseLink)), - set('class', strtolower($browseType) == 'onlyscene' ? 'active' : ''), + set('class', $isOnlyScene ? 'active' : ''), set('data-load', $load), $lang->testcase->onlyScene )