From c4e8cef7f8aac4e8d5b947e4d8101395cf24ff05 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Mon, 21 Nov 2016 12:03:44 +0800 Subject: [PATCH] * finish task #2776. --- module/story/control.php | 2 +- module/story/lang/en.php | 1 + module/story/lang/zh-cn.php | 1 + module/task/control.php | 17 +++++----- module/task/css/batchcreate.css | 5 +++ module/task/js/batchcreate.js | 47 ++++++++++++++++++++++++++- module/task/view/batchcreate.html.php | 2 ++ 7 files changed, 65 insertions(+), 10 deletions(-) diff --git a/module/story/control.php b/module/story/control.php index c3ccb5d502..896e320bf1 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -1085,7 +1085,7 @@ class story extends control */ public function ajaxGetProjectStories($projectID, $productID = 0, $branch = 0, $moduleID = 0, $storyID = 0, $number = '', $type= 'full') { - if($moduleID) + if($moduleID) { $moduleID = $this->loadModel('tree')->getStoryModule($moduleID); $moduleID = $this->tree->getAllChildID($moduleID); diff --git a/module/story/lang/en.php b/module/story/lang/en.php index 2ec8a6534c..1df3785675 100644 --- a/module/story/lang/en.php +++ b/module/story/lang/en.php @@ -31,6 +31,7 @@ $lang->story->linkStory = 'Link Story'; $lang->story->unlinkStory = 'Unlink Story'; $lang->story->export = "Export Data"; $lang->story->zeroCase = "Zero Case"; +$lang->story->zeroTask = "Zero Task"; $lang->story->reportChart = "Report"; $lang->story->batchChangePlan = "Batch Change Planning"; $lang->story->batchChangeBranch = "Batch Change Branch"; diff --git a/module/story/lang/zh-cn.php b/module/story/lang/zh-cn.php index a17937dbef..a47cbe81a2 100644 --- a/module/story/lang/zh-cn.php +++ b/module/story/lang/zh-cn.php @@ -31,6 +31,7 @@ $lang->story->linkStory = '关联需求'; $lang->story->unlinkStory = '移除相关需求'; $lang->story->export = "导出数据"; $lang->story->zeroCase = "零用例需求"; +$lang->story->zeroTask = "零任务需求"; $lang->story->reportChart = "统计报表"; $lang->story->batchChangePlan = "批量修改计划"; $lang->story->batchChangeBranch = "批量修改分支"; diff --git a/module/task/control.php b/module/task/control.php index 8b2b33a885..61d7371ad2 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -199,14 +199,15 @@ class task extends control $position[] = $this->lang->task->common; $position[] = $this->lang->task->batchCreate; - $this->view->title = $title; - $this->view->position = $position; - $this->view->project = $project; - $this->view->stories = $stories; - $this->view->modules = $modules; - $this->view->storyID = $storyID; - $this->view->story = $this->loadModel('story')->getByID($storyID); - $this->view->members = $members; + $this->view->title = $title; + $this->view->position = $position; + $this->view->project = $project; + $this->view->stories = $stories; + $this->view->modules = $modules; + $this->view->storyID = $storyID; + $this->view->story = $this->story->getByID($storyID); + $this->view->storyTasks = $this->task->getStoryTaskCounts(array_keys($stories), $projectID); + $this->view->members = $members; $this->display(); } diff --git a/module/task/css/batchcreate.css b/module/task/css/batchcreate.css index 631234f606..d09664df48 100644 --- a/module/task/css/batchcreate.css +++ b/module/task/css/batchcreate.css @@ -7,3 +7,8 @@ .chosen-container[id^="story"] {width: 200px;} .chosen-container[id^="story"] .chosen-drop {min-width: 450px;!important} .chosen-container[id^="module"] .chosen-drop {min-width: 400px;!important} + +#zeroTaskStory{background-color: #fafafa; color: #808080; padding: 5px 8px; text-align: center; margin-left: 10px; border: 1px solid #ddd; } +#zeroTaskStory .icon{display:none;} +#zeroTaskStory.zeroTask {background-color: #114f8e; color: #fff; border-color: #114f8e; } +#zeroTaskStory.zeroTask .icon{display:inline;} diff --git a/module/task/js/batchcreate.js b/module/task/js/batchcreate.js index 6ede43d55b..eb80ae51c1 100755 --- a/module/task/js/batchcreate.js +++ b/module/task/js/batchcreate.js @@ -12,8 +12,20 @@ function setStories(moduleID, projectID, num) var storyID = $('#story' + num).val(); if(!stories) stories = ''; $('#story' + num).replaceWith(stories); - if(moduleID == 0) $('#story' + num).append("") + if(moduleID == 0) $('#story' + num).append(""); $('#story' + num).val(storyID); + if($('#zeroTaskStory').hasClass('zeroTask')) + { + $('#story' + num).find('option').each(function() + { + value = $(this).attr('value'); + if(value != 'ditto' && storyTasks[value] > 0) + { + $(this).hide(); + if(storyID == value) $('#story' + num).val(''); + } + }) + } $("#story" + num + "_chosen").remove(); $("#story" + num).chosen(defaultChosenOptions); }); @@ -44,6 +56,38 @@ function setStoryRelated(num) } } +/* Toggle zero task story. */ +function toggleZeroTaskStory() +{ + if($('#zeroTaskStory').hasClass('zeroTask')) + { + $('#zeroTaskStory').removeClass('zeroTask'); + zeroTask = false; + } + else + { + $('#zeroTaskStory').addClass('zeroTask'); + zeroTask = true; + } + $.cookie('zeroTask', zeroTask, {expires:config.cookieLife, path:config.webRoot}); + $('select[name^="story"]').each(function() + { + selectVal = $(this).val(); + $(this).find('option').each(function() + { + value = $(this).attr('value'); + $(this).show(); + if(value != 'ditto' && storyTasks[value] > 0 && zeroTask) + { + $(this).hide(); + if(selectVal == value) selectVal = ''; + } + }) + $(this).val(selectVal); + $(this).trigger("chosen:updated"); + }) +} + $(document).on('click', '.chosen-with-drop', function() { var select = $(this).prev('select'); @@ -94,4 +138,5 @@ $(function() /* Adjust width for ie chosen width. */ $('#module0_chosen').width($('#module1_chosen').width()); $('#story0_chosen').width($('#story1_chosen').width()); + if($.cookie('zeroTask') == 'true') toggleZeroTaskStory(); }) diff --git a/module/task/view/batchcreate.html.php b/module/task/view/batchcreate.html.php index 4c4a651dd9..36d61ba004 100644 --- a/module/task/view/batchcreate.html.php +++ b/module/task/view/batchcreate.html.php @@ -16,6 +16,7 @@
icons['task']);?> icons['batchCreate']);?> task->batchCreate . $lang->task->common;?> + story->zeroTask;?>
pasteText, "data-toggle='myModal'")?> @@ -126,6 +127,7 @@ foreach(explode(',', $showFields) as $field) + task->ditto);?> createLink('custom', 'ajaxSaveCustomFields', 'module=task§ion=custom&key=batchCreateFields')?>