diff --git a/module/api/control.php b/module/api/control.php index d6d1f6a578..8b0451eff5 100755 --- a/module/api/control.php +++ b/module/api/control.php @@ -480,6 +480,8 @@ class api extends control if($api === false) return $this->sendError(dao::getError()); $this->action->create('api', $api->id, 'Created'); + + if(isonlybody()) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent')); return $this->sendSuccess(array('locate' => helper::createLink('api', 'index', "libID={$api->lib}&moduleID=0&apiID={$api->id}"))); } diff --git a/module/doc/control.php b/module/doc/control.php index 6678c7b1ca..a0784016c7 100755 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -1303,6 +1303,7 @@ class doc extends control $apiObjectType = $type == 'product' || $type == 'project' ? $type : ''; $apiObjectID = $apiObjectType ? $objectID : 0; + $apiLibs = $apiObjectType ? $this->doc->getApiLibs(0, $apiObjectType, $apiObjectID) : array(); $this->view->title = $title; $this->view->type = $type; @@ -1320,7 +1321,7 @@ class doc extends control $this->view->orderBy = $orderBy; $this->view->exportMethod = $type . '2export'; $this->view->canExport = common::hasPriv('doc', $type . '2export'); - $this->view->apiLibs = $type == 'execution' ? array() : $this->doc->getApiLibs(0, $apiObjectType, $apiObjectID); + $this->view->apiLibID = key($apiLibs); $this->display(); } diff --git a/module/doc/js/selectlibtype.js b/module/doc/js/selectlibtype.js index 4ca7d52cb6..0b4b399ca4 100644 --- a/module/doc/js/selectlibtype.js +++ b/module/doc/js/selectlibtype.js @@ -14,15 +14,20 @@ $(function() */ function redirectParentWindow(objectType, libID, docType) { - config.onlybody = 'no'; if(objectType == 'api') { - var link = createLink('api', 'create', 'libID=' + libID) + '#app=doc'; - } - else - { - var link = createLink('doc', 'create', 'objectType=' + objectType + '&objectID=0&libID=' + libID + '&moduleID=0&docType=' + docType + '&fromGlobal=true') + '#app=doc'; + parent.$.closeModal(function() + { + new parent.$.zui.ModalTrigger({ + iframe : createLink('api', 'create', 'libID=' + libID), + width: '85%' + }).show(); + }); + return false; } + + config.onlybody = 'no'; + var link = createLink('doc', 'create', 'objectType=' + objectType + '&objectID=0&libID=' + libID + '&moduleID=0&docType=' + docType + '&fromGlobal=true') + '#app=doc'; window.parent.$.apps.open(link); } diff --git a/module/doc/model.php b/module/doc/model.php index 8e246aabdc..3295f6fa4f 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -2906,4 +2906,60 @@ class docModel extends model $libTree = array_values($libTree[$type]); return $libTree; } + + /** + * Print create document button. + * + * @param object $lib + * @param type $type project|product|custom + * @param int $objectID + * @param int $moduleID + * @param int $apiLibID + * @param string $from list + * @access public + * @return string + */ + public function printCreateBtn($lib, $type, $objectID, $moduleID, $apiLibID = 0, $from = '') + { + $libType = isset($lib->type) && $lib->type == 'api' ? 'api' : 'lib'; + + $class = $from == 'list' ? 'btn-info' : 'btn-primary'; + $html = "'; + return $html; + } } diff --git a/module/doc/view/doclist.html.php b/module/doc/view/doclist.html.php index 06cc4011f2..264da9c910 100644 --- a/module/doc/view/doclist.html.php +++ b/module/doc/view/doclist.html.php @@ -27,44 +27,9 @@

doc->noDoc;?> "; - $html .= html::a($this->createLink('doc', 'createBasicInfo', "objectType={$lib->type}&objectID=$objectID&libID=$libID&moduleID=$moduleID&type=html", '', true), " {$lang->doc->create}", '', "class='btn btn-info iframe'"); - $html .= ""; - $html .= "

'; - echo $html; - } + echo $this->doc->printCreateBtn($lib, $type, $objectID, $moduleID, $apiLibID, 'list'); } ?>

diff --git a/module/doc/view/tablecontents.html.php b/module/doc/view/tablecontents.html.php index 8507b9f5c9..9ec4863fb8 100644 --- a/module/doc/view/tablecontents.html.php +++ b/module/doc/view/tablecontents.html.php @@ -35,44 +35,9 @@ echo html::a(helper::createLink('doc', 'createLib', "type=$type&objectID=$objectID"), ' ' . $this->lang->doc->createLib, '', 'class="btn btn-secondary iframe"'); } - if(common::hasPriv('doc', 'create') or (common::hasPriv('api', 'create') and !empty($apiLibs))) + if($libID and (common::hasPriv('doc', 'create') or (common::hasPriv('api', 'create') and !$apiLibID))) { - if($libID) - { - $html = "'; - echo $html; - } + echo $this->doc->printCreateBtn($lib, $type, $objectID, $moduleID, $apiLibID); } ?>