From 6289859fb27ec433b47006ef13e002b649774a31 Mon Sep 17 00:00:00 2001 From: mayue Date: Wed, 29 Jun 2022 16:40:57 +0800 Subject: [PATCH] * Finish task #58767. --- module/story/control.php | 57 +++++++++++++++++++++++++++---- module/story/js/change.js | 31 +++++++++++++++++ module/story/js/create.js | 8 ++++- module/story/js/review.js | 46 +++++++++++++++++++++---- module/story/model.php | 13 +++++-- module/story/view/change.html.php | 8 ++++- module/story/view/review.html.php | 7 +++- 7 files changed, 152 insertions(+), 18 deletions(-) diff --git a/module/story/control.php b/module/story/control.php index ef6da62ed6..87cfc0166f 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -1284,10 +1284,11 @@ class story extends control $this->view->position[] = $this->lang->story->common; $this->view->position[] = $this->lang->story->review; - $this->view->product = $product; - $this->view->story = $story; - $this->view->actions = $this->action->getList('story', $storyID); - $this->view->users = $this->loadModel('user')->getPairs('nodeleted', "$story->lastEditedBy,$story->openedBy"); + $this->view->product = $product; + $this->view->story = $story; + $this->view->actions = $this->action->getList('story', $storyID); + $this->view->users = $this->loadModel('user')->getPairs('nodeleted|noletter', "$story->lastEditedBy,$story->openedBy"); + $this->view->reviewers = $reviewers; /* Get the affcected things. */ $this->story->getAffectedScope($this->view->story); @@ -2595,16 +2596,58 @@ class story extends control /** * Ajax get story assignee. * - * @param $type create|review|change + * @param string $type create|review|change + * @param int $storyID + * @param array $assignees * * @access public * @return void */ - public function ajaxGetAssignedTo($type = '', $assignees = '') + public function ajaxGetAssignedTo($type = '', $storyID = 0, $assignees = '') { $users = $this->loadModel('user')->getPairs('noletter|noclosed'); - if($type = 'create') + if($type == 'create') + { + $selectUser = is_array($assignees) ? current($assignees) : ''; + + return print(html::select('assignedTo', $users, $selectUser, "class='from-control picker-select'")); + } + + if($type == 'review') + { + $story = $this->story->getByID($storyID); + $reviewers = $this->story->getReviewerPairs($storyID, $story->version); + $isChanged = $story->changedBy ? true : false; + $isSuperReviewer = strpos(',' . trim(zget($this->config->story, 'superReviewers', ''), ',') . ',', ',' . $this->app->user->account . ','); + + if(count($reviewers) == 1) + { + $selectUser = $isChanged ? $story->changedBy : $story->openedBy; + } + else + { + unset($reviewers[$this->app->user->account]); + foreach($reviewers as $account => $result) + { + if(!$reviewers[$account]) + { + $selectUser = $account; + break; + } + else + { + $selectUser = $isChanged ? $story->changedBy : $story->openedBy; + } + } + } + + if($isSuperReviewer !== false) $selectUser = $isChanged ? $story->changedBy : $story->openedBy; + + return print(html::select('assignedTo', $users, $selectUser, "class='from-control picker-select'")); + } + + if($type == 'change') { $selectUser = is_array($assignees) ? current($assignees) : ''; diff --git a/module/story/js/change.js b/module/story/js/change.js index bdab28bdaa..4a33c6cb57 100644 --- a/module/story/js/change.js +++ b/module/story/js/change.js @@ -11,8 +11,39 @@ $(function() { $('.input-group-addon').addClass('required'); } + + loadAssignedTo(); }); $('#needNotReview').change(); if($('.tabs .tab-content .tab-pane.active').children().length == 0) $('.tabs .nav-tabs li.active').css('border-bottom', '1px solid #ccc'); }); + +/** + * Load assignedTo. + * + * @access public + * @return void + */ +function loadAssignedTo() +{ + var assignees = $('#reviewer').val(); + var link = createLink('story', 'ajaxGetAssignedTo', 'type=change&storyID=' + storyID + '&assignees=' + assignees); + $.post(link, function(data) + { + $('#assignedTo').replaceWith(data); + $('#assignedToBox .picker').remove(); + $('#assignedTo').picker(); + }); + + if($('#needNotReview').is(':checked')) + { + $('#assignedToBox').removeClass('hidden'); + $('#reviewerBox').attr('colspan', 1); + } + else + { + $('#assignedToBox').addClass('hidden'); + $('#reviewerBox').attr('colspan', 2); + } +} diff --git a/module/story/js/create.js b/module/story/js/create.js index 6ba0258b5f..f0ed466ae8 100644 --- a/module/story/js/create.js +++ b/module/story/js/create.js @@ -51,10 +51,16 @@ $(function() }); }); +/** + * Load assignedTo. + * + * @access public + * @return void + */ function loadAssignedTo() { var assignees = $('#reviewer').val(); - var link = createLink('story', 'ajaxGetAssignedTo', 'type=create&assignees=' + assignees); + var link = createLink('story', 'ajaxGetAssignedTo', 'type=create&storyID=0&assignees=' + assignees); $.post(link, function(data) { $('#assignedTo').replaceWith(data); diff --git a/module/story/js/review.js b/module/story/js/review.js index 0ffa50543d..b310cfa1d6 100644 --- a/module/story/js/review.js +++ b/module/story/js/review.js @@ -6,6 +6,8 @@ function switchShow(result) { $('#rejectedReasonBox').show(); $('#preVersionBox').hide(); + $('#assignedToBox').hide(); + if(isMultiple) loadAssignedTo(); } else if(result == 'revert') { @@ -13,19 +15,34 @@ function switchShow(result) $('#rejectedReasonBox').hide(); $('#duplicateStoryBox').hide(); $('#childStoriesBox').hide(); + $('#assignedToBox').show(); + loadAssignedTo(); } - else + else if(result == 'clarify') { - if(result == 'pass') - { - $('#priBox').show(); - $('#estimateBox').show(); - } $('#preVersionBox').hide(); $('#rejectedReasonBox').hide(); $('#duplicateStoryBox').hide(); $('#childStoriesBox').hide(); $('#rejectedReasonBox').hide(); + $('#assignedToBox').show(); + loadAssignedTo(); + } + else + { + $('#preVersionBox').hide(); + $('#rejectedReasonBox').hide(); + $('#duplicateStoryBox').hide(); + $('#childStoriesBox').hide(); + $('#rejectedReasonBox').hide(); + $('#assignedToBox').hide(); + if(result == 'pass') + { + $('#priBox').show(); + $('#estimateBox').show(); + $('#assignedToBox').show(); + loadAssignedTo(); + } } getStatus('review', "storyID=" + storyID + ",result=" + result); @@ -50,6 +67,23 @@ function setStory(reason) } } +/** + * Load assignedTo. + * + * @access public + * @return void + */ +function loadAssignedTo() +{ + var link = createLink('story', 'ajaxGetAssignedTo', 'type=review&storyID=' + storyID); + $.post(link, function(data) + { + $('#assignedTo').replaceWith(data); + $('#assignedToBox .picker').remove(); + $('#assignedTo').picker(); + }); +} + $(function() { if($('.tabs .tab-content .tab-pane.active').children().length == 0) $('.tabs .nav-tabs li.active').css('border-bottom', '1px solid #ccc'); diff --git a/module/story/model.php b/module/story/model.php index 73373cf96f..7cb7b82bb2 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -681,15 +681,21 @@ class storyModel extends model ->setIF($specChanged and $oldStory->status == 'active' and $this->post->needNotReview == false, 'status', 'changed') ->setIF($oldStory->status == 'draft' and $this->post->needNotReview, 'status', 'active') ->setIF($specChanged, 'reviewedBy', '') + ->setIF($specChanged, 'changedBy', $this->app->user->account) + ->setIF($specChanged, 'changedDate', $now) ->setIF($specChanged, 'closedBy', '') ->setIF($specChanged, 'closedReason', '') ->setIF($specChanged and $oldStory->reviewedBy, 'reviewedDate', '0000-00-00') ->setIF($specChanged and $oldStory->closedBy, 'closedDate', '0000-00-00') ->stripTags($this->config->story->editor->change['id'], $this->config->allowedTags) - ->remove('files,labels,reviewer,comment,needNotReview,uid') + ->remove('files,labels,reviewer,comment,needNotReview,uid,assignedTo') ->get(); if($specChanged and isset($story->status) && $story->status == 'active' and $this->checkForceReview()) $story->status = 'changed'; $story = $this->loadModel('file')->processImgURL($story, $this->config->story->editor->change['id'], $this->post->uid); + + /* Add story assignedTo. */ + if($this->post->assignedTo) $story->assignedTo = $this->post->assignedTo; + $this->dao->update(TABLE_STORY)->data($story, 'spec,verify') ->autoCheck() ->batchCheck($this->config->story->change->requiredFields, 'notempty') @@ -1337,7 +1343,7 @@ class storyModel extends model ->removeIF($this->post->result == 'reject' and $this->post->closedReason != 'subdivided', 'childStories') ->add('reviewedBy', $oldStory->reviewedBy . ',' . $this->app->user->account) ->add('id', $storyID) - ->remove('result,preVersion,comment') + ->remove('result,preVersion,comment,assignedTo') ->get(); $story = $this->loadModel('file')->processImgURL($story, $this->config->story->editor->review['id'], $this->post->uid); @@ -1356,6 +1362,9 @@ class storyModel extends model if(count($reviewers) > 1) $skipFields = 'closedReason'; } + /* Add story assignedTo. */ + if($this->post->assignedTo) $story->assignedTo = $this->post->assignedTo; + $this->dao->update(TABLE_STORY)->data($story, $skipFields) ->autoCheck() ->batchCheck($this->config->story->review->requiredFields, 'notempty') diff --git a/module/story/view/change.html.php b/module/story/view/change.html.php index 79333c1e1e..893a942896 100644 --- a/module/story/view/change.html.php +++ b/module/story/view/change.html.php @@ -24,7 +24,7 @@ - + diff --git a/module/story/view/review.html.php b/module/story/view/review.html.php index 1e1d20a6dc..ad053920d1 100644 --- a/module/story/view/review.html.php +++ b/module/story/view/review.html.php @@ -29,7 +29,11 @@ - + + + + + @@ -85,4 +89,5 @@ id);?> type);?> app->rawModule);?> +
story->reviewedBy;?> +
story->checkForceReview() ? ' required' : ''));?> story->checkForceReview()):?> @@ -34,6 +34,12 @@
+
+
story->assignedTo;?>
+ +
+
story->status;?>
story->reviewResult;?>story->resultList, '', 'class=form-control onchange="switchShow(this.value)"');?>story->resultList, '', 'class="form-control chosen" onchange="switchShow(this.value)"');?>
story->assignedTo;?>
story->rejectedReason;?>