diff --git a/module/testcase/config/form.php b/module/testcase/config/form.php index 72498d1d38..5e2b9ff3cc 100644 --- a/module/testcase/config/form.php +++ b/module/testcase/config/form.php @@ -124,7 +124,7 @@ $config->testcase->form->showImport['expect'] = array('required' => false, $config->testcase->form->showImport['stepType'] = array('required' => false, 'type' => 'array', 'default' => array()); $config->testcase->form->automation = common::formConfig('testcase', 'automation'); -$config->testcase->form->automation['product'] = array('required' => false, 'type' => 'int', 'default' => 0); -$config->testcase->form->automation['node'] = array('required' => false, 'type' => 'int', 'default' => 0); +$config->testcase->form->automation['product'] = array('required' => true, 'type' => 'int', 'default' => 0); +$config->testcase->form->automation['node'] = array('required' => true, 'type' => 'int', 'default' => 0); $config->testcase->form->automation['scriptPath'] = array('required' => true, 'type' => 'string', 'default' => ''); -$config->testcase->form->automation['shell'] = array('required' => true, 'type' => 'string', 'default' => '', 'control' => 'editor'); +$config->testcase->form->automation['shell'] = array('required' => false, 'type' => 'string', 'default' => '', 'control' => 'editor'); diff --git a/module/testcase/control.php b/module/testcase/control.php index d98de89080..40f4a164b5 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -1295,32 +1295,32 @@ class testcase extends control * @access public * @return void */ - public function automation($productID = 0) + public function automation(int $productID = 0) { - $this->loadModel('zanode'); - if($_POST) { - $automation = form::data($this->config->testcase->form->automation) - ->setIF($this->post->id, 'id', $this->post->id) - ->setDefault('createdBy', $this->app->user->account) - ->setdefault('createddate', helper::now()) - ->get(); - $this->zanode->setAutomationSetting($automation); + /* 设置语言项以便 form 类检查必填项时输出正确的字段名。*/ + /* Set language item for form class to check required fields. */ + $this->loadModel('zanode'); + $this->lang->testcase->scriptPath = $this->lang->zanode->scriptPath; + $this->lang->testcase->node = $this->lang->zanode->common; + $automation = form::data($this->config->testcase->form->automation) + ->add('createdBy', $this->app->user->account) + ->add('createddate', helper::now()) + ->get(); + + $this->zanode->setAutomationSetting($automation); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); - // if($this->post->syncToZentao) $this->zanode->syncCasesToZentao($this->post->scriptPath); - // if($this->post->node) $node = $this->zanode->getNodeByID($this->post->node); - - return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => $this->createLink('testcase', 'browse', "productID={$this->post->product}"))); + return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => inlink('browse', "productID={$automation->product}"))); } - $this->view->title = $this->lang->zanode->automation; - $this->view->automation = $this->zanode->getPairs(); - $this->view->nodeList = $this->zanode->getAutomationByProduct($productID); + $this->view->title = $this->lang->testcase->automation; + $this->view->automation = $this->loadModel('zanode')->getAutomationByProduct($productID); + $this->view->nodeList = $this->zanode->getPairs(); + $this->view->products = $productID ? array() : $this->product->getPairs('', 0, '', 'all'); $this->view->productID = $productID; - $this->view->products = $this->product->getPairs('', 0, '', 'all'); $this->display(); } diff --git a/module/testcase/ui/automation.html.php b/module/testcase/ui/automation.html.php index 8e49f1b429..f2bd73cf80 100644 --- a/module/testcase/ui/automation.html.php +++ b/module/testcase/ui/automation.html.php @@ -36,7 +36,7 @@ to::header formPanel ( - !$productID ? formGroup + $productID ? formHidden('product', $productID) : formGroup ( set::label($lang->testcase->product), set::required(true), @@ -46,7 +46,7 @@ formPanel set::items($products), on::change('#product', 'loadProduct') ) - ) : null, + ), formGroup ( set::label($lang->zanode->common), @@ -58,7 +58,7 @@ formPanel setID('node'), set::name('node'), set::items($nodeList), - set::value(!empty($automation->node) ? $automation->node : '') + set::value(isset($automation->node) ? $automation->node : '') ), div ( @@ -78,7 +78,7 @@ formPanel set::label($lang->zanode->scriptPath), set::required(true), set::name('scriptPath'), - set::value(!empty($automation->scriptPath) ? $automation->scriptPath : ''), + set::value(isset($automation->scriptPath) ? $automation->scriptPath : ''), set::placeholder($lang->zanode->scriptTips) ), formGroup @@ -87,23 +87,12 @@ formPanel editor ( set::name('shell'), - set::value(!empty($automation->shell) ? $automation->shell : ''), + set::value(isset($automation->shell) ? $automation->shell : ''), set::rows(6), set::placeholder($lang->zanode->shellTips) ) ), - $productID ? input - ( - set::type('hidden'), - set::name('product'), - set::value($productID) - ) : null, - $automation ? input - ( - set::type('hidden'), - set::name('id'), - set::value($automation->id) - ) : null, + formHidden('id', isset($automation->id) ? $automation->id : 0), set::actions(array('submit')), set::submitBtnText($lang->save) );