From 621e382cb6d2712d2340ebd0221aaa07a7f8a09e Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 28 Jun 2022 15:35:49 +0800 Subject: [PATCH] * Finish task #58554. --- module/custom/control.php | 4 +- module/task/js/batchcreate.js | 25 ++++++++ module/task/js/common.js | 60 +++++++++++++++++++ module/task/js/create.js | 28 +++++++++ module/task/view/batchcreate.html.php | 85 ++++++++++++++------------- module/task/view/create.html.php | 60 ++++++++----------- 6 files changed, 186 insertions(+), 76 deletions(-) diff --git a/module/custom/control.php b/module/custom/control.php index 88af46aca5..64f9469391 100644 --- a/module/custom/control.php +++ b/module/custom/control.php @@ -675,14 +675,16 @@ class custom extends control $account = $this->app->user->account; if($this->server->request_method == 'POST') { - $fields = $this->post->fields; + $fields = $this->post->fields; if(is_array($fields)) $fields = join(',', $fields); $this->loadModel('setting')->setItem("$account.$module.$section.$key", $fields); + if(in_array($module, array('task', 'bug', 'testcase', 'story')) and $section == 'custom' and in_array($key, array('createFields', 'batchCreateFields'))) return; } else { $this->loadModel('setting')->deleteItems("owner=$account&module=$module§ion=$section&key=$key"); } + return print(js::reload('parent')); } diff --git a/module/task/js/batchcreate.js b/module/task/js/batchcreate.js index b98330264c..9d68a3483c 100755 --- a/module/task/js/batchcreate.js +++ b/module/task/js/batchcreate.js @@ -5,6 +5,31 @@ $(function() if($('th.c-name').width() < 200) $('th.c-name').width(200); if(taskConsumed > 0) bootbox.alert(addChildTask); $('#customField').on('click', function(){$('#tableBody .chosen-with-drop').removeClass('chosen-with-drop chosen-container-active')}); + + $('#customField').click(function() + { + disabledRequireFields(); + }); + + $('#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=task§ion=custom&key=batchCreateFields'); + $.post(link, {'fields' : fields}, function() + { + checkedShowFields(fields); + disabledRequireFields(); + $('#formSetting').parent().removeClass('open'); + }); + + return false; + }); }); $(document).on('change', "[name^='estStarted'], [name^='deadline']", function() diff --git a/module/task/js/common.js b/module/task/js/common.js index cad7f13d6f..8556c357e9 100644 --- a/module/task/js/common.js +++ b/module/task/js/common.js @@ -20,3 +20,63 @@ function setStoryModule() } } +/** + * Checked show fields. + * + * @param string fields + * @access public + * @return void + */ +function checkedShowFields(fields) +{ + var fieldList = ',' + fields + ','; + $('#formSettingForm > .checkboxes > .checkbox-primary > input').each(function() + { + var field = ',' + $(this).val() + ','; + var $fieldBox = $('.' + $(this).val() + 'Box' ); + if(fieldList.indexOf(field) >= 0) + { + + $(this).attr('checked', true); + $fieldBox.removeClass('hidden'); + } + else + { + if(!$fieldBox.hasClass('hidden')) $fieldBox.addClass('hidden'); + } + }); + + if(config.currentMethod == 'create'); + { + if(fieldList.indexOf(',estStarted,') >= 0 && fieldList.indexOf(',deadline,') >= 0) + { + $('.borderBox').removeClass('hidden'); + } + else if(fieldList.indexOf(',estStarted,') >= 0 || fieldList.indexOf(',deadline,') >= 0) + { + $('.datePlanBox').removeClass('hidden'); + if(!$('.borderBox').hasClass('hidden')) $('.borderBox').addClass('hidden'); + } + else + { + if(!$('.borderBox').hasClass('hidden')) $('.borderBox').addClass('hidden'); + if(!$('.datePlanBox').hasClass('hidden')) $('.datePlanBox').addClass('hidden'); + } + } +} + +/** + * Disabled require field. + * + * @access public + * @return void + */ +function disabledRequireFields() +{ + $('#formSettingForm > .checkboxes > .checkbox-primary > input').each(function() + { + var field = ',' + $(this).val() + ','; + var required = ',' + requiredFields + ','; + if(required.indexOf(field) >= 0) $(this).attr('disabled', 'disabled'); + }); +} diff --git a/module/task/js/create.js b/module/task/js/create.js index 3c3c133f7b..c187786901 100644 --- a/module/task/js/create.js +++ b/module/task/js/create.js @@ -1,3 +1,31 @@ +$(function() +{ + $('#customField').click(function() + { + disabledRequireFields(); + }); + + $('#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=task§ion=custom&key=createFields'); + $.post(link, {'fields' : fields}, function() + { + checkedShowFields(fields); + disabledRequireFields(); + $('#formSetting').parent().removeClass('open'); + }); + + return false; + }); +}) + /** * Load module, stories and members. * diff --git a/module/task/view/batchcreate.html.php b/module/task/view/batchcreate.html.php index 363d589017..26c152c7b4 100755 --- a/module/task/view/batchcreate.html.php +++ b/module/task/view/batchcreate.html.php @@ -15,6 +15,26 @@ task->addChildTask);?> +task->create->requiredFields);?> +task->create->requiredFields) as $field) +{ + if($field) + { + $requiredFields[$field] = ''; + if(strpos(",{$config->task->customBatchCreateFields},", ",{$field},") !== false) $visibleFields[$field] = ''; + } +} +$colspan = count($visibleFields) + 3; +?> +

@@ -40,32 +60,15 @@

- task->create->requiredFields) as $field) - { - if($field) - { - $requiredFields[$field] = ''; - if(strpos(",{$config->task->customBatchCreateFields},", ",{$field},") !== false) $visibleFields[$field] = ''; - } - } - $colspan = count($visibleFields) + 3; - ?>
- + type != 'ops'):?> - + type == 'kanban'):?> @@ -73,12 +76,12 @@ - - - - - - + + + + + + task->getFlowExtendFields(); foreach($extendFields as $extendField) @@ -113,12 +116,12 @@ - type != 'ops'):?> - - - - + + - - - + + loadModel('flow'); foreach($extendFields as $extendField) echo "control == 'select' or $extendField->control == 'multi-select') ? " style='overflow:visible'" : '') . ">" . $this->flow->getFieldControl($extendField, '', $extendField->field . "[$i]") . ""; @@ -189,11 +192,11 @@ - - - - - + + - - + + 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/task/view/create.html.php b/module/task/view/create.html.php index e9a1510f9a..0f6c3bf5a1 100644 --- a/module/task/view/create.html.php +++ b/module/task/view/create.html.php @@ -17,9 +17,17 @@ task->error->teamMember);?> vision);?> +task->create->requiredFields);?> +task->create->requiredFields) as $field) +{ + if($field and strpos($showFields, $field) === false) $showFields .= ',' . $field; +} +?> +
@@ -29,12 +37,6 @@
- task->create->requiredFields) as $field) - { - if($field and strpos($showFields, $field) === false) $showFields .= ',' . $field; - } - ?>
idAB;?>'>task->module?> moduleBox'>task->module?> '>task->story;?> storyBox'>task->story;?> task->name;?> kanbancard->lane;?> typeAB;?>'>task->assignedTo;?>'>task->estimateAB;?>'>task->estStarted;?>'>task->deadline;?>'>task->desc;?>'>task->pri;?> assignedToBox'>task->assignedTo;?> estimateBox'>task->estimateAB;?> estStartedBox'>task->estStarted;?> deadlineBox'>task->deadline;?> descBox'>task->desc;?> priBox'>task->pri;?>
style='overflow:visible'> + style='overflow: visible'> +
@@ -146,9 +149,9 @@
task->typeList, $type, 'class=form-control');?> style='overflow:visible'>>> +
> +
>>task->priList, $pri, 'class=form-control');?>task->priList, $pri, 'class=form-control');?>
%s style='overflow:visible'> + id, \"%s\")'")?> style='overflow: visible'> +
@@ -216,9 +219,9 @@
task->typeList, $type, 'class="form-control"');?> style='overflow:visible'>>> +
> +
{$lang->task->ditto}"; ?>
-
>>task->priList, $pri, 'class=form-control');?>task->priList, $pri, 'class=form-control');?>
type != 'kanban' or $this->config->vision == 'lite'):?> @@ -97,8 +99,8 @@ printExtendFields('', 'table', 'columns=3');?> - lifetime != 'ops'):?> - + lifetime != 'ops') ? '' : 'hidden'?> + - type != 'ops'):?> @@ -174,8 +175,8 @@ task->copyStoryTitle;?> - - task->pri;?> + + task->pri;?>task->priList as $priKey => $priValue) @@ -195,9 +196,9 @@ } ?> - pri, "class='form-control'");?> + pri, "class='form-control $hiddenPri'");?> -
+
@@ -206,15 +207,13 @@
- - -
+ +
task->estimateAB;?>
-
@@ -231,29 +230,23 @@ - - + - - - + + -
task->story;?> task->noticeLinkStory, html::a($this->createLink('execution', 'linkStory', "executionID=$execution->id"), $lang->execution->linkStory, '', 'class="text-primary"'), html::a("javascript:loadStories($execution->id)", $lang->refresh, '', 'class="text-primary"'));?> @@ -110,7 +112,6 @@
task->datePlan;?>
- - estStarted, "class='form-control form-date' placeholder='{$lang->task->estStarted}'");?> - - - ~ - - - deadline, "class='form-control form-date' placeholder='{$lang->task->deadline}'");?> - + estStarted, "class='form-control form-date $hiddenEstStarted estStartedBox' placeholder='{$lang->task->estStarted}'");?> + + ~ + deadline, "class='form-control form-date $hiddenDeadline deadlineBox' placeholder='{$lang->task->deadline}'");?>
story->mailto;?>
@@ -262,7 +255,6 @@
task->afterSubmit;?>