diff --git a/module/mr/js/edit.js b/module/mr/js/edit.js index f135e7907a..9c443fa984 100644 --- a/module/mr/js/edit.js +++ b/module/mr/js/edit.js @@ -22,4 +22,10 @@ $(function () }); }); + $("#needCI").change(function() + { + if(this.checked == false) $("#jobID").parent().parent().addClass('hidden'); + if(this.checked == true) $("#jobID").parent().parent().removeClass('hidden'); + }); + $("#needCI").trigger('change'); }); diff --git a/module/mr/model.php b/module/mr/model.php index a8f9fb9857..4d41061c2c 100644 --- a/module/mr/model.php +++ b/module/mr/model.php @@ -169,27 +169,18 @@ class mrModel extends model */ public function update($MRID) { - if (!empty($_POST['job'])) - { - $repoID = $this->post->repo; - $jobID = $this->post->job; - - $MR = fixer::input('post') - ->setDefault('editedBy', $this->app->user->account) - ->setDefault('editedDate', helper::now()) - ->add('repoID', $repoID) - ->add('jobID', $jobID) - ->get(); - } - else - { - $MR = fixer::input('post') - ->setDefault('editedBy', $this->app->user->account) - ->setDefault('editedDate', helper::now()) - ->get(); - } + $MR = fixer::input('post') + ->setDefault('jobID', 0) + ->setDefault('repoID', 0) + ->setDefault('needCI', 0) + ->setDefault('editedBy', $this->app->user->account) + ->setDefault('editedDate', helper::now()) + ->get(); $oldMR = $this->getByID($MRID); + $this->dao->update(TABLE_MR)->data($MR)->checkIF($MR->needCI, 'jobID', 'notempty'); + if(dao::isError()) return array('result' => 'fail', 'message' => dao::getError()); + /* Exec Job */ if(isset($MR->jobID) && $MR->jobID) { diff --git a/module/mr/view/edit.html.php b/module/mr/view/edit.html.php index a56a843d56..5527387a32 100644 --- a/module/mr/view/edit.html.php +++ b/module/mr/view/edit.html.php @@ -65,6 +65,10 @@ mr->description;?> description, "rows='3' class='form-control'");?> + + devops->repo;?> + repoID, "class='form-control chosen'");?> + mr->needCI;?> @@ -75,13 +79,9 @@ - - devops->repo;?> - repoID, "class='form-control chosen'");?> - job->common;?> - jobID, "class='form-control chosen'");?> + jobID, "class='form-control chosen'");?> mr->assignee;?>