diff --git a/module/job/view/edit.html.php b/module/job/view/edit.html.php index 82f235fe65..3d0894484b 100644 --- a/module/job/view/edit.html.php +++ b/module/job/view/edit.html.php @@ -12,7 +12,7 @@ ?> - + triggerType);?> pipeline);?> job->dirChange);?> diff --git a/module/mr/config.php b/module/mr/config.php index da874423db..b0535585c1 100644 --- a/module/mr/config.php +++ b/module/mr/config.php @@ -3,3 +3,6 @@ $config->MR = new stdclass(); $config->MR->create = new stdclass(); $config->MR->create->requiredFields = 'gitlabID,projectID,mrID,title'; $config->MR->create->skippedFields = 'sourceProject,sourceBranch,targetProject,targetBranch'; + +$config->MR->edit = new stdclass(); +$config->MR->edit->requiredFields = 'title'; diff --git a/module/mr/control.php b/module/mr/control.php index aee1de5c78..305d671217 100644 --- a/module/mr/control.php +++ b/module/mr/control.php @@ -48,22 +48,25 @@ class mr extends control } /** - * Update/Edit MR function. + * Edit MR function. * * @access public * @return void */ - public function update($MRID) + public function edit($MRID) { if($_POST) { - $this->mr->update(); + $this->mr->edit($MRID); if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError())); return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse'))); } - $this->view->MR = $this->mr->getByID($MRID); - $this->view->title = $this->lang->mr->update; + $MR = $this->mr->getByID($MRID); + $this->view->MR = $MR; + $this->view->title = $this->lang->mr->edit; + $this->view->users = array("" => "") + $this->loadModel('gitlab')->getUserIdRealnamePairs($MR->gitlabID); /* Get user list for assignee and reviewer. */ + $this->display(); } diff --git a/module/mr/model.php b/module/mr/model.php index 6e3635fed7..be700b5779 100644 --- a/module/mr/model.php +++ b/module/mr/model.php @@ -27,13 +27,16 @@ class mrModel extends model * Get a MR by id. * * @param int $id + * @param bool $process * @access public * @return object */ - public function getByID($id) + public function getByID($id, $process = true) { $MR = $this->dao->select('*')->from(TABLE_MR)->where('id')->eq($id)->fetch(); - return $this->processMR($MR); + + if($process) return $this->processMR($MR); + return $MR; } /** @@ -59,7 +62,7 @@ class mrModel extends model } /** - * Process MR info by api. + * Process MR info by api. Append extra attributes in GitLab. * * @param object $MR * @access public @@ -115,7 +118,7 @@ class mrModel extends model * Create MR function. * * @access public - * @return bool + * @return int|bool|object */ public function create() { @@ -161,14 +164,36 @@ class mrModel extends model } /** - * Update MR function. + * Edit MR function. * * @access public * @return void */ - public function update() + public function edit($MRID) { - } + /* Get MR in zentao database and do not append extra attributes in GitLab. */ + $MR = $this->getByID($MRID, $process = false); + $MR->title = $this->post->title; + $MR->description = $this->post->description; + $MR->assignee = $this->post->assignee; + $MR->reviewer = $this->post->reviewer; + + /* Update MR in GitLab. */ + $newMR = new stdclass; + $newMR->title = $MR->title; + $newMR->description = $MR->description; + $newMR->assignee = $MR->assignee; + $newMR->reviewer = $MR->reviewer; + $newMR->targetBranch = $this->post->targetBranch; + $this->apiUpdateMR($MR->gitlabID, $MR->projectID, $MR->mrID, $newMR); + + /* Update MR in Zentao database. */ + $this->dao->update(TABLE_MR)->data($MR) + ->batchCheck($this->config->MR->edit->requiredFields, 'notempty') + ->autoCheck() + ->exec(); + if(dao::isError()) return false; + } /** * Create MR by API. @@ -224,11 +249,11 @@ class mrModel extends model * @param int $gitlabID * @param int $projectID * @param int $MRID - * @param object $params + * @param object $MR * @access public * @return object */ - public function apiUpdateMR($gitlabID, $projectID, $MRID, $params) + public function apiUpdateMR($gitlabID, $projectID, $MRID, $MR) { $url = sprintf($this->gitlab->getApiRoot($gitlabID), "/projects/$projectID/merge_requests/$MRID"); return json_decode(commonModel::http($url, $MR, $options = array(CURLOPT_CUSTOMREQUEST => 'PUT'))); diff --git a/module/mr/view/browse.html.php b/module/mr/view/browse.html.php index d1491e98fb..b924bc50a9 100644 --- a/module/mr/view/browse.html.php +++ b/module/mr/view/browse.html.php @@ -45,7 +45,7 @@