From ab8f4f1ab02420867655f126cd4e09cd1485cfc6 Mon Sep 17 00:00:00 2001 From: wangyidong Date: Wed, 18 Oct 2023 15:46:48 +0800 Subject: [PATCH] * Adjust style for no doc page. --- lib/zin/wg/dtable/v1.php | 19 ++-- module/doc/ui/createbutton.html.php | 33 ++++--- module/doc/ui/doclist.html.php | 74 ++++++--------- module/doc/ui/mydoclist.html.php | 90 +++++++----------- module/doc/ui/myspace.html.php | 63 ++++++------- module/doc/ui/tablecontents.html.php | 135 +++++++++++++-------------- 6 files changed, 185 insertions(+), 229 deletions(-) diff --git a/lib/zin/wg/dtable/v1.php b/lib/zin/wg/dtable/v1.php index b4ef137288..d491d76ce8 100644 --- a/lib/zin/wg/dtable/v1.php +++ b/lib/zin/wg/dtable/v1.php @@ -177,15 +177,18 @@ class dtable extends wg { global $lang; $emptyTip = $this->prop('emptyTip', $lang->noData); - $createLink = !empty($this->prop('createLink')) ? $this->getLink($this->prop('createLink')) : ''; - if(!empty($createLink)) + $createLink = !empty($this->prop('createLink')) ? $this->prop('createLink') : ''; + if(is_string($emptyTip)) { - $createTip = $this->prop('createTip', $lang->create); - $emptyTip = array('html' => "
$emptyTip
$createTip", 'className' => 'row gap-4 items-center'); - } - else - { - $emptyTip = array('html' => "$emptyTip", 'className' => 'text-gray'); + if(!empty($createLink)) + { + $createTip = $this->prop('createTip', $lang->create); + $emptyTip = array('html' => "
$emptyTip
$createTip", 'className' => 'row gap-4 items-center'); + } + else + { + $emptyTip = array('html' => "$emptyTip", 'className' => 'text-gray'); + } } $this->setProp('emptyTip', $emptyTip); } diff --git a/module/doc/ui/createbutton.html.php b/module/doc/ui/createbutton.html.php index 7d9a67610d..4828c04d6f 100644 --- a/module/doc/ui/createbutton.html.php +++ b/module/doc/ui/createbutton.html.php @@ -33,24 +33,23 @@ foreach($lang->doc->createList as $typeKey => $typeName) $buildCreateBtn = function($type, $objectID, $lib, $moduleID, $templateParam, $buttonItems) use($app, $lang) { - return btngroup + return btngroup( + btn ( - btn - ( - setClass('btn primary ml-2'), - set::icon('plus'), - set::url(createLink('doc', 'create', "objectType={$type}&objectID={$objectID}&libID={$lib->id}&moduleID={$moduleID}&type=html{$templateParam}")), - set('data-app', $app->tab), - $lang->doc->create - ), - dropdown - ( - btn(setClass('btn primary dropdown-toggle'), - setStyle(array('padding' => '6px', 'border-radius' => '0 2px 2px 0'))), - set::placement('bottom-end'), - set::items($buttonItems), - ) - ); + setClass('btn primary ml-2'), + set::icon('plus'), + set::url(createLink('doc', 'create', "objectType={$type}&objectID={$objectID}&libID={$lib->id}&moduleID={$moduleID}&type=html{$templateParam}")), + set('data-app', $app->tab), + $lang->doc->create + ), + dropdown + ( + btn(setClass('btn primary dropdown-toggle'), + setStyle(array('padding' => '6px', 'border-radius' => '0 2px 2px 0'))), + set::placement('bottom-end'), + set::items($buttonItems), + ) + ); }; $createButton = $buildCreateBtn($type, $objectID, $lib, $moduleID, $templateParam, $buttonItems); diff --git a/module/doc/ui/doclist.html.php b/module/doc/ui/doclist.html.php index f8fe5965ef..2e8003f247 100644 --- a/module/doc/ui/doclist.html.php +++ b/module/doc/ui/doclist.html.php @@ -10,50 +10,36 @@ declare(strict_types=1); */ namespace zin; -$docContent = null; -if(empty($docs)) +jsVar('iconList', $config->doc->iconList); +jsVar('draftText', $lang->doc->draft); +jsVar('canViewDoc', common::hasPriv('doc', 'view')); +jsVar('canCollect', common::hasPriv('doc', 'collect') && $libType && $libType != 'api'); +jsVar('currentAccount', $app->user->account); + +$cols = array(); +foreach($config->doc->dtable->fieldList as $colName => $col) { - $emptyCreateBtn = $buildCreateBtn($type, $objectID, $lib, $moduleID, $templateParam, $buttonItems); - $docContent = div - ( - setClass('table-empty-tip flex justify-center items-center'), - span - ( - setClass('text-gray'), - $lang->doc->noDoc - ), - $browseType != 'bySearch' && $libID && (common::hasPriv('doc', 'create') || (common::hasPriv('api', 'create') && !$apiLibID)) ? $emptyCreateBtn : null - ); + if($canExport && $colName == 'id') $col['type'] = 'checkID'; + if(!in_array($colName, array('id', 'title', 'addedBy', 'addedDate', 'editedBy', 'editedDate', 'actions'))) continue; + + $cols[$colName] = $col; } -else -{ - jsVar('iconList', $config->doc->iconList); - jsVar('draftText', $lang->doc->draft); - jsVar('canViewDoc', common::hasPriv('doc', 'view')); - jsVar('canCollect', common::hasPriv('doc', 'collect') && $libType && $libType != 'api'); - jsVar('currentAccount', $app->user->account); - $cols = array(); - foreach($config->doc->dtable->fieldList as $colName => $col) - { - if($canExport && $colName == 'id') $col['type'] = 'checkID'; - if(!in_array($colName, array('id', 'title', 'addedBy', 'addedDate', 'editedBy', 'editedDate', 'actions'))) continue; - - $cols[$colName] = $col; - } - - $params = "objectID={$objectID}&libID={$libID}&moduleID={$moduleID}&browseType={$browseType}&orderBy={$orderBy}¶m={$param}&recTotal={recTotal}&recPerPage={recPerPage}&pageID={page}"; - $tableData = initTableData($docs, $cols); - $docContent = dtable - ( - set::module($this->app->moduleName), - set::userMap($users), - set::cols($cols), - set::data($tableData), - set::checkable($canExport), - set::onRenderCell(jsRaw('window.rendDocCell')), - set::orderBy($orderBy), - set::sortLink(createLink($app->rawModule, $app->rawMethod, "objectID={$objectID}&libID={$libID}&moduleID={$moduleID}&browseType={$browseType}&orderBy={name}_{sortType}¶m={$param}&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}")), - set::footPager(usePager(array('linkCreator' => helper::createLink($app->rawModule, $app->rawMethod, $params)))), - ); -} +$params = "objectID={$objectID}&libID={$libID}&moduleID={$moduleID}&browseType={$browseType}&orderBy={$orderBy}¶m={$param}&recTotal={recTotal}&recPerPage={recPerPage}&pageID={page}"; +$tableData = empty($docs) ? array() : initTableData($docs, $cols); +$createDocLink = ''; +if($browseType != 'bysearch' && $libID && common::hasPriv('doc', 'create')) $createDocLink = createLink('doc', 'create', "objectType={$type}&objectID={$objectID}&libID={$lib->id}&moduleID={$moduleID}&type=html{$templateParam}"); +$docContent = dtable( + set::module($this->app->moduleName), + set::userMap($users), + set::cols($cols), + set::data($tableData), + set::checkable($canExport), + set::onRenderCell(jsRaw('window.rendDocCell')), + set::emptyTip($lang->doc->noDoc), + set::createLink($createDocLink), + set::createTip($lang->doc->create), + set::orderBy($orderBy), + set::sortLink(createLink($app->rawModule, $app->rawMethod, "objectID={$objectID}&libID={$libID}&moduleID={$moduleID}&browseType={$browseType}&orderBy={name}_{sortType}¶m={$param}&recTotal={$pager->recTotal}&recPerPage={$pager->recPerPage}&pageID={$pager->pageID}")), + set::footPager(usePager(array('linkCreator' => helper::createLink('doc', $app->rawMethod, $params)))), +); diff --git a/module/doc/ui/mydoclist.html.php b/module/doc/ui/mydoclist.html.php index 3255a2cf24..325d8ec68d 100644 --- a/module/doc/ui/mydoclist.html.php +++ b/module/doc/ui/mydoclist.html.php @@ -10,61 +10,43 @@ declare(strict_types=1); */ namespace zin; -$docContent = null; -if(empty($docs)) +jsVar('iconList', $config->doc->iconList); +jsVar('draftText', $lang->doc->draft); +jsVar('canViewDoc', common::hasPriv('doc', 'view')); +jsVar('canCollect', common::hasPriv('doc', 'collect') && $libType && $libType != 'api'); +jsVar('currentAccount', $app->user->account); +jsVar('spaceMethodList', $config->doc->spaceMethod); +jsVar('myspacePriv', common::hasPriv('doc', 'myspace')); +jsVar('productspacePriv', common::hasPriv('doc', 'productspace')); +jsVar('projectspacePriv', common::hasPriv('doc', 'projectspace')); +jsVar('teamspacePriv', common::hasPriv('doc', 'teamspace')); +jsVar('currentTab', $app->tab); + +$cols = array(); +foreach($config->doc->dtable->fieldList as $colName => $col) { - $emptyCreateBtn = isset($buildCreateBtn) && is_callable($buildCreateBtn) ? $buildCreateBtn($type, $objectID, $lib, $moduleID, $templateParam, $buttonItems) : null; - $docContent = div - ( - setClass('table-empty-tip flex justify-center items-center'), - span - ( - setClass('text-gray'), - $lang->doc->noDoc - ), - $browseType != 'bysearch' && $libID && common::hasPriv('doc', 'create') ? $emptyCreateBtn : null - ); + if($type == 'mine' && in_array($colName, array('objectName', 'module', 'editedBy'))) continue; + if($colName == 'addedBy' && in_array($type, array('mine', 'createdby'))) continue; + + if($canExport && $colName == 'id') $col['type'] = 'checkID'; + $cols[$colName] = $col; } -else -{ - jsVar('iconList', $config->doc->iconList); - jsVar('draftText', $lang->doc->draft); - jsVar('canViewDoc', common::hasPriv('doc', 'view')); - jsVar('canCollect', common::hasPriv('doc', 'collect') && $libType && $libType != 'api'); - jsVar('currentAccount', $app->user->account); - jsVar('spaceMethodList', $config->doc->spaceMethod); - jsVar('myspacePriv', common::hasPriv('doc', 'myspace')); - jsVar('productspacePriv', common::hasPriv('doc', 'productspace')); - jsVar('projectspacePriv', common::hasPriv('doc', 'projectspace')); - jsVar('teamspacePriv', common::hasPriv('doc', 'teamspace')); - jsVar('currentTab', $app->tab); - $cols = array(); - foreach($config->doc->dtable->fieldList as $colName => $col) - { - if($type == 'mine' && in_array($colName, array('objectName', 'module', 'editedBy'))) continue; - if($colName == 'addedBy' && in_array($type, array('mine', 'createdby'))) continue; - if($canExport && $colName == 'id') $col['type'] = 'checkID'; - $cols[$colName] = $col; - } - - $tableData = initTableData($docs, $cols); - - $params = "libID={$libID}&moduleID={$moduleID}&browseType={$browseType}¶m={$param}&orderBy={$orderBy}&recTotal={recTotal}&recPerPage={recPerPage}&pageID={page}"; - if($app->rawMethod == 'myspace') $params = "type={$type}&" . $params; - $docContent = dtable - ( - set::userMap($users), - set::cols($cols), - set::data($tableData), - set::checkable($canExport), - set::onRenderCell(jsRaw('window.rendDocCell')), - set::footPager( - usePager - ( - array('linkCreator' => helper::createLink('doc', $app->rawMethod, $params)), - ), - ), - ); -} +$params = "libID={$libID}&moduleID={$moduleID}&browseType={$browseType}¶m={$param}&orderBy={$orderBy}&recTotal={recTotal}&recPerPage={recPerPage}&pageID={page}"; +$tableData = empty($docs) ? array() : initTableData($docs, $cols); +$createDocLink = ''; +if($browseType != 'bysearch' && $libID && common::hasPriv('doc', 'create')) $createDocLink = createLink('doc', 'create', "objectType={$type}&objectID={$objectID}&libID={$lib->id}&moduleID={$moduleID}&type=html{$templateParam}"); +if($app->rawMethod == 'myspace') $params = "type={$type}&" . $params; +$docContent = dtable +( + set::userMap($users), + set::cols($cols), + set::data($tableData), + set::checkable($canExport), + set::onRenderCell(jsRaw('window.rendDocCell')), + set::emptyTip($lang->doc->noDoc), + set::createLink($createDocLink), + set::createTip($lang->doc->create), + set::footPager(usePager(array('linkCreator' => helper::createLink('doc', $app->rawMethod, $params)))), +); diff --git a/module/doc/ui/myspace.html.php b/module/doc/ui/myspace.html.php index 45e7cbaf1c..6842cd65fc 100644 --- a/module/doc/ui/myspace.html.php +++ b/module/doc/ui/myspace.html.php @@ -11,7 +11,6 @@ declare(strict_types=1); namespace zin; include 'lefttree.html.php'; if($libID && common::hasPriv('doc', 'create')) include 'createbutton.html.php'; -include 'mydoclist.html.php'; jsVar('browseType', $browseType); jsVar('docLang', $lang->doc); @@ -19,39 +18,33 @@ jsVar('confirmDelete', $lang->doc->confirmDelete); jsVar('appTab', $app->tab); jsVar('treeData', $libTree); -div +/* zin: Define the set::module('doc') feature bar on main menu. */ +featureBar ( - setClass('flex flex-wrap content-start'), - /* zin: Define the set::module('doc') feature bar on main menu. */ - featureBar - ( - set::current($browseType), - set::linkParams("type={$type}&libID={$libID}&moduleID={$moduleID}&browseType={key}"), - li(searchToggle(set::module($type . $libType . 'Doc'))) - ), - toolbar - ( - $canExport ? item(set(array - ( - 'icon' => 'export', - 'class' => 'ghost export', - 'text' => $lang->export, - 'url' => createLink('doc', 'mine2export', "libID={$libID}&moduleID={$moduleID}"), - 'data-toggle' => 'modal' - ))) : null, - common::hasPriv('doc', 'createLib') ? item(set(array - ( - 'icon' => 'plus', - 'class' => 'btn secondary', - 'text' => $lang->doc->createLib, - 'url' => createLink('doc', 'createLib', 'type=mine'), - 'data-toggle' => 'modal' - ))) : null, - $libID && common::hasPriv('doc', 'create') ? $createButton : null - ), - div - ( - setClass('doc-content mt-2 flex-initial w-full'), - $docContent - ) + set::current($browseType), + set::linkParams("type={$type}&libID={$libID}&moduleID={$moduleID}&browseType={key}"), + li(searchToggle(set::module($type . $libType . 'Doc'))) ); +toolbar +( + $canExport ? item(set(array + ( + 'icon' => 'export', + 'class' => 'ghost export', + 'text' => $lang->export, + 'url' => createLink('doc', 'mine2export', "libID={$libID}&moduleID={$moduleID}"), + 'data-toggle' => 'modal' + ))) : null, + common::hasPriv('doc', 'createLib') ? item(set(array + ( + 'icon' => 'plus', + 'class' => 'btn secondary', + 'text' => $lang->doc->createLib, + 'url' => createLink('doc', 'createLib', 'type=mine'), + 'data-toggle' => 'modal' + ))) : null, + $libID && common::hasPriv('doc', 'create') ? $createButton : null +); + +include 'mydoclist.html.php'; +$docContent; diff --git a/module/doc/ui/tablecontents.html.php b/module/doc/ui/tablecontents.html.php index 3d704e9ece..aa12406d98 100644 --- a/module/doc/ui/tablecontents.html.php +++ b/module/doc/ui/tablecontents.html.php @@ -19,6 +19,69 @@ if($canExport) if($libType == 'api') $exportLink = $this->createLink('api', $exportMethod, "libID={$libID}&version=0&release={$release}&moduleID={$moduleID}"); } +/* zin: Define the set::module('doc') feature bar on main menu. */ +featureBar +( + set::current($browseType), + set::method('tableContents'), + set::linkParams("objectID={$objectID}&libID={$libID}&moduleID={$moduleID}&browseType={key}"), + li(searchToggle(set::module($type . $libType . 'Doc'))) +); + +toolbar +( + $libType == 'api' && common::hasPriv('api', 'struct') ? item(set(array + ( + 'icon' => 'treemap', + 'class' => 'ghost', + 'text' => $lang->api->struct, + 'url' => createLink('api', 'struct', "libID={$libID}"), + ))) : null, + $libType == 'api' && common::hasPriv('api', 'releases') ? item(set(array + ( + 'icon' => 'version', + 'class' => 'ghost', + 'text' => $lang->api->releases, + 'url' => createLink('api', 'releases', "libID={$libID}"), + 'data-toggle' => 'modal' + ))) : null, + $libType == 'api' && common::hasPriv('api', 'createRelease') ? item(set(array + ( + 'icon' => 'publish', + 'class' => 'ghost', + 'text' => $lang->api->createRelease, + 'url' => createLink('api', 'createRelease', "libID={$libID}"), + 'data-toggle' => 'modal' + ))) : null, + $canExport ? item(set(array + ( + 'id' => $exportMethod, + 'icon' => 'export', + 'class' => 'ghost export', + 'text' => $lang->export, + 'url' => $exportLink, + 'data-toggle' => 'modal' + ))) : null, + common::hasPriv('doc', 'createLib') ? item(set(array + ( + 'icon' => 'plus', + 'class' => 'btn secondary', + 'text' => $lang->doc->createLib, + 'url' => createLink('doc', 'createLib', "type={$type}&objectID={$objectID}"), + 'data-toggle' => 'modal' + ))) : null, + $libType == 'api' && common::hasPriv('api', 'create') ? item(set(array + ( + 'icon' => 'plus', + 'class' => 'btn primary ml-2', + 'text' => $lang->api->createApi, + 'url' => createLink('api', 'create', "libID={$libID}&moduleID={$moduleID}"), + 'data-size' => 'lg', + 'data-toggle' => 'modal' + ))) : null, + $libType != 'api' && $libID && common::hasPriv('doc', 'create') ? $createButton : null +); + if($browseType == 'annex') { include 'showfiles.html.php'; @@ -33,74 +96,4 @@ else include 'doclist.html.php'; } -/* zin: Define the set::module('doc') feature bar on main menu. */ -div -( - setClass('flex flex-wrap content-start'), - featureBar - ( - set::current($browseType), - set::method('tableContents'), - set::linkParams("objectID={$objectID}&libID={$libID}&moduleID={$moduleID}&browseType={key}"), - li(searchToggle(set::module($type . $libType . 'Doc'))) - ), - - toolbar - ( - $libType == 'api' && common::hasPriv('api', 'struct') ? item(set(array - ( - 'icon' => 'treemap', - 'class' => 'ghost', - 'text' => $lang->api->struct, - 'url' => createLink('api', 'struct', "libID={$libID}"), - ))) : null, - $libType == 'api' && common::hasPriv('api', 'releases') ? item(set(array - ( - 'icon' => 'version', - 'class' => 'ghost', - 'text' => $lang->api->releases, - 'url' => createLink('api', 'releases', "libID={$libID}"), - 'data-toggle' => 'modal' - ))) : null, - $libType == 'api' && common::hasPriv('api', 'createRelease') ? item(set(array - ( - 'icon' => 'publish', - 'class' => 'ghost', - 'text' => $lang->api->createRelease, - 'url' => createLink('api', 'createRelease', "libID={$libID}"), - 'data-toggle' => 'modal' - ))) : null, - $canExport ? item(set(array - ( - 'id' => $exportMethod, - 'icon' => 'export', - 'class' => 'ghost export', - 'text' => $lang->export, - 'url' => $exportLink, - 'data-toggle' => 'modal' - ))) : null, - common::hasPriv('doc', 'createLib') ? item(set(array - ( - 'icon' => 'plus', - 'class' => 'btn secondary', - 'text' => $lang->doc->createLib, - 'url' => createLink('doc', 'createLib', "type={$type}&objectID={$objectID}"), - 'data-toggle' => 'modal' - ))) : null, - $libType == 'api' && common::hasPriv('api', 'create') ? item(set(array - ( - 'icon' => 'plus', - 'class' => 'btn primary ml-2', - 'text' => $lang->api->createApi, - 'url' => createLink('api', 'create', "libID={$libID}&moduleID={$moduleID}"), - 'data-size' => 'lg', - 'data-toggle' => 'modal' - ))) : null, - $libType != 'api' && $libID && common::hasPriv('doc', 'create') ? $createButton : null - ), - div - ( - setClass('doc-content mt-2 flex-initial w-full'), - $docContent - ) -); +$docContent;