From 884b7b9c185a5f22e0eca10741255b5d2e91bf19 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Fri, 22 Mar 2019 15:13:50 +0800 Subject: [PATCH] * adjust for 5325. --- module/report/model.php | 9 +++++- module/task/control.php | 7 +---- module/task/css/create.css | 7 +++++ module/task/js/create.js | 54 ++++++++++++++++++++++++++++++++ module/task/view/create.html.php | 13 ++++++-- 5 files changed, 80 insertions(+), 10 deletions(-) diff --git a/module/report/model.php b/module/report/model.php index 8361e68a2b..96d8dec0fc 100644 --- a/module/report/model.php +++ b/module/report/model.php @@ -24,7 +24,14 @@ class reportModel extends model { $sum = 0; foreach($datas as $data) $sum += $data->value; - foreach($datas as $data) $data->percent = round($data->value / $sum, 4); + + $totalPercent = 0; + foreach($datas as $i => $data) + { + $data->percent = round($data->value / $sum, 4); + $totalPercent += $data->percent; + } + if(isset($i)) $datas[$i]->percent = round(1 - $totalPercent + $datas[$i]->percent, 4); return $datas; } diff --git a/module/task/control.php b/module/task/control.php index 45087ce0b6..3c0d0e2030 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -174,11 +174,6 @@ class task extends control /* Get no test stories. */ $testStoryIdList = $this->dao->select('story')->from(TABLE_TASK)->where('project')->eq($projectID)->andWhere('story')->in(array_keys($stories))->fetchPairs('story', 'story'); - $noTestStories = array(); - foreach($stories as $id => $title) - { - if(!isset($testStoryIdList[$id])) $noTestStories[$id] = $title; - } $title = $project->name . $this->lang->colon . $this->lang->task->create; $position[] = html::a($taskLink, $project->name); @@ -199,7 +194,7 @@ class task extends control $this->view->task = $task; $this->view->users = $users; $this->view->stories = $stories; - $this->view->noTestStories = $noTestStories; + $this->view->testStoryIdList = $testStoryIdList; $this->view->members = $members; $this->view->moduleOptionMenu = $moduleOptionMenu; $this->display(); diff --git a/module/task/css/create.css b/module/task/css/create.css index 5cc7ee5bbd..1f614cd986 100644 --- a/module/task/css/create.css +++ b/module/task/css/create.css @@ -10,5 +10,12 @@ #testStoryBox table tr td{padding:0px;} #testStoryBox table tr td .chosen-container .chosen-single{border:0px;} +#testStoryBox table tr td .chosen-compact.chosen-container-single .chosen-single>.chosen-search{top:0;right:0;left:0} #testStoryBox table tr td input{border:0px;} #testStoryBox table tr td .input-group .input-group-addon{border-left:1px solid #dcdcdc;border-right:1px solid #dcdcdc;} +#testStoryBox table button.btn{border:0px;} + +.chosen-results > li.has-test, +.chosen-results > li.has-new-test {position: relative; color: #388E3C;} +.chosen-results > li.has-test.highlighted, +.chosen-results > li.has-new-test.highlighted {color: #fff;} diff --git a/module/task/js/create.js b/module/task/js/create.js index 3fdc092a2c..15bd0236ea 100644 --- a/module/task/js/create.js +++ b/module/task/js/create.js @@ -272,6 +272,48 @@ function removeItem(obj) if($(obj).closest('table').find('tbody tr').size() > 1) $(obj).closest('tr').remove(); } +function markTestStory() +{ + $('#testStoryBox select[name^="testStory"]').each(function() + { + var $select = $(this); + $select.find('option').each(function() + { + var $option = $(this); + var value = $option.attr('value'); + var tests = testStoryIdList[value]; + $option.attr('data-data', value).toggleClass('has-test', !!(tests && tests !== '0')); + }); + $select.trigger("chosen:updated"); + }); + + var getStoriesHasTest = function() + { + var storiesHasTest = {}; + $('#testStoryBox table tbody>tr').each(function() + { + var $tr = $(this); + storiesHasTest[$tr.find('select[name^="testStory"]').val()] = true; + }); + console.log(storiesHasTest); + return storiesHasTest; + }; + + $('#testStoryBox').on('chosen:showing_dropdown', 'select[name^="testStory"],.chosen-with-drop', function() + { + var storiesHasTest = getStoriesHasTest(); + var $container = $(this).closest('td').find('.chosen-container'); + setTimeout(function() + { + $container.find('.chosen-results>li').each(function() + { + var $li = $(this); + $li.toggleClass('has-new-test', !!storiesHasTest[$li.data('data')]); + }); + }, 100); + }); +} + $(document).ready(function() { $('#pri').on('change', function() @@ -288,6 +330,7 @@ $(document).ready(function() }); setStoryRelated(); + markTestStory(); $('#selectAllUser').on('click', function() { @@ -299,6 +342,17 @@ $(document).ready(function() } }); + var preAssign = ''; + $('#assignedTo').change(function() + { + var assign = $(this).val(); + $('#testStoryBox').find('select[name^="testAssignedTo"]').each(function() + { + if($(this).val() == '' || $(this).val() == preAssign) $(this).val(assign).trigger('chosen:updated'); + }); + preAssign = assign; + }); + $('[data-toggle=tooltip]').tooltip(); $(window).resize(); diff --git a/module/task/view/create.html.php b/module/task/view/create.html.php index d762a6ffca..212900bb87 100644 --- a/module/task/view/create.html.php +++ b/module/task/view/create.html.php @@ -74,10 +74,10 @@ + global->flow != 'onlyTask' and $project->type != 'ops'):?> task->selectTestStory;?> - @@ -90,8 +90,11 @@ + + $storyTitle):?> + - + + + = 5) break;?> +
task->priList, $task->pri, "class='form-control chosen'");?>
@@ -109,11 +112,14 @@
- + task->name;?> @@ -262,4 +268,5 @@ +