diff --git a/module/productplan/control.php b/module/productplan/control.php index 48d00493ea..2a820a8806 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -228,13 +228,39 @@ class productplan extends control $this->session->set('storyList', $this->app->getURI(true) . '&type=' . 'story'); $this->session->set('bugList', $this->app->getURI(true) . '&type=' . 'bug'); + $reSort = false; + if($type == 'story' && strpos($orderBy, 'order') !== false) + { + $orderBy = str_replace('order', 'id', $orderBy); + $reSort = true; + } + /* Append id for secend sort. */ $sort = $this->loadModel('common')->appendOrder($orderBy); $plan = $this->productplan->getByID($planID, true); if(!$plan) die(js::error($this->lang->notFound) . js::locate('back')); $this->commonAction($plan->product, $plan->branch); - $products = $this->product->getPairs(); + $products = $this->product->getPairs(); + + $planStories = $this->loadModel('story')->getPlanStories($planID, 'all', $type == 'story' ? $sort : 'id_desc'); + if($reSort) + { + if(!empty($plan->order)) + { + $stories = array(); + $order = explode(',', $plan->order); + if(strpos($orderBy, 'asc') !== false) $order = array_reverse($order, true); + foreach($order as $id) + { + if(empty($id)) continue; + $stories[$id] = $planStories[$id]; + } + $planStories = $stories; + unset($stories); + } + $orderBy = str_replace('id', 'order', $orderBy); + } $this->loadModel('datatable'); $showModule = !empty($this->config->datatable->productBrowse->showModule) ? $this->config->datatable->productBrowse->showModule : ''; @@ -242,7 +268,7 @@ class productplan extends control $this->view->title = "PLAN #$plan->id $plan->title/" . $products[$plan->product]; $this->view->position[] = $this->lang->productplan->view; - $this->view->planStories = $this->loadModel('story')->getPlanStories($planID, 'all', $type == 'story' ? $sort : 'id_desc'); + $this->view->planStories = $planStories; $this->view->planBugs = $this->loadModel('bug')->getPlanBugs($planID, 'all', $type == 'bug' ? $sort : 'id_desc'); $this->view->products = $products; $this->view->summary = $this->product->summary($this->view->planStories); @@ -277,6 +303,20 @@ class productplan extends control die(html::select($planName, $plans, '', "class='form-control'")); } + /** + * Sort story for productplan. + * + * @param int $planID + * + * @access public + * @return bool + */ + public function ajaxStorySort($planID = 0) + { + if(empty($planID)) return true; + $this->dao->update(TABLE_PRODUCTPLAN)->set('`order`')->eq($this->post->storys)->where('id')->eq((int)$planID)->exec(); + } + /** * Link stories. * diff --git a/module/productplan/js/view.js b/module/productplan/js/view.js index c95692ba4f..5222235cbc 100644 --- a/module/productplan/js/view.js +++ b/module/productplan/js/view.js @@ -41,4 +41,19 @@ $(function() $option.toggleClass('hide', $option.text().toString().toLowerCase().indexOf(val) < 0 && $option.data('key').toString().toLowerCase().indexOf(val) < 0); }); }); -}) + + $('#storyList').on('sort.sortable', function(e, data) + { + var list = ''; + for(i = 0; i < data.list.length; i++) list += $(data.list[i]).attr('data-id') + ','; + console.log(list); + $.post(createLink('productplan', 'ajaxStorySort', 'planID=' + planID), {'storys' : list, 'orderBy' : orderBy}, function() + { + var $target = $(data.element[0]); + $target.hide(); + $target.fadeIn(1000); + order = 'order_asc'; + history.pushState({}, 0, createLink('productplan', 'view', "planID=" + planID + '&type=story&orderBy=' + order)); + }); + }); +}); diff --git a/module/productplan/view/view.html.php b/module/productplan/view/view.html.php index fa9370e780..59422c92de 100644 --- a/module/productplan/view/view.html.php +++ b/module/productplan/view/view.html.php @@ -11,8 +11,10 @@ */ ?> + productplan->confirmUnlinkStory)?> productplan->confirmUnlinkBug)?> +id);?>
icons['plan']);?> id;?> @@ -102,7 +104,7 @@ actions?> - + createLink('story', 'view', "storyID=$story->id"); $totalEstimate += $story->estimate; ?> - + - + id));?> @@ -349,7 +351,7 @@ - + createLink('bug', 'view', "bugID=$bug->id"), sprintf("%03d", $bug->id));?> @@ -374,7 +376,7 @@
- verify = $story->verify; $this->dao->insert(TABLE_STORYSPEC)->data($data)->exec(); - if($projectID != 0 and $story->status != 'draft') + if($projectID != 0 and $story->status != 'draft') { $lastOrder = (int)$this->dao->select('*')->from(TABLE_PROJECTSTORY)->where('project')->eq($projectID)->orderBy('order_desc')->limit(1)->fetch('order'); $this->dao->insert(TABLE_PROJECTSTORY) @@ -209,7 +209,7 @@ class storyModel extends model $bug->assignedTo = 'closed'; $bug->assignedDate = $now; $this->dao->update(TABLE_BUG)->data($bug)->where('id')->eq($bugID)->exec(); - + $this->loadModel('action')->create('bug', $bugID, 'ToStory', '', $storyID); $this->action->create('bug', $bugID, 'Closed'); @@ -218,13 +218,13 @@ class storyModel extends model ->where('objectType')->eq('bug') ->andWhere('objectID')->eq($bugID) ->fetchAll(); - if(!empty($files)) - { + if(!empty($files)) + { foreach($files as $file) { $file->objectType = 'story'; - $file->objectID = $storyID; - unset($file->id); + $file->objectID = $storyID; + unset($file->id); $this->dao->insert(TABLE_FILE)->data($file)->exec(); } } @@ -238,7 +238,7 @@ class storyModel extends model /** * Create a batch stories. - * + * * @access public * @return int|bool the id of the created story or false when error. */ @@ -299,7 +299,7 @@ class storyModel extends model $this->dao->insert(TABLE_STORY)->data($data)->autoCheck() ->batchCheck($this->config->story->create->requiredFields, 'notempty') ->exec(); - if(dao::isError()) + if(dao::isError()) { echo js::error(dao::getError()); die(js::reload('parent')); @@ -327,8 +327,8 @@ class storyModel extends model if(rename($realPath, $this->file->savePath . $this->file->getSaveName($file['pathname']))) { - $file['addedBy'] = $this->app->user->account; - $file['addedDate'] = $now; + $file['addedBy'] = $this->app->user->account; + $file['addedDate'] = $now; $file['objectType'] = 'story'; $file['objectID'] = $storyID; if(in_array($file['extension'], $this->config->file->imageExtensions)) @@ -359,7 +359,7 @@ class storyModel extends model /* Remove upload image file and session. */ if(!empty($stories->uploadImage) and $this->session->storyImagesFile) { - $classFile = $this->app->loadClass('zfile'); + $classFile = $this->app->loadClass('zfile'); $file = current($_SESSION['storyImagesFile']); $realPath = dirname($file['realpath']); if(is_dir($realPath)) $classFile->removeDir($realPath); @@ -371,8 +371,8 @@ class storyModel extends model /** * Change a story. - * - * @param int $storyID + * + * @param int $storyID * @access public * @return array the change of the story. */ @@ -447,8 +447,8 @@ class storyModel extends model /** * Update a story. - * - * @param int $storyID + * + * @param int $storyID * @access public * @return array the changes of the story. */ @@ -513,7 +513,7 @@ class storyModel extends model /** * Batch update stories. - * + * * @access public * @return array. */ @@ -539,9 +539,9 @@ class storyModel extends model if($data->modules[$storyID] == 'ditto') $data->modules[$storyID] = isset($prev['module']) ? $prev['module'] : 0; if($data->plans[$storyID] == 'ditto') $data->plans[$storyID] = isset($prev['plan']) ? $prev['plan'] : 0; if($data->sources[$storyID] == 'ditto') $data->sources[$storyID] = isset($prev['source']) ? $prev['source'] : ''; - if(isset($data->stages[$storyID]) and ($data->stages[$storyID] == 'ditto')) $data->stages[$storyID] = isset($prev['stage']) ? $prev['stage'] : ''; - if(isset($data->closedBys[$storyID]) and ($data->closedBys[$storyID] == 'ditto')) $data->closedBys[$storyID] = isset($prev['closedBy']) ? $prev['closedBy'] : ''; - if(isset($data->closedReasons[$storyID]) and ($data->closedReasons[$storyID] == 'ditto')) $data->closedReasons[$storyID] = isset($prev['closedReason']) ? $prev['closedReason'] : ''; + if(isset($data->stages[$storyID]) and ($data->stages[$storyID] == 'ditto')) $data->stages[$storyID] = isset($prev['stage']) ? $prev['stage'] : ''; + if(isset($data->closedBys[$storyID]) and ($data->closedBys[$storyID] == 'ditto')) $data->closedBys[$storyID] = isset($prev['closedBy']) ? $prev['closedBy'] : ''; + if(isset($data->closedReasons[$storyID]) and ($data->closedReasons[$storyID] == 'ditto')) $data->closedReasons[$storyID] = isset($prev['closedReason']) ? $prev['closedReason'] : ''; $prev['pri'] = $data->pris[$storyID]; $prev['branch'] = isset($data->branches[$storyID]) ? $data->branches[$storyID] : 0; @@ -611,7 +611,7 @@ class storyModel extends model $this->dao->insert(TABLE_STORYSPEC)->data($data)->exec(); } - if(!dao::isError()) + if(!dao::isError()) { if($story->closedReason == 'done') $this->loadModel('score')->create('story', 'close'); $allChanges[$storyID] = common::createChanges($oldStory, $story); @@ -628,8 +628,8 @@ class storyModel extends model /** * Review a story. - * - * @param int $storyID + * + * @param int $storyID * @access public * @return bool */ @@ -689,8 +689,8 @@ class storyModel extends model /** * Batch review stories. - * - * @param array $storyIDList + * + * @param array $storyIDList * @access public * @return array */ @@ -733,10 +733,10 @@ class storyModel extends model } /** - * Subdivide story - * - * @param int $storyID - * @param array $stories + * Subdivide story + * + * @param int $storyID + * @param array $stories * @access public * @return int */ @@ -776,8 +776,8 @@ class storyModel extends model /** * Close a story. - * - * @param int $storyID + * + * @param int $storyID * @access public * @return bool */ @@ -798,7 +798,7 @@ class storyModel extends model ->add('closedBy', $this->app->user->account) ->add('assignedTo', 'closed') ->add('assignedDate', $now) - ->add('status', 'closed') + ->add('status', 'closed') ->removeIF($this->post->closedReason != 'duplicate', 'duplicateStory') ->removeIF($this->post->closedReason != 'subdivided', 'childStories') ->setIF($this->post->closedReason == 'done', 'stage', 'released') @@ -817,7 +817,7 @@ class storyModel extends model /** * Batch close story. - * + * * @access public * @return void */ @@ -867,7 +867,7 @@ class storyModel extends model ->checkIF($story->closedReason == 'duplicate', 'duplicateStory', 'notempty') ->where('id')->eq($storyID)->exec(); - if(!dao::isError()) + if(!dao::isError()) { $allChanges[$storyID] = common::createChanges($oldStory, $story); } @@ -912,11 +912,11 @@ class storyModel extends model /** * Batch change the plan of story. - * - * @param array $storyIDList - * @param int $planID + * + * @param array $storyIDList + * @param int $planID * @access public - * @return array + * @return array */ public function batchChangePlan($storyIDList, $planID, $oldPlanID = 0) { @@ -952,9 +952,9 @@ class storyModel extends model /** * Batch change branch. - * - * @param array $storyIDList - * @param int $branchID + * + * @param array $storyIDList + * @param int $branchID * @access public * @return void */ @@ -980,8 +980,8 @@ class storyModel extends model /** * Batch change the stage of story. - * - * @param string $stage + * + * @param string $stage * @access public * @return array */ @@ -1011,7 +1011,7 @@ class storyModel extends model /** * Batch assign to. - * + * * @access public * @return array */ @@ -1041,8 +1041,8 @@ class storyModel extends model /** * Activate a story. - * - * @param int $storyID + * + * @param int $storyID * @access public * @return bool */ @@ -1069,8 +1069,8 @@ class storyModel extends model /** * Set stage of a story. - * - * @param int $storyID + * + * @param int $storyID * @access public * @return bool */ @@ -1162,11 +1162,11 @@ class storyModel extends model } /** - * Judge stage according to the devel and test tasks' status. - * + * Judge stage according to the devel and test tasks' status. + * * 1. one doing devel task, all test tasks waiting, set stage as developing. * 2. all devel tasks done, all test tasks waiting, set stage as developed. - * 3. one test task doing, set stage as testing. + * 3. one test task doing, set stage as testing. * 4. all test tasks done, still some devel tasks not done(wait, doing), set stage as testing. * 5. all test tasks done, all devel tasks done, set stage as tested. */ @@ -1175,7 +1175,7 @@ class storyModel extends model $stage = 'projected'; $testTasks = isset($branchTestTasks[$branch]) ? $branchTestTasks[$branch] : 0; $develTasks = isset($branchDevelTasks[$branch]) ? $branchDevelTasks[$branch] : 0; - if($statusList['devel']['doing'] > 0 and $statusList['test']['wait'] == $testTasks) $stage = 'developing'; + if($statusList['devel']['doing'] > 0 and $statusList['test']['wait'] == $testTasks) $stage = 'developing'; if($statusList['devel']['done'] == $develTasks and $develTasks > 0 and $statusList['test']['wait'] == $testTasks) $stage = 'developed'; if($statusList['test']['doing'] > 0) $stage = 'testing'; if(($statusList['devel']['wait'] > 0 or $statusList['devel']['doing'] > 0) and $statusList['test']['done'] == $testTasks and $testTasks > 0) $stage = 'testing'; @@ -1305,7 +1305,7 @@ class storyModel extends model /** * Get stories list of a product. - * + * * @param int $productID * @param array|string $moduleIdList * @param string $status @@ -1337,12 +1337,12 @@ class storyModel extends model /** * Get stories pairs of a product. - * - * @param int $productID - * @param array|string $moduleIdList - * @param string $status - * @param string $order - * @param int $limit + * + * @param int $productID + * @param array|string $moduleIdList + * @param string $status + * @param string $order + * @param int $limit * @access public * @return array */ @@ -1365,11 +1365,11 @@ class storyModel extends model /** * Get stories by assignedTo. - * - * @param int $productID - * @param string $account - * @param string $orderBy - * @param object $pager + * + * @param int $productID + * @param string $account + * @param string $orderBy + * @param object $pager * @access public * @return array */ @@ -1380,11 +1380,11 @@ class storyModel extends model /** * Get stories by openedBy. - * - * @param int $productID - * @param string $account - * @param string $orderBy - * @param object $pager + * + * @param int $productID + * @param string $account + * @param string $orderBy + * @param object $pager * @access public * @return array */ @@ -1395,11 +1395,11 @@ class storyModel extends model /** * Get stories by reviewedBy. - * - * @param int $productID - * @param string $account - * @param string $orderBy - * @param object $pager + * + * @param int $productID + * @param string $account + * @param string $orderBy + * @param object $pager * @access public * @return array */ @@ -1410,11 +1410,11 @@ class storyModel extends model /** * Get stories by closedBy. - * - * @param int $productID - * @param string $account - * @param string $orderBy - * @param object $pager + * + * @param int $productID + * @param string $account + * @param string $orderBy + * @param object $pager * @return array */ public function getByClosedBy($productID, $branch, $modules, $account, $orderBy, $pager) @@ -1424,11 +1424,11 @@ class storyModel extends model /** * Get stories by status. - * - * @param int $productID - * @param string $orderBy - * @param object $pager - * @param string $status + * + * @param int $productID + * @param string $orderBy + * @param object $pager + * @param string $status * @access public * @return array */ @@ -1456,12 +1456,12 @@ class storyModel extends model /** * Get stories by a field. - * - * @param int $productID - * @param string $fieldName - * @param mixed $fieldValue - * @param string $orderBy - * @param object $pager + * + * @param int $productID + * @param string $fieldName + * @param mixed $fieldValue + * @param string $orderBy + * @param object $pager * @param string $operator equal|include * @access public * @return array @@ -1484,10 +1484,10 @@ class storyModel extends model /** * Get to be closed stories. - * - * @param int $productID - * @param string $orderBy - * @param string $pager + * + * @param int $productID + * @param string $orderBy + * @param string $pager * @access public * @return array */ @@ -1522,7 +1522,7 @@ class storyModel extends model { if($projectID != '') { - $products = $this->loadModel('project')->getProducts($projectID); + $products = $this->loadModel('project')->getProducts($projectID); } else { @@ -1552,7 +1552,7 @@ class storyModel extends model foreach($products as $product) $branches[$product->branch] = $product->branch; unset($branches[0]); $branches = join(',', $branches); - if($branches) $storyQuery .= " AND `branch`" . helper::dbIN("0,$branches"); + if($branches) $storyQuery .= " AND `branch`" . helper::dbIN("0,$branches"); if($this->app->moduleName == 'release' or $this->app->moduleName == 'build') { $storyQuery .= " AND `status` NOT IN ('draft')";// Fix bug #990. @@ -1575,11 +1575,11 @@ class storyModel extends model /** * Get stories by a sql. - * - * @param int $productID - * @param string $sql - * @param string $orderBy - * @param object $pager + * + * @param int $productID + * @param string $sql + * @param string $orderBy + * @param object $pager * @access public * @return array */ @@ -1614,12 +1614,12 @@ class storyModel extends model } return $stories; } - + /** * Get stories list of a project. - * - * @param int $projectID - * @param string $orderBy + * + * @param int $projectID + * @param string $orderBy * @access public * @return array */ @@ -1696,9 +1696,9 @@ class storyModel extends model /** * Get stories pairs of a project. - * - * @param int $projectID - * @param int $productID + * + * @param int $projectID + * @param int $productID * @param array|string $moduleIdList * @param string $type * @access public @@ -1766,11 +1766,11 @@ class storyModel extends model /** * Get stories of a user. - * - * @param string $account - * @param string $type the query type - * @param string $orderBy - * @param object $pager + * + * @param string $account + * @param string $type the query type + * @param string $orderBy + * @param object $pager * @access public * @return array */ @@ -1788,19 +1788,19 @@ class storyModel extends model ->orderBy($orderBy) ->page($pager) ->fetchAll(); - + $this->loadModel('common')->saveQueryCondition($this->dao->get(), 'story'); $productIdList = array(); foreach($stories as $story) $productIdList[$story->product] = $story->product; - + return $this->mergePlanTitle($productIdList, $stories); } /** * Get story pairs of a user. - * - * @param string $account - * @param string $limit + * + * @param string $account + * @param string $limit * @access public * @return array */ @@ -1814,11 +1814,11 @@ class storyModel extends model ->limit($limit) ->fetchAll(); } - + /** * Get doing projects' members of a story. - * - * @param int $storyID + * + * @param int $storyID * @access public * @return array */ @@ -1835,8 +1835,8 @@ class storyModel extends model /** * Get version of a story. - * - * @param int $storyID + * + * @param int $storyID * @access public * @return int */ @@ -1847,7 +1847,7 @@ class storyModel extends model /** * Get versions of some stories. - * + * * @param array|string story id list * @access public * @return array @@ -1859,8 +1859,8 @@ class storyModel extends model /** * Get zero case. - * - * @param int $productID + * + * @param int $productID * @access public * @return array */ @@ -1879,8 +1879,8 @@ class storyModel extends model /** * Batch get story stage. - * - * @param array $stories + * + * @param array $stories * @access public * @return array */ @@ -1893,8 +1893,8 @@ class storyModel extends model /** * Check need confirm. - * - * @param array $dataList + * + * @param array $dataList * @access public * @return array */ @@ -1922,9 +1922,9 @@ class storyModel extends model } /** - * Format stories - * - * @param array $stories + * Format stories + * + * @param array $stories * @param string $type * @param int $limit * @access public @@ -1963,8 +1963,8 @@ class storyModel extends model /** * Extract accounts from some stories. - * - * @param array $stories + * + * @param array $stories * @access public * @return array */ @@ -1983,8 +1983,8 @@ class storyModel extends model /** * Extract accounts from a story. - * - * @param object $story + * + * @param object $story * @access public * @return array */ @@ -2000,8 +2000,8 @@ class storyModel extends model /** * Merge the default chart settings and the settings of current chart. - * - * @param string $chartType + * + * @param string $chartType * @access public * @return void */ @@ -2019,7 +2019,7 @@ class storyModel extends model } /** - * Get report data of storys per product + * Get report data of storys per product * * @access public * @return array @@ -2073,7 +2073,7 @@ class storyModel extends model } /** - * Get report data of storys per source + * Get report data of storys per source * * @access public * @return array @@ -2090,8 +2090,8 @@ class storyModel extends model } /** - * Get report data of storys per plan - * + * Get report data of storys per plan + * * @access public * @return array */ @@ -2107,8 +2107,8 @@ class storyModel extends model } /** - * Get report data of storys per status - * + * Get report data of storys per status + * * @access public * @return array */ @@ -2123,8 +2123,8 @@ class storyModel extends model } /** - * Get report data of storys per stage - * + * Get report data of storys per stage + * * @access public * @return array */ @@ -2139,8 +2139,8 @@ class storyModel extends model } /** - * Get report data of storys per pri - * + * Get report data of storys per pri + * * @access public * @return array */ @@ -2155,8 +2155,8 @@ class storyModel extends model } /** - * Get report data of storys per estimate - * + * Get report data of storys per estimate + * * @access public * @return array */ @@ -2168,8 +2168,8 @@ class storyModel extends model } /** - * Get report data of storys per openedBy - * + * Get report data of storys per openedBy + * * @access public * @return array */ @@ -2185,8 +2185,8 @@ class storyModel extends model } /** - * Get report data of storys per assignedTo - * + * Get report data of storys per assignedTo + * * @access public * @return array */ @@ -2202,8 +2202,8 @@ class storyModel extends model } /** - * Get report data of storys per closedReason - * + * Get report data of storys per closedReason + * * @access public * @return array */ @@ -2218,8 +2218,8 @@ class storyModel extends model } /** - * Get report data of storys per change - * + * Get report data of storys per change + * * @access public * @return array */ @@ -2231,9 +2231,9 @@ class storyModel extends model } /** - * Get kanban group data. - * - * @param array $stories + * Get kanban group data. + * + * @param array $stories * @access public * @return array */ @@ -2247,9 +2247,9 @@ class storyModel extends model /** * Adjust the action clickable. - * - * @param object $story - * @param string $action + * + * @param object $story + * @param string $action * @access public * @return void */ @@ -2267,9 +2267,9 @@ class storyModel extends model /** * Merge plan title. - * - * @param int|array $productID - * @param array $stories + * + * @param int|array $productID + * @param array $stories * @access public * @return array */ @@ -2458,7 +2458,7 @@ class storyModel extends model /** * Set report condition. - * + * * @access public * @return string */ @@ -2478,7 +2478,7 @@ class storyModel extends model /** * Check force review for user. - * + * * @access public * @return bool */ @@ -2491,10 +2491,10 @@ class storyModel extends model } /** - * Send mail - * - * @param int $storyID - * @param int $actionID + * Send mail + * + * @param int $storyID + * @param int $actionID * @access public * @return void */