From a6320ac7ea4e402cad1092e3a713339e950cd7da Mon Sep 17 00:00:00 2001 From: liuruogu Date: Wed, 10 May 2023 15:41:05 +0800 Subject: [PATCH] * Modify 'of' in the language item to 'blockTitle'. --- module/block/control.php | 9 +++++---- module/block/js/create.ui.js | 15 ++------------- module/block/js/edit.ui.js | 28 ++++++++++++---------------- module/block/lang/de.php | 2 +- module/block/lang/en.php | 2 +- module/block/lang/fr.php | 2 +- module/block/lang/vi.php | 2 +- module/block/lang/zh-cn.php | 2 +- module/block/lang/zh-tw.php | 2 +- module/block/ui/create.html.php | 9 +++++++-- module/block/ui/edit.html.php | 2 +- 11 files changed, 33 insertions(+), 42 deletions(-) diff --git a/module/block/control.php b/module/block/control.php index db5b8f6512..bbf16d7791 100755 --- a/module/block/control.php +++ b/module/block/control.php @@ -86,14 +86,15 @@ class block extends control /* 如果没传 $code 说明是首次进入页面,直接使用待编辑 $block 的 $code。 */ /* If no $code is passed, it indicates that you are entering the page for the first time, and you can directly use the $code of the $block to be edited. */ - $block = $this->block->getByID($blockID); - $code = $code ? $code : $block->code; - $codes = $this->blockZen->getAvailableCodes($block->dashboard, $this->view->module); + $block = $this->block->getByID($blockID); + $module = $module ? $module : $block->module; + $code = $code ? $code : $block->code; + $codes = $this->blockZen->getAvailableCodes($block->dashboard, $module); $this->view->title = $this->lang->block->editBlock; $this->view->block = $block; $this->view->dashboard = $block->dashboard; - $this->view->module = $module ? $module : $block->module; + $this->view->module = $module; $this->view->modules = $this->blockZen->getAvailableModules($block->dashboard); $this->view->codes = $codes; /* $codes 包含 $code 时,页面才选中对应的 $code,否则为空。 */ diff --git a/module/block/js/create.ui.js b/module/block/js/create.ui.js index 9a2e34f9e4..070c357838 100644 --- a/module/block/js/create.ui.js +++ b/module/block/js/create.ui.js @@ -8,7 +8,7 @@ function getForm(event) } /** - * Get block title. + * Updates the blockTitle when the type is changed. * * @return void */ @@ -26,17 +26,6 @@ function onParamsTypeChange() } const $paramstype = $('#paramstype')[0]; - let blockTitle = ''; - /* Chinese attributives come first, while other language items have attributives placed after. */ - if(lang.indexOf('zh') >= 0) - { - blockTitle = $paramstype.options[$paramstype.selectedIndex].text + of + $code.options[$code.selectedIndex].text; - } - else - { - blockTitle = $code.options[$code.selectedIndex].text + of + $paramstype.options[$paramstype.selectedIndex].text; - } - - $('#title').val(blockTitle); + $('#title').val(blockTitle.replace('%1$s', $paramstype.options[$paramstype.selectedIndex].text).replace('%2$s', $code.options[$code.selectedIndex].text)); } diff --git a/module/block/js/edit.ui.js b/module/block/js/edit.ui.js index 292eb0b89c..25b98235f8 100644 --- a/module/block/js/edit.ui.js +++ b/module/block/js/edit.ui.js @@ -7,29 +7,25 @@ function getForm(event) loadPage(url, '#codesRow, #paramsRow'); } -function onParamsTypeChange(event) +/** + * Updates the blockTitle when the type is changed. + * + * @return void + */ +function onParamsTypeChange() { const lang = config.clientLang; - const $code = document.querySelector('#code'); + const $code = $('#code')[0]; + /* 在项目仪表盘创建的待测版本区块时,直接取类型名称为该区块的标题。*/ + /* When creating a test version block in the project dashboard, directly take the name of the block of type.*/ if($('#module').val() == 'scrumtest' && $('#paramstype').val() != 'all') { $('#title').val($code.options[$code.selectedIndex].text); + return; } - else - { - const $paramstype = document.querySelector('#paramstype'); - let blockTitle = ''; - if(lang.indexOf('zh') >= 0) - { - blockTitle = $paramstype.options[$paramstype.selectedIndex].text + of + $code.options[$code.selectedIndex].text; - } - else - { - blockTitle = $code.options[$code.selectedIndex].text + of + $paramstype.options[$paramstype.selectedIndex].text; - } + const $paramstype = $('#paramstype')[0]; - $('#title').val(blockTitle); - } + $('#title').val(blockTitle.replace('%1$s', $paramstype.options[$paramstype.selectedIndex].text).replace('%2$s', $code.options[$code.selectedIndex].text)); } diff --git a/module/block/lang/de.php b/module/block/lang/de.php index fd034a1752..11a706cc52 100644 --- a/module/block/lang/de.php +++ b/module/block/lang/de.php @@ -76,7 +76,7 @@ $lang->block->time = 'No'; $lang->block->week = 'Week'; $lang->block->month = 'Month'; $lang->block->selectProduct = "{$lang->productCommon} selection"; -$lang->block->of = ' von '; +$lang->block->blockTitle = '%2$s von %1$s'; $lang->block->remain = 'Left'; $lang->block->allStories = 'All'; diff --git a/module/block/lang/en.php b/module/block/lang/en.php index e3f3fb1982..2cdb9c1377 100644 --- a/module/block/lang/en.php +++ b/module/block/lang/en.php @@ -76,7 +76,7 @@ $lang->block->time = 'No'; $lang->block->week = 'Week'; $lang->block->month = 'Month'; $lang->block->selectProduct = "{$lang->productCommon} selection"; -$lang->block->of = ' of '; +$lang->block->blockTitle = '%2$s of %1$s'; $lang->block->remain = 'Left'; $lang->block->allStories = 'All'; diff --git a/module/block/lang/fr.php b/module/block/lang/fr.php index a877027442..6a49d0e5ce 100644 --- a/module/block/lang/fr.php +++ b/module/block/lang/fr.php @@ -76,7 +76,7 @@ $lang->block->time = 'No'; $lang->block->week = 'Week'; $lang->block->month = 'Month'; $lang->block->selectProduct = "{$lang->productCommon} selection"; -$lang->block->of = ' di '; +$lang->block->blockTitle = '%2%s di %1%s'; $lang->block->remain = 'Left'; $lang->block->allStories = 'All'; diff --git a/module/block/lang/vi.php b/module/block/lang/vi.php index 6ba1156736..bbe0b5cbad 100644 --- a/module/block/lang/vi.php +++ b/module/block/lang/vi.php @@ -70,7 +70,7 @@ $lang->block->time = 'No'; $lang->block->week = 'Week'; $lang->block->month = 'Month'; $lang->block->selectProduct = 'Product selection'; -$lang->block->of = ' thực '; +$lang->block->blockTitle = '%1$s thực %2$s'; $lang->block->remain = 'Left'; $lang->block->createBlock = 'Thêm Block'; diff --git a/module/block/lang/zh-cn.php b/module/block/lang/zh-cn.php index 09c2f0bd7f..94e755c7b8 100644 --- a/module/block/lang/zh-cn.php +++ b/module/block/lang/zh-cn.php @@ -77,7 +77,7 @@ $lang->block->time = '第'; $lang->block->week = '周'; $lang->block->month = '月'; $lang->block->selectProduct = "选择{$lang->productCommon}"; -$lang->block->of = '的'; +$lang->block->blockTitle = '%1$s的%2$s'; $lang->block->remain = '剩余工时'; $lang->block->allStories = '总需求'; diff --git a/module/block/lang/zh-tw.php b/module/block/lang/zh-tw.php index a821639e8e..8ed0725caa 100644 --- a/module/block/lang/zh-tw.php +++ b/module/block/lang/zh-tw.php @@ -75,7 +75,7 @@ $lang->block->time = '第'; $lang->block->week = '周'; $lang->block->month = '月'; $lang->block->selectProduct = '選擇產品'; -$lang->block->of = '的'; +$lang->block->blockTitle = '%1$s的%2$s'; $lang->block->remain = '剩餘工時'; $lang->block->createBlock = '添加區塊'; diff --git a/module/block/ui/create.html.php b/module/block/ui/create.html.php index dc6ed188fc..16555fe068 100644 --- a/module/block/ui/create.html.php +++ b/module/block/ui/create.html.php @@ -13,7 +13,7 @@ namespace zin; set::title($title); jsVar('dashboard', $dashboard); -jsVar('of', $lang->block->of); +jsVar('blockTitle', $lang->block->blockTitle); $paramsRows = array(); $showModules = ($dashboard == 'my' && $modules); @@ -26,7 +26,12 @@ if($module == 'scrumtest' && $code != 'all') else { $typeOptions = isset($params['type']['options']) ? $params['type']['options'] : array(); - $blockTitle = (count($typeOptions) ? $typeOptions[array_keys($typeOptions)[0]] . $lang->block->of : '') . zget($codes, $code); + $blockTitle = zget($codes, $code); + if(!empty($typeOptions)) + { + $typeName = empty($typeOptions) ? '' : $typeOptions[array_keys($typeOptions)[0]]; + $blockTitle = vsprintf($lang->block->blockTitle, array($typeName, $blockTitle)); + } } foreach($params as $key => $row) diff --git a/module/block/ui/edit.html.php b/module/block/ui/edit.html.php index 1828a62ded..0c8e4e454e 100644 --- a/module/block/ui/edit.html.php +++ b/module/block/ui/edit.html.php @@ -13,7 +13,7 @@ namespace zin; set::title($title); jsVar('blockID', $block->id); -jsVar('of', $lang->block->of); +jsVar('blockTitle', $lang->block->blockTitle); $paramsRows = array(); $showModules = ($dashboard == 'my' && $modules);