From 0424801e4eb806ae3ebecb35ca1aac3b0b6eb9ed Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Wed, 27 Apr 2022 10:48:28 +0800 Subject: [PATCH] * Fix bug #15654. --- module/api/control.php | 1 + module/api/lang/en.php | 3 -- module/api/lang/zh-cn.php | 3 -- module/api/lang/zh-tw.php | 3 -- module/api/view/createlib.html.php | 12 ------- module/doc/control.php | 2 ++ module/doc/js/common.js | 2 +- module/doc/js/createlib.js | 53 ++++++++++++++++++++++++++++++ module/doc/lang/en.php | 4 +++ module/doc/lang/zh-cn.php | 5 +++ module/doc/view/createlib.html.php | 18 ++++++++-- 11 files changed, 82 insertions(+), 24 deletions(-) diff --git a/module/api/control.php b/module/api/control.php index a97c4c81cf..c445d379ff 100755 --- a/module/api/control.php +++ b/module/api/control.php @@ -319,6 +319,7 @@ class api extends control /* Record action for create api library. */ $this->action->create('docLib', $libID, 'Created'); + if(!helper::isAjaxRequest()) return print(js::locate($this->createLink('api', 'index', "libID=$libID"), 'parent.parent')); return $this->sendSuccess(array('locate' => $this->createLink('api', 'index', "libID=$libID"))); } diff --git a/module/api/lang/en.php b/module/api/lang/en.php index 269484c932..20aefb7498 100644 --- a/module/api/lang/en.php +++ b/module/api/lang/en.php @@ -199,9 +199,6 @@ $lang->api->structParamsOptons = array_merge($lang->api->paramsTypeOptions, ar $lang->api->allParamsTypeOptions = array_merge($lang->api->paramsTypeOptions, $lang->api->paramsTypeCustomOptions); $lang->api->requiredOptions = array(0 => 'No', 1 => 'Yes'); -$lang->doclib = new stdclass(); -$lang->doclib->name = 'API Library Name'; - $lang->apistruct = new stdClass(); $lang->apistruct->name = 'Name'; diff --git a/module/api/lang/zh-cn.php b/module/api/lang/zh-cn.php index ce73a1bf19..e49b961316 100755 --- a/module/api/lang/zh-cn.php +++ b/module/api/lang/zh-cn.php @@ -199,9 +199,6 @@ $lang->api->structParamsOptons = array_merge($lang->api->paramsTypeOptions, ar $lang->api->allParamsTypeOptions = array_merge($lang->api->paramsTypeOptions, $lang->api->paramsTypeCustomOptions); $lang->api->requiredOptions = array(0 => '否', 1 => '是'); -$lang->doclib = new stdclass(); -$lang->doclib->name = '接口库名称'; - $lang->apistruct = new stdClass(); $lang->apistruct->name = '结构名'; diff --git a/module/api/lang/zh-tw.php b/module/api/lang/zh-tw.php index 6e33b20062..e56d998aee 100644 --- a/module/api/lang/zh-tw.php +++ b/module/api/lang/zh-tw.php @@ -199,9 +199,6 @@ $lang->api->structParamsOptons = array_merge($lang->api->paramsTypeOptions, ar $lang->api->allParamsTypeOptions = array_merge($lang->api->paramsTypeOptions, $lang->api->paramsTypeCustomOptions); $lang->api->requiredOptions = array(0 => '否', 1 => '是'); -$lang->doclib = new stdclass(); -$lang->doclib->name = '介面庫名稱'; - $lang->apistruct = new stdClass(); $lang->apistruct->name = '結構名'; diff --git a/module/api/view/createlib.html.php b/module/api/view/createlib.html.php index 9ae2834d75..8e215817d9 100644 --- a/module/api/view/createlib.html.php +++ b/module/api/view/createlib.html.php @@ -65,17 +65,5 @@ - api->noticeAcl);?> diff --git a/module/doc/control.php b/module/doc/control.php index e4dd5e20ba..362d8e7ef4 100644 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -171,6 +171,8 @@ class doc extends control if(empty($projects)) unset($libTypeList['project']); if(empty($executions)) unset($libTypeList['execution']); + $this->app->loadLang('api'); + $this->view->groups = $this->loadModel('group')->getPairs(); $this->view->users = $this->user->getPairs('nocode|noclosed'); $this->view->products = $products; diff --git a/module/doc/js/common.js b/module/doc/js/common.js index 13d5973f69..48edfdbc1d 100644 --- a/module/doc/js/common.js +++ b/module/doc/js/common.js @@ -42,7 +42,7 @@ function toggleAcl(acl, type) var notice = typeof(noticeAcl[libType][acl]) != 'undefined' ? noticeAcl[libType][acl] : ''; $('#noticeAcl').html(notice); - if(libType == 'custom' && acl == 'private') $('#whiteListBox').addClass('hidden'); + if((libType == 'custom' || libType == 'api') && acl == 'private') $('#whiteListBox').addClass('hidden'); if(libType == 'project' && typeof(doclibID) != 'undefined') { diff --git a/module/doc/js/createlib.js b/module/doc/js/createlib.js index 9867c1de4e..109cb8c86a 100644 --- a/module/doc/js/createlib.js +++ b/module/doc/js/createlib.js @@ -29,6 +29,14 @@ function changeByLibType(libType) $('table tr.execution').addClass('hidden'); $('#execution').attr('disabled', true); + $('.normalLib').removeClass('hidden'); + $('.normalLib input').attr('disabled', false); + + $('table tr.apilib').addClass('hidden'); + $('.apilib input, #desc, #baseUrl').attr('disabled', true); + + $('form').removeAttr('action'); + changeDoclibAcl(libType); } else if(libType == 'project') @@ -42,6 +50,14 @@ function changeByLibType(libType) $('table tr.execution').addClass('hidden'); $('#execution').attr('disabled', true); + $('.normalLib').removeClass('hidden'); + $('.normalLib input').attr('disabled', false); + + $('table tr.apilib').addClass('hidden'); + $('.apilib input, #desc, #baseUrl').attr('disabled', true); + + $('form').removeAttr('action'); + changeDoclibAcl(libType); } else if(libType == 'execution') @@ -55,6 +71,35 @@ function changeByLibType(libType) $('table tr.project').addClass('hidden'); $('#project').attr('disabled', true); + $('.normalLib').removeClass('hidden'); + $('.normalLib input').attr('disabled', false); + + $('table tr.apilib').addClass('hidden'); + $('.apilib input, #desc, #baseUrl').attr('disabled', true); + + $('form').removeAttr('action'); + + changeDoclibAcl(libType); + } + else if(libType == 'api') + { + $('table tr.product').addClass('hidden'); + $('#product').attr('disabled', true); + + $('table tr.project').addClass('hidden'); + $('#project').attr('disabled', true); + + $('table tr.execution').addClass('hidden'); + $('#execution').attr('disabled', true); + + $('.normalLib').addClass('hidden'); + $('.normalLib input').attr('disabled', true); + + $('table tr.apilib').removeClass('hidden'); + $('.apilib input, #desc, #baseUrl').attr('disabled', false); + + $('form').attr('action', createLink('api', 'createLib')); + changeDoclibAcl(libType); } else @@ -68,6 +113,14 @@ function changeByLibType(libType) $('table tr.execution').addClass('hidden'); $('#execution').attr('disabled', true); + $('.normalLib').removeClass('hidden'); + $('.normalLib input').attr('disabled', false); + + $('table tr.apilib').addClass('hidden'); + $('.apilib input, #desc, #baseUrl').attr('disabled', true); + + $('form').removeAttr('action'); + changeDoclibAcl(libType); } diff --git a/module/doc/lang/en.php b/module/doc/lang/en.php index 7fa62b2cd8..8dd3708511 100644 --- a/module/doc/lang/en.php +++ b/module/doc/lang/en.php @@ -158,6 +158,7 @@ $lang->doc->allExecutions = 'All' . $lang->executionCommon . 's'; $lang->doc->libTypeList['product'] = $lang->productCommon . ' Library'; if($config->systemMode == 'new') $lang->doc->libTypeList['project'] = 'Project Library'; $lang->doc->libTypeList['execution'] = $lang->execution->common . ' Library'; +$lang->doc->libTypeList['api'] = 'API Library'; $lang->doc->libTypeList['custom'] = 'Custom Library'; $lang->doc->libGlobalList['api'] = 'Api Libray'; @@ -248,6 +249,9 @@ $lang->doc->noticeAcl['lib']['project']['private'] = 'Users who can access the $lang->doc->noticeAcl['lib']['project']['custom'] = 'Users in the whiltelist can access it.'; $lang->doc->noticeAcl['lib']['execution']['default'] = "Users who can access the selected {$lang->executionCommon} can access it."; $lang->doc->noticeAcl['lib']['execution']['custom'] = "Users who can access the selected {$lang->executionCommon} or users in the whiltelist can access it."; +$lang->doc->noticeAcl['lib']['api']['open'] = 'All users can access it.'; +$lang->doc->noticeAcl['lib']['api']['custom'] = 'Users in the whitelist can access it.'; +$lang->doc->noticeAcl['lib']['api']['private'] = 'Only the one who created it can access it.'; $lang->doc->noticeAcl['lib']['custom']['open'] = 'All users can access it.'; $lang->doc->noticeAcl['lib']['custom']['custom'] = 'Users in the whitelist can access it.'; $lang->doc->noticeAcl['lib']['custom']['private'] = 'Only the one who created it can access it.'; diff --git a/module/doc/lang/zh-cn.php b/module/doc/lang/zh-cn.php index c850ff1b94..ff69f8c514 100644 --- a/module/doc/lang/zh-cn.php +++ b/module/doc/lang/zh-cn.php @@ -21,6 +21,7 @@ $lang->doclib->execution = $lang->executionCommon . '库'; $lang->doclib->product = $lang->productCommon . '库'; $lang->doclib->apiLibName = '接口库名称'; +$lang->doclib->aclListA = array(); $lang->doclib->aclListA['default'] = '默认'; $lang->doclib->aclListA['custom'] = '自定义'; @@ -158,6 +159,7 @@ $lang->doc->allExecutions = '所有' . $lang->executionCommon; $lang->doc->libTypeList['product'] = $lang->productCommon . '文档库'; if($config->systemMode == 'new') $lang->doc->libTypeList['project'] = '项目文档库'; $lang->doc->libTypeList['execution'] = $lang->execution->common . '文档库'; +$lang->doc->libTypeList['api'] = '接口库'; $lang->doc->libTypeList['custom'] = '自定义文档库'; $lang->doc->libGlobalList['api'] = '接口文档库'; @@ -248,6 +250,9 @@ $lang->doc->noticeAcl['lib']['project']['private'] = "有所选项目访问权 $lang->doc->noticeAcl['lib']['project']['custom'] = "白名单的用户可以访问。"; $lang->doc->noticeAcl['lib']['execution']['default'] = "有所选{$lang->executionCommon}访问权限的用户可以访问。"; $lang->doc->noticeAcl['lib']['execution']['custom'] = "有所选{$lang->executionCommon}访问权限或白名单里的用户可以访问。"; +$lang->doc->noticeAcl['lib']['api']['open'] = '所有人都可以访问。'; +$lang->doc->noticeAcl['lib']['api']['custom'] = '白名单的用户可以访问。'; +$lang->doc->noticeAcl['lib']['api']['private'] = '只有创建者自己可以访问。'; $lang->doc->noticeAcl['lib']['custom']['open'] = '所有人都可以访问。'; $lang->doc->noticeAcl['lib']['custom']['custom'] = '白名单的用户可以访问。'; $lang->doc->noticeAcl['lib']['custom']['private'] = '只有创建者自己可以访问。'; diff --git a/module/doc/view/createlib.html.php b/module/doc/view/createlib.html.php index f9c701c3af..b0a84345ee 100644 --- a/module/doc/view/createlib.html.php +++ b/module/doc/view/createlib.html.php @@ -19,7 +19,7 @@

doc->createLib;?>

-
+ @@ -45,10 +45,18 @@ - + + + + + + + + + + + + +
doc->libType?>doc->execution?>
doclib->name?>
doclib->control;?> @@ -69,6 +77,12 @@