From 4fc78bcfee53107dd3fc9853793ba28e41166879 Mon Sep 17 00:00:00 2001 From: sunhao Date: Tue, 12 Nov 2024 14:31:53 +0800 Subject: [PATCH] * [ui] show current api type in api dropmenu in docApp. --- module/api/js/index.ui.js | 26 ++++++++++++++++++++------ module/api/ui/index.html.php | 1 + 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/module/api/js/index.ui.js b/module/api/js/index.ui.js index 9e0d9ea63f..c16339b952 100644 --- a/module/api/js/index.ui.js +++ b/module/api/js/index.ui.js @@ -230,12 +230,21 @@ function getSpaceFetcher(spaceType, spaceID) function handleClickSpaceMenu(event, value) { event.preventDefault(); - const $item = $(event.target).closest('[z-item]'); - if(!$item.length) return; - const type = $item.z('type'); + if($(event.target).closest('.dropmenu-nav').length) return; + const parts = String(value).split('.'); + const type = parts[0]; + const id = parts[1] || 0; const docApp = getDocApp(); - if(type === 'product' || type === 'project') docApp.selectSpace(`${type}.${value}`, true); - else docApp.selectSpace('nolink', value); + if(type === 'product' || type === 'project') docApp.selectSpace(value, '_first'); + else docApp.selectSpace('nolink', +id); +} + +function getSpaceMenuText(text, state) +{ + const spaceID = getDocApp().spaceID; + if(spaceID === 'nolink') return text; + const libTypeList = getDocAppLang('libTypeList'); + return `${libTypeList[spaceID.split('.')[0]]} / ${text}`; } /* 扩展文档应用操作按钮生成定义。 Extend the doc app action definition. */ @@ -480,7 +489,12 @@ window.setDocAppOptions = function(_, options) // Override the method. return $.extend(options, { defaultState : {libReleaseMap: {}, listType: ''}, - spaceMenuOptions : {popWidth: 350, onClickItem: handleClickSpaceMenu}, + spaceMenuOptions : { + popWidth : 350, + onClickItem : handleClickSpaceMenu, + defaultValue: options.spaceID === 'nolink' ? `lib.${options.libID}`: options.spaceID, + display : getSpaceMenuText + }, customRenders : customRenders, viewModeUrl : getViewModeUrl, getTableOptions : getTableOptions, diff --git a/module/api/ui/index.html.php b/module/api/ui/index.html.php index 82691e74d3..17de71658a 100644 --- a/module/api/ui/index.html.php +++ b/module/api/ui/index.html.php @@ -39,6 +39,7 @@ $langData['version'] = $lang->api->version; $langData['defaultVersion'] = $lang->api->defaultVersion; $langData['createStruct'] = $lang->api->createStruct; $langData['createRelease'] = $lang->api->createRelease; +$langData['libTypeList'] = $lang->api->libTypeList; $langData['save'] = $lang->save; docApp