From d24f481cbbb3eb7429427762760024c5df71145b Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Wed, 23 Oct 2024 11:02:57 +0800 Subject: [PATCH] *[misc] finish selectproject. --- module/doc/js/selectlibtype.ui.js | 12 +++ module/doc/ui/selectlibtype.html.php | 1 + module/doc/ui/selectproduct.html.php | 3 - module/doc/ui/selectproject.html.php | 107 +++++++++++++++++++++++++++ 4 files changed, 120 insertions(+), 3 deletions(-) create mode 100644 module/doc/ui/selectproject.html.php diff --git a/module/doc/js/selectlibtype.ui.js b/module/doc/js/selectlibtype.ui.js index 4fd427c3ef..8131e3c3b3 100644 --- a/module/doc/js/selectlibtype.ui.js +++ b/module/doc/js/selectlibtype.ui.js @@ -24,6 +24,18 @@ window.reloadProduct = function() loadModal($.createLink('doc', 'selectLibType', `objectType=${objectType}¶ms=${params}`)); } +window.reloadProject = function() +{ + const objectType = getSpaceType(); + const docType = $('.modal-body input[name=type]:checked').val(); + const objectID = $('.modal-body input[name=project]').val(); + const executionID = $('.modal-body input[name=execution]').val(); + const libID = $('.modal-body input[name=lib]').val(); + const params = window.btoa('docType=' + docType + '&objectID=' + objectID + '&executionID=' + executionID + '&libID=' + libID); + + loadModal($.createLink('doc', 'selectLibType', `objectType=${objectType}¶ms=${params}`)); +} + /** * Change space. * diff --git a/module/doc/ui/selectlibtype.html.php b/module/doc/ui/selectlibtype.html.php index a26785f0a1..ccd8dae904 100644 --- a/module/doc/ui/selectlibtype.html.php +++ b/module/doc/ui/selectlibtype.html.php @@ -21,6 +21,7 @@ to::header if(in_array($objectType, array('mine', 'custom'))) include './selectmineandcustom.html.php'; if($objectType == 'product') include './selectproduct.html.php'; +if($objectType == 'project') include './selectproject.html.php'; /* ====== Render page ====== */ render(); diff --git a/module/doc/ui/selectproduct.html.php b/module/doc/ui/selectproduct.html.php index 51981adc0d..8c6f9caf1a 100644 --- a/module/doc/ui/selectproduct.html.php +++ b/module/doc/ui/selectproduct.html.php @@ -80,6 +80,3 @@ form set::control(array('control' => 'picker', 'name' => 'module', 'items' => $modules, 'value' => $moduleID, 'required' => true)) ) ); - -/* ====== Render page ====== */ -render(); diff --git a/module/doc/ui/selectproject.html.php b/module/doc/ui/selectproject.html.php new file mode 100644 index 0000000000..dba4c842f9 --- /dev/null +++ b/module/doc/ui/selectproject.html.php @@ -0,0 +1,107 @@ + + * @package doc + * @link https://www.zentao.net + */ +namespace zin; + +// In this page, $objectType = project +// $params may have three key: objectID|executionID|docType|libID + +$projects = $this->loadModel('project')->getPairsByProgram(0, 'all', false, 'order_asc'); +$objectID = isset($params['objectID']) ? (int)$params['objectID'] : key($projects); +$docType = isset($params['docType']) ? $params['docType'] : 'doc'; +$executions = $docType == 'doc' ? $this->loadModel('execution')->getPairs($objectID, 'all', 'multiple,leaf,noprefix') : array(); +$executionID = (isset($params['executionID']) && isset($executions[$params['executionID']])) ? $params['executionID'] : ''; + +$useType = $executionID ? 'execution' : 'project'; +$useID = $executionID ? $executionID : $objectID; +if($docType == 'doc') +{ + $libPairs = $this->doc->getLibs($useType, '', '', (int)$useID); +} +else +{ + $libs = $this->doc->getApiLibs(0, $useType, (int)$useID); + $libPairs = array(); + foreach($libs as $libID => $lib) $libPairs[$libID] = $lib->name; +} +$libID = isset($params['libID']) && isset($libPairs[$params['libID']]) ? $params['libID'] : key($libPairs); + +$modules = $this->loadModel('tree')->getOptionMenu((int)$libID, 'doc', 0); +$moduleID = key($modules); + +form +( + setID('selectLibTypeForm'), + set::submitBtnText($lang->doc->nextStep), + on::change('[name=rootSpace]', "changeSpace"), + on::change('[name=type]', "reloadProject"), + on::change('[name=project]', "reloadProject"), + on::change('[name=execution]', "reloadProject"), + on::change('[name=lib]', "reloadProject"), + formGroup + ( + set::label($lang->doc->selectSpace), + radioList(set::name('rootSpace'), set::items($spaceList), set::value($objectType), set::inline(true)) + ), + formRow + ( + setID('docType'), + formGroup + ( + set::label($lang->doc->type), + radioList(set::name('type'), set::items($typeList), set::value($docType), set::inline(true)) + ) + ), + formRow + ( + formGroup + ( + set::label($lang->doc->project), + set::width('2/5'), + set::control(array('control' => 'picker', 'name' => 'project', 'items' => $projects, 'value' => $objectID, 'required' => true)) + ), + $docType == 'doc' ? formGroup + ( + set::width('2/5'), + set::label($lang->doc->execution), + set::labelClass('executionTH'), + set::control(array('control' => 'picker', 'name' => 'execution', 'items' => $executions, 'value' => $executionID)) + ) : null, + $docType == 'doc' ? formGroup + ( + setClass('executionHelp'), + icon + ( + 'help', + set('data-toggle', 'tooltip'), + set('data-title', $lang->doc->placeholder->execution), + set('data-placement', 'right'), + set('data-type', 'white'), + set('data-class-name', 'text-gray border border-light'), + setClass('ml-2 mt-2 text-gray') + ) + ) : null + ), + formGroup + ( + set::width('4/5'), + set::label($lang->doc->lib), + set::required(true), + set::control(array('control' => 'picker', 'name' => 'lib', 'items' => $libPairs, 'value' => $libID, 'required' => true)) + ), + formGroup + ( + setClass('moduleBox'), + set::width('4/5'), + set::label($lang->doc->module), + set::required(true), + set::control(array('control' => 'picker', 'name' => 'module', 'items' => $modules, 'value' => $moduleID, 'required' => true)) + ) +);