This commit is contained in:
wangyidong
2022-04-25 15:20:20 +08:00
9 changed files with 128 additions and 131 deletions
+30 -47
View File
@@ -151,7 +151,7 @@ class api extends control
->get();
/* Check version is exist. */
if(!empty($data->version) and $this->api->getReleaseByVersion($libID, $data->version))
if(!empty($data->version) and $this->api->getRelease($libID, 'byVersion', $data->version))
{
return $this->sendError($this->lang->api->noUniqueVersion);
}
@@ -257,16 +257,7 @@ class api extends control
if(!empty($_POST))
{
$now = helper::now();
$userId = $this->app->user->account;
$data = fixer::input('post')
->skipSpecial('attribute')
->add('lib', $struct->lib)
->add('editedBy', $userId)
->add('editedDate', $now)
->get();
$changes = $this->api->updateStruct($structID, $data);
$changes = $this->api->updateStruct($structID);
if(dao::isError()) return $this->sendError(dao::getError());
$actionID = $this->action->create('apistruct', $structID, 'Edited');
$this->action->logHistory($actionID, $changes);
@@ -434,12 +425,13 @@ class api extends control
$this->setMenu($api->lib);
$this->getTypeOptions($api->lib);
$this->view->title = $api->title . $this->lang->api->edit;
$this->view->gobackLink = $this->createLink('api', 'index', "libID={$api->lib}&moduleID={$api->module}");
$this->view->user = $this->app->user->account;
$this->view->allUsers = $this->loadModel('user')->getPairs('devfirst|noclosed');;
$this->view->moduleOptionMenu = $this->loadModel('tree')->getOptionMenu($api->lib, 'api', $startModuleID = 0);
$this->view->moduleID = $api->module ? (int)$api->module : (int)$this->cookie->lastDocModule;
$this->view->title = $api->title . $this->lang->api->edit;
$this->display();
}
@@ -456,24 +448,11 @@ class api extends control
{
if(!empty($_POST))
{
$now = helper::now();
$params = fixer::input('post')
->trim('title,path')
->remove('type')
->skipSpecial('params,response')
->add('addedBy', $this->app->user->account)
->add('addedDate', $now)
->add('editedBy', $this->app->user->account)
->add('editedDate', $now)
->add('version', 1)
->setDefault('product,module', 0)
->get();
$api = $this->api->create();
if($api === false) return $this->sendError(dao::getError());
$apiID = $this->api->create($params);
if(empty($apiID)) return $this->sendError(dao::getError());
$this->action->create('api', $apiID, 'Created');
return $this->sendSuccess(array('locate' => helper::createLink('api', 'index', "libID={$params->lib}&moduleID=0&apiID=$apiID")));
$this->action->create('api', $api->id, 'Created');
return $this->sendSuccess(array('locate' => helper::createLink('api', 'index', "libID={$api->lib}&moduleID=0&apiID={$api->id}")));
}
$libs = $this->doc->getLibs('api', '', $libID);
@@ -500,6 +479,8 @@ class api extends control
}
/**
* Delete an api.
*
* @param int $apiID
* @param string $confirm
* @access public
@@ -509,8 +490,7 @@ class api extends control
{
if($confirm == 'no')
{
$tips = $this->lang->api->confirmDelete;
return print(js::confirm($tips, inlink('delete', "apiID=$apiID&confirm=yes")));
return print(js::confirm($this->lang->api->confirmDelete, inlink('delete', "apiID=$apiID&confirm=yes")));
}
else
{
@@ -529,7 +509,7 @@ class api extends control
}
/**
* Get params type options by scope
* AJAX: Get params type options by scope.
*
* @access public
* @return void
@@ -545,9 +525,10 @@ class api extends control
}
/**
* Get ref options by ajax.
* AJAX: Get ref options.
*
* @param int $libID
* @param int $libID
* @param int $structID
* @access public
* @return void
*/
@@ -558,8 +539,8 @@ class api extends control
$options = array();
foreach($res as $item)
{
if($item->id == $structID)
continue;
if($item->id == $structID) continue;
$options[$item->id] = $item->name;
}
@@ -567,9 +548,9 @@ class api extends control
}
/**
* Get ref info by ajax.
* AJAX: Get ref info.
*
* @param int $refID
* @param int $refID
* @access public
* @return void
*/
@@ -580,8 +561,10 @@ class api extends control
}
/**
* Ajax get all child module.
* AJAX: Get all child module.
*
* @param int $libID
* @param string $type
* @access public
* @return void
*/
@@ -596,8 +579,8 @@ class api extends control
/**
* Set doc menu by method name.
*
* @param int $libID
* @param int $moduleID
* @param int $libID
* @param int $moduleID
* @access public
* @return void
*/
@@ -675,7 +658,7 @@ EOT;
foreach($libs as $key => $lib)
{
$selected = $key == $libID ? 'selected' : '';
$output .= html::a(inlink('index', "libID=$key"), $lib->name, '', "class='$selected' data-app='{$this->app->tab}'");
$output .= html::a(inlink('index', "libID=$key"), $lib->name, '', "class='$selected' data-app='{$this->app->tab}'");
}
$output .= "</div></div></div></div></div>";
@@ -684,7 +667,7 @@ EOT;
if(!empty($versions))
{
$versionName = $version > 0 ? $versions[$version]->version : $this->lang->api->defaultVersion;
$output .= <<<EOT
$output .= <<<EOT
<div class='btn-group angle-btn'>
<div class='btn-group'>
<button id='currentBranch' data-toggle='dropdown' type='button' class='btn btn-limit'>{$versionName} <span class='caret'></span>
@@ -698,12 +681,12 @@ EOT;
<div class='table-col'>
<div class='list-group'>
EOT;
$selected = $version > 0 ? '' : 'selected';
$output .= html::a(inlink('index', "libID=$libID&moduleID=0&apiID=0&version=0&release=0"), $this->lang->api->defaultVersion, '', "class='$selected'");
$selected = $version > 0 ? '' : 'selected';
$output .= html::a(inlink('index', "libID=$libID&moduleID=0&apiID=0&version=0&release=0"), $this->lang->api->defaultVersion, '', "class='$selected'");
foreach($versions as $key => $item)
{
$selected = $key == $version ? 'selected' : '';
$output .= html::a(inlink('index', "libID=$libID&moduleID=0&apiID=0&version=0&release=$key"), $item->version, '', "class='$selected' data-app='{$this->app->tab}'");
$output .= html::a(inlink('index', "libID=$libID&moduleID=0&apiID=0&version=0&release=$key"), $item->version, '', "class='$selected' data-app='{$this->app->tab}'");
}
$output .= "</div></div></div></div></div>";
}
@@ -743,7 +726,7 @@ EOT;
$newParams = array_shift($params);
foreach($params as $param)
{
$sign = strpos($param, '=') !== false ? '&' : ',';
$sign = strpos($param, '=') !== false ? '&' : ',';
$newParams .= $sign . $param;
}
+73 -70
View File
@@ -12,17 +12,17 @@
class apiModel extends model
{
/* Status. */
const STATUS_DOING = 'doing';
const STATUS_DONE = 'done';
const STATUS_DOING = 'doing';
const STATUS_DONE = 'done';
const STATUS_HIDDEN = 'hidden';
/* Scope. */
const SCOPE_QUERY = 'query';
const SCOPE_QUERY = 'query';
const SCOPE_FORM_DATA = 'formData';
const SCOPE_PATH = 'path';
const SCOPE_BODY = 'body';
const SCOPE_HEADER = 'header';
const SCOPE_COOKIE = 'cookie';
const SCOPE_PATH = 'path';
const SCOPE_BODY = 'body';
const SCOPE_HEADER = 'header';
const SCOPE_COOKIE = 'cookie';
/* Params. */
const PARAMS_TYPE_CUSTOM = 'custom';
@@ -68,7 +68,7 @@ class apiModel extends model
/**
* Delete a lib publish.
*
* @param int $id
* @param int $id
* @access public
* @return void
*/
@@ -82,29 +82,43 @@ class apiModel extends model
/**
* Create an api doc.
*
* @param object $params
* @access public
* @return int
* @return object | bool
*/
public function create($params)
public function create()
{
$this->dao->insert(TABLE_API)->data($params)
$now = helper::now();
$data = fixer::input('post')
->trim('title,path')
->remove('type')
->skipSpecial('params,response')
->add('addedBy', $this->app->user->account)
->add('addedDate', $now)
->add('editedBy', $this->app->user->account)
->add('editedDate', $now)
->add('version', 1)
->setDefault('product,module', 0)
->get();
$this->dao->insert(TABLE_API)->data($data)
->autoCheck()
->batchCheck($this->config->api->create->requiredFields, 'notempty')
->exec();
$params->id = $this->dao->lastInsertID();
if(dao::isError()) return false;
$apiSpec = $this->getApiSpecByData($params);
$data->id = $this->dao->lastInsertID();
$apiSpec = $this->getApiSpecByData($data);
$this->dao->replace(TABLE_API_SPEC)->data($apiSpec)->exec();
return dao::isError() ? false : $params->id;
return $data;
}
/**
* Create a global struct
* Create a global struct.
*
* @param object $data
* @param object $data
* @access public
* @return int
*/
@@ -116,6 +130,8 @@ class apiModel extends model
->batchCheck($this->config->api->struct->requiredFields, 'notempty')
->exec();
if(dao::isError()) return false;
$id = $this->dao->lastInsertID();
/* Create a struct version. */
@@ -130,19 +146,28 @@ class apiModel extends model
);
$this->dao->insert(TABLE_APISTRUCT_SPEC)->data($version)->exec();
return dao::isError() ? 0 : $id;
if(dao::isError()) return false;
return $id;
}
/**
* Update a struct.
*
* @param int $id
* @param object $data
* @param int $id
* @access public
* @return array
*/
public function updateStruct($id, $data)
public function updateStruct($id)
{
$now = helper::now();
$data = fixer::input('post')
->skipSpecial('attribute')
->add('lib', $struct->lib)
->add('editedBy', $this->app->user->account)
->add('editedDate', $now)
->get();
$old = $this->dao->findByID($id)->from(TABLE_APISTRUCT)->fetch();
unset($data->addedBy);
@@ -190,11 +215,10 @@ class apiModel extends model
return false;
}
$now = helper::now();
$account = $this->app->user->account;
$data = fixer::input('post')
$now = helper::now();
$data = fixer::input('post')
->skipSpecial('params,response')
->add('editedBy', $account)
->add('editedBy', $this->app->user->account)
->add('editedDate', $now)
->add('version', $oldApi->version)
->setDefault('product,module', 0)
@@ -259,36 +283,21 @@ class apiModel extends model
}
/**
* Get release by version.
* Get release.
*
* @param int $libID
* @param string $version
* @param int $libID
* @param string $type
* @param int $param
* @access public
* @return object
* @access public
*/
public function getReleaseByVersion($libID, $version)
public function getRelease($libID = 0, $type = '', $param = 0)
{
$model = $this->dao->select('*')
->from(TABLE_API_LIB_RELEASE)
->where('version')->eq($version)
->andWhere('lib')->eq($libID)
->fetch();
if($model) $model->snap = json_decode($model->snap, true);
return $model;
}
/**
* Get release by id.
*
* @param int $id
* @access public
* @return array
*/
public function getReleaseById($id)
{
$model = $this->dao->select('*')
->from(TABLE_API_LIB_RELEASE)
->where('id')->eq($id)
$model = $this->dao->select('*')->from(TABLE_API_LIB_RELEASE)
->where('1 = 1')
->beginIF($libID)->andWhere('lib')->eq($libID)->fi()
->beginIF($type == 'byVersion')->andWhere('version')->eq($param)->fi()
->beginIF($type == 'byId')->andWhere('id')->eq($param)->fi()
->fetch();
if($model) $model->snap = json_decode($model->snap, true);
return $model;
@@ -303,10 +312,7 @@ class apiModel extends model
*/
public function getReleaseListByApi($libID)
{
$versions = $this->dao->select('*')->from(TABLE_API_LIB_RELEASE)
->where('lib')->eq($libID)
->fetchAll('id');
return $versions;
return $this->dao->select('*')->from(TABLE_API_LIB_RELEASE)->where('lib')->eq($libID)->fetchAll('id');
}
@@ -323,7 +329,7 @@ class apiModel extends model
{
if($release)
{
$rel = $this->getReleaseById($release);
$rel = $this->getRelease(0, 'byId', $release);
foreach($rel->snap['apis'] as $api)
{
if($api['id'] == $id) $version = $api['version'];
@@ -338,9 +344,7 @@ class apiModel extends model
$fields = 'api.*,doc.name as libName,module.name as moduleName';
}
$model = $this->dao
->select($fields)
->from(TABLE_API)->alias('api')
$model = $this->dao->select($fields)->from(TABLE_API)->alias('api')
->beginIF($version)->leftJoin(TABLE_API_SPEC)->alias('spec')->on('api.id = spec.doc')->fi()
->leftJoin(TABLE_DOCLIB)->alias('doc')->on('api.lib = doc.id')
->leftJoin(TABLE_MODULE)->alias('module')->on('api.module = module.id')
@@ -359,8 +363,9 @@ class apiModel extends model
/**
* Get api list by release.
*
* @param object $release
* @param string $where
* @param object $release
* @param string $where
* @access public
* @return array
*/
public function getApiListByRelease($release, $where = '')
@@ -380,20 +385,19 @@ class apiModel extends model
}
/**
* Get api doc list by module id
* Get api doc list by module id.
*
* @param int $libID
* @param int $moduleID
* @param int $release
* @param int $libID
* @param int $moduleID
* @param int $release
* @return array $list
* @author thanatos thanatos915@163.com
*/
public function getListByModuleId($libID = 0, $moduleID = 0, $release = 0)
{
/* Get release info. */
if($release > 0)
{
$rel = $this->getReleaseById($release);
$rel = $this->getRelease(0, 'byId', $release);
$where = "1=1 and lib = $libID ";
if($moduleID > 0)
@@ -413,7 +417,6 @@ class apiModel extends model
}
else
{
if($moduleID > 0)
{
$sub = $this->dao->select('id')->from(TABLE_MODULE)->where('FIND_IN_SET(' . $moduleID . ', path)')->processSQL();
@@ -585,7 +588,7 @@ class apiModel extends model
foreach($_POST as $key => $value) $param .= ',' . $key . '=' . $value;
$param = ltrim($param, ',');
}
$url = rtrim($host, '/') . inlink('getModel', "moduleName=$moduleName&methodName=$methodName&params=$param", 'json');
$url = rtrim($host, '/') . inlink('getModel', "moduleName=$moduleName&methodName=$methodName&params=$param", 'json');
$url .= $this->config->requestType == "PATH_INFO" ? '?' : '&';
$url .= $this->config->sessionVar . '=' . session_id();
}
@@ -596,7 +599,7 @@ class apiModel extends model
foreach($_POST as $key => $value) $param .= '&' . $key . '=' . $value;
$param = ltrim($param, '&');
}
$url = rtrim($host, '/') . helper::createLink($moduleName, $methodName, $param, 'json');
$url = rtrim($host, '/') . helper::createLink($moduleName, $methodName, $param, 'json');
$url .= $this->config->requestType == "PATH_INFO" ? '?' : '&';
$url .= $this->config->sessionVar . '=' . session_id();
}
+1 -1
View File
@@ -195,7 +195,7 @@ class bug extends control
/* Build the search form. */
$actionURL = $this->createLink('bug', 'browse', "productID=$productID&branch=$branch&browseType=bySearch&queryID=myQueryID");
$this->config->bug->search['onMenuBar'] = 'yes';
$this->bug->buildSearchForm($productID, $this->products, $queryID, $actionURL);
$this->bug->buildSearchForm($productID, $this->products, $queryID, $actionURL, $branch);
$showModule = !empty($this->config->datatable->bugBrowse->showModule) ? $this->config->datatable->bugBrowse->showModule : '';
$productName = ($productID and isset($this->products[$productID])) ? $this->products[$productID] : $this->lang->product->allProduct;
+3 -2
View File
@@ -1415,10 +1415,11 @@ class bugModel extends model
* @param array $products
* @param int $queryID
* @param string $actionURL
* @param int $branch
* @access public
* @return void
*/
public function buildSearchForm($productID, $products, $queryID, $actionURL)
public function buildSearchForm($productID, $products, $queryID, $actionURL, $branch = 0)
{
$projectID = $this->lang->navGroup->bug == 'qa' ? 0 : $this->session->project;
$productParams = ($productID and isset($products[$productID])) ? array($productID => $products[$productID]) : $products;
@@ -1429,7 +1430,7 @@ class bugModel extends model
/* Get all modules. */
$modules = array();
$this->loadModel('tree');
if($productID) $modules = $this->tree->getOptionMenu($productID, 'bug', 0);
if($productID) $modules = $this->tree->getOptionMenu($productID, 'bug', 0, $branch);
if(!$productID)
{
foreach($products as $id => $productName) $modules += $this->tree->getOptionMenu($id, 'bug');
+15 -6
View File
@@ -82,13 +82,22 @@ class release extends control
foreach($releasedBuilds as $build) unset($builds[$build]);
unset($builds['trunk']);
/* Get the builds of the linked stories or bugs. */
$notEmptyBuilds = array();
$buildList = $this->build->getByList(array_keys($builds));
foreach($buildList as $build)
{
if(!empty($build->stories) or !empty($build->bugs)) $notEmptyBuilds[$build->id] = $build->id;
}
$this->commonAction($productID, $branch);
$this->view->title = $this->view->product->name . $this->lang->colon . $this->lang->release->create;
$this->view->position[] = $this->lang->release->create;
$this->view->productID = $productID;
$this->view->builds = $builds;
$this->view->users = $this->loadModel('user')->getPairs('noletter|noclosed');
$this->view->lastRelease = $this->release->getLast($productID, $branch);
$this->view->title = $this->view->product->name . $this->lang->colon . $this->lang->release->create;
$this->view->position[] = $this->lang->release->create;
$this->view->productID = $productID;
$this->view->builds = $builds;
$this->view->users = $this->loadModel('user')->getPairs('noletter|noclosed');
$this->view->lastRelease = $this->release->getLast($productID, $branch);
$this->view->notEmptyBuilds = $notEmptyBuilds;
$this->display();
}
+1 -1
View File
@@ -4,7 +4,7 @@ $('#submit').click(function()
var name = $('#name').val();
var date = $('#date').val();
var build = $('#build').val();
if(name && build && dateFormat.test(date))
if(name && build && typeof(notEmptyBuilds[build]) != 'undefined' && dateFormat.test(date))
{
var result = confirm(confirmLink) ? true : false;
$('#sync').val(result);
+1
View File
@@ -13,6 +13,7 @@
<?php include '../../common/view/header.html.php';?>
<?php include '../../common/view/kindeditor.html.php';?>
<?php js::set('confirmLink', $lang->release->confirmLink);?>
<?php js::set('notEmptyBuilds', $notEmptyBuilds);?>
<div id='mainContent' class='main-content'>
<div class='center-block'>
<div class='main-header'>
+2 -2
View File
@@ -1641,7 +1641,7 @@ class taskModel extends model
$data->lastEditedDate = $now;
if(helper::isZeroDate($task->realStarted)) $data->realStarted = $now;
if($left == 0)
if($left == 0 and strpos('done,cancel,closed', $task->status) === false)
{
$data->status = 'done';
$data->assignedTo = $task->openedBy;
@@ -1656,7 +1656,7 @@ class taskModel extends model
$data->assignedDate = $now;
$data->realStarted = $earliestTime;
}
elseif($task->status == 'pause')
elseif($left != 0 and strpos('done,cancel,closed,pause', $task->status) !== false)
{
$data->status = 'doing';
$data->assignedTo = $this->app->user->account;
+2 -2
View File
@@ -25,7 +25,7 @@
<th class='w-80px'><?php echo $lang->task->date;?></th>
<td class='w-p45'><?php echo html::input('date', $estimate->date, 'class="form-control form-date"');?></td>
<td></td>
</tr>
</tr>
<tr>
<th><?php echo $lang->task->record;?></th>
<td><?php echo html::input('consumed', $estimate->consumed, 'class="form-control"');?></td>
@@ -37,7 +37,7 @@
<tr>
<th><?php echo $lang->comment;?></th>
<td colspan='2'><?php echo html::textarea('work', $estimate->work, "class=form-control");?></td>
</tr>
</tr>
<tr>
<td colspan='3' class='text-center form-actions'><?php echo html::submitButton() . html::backButton();?></td>
</tr>