From aa1079feaf011f4a955d65a63043b0e05444db49 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 5 Jul 2022 15:30:58 +0800 Subject: [PATCH] * Finish task #58557. --- module/testcase/css/create.css | 2 +- module/testcase/js/batchcreate.js | 39 ++++++++++++++---- module/testcase/js/common.js | 49 +++++++++++++++++++++- module/testcase/js/create.js | 24 +++++++++++ module/testcase/view/batchcreate.html.php | 50 ++++++++++++----------- module/testcase/view/create.html.php | 31 +++++++------- 6 files changed, 147 insertions(+), 48 deletions(-) diff --git a/module/testcase/css/create.css b/module/testcase/css/create.css index 9371649ca7..5efab6dadf 100644 --- a/module/testcase/css/create.css +++ b/module/testcase/css/create.css @@ -40,4 +40,4 @@ .title-group.required > .required:after {display: block; right: 29px; top: 5px;} .pri-selector > .btn {padding: 5px 8px !important; width: 100%;} .pri-selector > .dropdown-menu {padding: 10px;} - +.stageBox {padding-left: 15px !important;} diff --git a/module/testcase/js/batchcreate.js b/module/testcase/js/batchcreate.js index 8a788bd65a..334a133631 100644 --- a/module/testcase/js/batchcreate.js +++ b/module/testcase/js/batchcreate.js @@ -29,16 +29,41 @@ $(document).ready(function() $('#customField').click(function() { - $('#formSettingForm > .checkboxes > .checkbox-primary > input').each(function() - { - var field = ',' + $(this).val() + ','; - var required = ',' + requiredFields + ','; - if(required.indexOf(field) >= 0) $(this).attr('disabled', 'disabled'); - }); + hiddenRequireFields(); }); + /* Implement a custom form without feeling refresh. */ $('#formSettingForm .btn-primary').click(function() { - $('#formSettingForm > .checkboxes > .checkbox-primary > input').removeAttr('disabled'); + var fields = ''; + $('#formSettingForm > .checkboxes > .checkbox-primary > input:checked').each(function() + { + fields += ',' + $(this).val(); + }); + + var link = createLink('custom', 'ajaxSaveCustomFields', 'module=testcase§ion=custom&key=batchCreateFields'); + $.post(link, {'fields' : fields}, function() + { + showCheckedFields(fields); + $('#formSetting').parent().removeClass('open'); + + var fieldCount = $('#batchCreateForm .table thead>tr>th:visible').length; + $('.form-actions').attr('colspan', fieldCount); + + if(fieldCount > 8) + { + $('#batchCreateForm > .table-responsive').removeClass('scroll-none'); + $('#batchCreateForm > .table-responsive').css('overflow', 'auto'); + } + else + { + $('#batchCreateForm > .table-responsive').addClass('scroll-none'); + $('#batchCreateForm > .table-responsive').css('overflow', 'visible'); + } + + if($('#batchCreateForm table thead tr th.c-title').width() < 170) $('#batchCreateForm table thead tr th.c-title').width('170'); + }); + + return false; }); }); diff --git a/module/testcase/js/common.js b/module/testcase/js/common.js index e15400f349..cd380b77b7 100644 --- a/module/testcase/js/common.js +++ b/module/testcase/js/common.js @@ -370,7 +370,7 @@ function loadStories(productID, moduleID, num) if(!stories) stories = ''; if(config.currentMethod == 'batchcreate') { - for(var i = num; i < 10 ; i ++) + for(var i = num; i <= itemIndex ; i ++) { if(i != num && $('#module' + i).val() != 'ditto') break; var nowStories = stories.replaceAll('story' + num, 'story' + i); @@ -426,3 +426,50 @@ function setModules(branchID, productID, num) $('#plan' + (num + 1)).trigger("chosen:updated"); } } + +/** + * Show checked fields. + * + * @param string fields + * @access public + * @return void + */ +function showCheckedFields(fields) +{ + showFields = fields; + + var fieldList = ',' + fields + ','; + $('#formSettingForm > .checkboxes > .checkbox-primary > input').each(function() + { + var field = ',' + $(this).val() + ','; + var $field = config.currentMethod == 'create' ? $('#' + $(this).val()) : $('[name^=' + $(this).val() + ']'); + var required = ',' + requiredFields + ','; + var $fieldBox = $('.' + $(this).val() + 'Box' ); + if(fieldList.indexOf(field) >= 0 || required.indexOf(field) >= 0) + { + $fieldBox.removeClass('hidden'); + $field.removeAttr('disabled'); + } + else if(!$fieldBox.hasClass('hidden')) + { + $fieldBox.addClass('hidden'); + $field.attr('disabled', true); + } + }); +} + +/** + * Hidden require field. + * + * @access public + * @return void + */ +function hiddenRequireFields() +{ + $('#formSettingForm > .checkboxes > .checkbox-primary > input').each(function() + { + var field = ',' + $(this).val() + ','; + var required = ',' + requiredFields + ','; + if(required.indexOf(field) >= 0) $(this).closest('div').addClass('hidden'); + }); +} diff --git a/module/testcase/js/create.js b/module/testcase/js/create.js index 5a525a8ba6..9acacae0da 100644 --- a/module/testcase/js/create.js +++ b/module/testcase/js/create.js @@ -156,4 +156,28 @@ $(function() }); $('#subNavbar li[data-id="testcase"]').addClass('active'); + + $('#customField').click(function() + { + hiddenRequireFields(); + }); + + /* Implement a custom form without feeling refresh. */ + $('#formSettingForm .btn-primary').click(function() + { + var fields = ''; + $('#formSettingForm > .checkboxes > .checkbox-primary > input:checked').each(function() + { + fields += ',' + $(this).val(); + }); + + var link = createLink('custom', 'ajaxSaveCustomFields', 'module=testcase§ion=custom&key=createFields'); + $.post(link, {'fields' : fields}, function() + { + showCheckedFields(fields); + $('#formSetting').parent().removeClass('open'); + }); + + return false; + }); }); diff --git a/module/testcase/view/batchcreate.html.php b/module/testcase/view/batchcreate.html.php index 0584fdb584..6dba2f4c5d 100644 --- a/module/testcase/view/batchcreate.html.php +++ b/module/testcase/view/batchcreate.html.php @@ -15,6 +15,7 @@ testcase->create->requiredFields)?> +

@@ -54,16 +55,16 @@ idAB;?> - '>product->branch;?> - '>testcase->module;?> - '> testcase->story;?> + branchBox'>product->branch;?> + moduleBox'>testcase->module;?> + storyBox'> testcase->story;?> testcase->title;?> testcase->type;?> - '>testcase->pri;?> - '>testcase->precondition;?> - '>testcase->keywords;?> - '>testcase->stage;?> - '>testcase->review;?> + priBox'>testcase->pri;?> + preconditionBox'>testcase->precondition;?> + keywordsBox'>testcase->keywords;?> + stageBox'>testcase->stage;?> + reviewBox'>testcase->review;?> testcase->getFlowExtendFields(); foreach($extendFields as $extendField) @@ -86,9 +87,9 @@ ?> - '> - ' style='overflow:visible'> - ' style='overflow:visible'> id : '', 'class="form-control chosen"');?> + branchBox'> + moduleBox' style='overflow:visible'> + storyBox' style='overflow:visible'> id : '', 'class="form-control chosen"');?>
@@ -102,11 +103,11 @@
testcase->typeList, $type, "class='form-control chosen'");?> - '> testcase->priList, $pri, "class='form-control chosen'");?> - '> - '> - ' style='overflow:visible'>testcase->stageList, '', "class='form-control chosen' multiple");?> - '>testcase->reviewList, $needReview, "class='form-control'");?> + priBox'>testcase->priList, $pri, "class='form-control chosen'");?> + preconditionBox'> + keywordsBox'> + stageBox' style='overflow:visible'>testcase->stageList, '', "class='form-control chosen' multiple");?> + reviewBox'>testcase->reviewList, $needReview, "class='form-control'");?> loadModel('flow'); foreach($extendFields as $extendField) echo "control == 'select' or $extendField->control == 'multi-select') ? " style='overflow:visible'" : '') . ">" . $this->flow->getFieldControl($extendField, '', $extendField->field . "[$i]") . ""; @@ -126,13 +127,14 @@

+ - - - + + + - - - - - + + + + + loadModel('flow'); foreach($extendFields as $extendField) echo "control == 'select' or $extendField->control == 'multi-select') ? " style='overflow:visible'" : '') . ">" . $this->flow->getFieldControl($extendField, '', $extendField->field . "[%s]") . ""; diff --git a/module/testcase/view/create.html.php b/module/testcase/view/create.html.php index 54433855c8..7885bb2e53 100644 --- a/module/testcase/view/create.html.php +++ b/module/testcase/view/create.html.php @@ -21,6 +21,14 @@ app->tab);?> app->tab == 'execution') js::set('objectID', $executionID);?> app->tab == 'project') js::set('objectID', $projectID);?> +testcase->create->requiredFields) as $field) +{ + if($field and strpos($showFields, $field) === false) $showFields .= ',' . $field; +} +?> +testcase->create->requiredFields);?> +
@@ -30,12 +38,6 @@
- testcase->create->requiredFields) as $field) - { - if($field and strpos($showFields, $field) === false) $showFields .= ',' . $field; - } - ?>
%s'>' style='overflow:visible'>' style='overflow:visible'> branchBox'> moduleBox' style='overflow:visible'> storyBox' style='overflow:visible'>
@@ -146,11 +148,11 @@
testcase->typeList, $type, "class='form-control chosen'");?>'> testcase->priList, $pri, "class='form-control chosen'");?>'>'> ' style='overflow:visible'>testcase->stageList, '', "class='form-control chosen' multiple");?>'>testcase->reviewList, $needReview, "class='form-control chosen'");?> priBox'>testcase->priList, $pri, "class='form-control chosen'");?> preconditionBox'> keywordsBox'> stageBox' style='overflow:visible'>testcase->stageList, '', "class='form-control chosen' multiple");?> reviewBox'>testcase->reviewList, $needReview, "class='form-control chosen'");?>
@@ -68,7 +70,8 @@ testcase->typeList['unit']);?> -
testcase->typeList, $type, "class='form-control chosen'");?> + +
testcase->stage?> testcase->stageList, $stage, "class='form-control chosen' multiple='multiple'");?> @@ -108,8 +111,8 @@
- - testcase->pri;?> + + testcase->pri;?> testcase->priList as $priKey => $priValue) @@ -129,10 +132,10 @@ } ?> - + -
+
@@ -141,7 +144,6 @@
- testcase->forceNotReview()):?> testcase->forceNotReview, '', "id='forceNotReview0'");?> @@ -220,12 +222,11 @@
- - + + testcase->keywords;?> - testcase->status;?>