diff --git a/api/v1/entries/projectreleases.php b/api/v1/entries/projectreleases.php index 75b18aa7c5..4a744952c0 100644 --- a/api/v1/entries/projectreleases.php +++ b/api/v1/entries/projectreleases.php @@ -35,9 +35,10 @@ class projectReleasesEntry extends entry { $result = array(); $releases = $data->data->releases; + $pager = $data->data->pager; foreach($releases as $release) $result[] = $this->format($release, 'deleted:bool,date:date,mailto:userList'); - return $this->send(200, array('total' => count($result), 'releases' => $result)); + return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'releases' => $result)); } if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message); diff --git a/api/v1/entries/releases.php b/api/v1/entries/releases.php index eae75ccb89..5ac2378f4d 100644 --- a/api/v1/entries/releases.php +++ b/api/v1/entries/releases.php @@ -32,9 +32,10 @@ class releasesEntry extends entry { $result = array(); $releases = $data->data->releases; + $pager = $data->data->pager; foreach($releases as $release) $result[] = $this->format($release, 'deleted:bool,date:date,mailto:userList'); - return $this->send(200, array('total' => count($result), 'releases' => $result)); + return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'releases' => $result)); } if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message); diff --git a/db/update18.4.sql b/db/update18.4.sql index 04d5702cc9..d3fb8eb119 100644 --- a/db/update18.4.sql +++ b/db/update18.4.sql @@ -9,6 +9,7 @@ INSERT INTO `zt_privlang` (`objectID`, `objectType`, `lang`, `key`, `value`, `de ALTER TABLE `zt_traincourse` ADD `importedStatus` enum('wait','doing','done') NOT NULL DEFAULT 'wait' AFTER `desc`; ALTER TABLE `zt_traincourse` ADD `lastUpdatedTime` int UNSIGNED NOT NULL DEFAULT 0 AFTER `importedStatus`; +ALTER TABLE `zt_traincourse` MODIFY COLUMN `code` varchar(255) DEFAULT '' NOT NULL; UPDATE `zt_im_chat` SET `createdDate` = NULL WHERE `createdDate` = '0000-00-00 00:00:00'; UPDATE `zt_im_chat` SET `editedDate` = NULL WHERE `editedDate` = '0000-00-00 00:00:00'; diff --git a/db/zentao.sql b/db/zentao.sql index bfab986ff6..0ceb3fefbb 100755 --- a/db/zentao.sql +++ b/db/zentao.sql @@ -3073,7 +3073,7 @@ CREATE TABLE IF NOT EXISTS `zt_deployscope` ( -- DROP TABLE IF EXISTS `zt_traincourse`; CREATE TABLE IF NOT EXISTS `zt_traincourse` ( `id` mediumint(8) NOT NULL AUTO_INCREMENT, - `code` varchar(50) NOT NULL DEFAULT '', + `code` varchar(255) NOT NULL DEFAULT '', `category` mediumint(8) NOT NULL DEFAULT '0', `name` varchar(255) NOT NULL DEFAULT '', `status` varchar(10) NOT NULL DEFAULT '', diff --git a/module/bug/control.php b/module/bug/control.php index 74b2bd36d0..f383f77f08 100755 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -1185,7 +1185,6 @@ class bug extends control $this->view->moduleOptionMenu = $moduleOptionMenu; $this->view->currentModuleID = $currentModuleID; $this->view->executions = $executions; - $this->view->stories = $bug->execution ? $this->story->getExecutionStoryPairs($bug->execution) : $this->story->getProductStoryPairs($bug->product, $bug->branch, 0, 'all', 'id_desc', 0, 'full', 'story', false); $this->view->branchOption = $branchOption; $this->view->branchTagOption = $branchTagOption; $this->view->tasks = $this->task->getExecutionTaskPairs($bug->execution); @@ -1202,7 +1201,7 @@ class bug extends control * * @param int $bugID * @access public - * @return mixed + * @return int */ public function ajaxGetAllBuilds($bugID) { @@ -1239,30 +1238,47 @@ class bug extends control if(($bug->resolvedBuild) and isset($allBuilds[$bug->resolvedBuild])) $oldResolvedBuild[$bug->resolvedBuild] = $allBuilds[$bug->resolvedBuild]; $builds = new stdclass(); - $builds->openedBuilds = array_map(function($key, $value) - { - return (object) array('value' => $key, 'text' => $value); - }, array_keys($openedBuilds), array_values($openedBuilds)); + $builds->openedBuilds = $this->bug->convertArrayToObjectArray($openedBuilds); $resolvedBuilds = $openedBuilds + $oldResolvedBuild; - $builds->resolvedBuilds = array_map(function($key, $value) - { - return (object) array('value' => $key, 'text' => $value); - }, array_keys($resolvedBuilds), array_values($resolvedBuilds)); + $builds->resolvedBuilds = $this->bug->convertArrayToObjectArray($resolvedBuilds); $builds->resolvedBuildName = zget($resolvedBuilds, $bug->resolvedBuild); - echo json_encode($builds); + + return print(helper::jsonEncode($builds)); } + /** + * Ajax get testTasks. + * + * @param int $bugID + * @access public + * @return int + */ public function ajaxGetTestTasks($bugID) { $bug = $this->bug->getById($bugID); - $testTasks = $this->loadModel('testtask')->getPairs($bug->product, $bug->execution, $bug->testtask); - $testTasks = array_map(function($key, $value) - { - return (object) array('value' => $key, 'text' => $value); - }, array_keys($testTasks), array_values($testTasks)); - echo json_encode($testTasks); + $testTasks = $this->loadModel('testtask')->getPairs($bug->product, $bug->execution, $bug->testtask, 'noempty'); + $testTasks = $this->bug->convertArrayToObjectArray($testTasks); + + return print(helper::jsonEncode($testTasks)); + } + + /** + * Ajax get stories. + * + * @param int $bugID + * @access public + * @return int + */ + public function ajaxGetStories($bugID) + { + $bug = $this->bug->getById($bugID); + $stories = $bug->execution ? $this->story->getExecutionStoryPairs($bug->execution) : $this->story->getProductStoryPairs($bug->product, $bug->branch, 0, 'all', 'id_desc', 0, 'full', 'story', false); + if(isset($stories[0])) unset($stories[0]); + $stories = $this->bug->convertArrayToObjectArray($stories); + + return print(helper::jsonEncode($stories)); } /** diff --git a/module/bug/js/common.js b/module/bug/js/common.js index 5c2ab06066..cc77ae25bf 100644 --- a/module/bug/js/common.js +++ b/module/bug/js/common.js @@ -319,7 +319,7 @@ function loadProductStories(productID) if(typeof(branch) == 'undefined') branch = 0; if(typeof(oldStoryID) == 'undefined') oldStoryID = 0; link = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branch + '&moduleId=0&storyID=' + oldStoryID); - $('#storyIdBox').load(link, function(){$('#story').chosen();}); + $('#storyIdBox').load(link, function(){$('#story').picker();}); } /** @@ -773,7 +773,7 @@ function setStories(moduleID, productID, storyID) $('#story').replaceWith(stories); $('#story_chosen').remove(); $('#story').next('.picker').remove(); - $("#story").chosen(); + $("#story").picker(); }); } diff --git a/module/bug/js/edit.js b/module/bug/js/edit.js index 5fbec057e2..65b81da550 100644 --- a/module/bug/js/edit.js +++ b/module/bug/js/edit.js @@ -9,7 +9,7 @@ $(function() if(picker) picker.destroy(); - var options = $.extend({}, originOptions, {searchDelay : 1000}); + var options = $.extend({}, originOptions, {searchDelay: 1000}); $element.picker(options); }; @@ -17,6 +17,7 @@ $(function() initPicker($('#duplicateBug')); renderBuilds(); renderTestTasks(); + renderStories(); $('#duplicateBug').picker( { @@ -59,7 +60,7 @@ function renderBuilds() $('#openedBuild').data('zui.picker').setValue(oldOpenedBuild); var resolvedBuilds = data.resolvedBuilds; $('#resolvedBuild').data('zui.picker').destroy(); - $('#resolvedBuild').picker({list: resolvedBuilds}); + $('#resolvedBuild').picker({list: resolvedBuilds, allowSingleDeselect: 'true'}); $('#resolvedBuild').data('zui.picker').setValue(oldResolvedBuild); resolution = $('#resolution').val(); @@ -93,11 +94,27 @@ function renderTestTasks() $.get(createLink('bug', 'ajaxGetTestTasks', 'bugID=' + bugID), function(data) { $('#testtask').data('zui.picker').destroy(); - $('#testtask').picker({list: data}); + $('#testtask').picker({list: data, allowSingleDeselect: 'true'}); $('#testtask').data('zui.picker').setValue(bugTestTask); }, 'json'); } +/** + * render stories. + * + * @access public + * @return void + */ +function renderStories() +{ + $.get(createLink('bug', 'ajaxGetStories', 'bugID=' + bugID), function(data) + { + $('#story').data('zui.picker').destroy(); + $('#story').picker({list: data, allowSingleDeselect: 'true'}); + $('#story').data('zui.picker').setValue(oldStoryID); + }, 'json'); +} + /** * Set duplicate field. * diff --git a/module/bug/model.php b/module/bug/model.php index 48cfd52023..a96a6887c1 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -3796,4 +3796,19 @@ class bugModel extends model return $index; } + + /** + * Convert array to object array. + * + * @param int $data + * @access public + * @return array + */ + public function convertArrayToObjectArray($data) + { + return array_map(function($key, $value) + { + return (object) array('value' => $key, 'text' => $value); + }, array_keys($data), array_values($data)); + } } diff --git a/module/bug/view/edit.html.php b/module/bug/view/edit.html.php index ad5d69a9d1..327884b86b 100644 --- a/module/bug/view/edit.html.php +++ b/module/bug/view/edit.html.php @@ -221,7 +221,7 @@ if($this->app->tab == 'project') js::set('objectID', $bug->project); bug->story;?> -
story, "class='form-control chosen'");?>
+
@@ -314,7 +314,7 @@ if($this->app->tab == 'project') js::set('objectID', $bug->project); bug->testtask;?> - + testtask, 'class="form-control picker-select"');?> bug->fromCase;?>