From 9b3d6387a555c58db19f26b2d46838816f8a8a1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B9=BF=E6=98=8E?= Date: Thu, 29 Dec 2022 10:54:32 +0800 Subject: [PATCH] * Finish task #81192. --- module/story/control.php | 19 ++++++++++++++--- module/story/js/batchclose.js | 30 ++++++++++++++++++++------- module/story/view/batchclose.html.php | 2 +- 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/module/story/control.php b/module/story/control.php index ae93eff8be..835c78c6af 100755 --- a/module/story/control.php +++ b/module/story/control.php @@ -1909,7 +1909,6 @@ class story extends control /* Get edited stories. */ $stories = $this->story->getByList($storyIdList); - $productStoryList = array(); $productList = array(); $ignoreTwins = array(); $twinsCount = array(); @@ -1934,7 +1933,6 @@ class story extends control $storyProduct = isset($productList[$story->product]) ? $productList[$story->product] : $this->product->getByID($story->product); $branch = $storyProduct->type == 'branch' ? ($story->branch > 0 ? $story->branch : '0') : 'all'; - if(!isset($productStoryList[$story->product][$story->branch])) $productStoryList[$story->product][$story->branch] = $this->story->getProductStoryPairs($story->product, $branch, 0, 'all', 'id_desc', 0, '', $story->type); if(!empty($story->twins)) { @@ -2030,7 +2028,6 @@ class story extends control $this->view->storyIdList = $storyIdList; $this->view->storyType = $storyType; $this->view->reasonList = $this->lang->story->reasonList; - $this->view->productStoryList = $productStoryList; $this->view->twinsCount = $twinsCount; $this->display(); @@ -3065,4 +3062,20 @@ class story extends control if(!dao::isError()) $this->loadModel('action')->create('story', $twinID, 'relieved'); return $this->send(array('result' => 'success', 'silbingsCount' => count($twins)-1)); } + + /** + * Ajax get story pairs. + * + * @param int $storyID + * @access public + * @return void + */ + public function ajaxGetStoryPairs($storyID) + { + $this->app->loadLang('bug'); + $story = $this->story->getByID($storyID); + $stories = $this->story->getProductStoryPairs($story->product, $story->branch, 0, 'all', 'id_desc', 0, '', $story->type); + + return print html::select("duplicateStoryIDList[$storyID]", $stories, '', "class='form-control' placeholder='{$this->lang->bug->duplicateTip}'"); + } } diff --git a/module/story/js/batchclose.js b/module/story/js/batchclose.js index 7c15a5c040..7b2234290c 100755 --- a/module/story/js/batchclose.js +++ b/module/story/js/batchclose.js @@ -27,14 +27,30 @@ function setDuplicateAndChild(resolution, storyID) $(function() { - $('select[id^="duplicateStoryIDList"]').picker( + $('td[id^="duplicateStoryBox"]').on('mouseenter', 'select[id^="duplicateStoryIDList"]', function() { - disableEmptySearch : true, - dropWidth : 'auto', - onReady: function(event) + var options = $(this).find('option').length; + if(options <= 1) { - $(event.picker.$container).addClass('required'); - } + var id = $(this).attr('id'); + var storyID = id.replace('duplicateStoryIDList', ''); + var link = createLink('story', 'ajaxGetStoryPairs', 'storyID=' + storyID); + var that = $(this); - }); + $.get(link, function(data) + { + that.replaceWith(data); + $("#duplicateStoryIDList" + storyID).picker( + { + disableEmptySearch : true, + dropWidth : 'auto', + onReady: function(event) + { + $(event.picker.$container).addClass('required'); + } + + }); + }) + } + }) }); diff --git a/module/story/view/batchclose.html.php b/module/story/view/batchclose.html.php index 3427bf860b..4ab3ca1a84 100755 --- a/module/story/view/batchclose.html.php +++ b/module/story/view/batchclose.html.php @@ -49,7 +49,7 @@ ' closedReason != 'duplicate') echo "style='display:none'";?>> - '') + $productStoryList[$story->product][$story->branch], $story->duplicateStory ? $story->duplicateStory : '', "class='form-control' placeholder='{$lang->bug->duplicateTip}'");?> + bug->duplicateTip}'");?> ' closedReason != 'subdivided') echo "style='display:none'";?>> idAB}'");?>