From 40dbcd96bd9c0490d0d39701f00cecdbc09ce957 Mon Sep 17 00:00:00 2001 From: qixinzhi Date: Tue, 14 Nov 2023 14:37:16 +0800 Subject: [PATCH] * Finish custom metric implement. --- module/metric/config.php | 7 +--- module/metric/js/implement.ui.js | 59 +++++++++++++++++++++++++++++ module/metric/lang/de.php | 24 ++++++++++-- module/metric/lang/en.php | 24 ++++++++++-- module/metric/lang/fr.php | 24 ++++++++++-- module/metric/lang/zh-cn.php | 24 ++++++++++-- module/metric/ui/implement.html.php | 36 ++++-------------- 7 files changed, 148 insertions(+), 50 deletions(-) create mode 100644 module/metric/js/implement.ui.js diff --git a/module/metric/config.php b/module/metric/config.php index 0d528e8718..076318ea6f 100644 --- a/module/metric/config.php +++ b/module/metric/config.php @@ -18,7 +18,7 @@ $config->metric->actionList['implement']['icon'] = 'code'; $config->metric->actionList['implement']['text'] = $lang->metric->implement->common; $config->metric->actionList['implement']['hint'] = $lang->metric->implement->common; $config->metric->actionList['implement']['data-toggle'] = 'modal'; -$config->metric->actionList['implement']['url'] = helper::createLink('metric', 'implement', 'metricID={id}&isVerify=true'); +$config->metric->actionList['implement']['url'] = helper::createLink('metric', 'implement', 'metricID={id}'); $config->metric->actionList['delist']['icon'] = 'ban-circle'; $config->metric->actionList['delist']['text'] = $lang->metric->delist; @@ -55,8 +55,3 @@ $config->metric->oldObjectMap['stage'] = 'execution'; $config->metric->oldObjectMap['program'] = 'project'; $config->metric->oldObjectMap['softRequest'] = 'story'; $config->metric->oldObjectMap['userRequest'] = 'requirement'; - -$config->metric->verifyList = array(); -$config->metric->verifyList['checkCustomCalcExists'] = $lang->metric->verifyList['checkCustomCalcExists']; -$config->metric->verifyList['checkCalcClass'] = $lang->metric->verifyList['checkCalcClass']; -$config->metric->verifyList['checkCalcMethods'] = $lang->metric->verifyList['checkCalcMethods']; diff --git a/module/metric/js/implement.ui.js b/module/metric/js/implement.ui.js new file mode 100644 index 0000000000..1a4cd11c6b --- /dev/null +++ b/module/metric/js/implement.ui.js @@ -0,0 +1,59 @@ +var methods = []; +$(document).ready(function() +{ + if(!isVerify) verify(); +}); + +function verify(method) +{ + if(!method) + { + methods = Object.keys(verifyCustomMethods); + $('.verify-content').empty(); + method = methods.shift(); + } + + verifyStep(method, function(status, error){ + if(!status) return; + + if(methods.length == 0) + { + var url = $.createLink('metric', 'implement', 'metricID=' + metricId + '&isVerify=true'); + var modal = $('.verify-content').closest('.modal'); + modalId = modal.attr('id'); + setTimeout(function(){ + openUrl(url, {load: 'modal', target: modalId}); + }, 1000); + return; + } + + method = methods.shift(); + verify(method); + }); +} + +function verifyStep(step, callback) +{ + var url = $.createLink('metric', 'ajaxCheck', 'code=' + code + '&step=' + step); + $.get(url, function(resp){ + resp = JSON.parse(resp); + var status = resp[0]; + var error = resp[1]; + + var $html = genVerifyResult(verifyCustomMethods[step].text, status, error); + $('.verify-content').append($html); + if(typeof callback == 'function') callback(status, error); + }); +} + +function genVerifyResult(tip, status, error) +{ + var sentenceClass = status ? 'pass' : 'error'; + var iconClass = status ? 'check' : 'close'; + var html = '

'; + html += tip; + html += ''; + if(error && error.length) html += ''; + html += '

'; + return $(html); +} diff --git a/module/metric/lang/de.php b/module/metric/lang/de.php index b340bf108d..cf1ff59acd 100755 --- a/module/metric/lang/de.php +++ b/module/metric/lang/de.php @@ -237,10 +237,26 @@ $lang->metric->implement->instructionTips[] = '1.Download the measurement templa $lang->metric->implement->instructionTips[] = '2.Please put the developed file in the following directory,Keep the file name consistent with the measurement code。
{tmpRoot}metric'; $lang->metric->implement->instructionTips[] = '3.Execute commands to grant executable permissions to files:

chmod 777 {tmpRoot}metric

chmod 777 {tmpRoot}metric/{code}.php

'; -$lang->metric->verifyList = array(); -$lang->metric->verifyList['checkCustomCalcExists'] = 'Check whether the metric exists'; -$lang->metric->verifyList['checkCalcClass'] = 'Check the metric class name is correct'; -$lang->metric->verifyList['checkCalcMethods'] = 'Check whether the metrics defines the required methods'; +$lang->metric->verifyCustom = new stdclass(); +$lang->metric->verifyCustom->checkCustomCalcExists = array(); +$lang->metric->verifyCustom->checkCustomCalcExists['text'] = 'Check if the metric file exists'; +$lang->metric->verifyCustom->checkCustomCalcExists['error'] = 'The metric file does not exist'; + +$lang->metric->verifyCustom->checkCustomCalcSyntax = array(); +$lang->metric->verifyCustom->checkCustomCalcSyntax['text'] = 'Check if the metric file syntax is correct'; +$lang->metric->verifyCustom->checkCustomCalcSyntax['error'] = 'The metric file syntax is incorrect'; + +$lang->metric->verifyCustom->checkCustomCalcClassName = array(); +$lang->metric->verifyCustom->checkCustomCalcClassName['text'] = 'Check if the metric file class name is correct'; +$lang->metric->verifyCustom->checkCustomCalcClassName['error'] = 'The metric file class name is incorrect'; + +$lang->metric->verifyCustom->checkCustomCalcClassMethod = array(); +$lang->metric->verifyCustom->checkCustomCalcClassMethod['text'] = 'Check if the metric file class method is correct'; +$lang->metric->verifyCustom->checkCustomCalcClassMethod['error'] = 'The metric file class method is incorrect'; + +$lang->metric->verifyCustom->checkCustomCalcRuntime = array(); +$lang->metric->verifyCustom->checkCustomCalcRuntime['text'] = 'Check if the metric file can be executed'; +$lang->metric->verifyCustom->checkCustomCalcRuntime['error'] = ''; $lang->metric->weekList = array(); $lang->metric->weekList['1'] = 'Monday'; diff --git a/module/metric/lang/en.php b/module/metric/lang/en.php index b340bf108d..cf1ff59acd 100755 --- a/module/metric/lang/en.php +++ b/module/metric/lang/en.php @@ -237,10 +237,26 @@ $lang->metric->implement->instructionTips[] = '1.Download the measurement templa $lang->metric->implement->instructionTips[] = '2.Please put the developed file in the following directory,Keep the file name consistent with the measurement code。
{tmpRoot}metric'; $lang->metric->implement->instructionTips[] = '3.Execute commands to grant executable permissions to files:

chmod 777 {tmpRoot}metric

chmod 777 {tmpRoot}metric/{code}.php

'; -$lang->metric->verifyList = array(); -$lang->metric->verifyList['checkCustomCalcExists'] = 'Check whether the metric exists'; -$lang->metric->verifyList['checkCalcClass'] = 'Check the metric class name is correct'; -$lang->metric->verifyList['checkCalcMethods'] = 'Check whether the metrics defines the required methods'; +$lang->metric->verifyCustom = new stdclass(); +$lang->metric->verifyCustom->checkCustomCalcExists = array(); +$lang->metric->verifyCustom->checkCustomCalcExists['text'] = 'Check if the metric file exists'; +$lang->metric->verifyCustom->checkCustomCalcExists['error'] = 'The metric file does not exist'; + +$lang->metric->verifyCustom->checkCustomCalcSyntax = array(); +$lang->metric->verifyCustom->checkCustomCalcSyntax['text'] = 'Check if the metric file syntax is correct'; +$lang->metric->verifyCustom->checkCustomCalcSyntax['error'] = 'The metric file syntax is incorrect'; + +$lang->metric->verifyCustom->checkCustomCalcClassName = array(); +$lang->metric->verifyCustom->checkCustomCalcClassName['text'] = 'Check if the metric file class name is correct'; +$lang->metric->verifyCustom->checkCustomCalcClassName['error'] = 'The metric file class name is incorrect'; + +$lang->metric->verifyCustom->checkCustomCalcClassMethod = array(); +$lang->metric->verifyCustom->checkCustomCalcClassMethod['text'] = 'Check if the metric file class method is correct'; +$lang->metric->verifyCustom->checkCustomCalcClassMethod['error'] = 'The metric file class method is incorrect'; + +$lang->metric->verifyCustom->checkCustomCalcRuntime = array(); +$lang->metric->verifyCustom->checkCustomCalcRuntime['text'] = 'Check if the metric file can be executed'; +$lang->metric->verifyCustom->checkCustomCalcRuntime['error'] = ''; $lang->metric->weekList = array(); $lang->metric->weekList['1'] = 'Monday'; diff --git a/module/metric/lang/fr.php b/module/metric/lang/fr.php index b340bf108d..cf1ff59acd 100755 --- a/module/metric/lang/fr.php +++ b/module/metric/lang/fr.php @@ -237,10 +237,26 @@ $lang->metric->implement->instructionTips[] = '1.Download the measurement templa $lang->metric->implement->instructionTips[] = '2.Please put the developed file in the following directory,Keep the file name consistent with the measurement code。
{tmpRoot}metric'; $lang->metric->implement->instructionTips[] = '3.Execute commands to grant executable permissions to files:

chmod 777 {tmpRoot}metric

chmod 777 {tmpRoot}metric/{code}.php

'; -$lang->metric->verifyList = array(); -$lang->metric->verifyList['checkCustomCalcExists'] = 'Check whether the metric exists'; -$lang->metric->verifyList['checkCalcClass'] = 'Check the metric class name is correct'; -$lang->metric->verifyList['checkCalcMethods'] = 'Check whether the metrics defines the required methods'; +$lang->metric->verifyCustom = new stdclass(); +$lang->metric->verifyCustom->checkCustomCalcExists = array(); +$lang->metric->verifyCustom->checkCustomCalcExists['text'] = 'Check if the metric file exists'; +$lang->metric->verifyCustom->checkCustomCalcExists['error'] = 'The metric file does not exist'; + +$lang->metric->verifyCustom->checkCustomCalcSyntax = array(); +$lang->metric->verifyCustom->checkCustomCalcSyntax['text'] = 'Check if the metric file syntax is correct'; +$lang->metric->verifyCustom->checkCustomCalcSyntax['error'] = 'The metric file syntax is incorrect'; + +$lang->metric->verifyCustom->checkCustomCalcClassName = array(); +$lang->metric->verifyCustom->checkCustomCalcClassName['text'] = 'Check if the metric file class name is correct'; +$lang->metric->verifyCustom->checkCustomCalcClassName['error'] = 'The metric file class name is incorrect'; + +$lang->metric->verifyCustom->checkCustomCalcClassMethod = array(); +$lang->metric->verifyCustom->checkCustomCalcClassMethod['text'] = 'Check if the metric file class method is correct'; +$lang->metric->verifyCustom->checkCustomCalcClassMethod['error'] = 'The metric file class method is incorrect'; + +$lang->metric->verifyCustom->checkCustomCalcRuntime = array(); +$lang->metric->verifyCustom->checkCustomCalcRuntime['text'] = 'Check if the metric file can be executed'; +$lang->metric->verifyCustom->checkCustomCalcRuntime['error'] = ''; $lang->metric->weekList = array(); $lang->metric->weekList['1'] = 'Monday'; diff --git a/module/metric/lang/zh-cn.php b/module/metric/lang/zh-cn.php index 94171af4b2..d784725892 100755 --- a/module/metric/lang/zh-cn.php +++ b/module/metric/lang/zh-cn.php @@ -237,10 +237,26 @@ $lang->metric->implement->instructionTips[] = '1.下载度量项模板文件, $lang->metric->implement->instructionTips[] = '2.请将开发后的文件放到下方目录,需保持文件名称与度量代号一致。
{tmpRoot}metric'; $lang->metric->implement->instructionTips[] = '3.执行命令赋予文件可执行权限:

chmod 777 {tmpRoot}metric

chmod 777 {tmpRoot}metric/{code}.php

'; -$lang->metric->verifyList = array(); -$lang->metric->verifyList['checkCustomCalcExists'] = '检查度量项是否存在'; -$lang->metric->verifyList['checkCalcClass'] = '检查度量项类名是否正确'; -$lang->metric->verifyList['checkCalcMethods'] = '检查度量项是否定义了必须的方法'; +$lang->metric->verifyCustom = new stdclass(); +$lang->metric->verifyCustom->checkCustomCalcExists = array(); +$lang->metric->verifyCustom->checkCustomCalcExists['text'] = '检查度量项文件是否存在'; +$lang->metric->verifyCustom->checkCustomCalcExists['error'] = '度量项文件不存在'; + +$lang->metric->verifyCustom->checkCustomCalcSyntax = array(); +$lang->metric->verifyCustom->checkCustomCalcSyntax['text'] = '检查语法错误'; +$lang->metric->verifyCustom->checkCustomCalcSyntax['error'] = '语法错误'; + +$lang->metric->verifyCustom->checkCustomCalcClassName = array(); +$lang->metric->verifyCustom->checkCustomCalcClassName['text'] = '检查度量项类名是否正确'; +$lang->metric->verifyCustom->checkCustomCalcClassName['error'] = '度量项类名错误'; + +$lang->metric->verifyCustom->checkCustomCalcClassMethod = array(); +$lang->metric->verifyCustom->checkCustomCalcClassMethod['text'] = '检查度量项是否定义了必须的方法'; +$lang->metric->verifyCustom->checkCustomCalcClassMethod['error'] = '度量项没有定义必须的方法'; + +$lang->metric->verifyCustom->checkCustomCalcRuntime = array(); +$lang->metric->verifyCustom->checkCustomCalcRuntime['text'] = '检查度量项运行时错误'; +$lang->metric->verifyCustom->checkCustomCalcRuntime['error'] = ''; $lang->metric->weekList = array(); $lang->metric->weekList['1'] = '星期一'; diff --git a/module/metric/ui/implement.html.php b/module/metric/ui/implement.html.php index 6bec698651..d3bb39d04c 100644 --- a/module/metric/ui/implement.html.php +++ b/module/metric/ui/implement.html.php @@ -10,6 +10,10 @@ declare(strict_types=1); * @link http://www.zentao.net */ namespace zin; +jsVar('metricId', $metric->id); +jsVar('code', $metric->code); +jsVar('verifyCustomMethods', $verifyCustom); +jsVar('isVerify', $isVerify); detailHeader ( @@ -33,30 +37,6 @@ detailHeader ) ); -$fnGenerateVerifyResult = function() use($verifyResult) -{ - if(empty($verifyResult)) return null; - - $results = array(); - foreach($verifyResult as $result) - { - $class = 'verify-sentence'; - $class .= $result->result ? ' pass' : ' error'; - $icon = $result->result ? 'check' : 'close'; - $results[] = p - ( - setClass($class), - $result->tip, - icon - ( - $icon - ) - ); - } - - return $results; -}; - $fnGenerateInstructions = function() use($lang) { $instructions = array(); @@ -143,8 +123,7 @@ panel empty($result) ? div ( setClass('verify-content'), - $fnGenerateVerifyResult() - ) : $fnGenerateDataDisplay() + ) : $fnGenerateDataDisplay(), ), set::footerClass('footer-actions'), @@ -152,8 +131,9 @@ panel ([ [ 'type' => 'secondary', + 'class' => 'btn-verify', 'text' => $lang->metric->verifyFile, - 'url' => helper::createLink('metric', 'implement', "metricID={$metric->id}&isVerify=true") + 'url' => helper::createLink('metric', 'implement', "metricID={$metric->id}") ], [ 'type' => 'primary', @@ -161,7 +141,7 @@ panel 'btnType' => 'submit', 'disabled' => empty($result), 'url' => helper::createLink('metric', 'publish', "metricID={$metric->id}") - ] + ], ]) );