* Fix import repo

This commit is contained in:
zenggang
2023-08-02 08:39:24 +00:00
parent 27f0502d2e
commit 669d4f3b02
2 changed files with 17 additions and 6 deletions
+6
View File
@@ -48,6 +48,12 @@ featureBar
formBatchPanel
(
h::input
(
set::type('hidden'),
set::name('serviceHost'),
set::value($gitlab->id),
),
set::id('repoList'),
set::back('repo-maintain'),
set::mode(count($repoList) == 0 ? 'edit' : 'add'),
+11 -6
View File
@@ -267,17 +267,22 @@ class repoZen extends repo
*/
protected function prepareBatchCreate(): array|false
{
$this->app->loadLang('testcase');
$data = array();
foreach($_POST as $key => $val)
foreach($_POST as $key => $vals)
{
if(strpos($key, 'serviceProject') === 0)
{
$i = substr($key, 14);
if($this->post->{'product' . $i} == '') dao::$errors['product' . $i][] = sprintf($this->lang->error->notempty, $this->lang->repo->product);
if($this->post->{'name' . $i} == '') dao::$errors['name' . $i][] = sprintf($this->lang->error->notempty, $this->lang->repo->name);
if(dao::isError()) continue;
foreach($vals as $i => $project)
{
$products = array_filter($this->post->product[$i]);
if(empty($products)) dao::$errors['product'][] = sprintf($this->lang->testcase->whichLine . $this->lang->error->notempty, $i, $this->lang->repo->product);
if($this->post->name[$i] == '') dao::$errors['name'][] = sprintf($this->lang->testcase->whichLine . $this->lang->error->notempty, $i, $this->lang->repo->name);
if(dao::isError()) continue;
$data[] = array('serviceProject' => $this->post->{'serviceProject' . $i}, 'product' => implode(',', $this->post->{'product' . $i}), 'name' => $this->post->{'name' . $i}, 'projects' => empty($_POST['projects'][$i]) ? '' : implode(',', $this->post->projects[$i]));
$data[] = array('serviceProject' => $project, 'product' => implode(',', $this->post->product[$i]), 'name' => $this->post->name[$i], 'projects' => empty($_POST['projects'][$i]) ? '' : implode(',', $this->post->projects[$i]));
}
}
}
if(dao::isError()) return false;