diff --git a/module/story/control.php b/module/story/control.php index 7a04436294..47f90a0169 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -866,6 +866,7 @@ class story extends control $this->view->branchTagOption = $branchTagOption; $this->view->reviewers = array_keys($reviewerList); $this->view->reviewedReviewer = $reviewedReviewer; + $this->view->lastReviewer = $this->story->getLastReviewer($story->id); $this->view->productReviewers = $this->user->getPairs('noclosed|nodeleted', array_keys($reviewerList), 0, $productReviewers); $this->display(); @@ -1158,6 +1159,7 @@ class story extends control $this->view->needReview = (($this->app->user->account == $this->view->product->PO or $this->config->story->needReview == 0 or !$this->story->checkForceReview()) and empty($reviewer)) ? "checked='checked'" : ""; $this->view->reviewer = implode(',', array_keys($reviewer)); $this->view->productReviewers = $this->user->getPairs('noclosed|nodeleted', $reviewer, 0, $productReviewers); + $this->view->lastReviewer = $this->story->getLastReviewer($story->id); $this->display(); } @@ -1573,11 +1575,12 @@ class story extends control $reviewerList = $this->story->getReviewerPairs($story->id, $story->version); $story->reviewer = array_keys($reviewerList); - $this->view->story = $story; - $this->view->actions = $this->action->getList('story', $storyID); - $this->view->reviewers = $this->user->getPairs('noclosed|nodeleted', '', 0, $reviewers); - $this->view->users = $this->user->getPairs('noclosed|noletter'); - $this->view->needReview = (($this->app->user->account == $product->PO or $this->config->story->needReview == 0 or !$this->story->checkForceReview()) and empty($story->reviewer)) ? "checked='checked'" : ""; + $this->view->story = $story; + $this->view->actions = $this->action->getList('story', $storyID); + $this->view->reviewers = $this->user->getPairs('noclosed|nodeleted', '', 0, $reviewers); + $this->view->users = $this->user->getPairs('noclosed|noletter'); + $this->view->needReview = (($this->app->user->account == $product->PO or $this->config->story->needReview == 0 or !$this->story->checkForceReview()) and empty($story->reviewer)) ? "checked='checked'" : ""; + $this->view->lastReviewer = $this->story->getLastReviewer($story->id); $this->display(); } diff --git a/module/story/js/change.js b/module/story/js/change.js index 26c5e8c194..3d1d19c8f4 100644 --- a/module/story/js/change.js +++ b/module/story/js/change.js @@ -2,7 +2,7 @@ $(function() { $('#needNotReview').on('change', function() { - $('#reviewer').text('').attr('disabled', $(this).is(':checked') ? 'disabled' : null).trigger('chosen:updated'); + $('#reviewer').val($(this).is(':checked') ? '' : lastReviewer).attr('disabled', $(this).is(':checked') ? 'disabled' : null).trigger('chosen:updated'); if($(this).is(':checked')) { $('.input-group-addon').removeClass('required'); diff --git a/module/story/js/edit.js b/module/story/js/edit.js index d81afca352..8358c2009e 100644 --- a/module/story/js/edit.js +++ b/module/story/js/edit.js @@ -33,7 +33,7 @@ $(function() $('#needNotReview').on('change', function() { - $('#reviewer').text('').attr('disabled', $(this).is(':checked') ? 'disabled' : null).trigger('chosen:updated'); + $('#reviewer').val($(this).is(':checked') ? '' : lastReviewer).attr('disabled', $(this).is(':checked') ? 'disabled' : null).trigger('chosen:updated'); if($(this).is(':checked')) { $('#reviewerBox').removeClass('required'); diff --git a/module/story/js/submitreview.js b/module/story/js/submitreview.js index 3734ca5b4e..ec36e4121d 100644 --- a/module/story/js/submitreview.js +++ b/module/story/js/submitreview.js @@ -2,7 +2,7 @@ $(function() { $('#needNotReview').on('change', function() { - $('#reviewer').text('').attr('disabled', $(this).is(':checked') ? 'disabled' : null).trigger('chosen:updated'); + $('#reviewer').val($(this).is(':checked') ? '' : lastReviewer).attr('disabled', $(this).is(':checked') ? 'disabled' : null).trigger('chosen:updated'); if($(this).is(':checked')) { $('#reviewerBox').removeClass('required'); diff --git a/module/story/model.php b/module/story/model.php index 1c478ff82e..6667ef89d4 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -6040,4 +6040,25 @@ class storyModel extends model $reviewers = $this->loadModel('user')->getProductViewListUsers($product, '', '', '', ''); return $this->user->getPairs('noclosed|nodeleted', '', 0, $reviewers); } + + /** + * Get the last reviewer. + * + * @param int $storyID + * @access public + * @return string + */ + public function getLastReviewer($storyID) + { + $lastReviewer = $this->dao->select('t2.new')->from(TABLE_ACTION)->alias('t1') + ->leftJoin(TABLE_HISTORY)->alias('t2')->on('t1.id = t2.action') + ->where('t1.objectType')->eq('story') + ->andWhere('t1.objectID')->eq($storyID) + ->andWhere('t2.field')->in('reviewer,reviewers') + ->andWhere('t2.new')->ne('') + ->orderBy('t1.id_desc') + ->fetch('new'); + + return $lastReviewer; + } } diff --git a/module/story/view/change.html.php b/module/story/view/change.html.php index af6fcf4670..c4fc435056 100644 --- a/module/story/view/change.html.php +++ b/module/story/view/change.html.php @@ -11,6 +11,7 @@ */ ?> +
diff --git a/module/story/view/edit.html.php b/module/story/view/edit.html.php index 9ee361c6cb..39540014aa 100644 --- a/module/story/view/edit.html.php +++ b/module/story/view/edit.html.php @@ -23,6 +23,7 @@ story->notice->reviewerNotEmpty);?> story->feedbackSource); ?> status);?> +
diff --git a/module/story/view/submitreview.html.php b/module/story/view/submitreview.html.php index 59037bfbff..4e8ef61ae9 100644 --- a/module/story/view/submitreview.html.php +++ b/module/story/view/submitreview.html.php @@ -12,6 +12,7 @@ ?> +