From 6b4a7348dedf8580d98cf8665b79af2ebd6074b8 Mon Sep 17 00:00:00 2001 From: daitingting Date: Tue, 24 Apr 2018 15:46:45 +0800 Subject: [PATCH] * Rewrite create and edit page of build. --- module/build/control.php | 8 +- module/build/js/common.js | 3 +- module/build/view/create.html.php | 133 +++++++++++++++--------------- module/build/view/edit.html.php | 117 ++++++++++++++------------ 4 files changed, 135 insertions(+), 126 deletions(-) diff --git a/module/build/control.php b/module/build/control.php index 21a79b3d9d..859acd00fe 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -23,9 +23,9 @@ class build extends control if(!empty($_POST)) { $buildID = $this->build->create($projectID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError())); $this->loadModel('action')->create('build', $buildID, 'opened'); - die(js::locate($this->createLink('build', 'view', "buildID=$buildID"), 'parent')); + $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('build', 'view', "buildID=$buildID"))); } $this->session->set('buildCreate', $this->app->getURI(true)); @@ -93,7 +93,7 @@ class build extends control if(!empty($_POST)) { $changes = $this->build->update($buildID); - if(dao::isError()) die(js::error(dao::getError())); + if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError())); $files = $this->loadModel('file')->saveUpload('build', $buildID); if($changes or $files) @@ -103,7 +103,7 @@ class build extends control $actionID = $this->loadModel('action')->create('build', $buildID, 'Edited', $fileAction); if(!empty($changes)) $this->action->logHistory($actionID, $changes); } - die(js::locate(inlink('view', "buildID=$buildID"), 'parent')); + $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('view', "buildID=$buildID"))); } $build = $this->build->getById((int)$buildID); diff --git a/module/build/js/common.js b/module/build/js/common.js index 7ac9315de8..deff5408ea 100644 --- a/module/build/js/common.js +++ b/module/build/js/common.js @@ -13,12 +13,13 @@ $(document).ready(function() function loadBranches(productID) { $('#branch').remove(); + $('#branch_chosen').remove(); $.get(createLink('branch', 'ajaxGetBranches', 'productID=' + productID + '&oldBranch=' + productGroups[productID]['branch']), function(data) { if(data) { $('#product').closest('.input-group').append(data); - $('#branch').css('width', '100px'); + $('#branch').chosen(); } }); } diff --git a/module/build/view/create.html.php b/module/build/view/create.html.php index f6ca6159da..bfe4b75ead 100644 --- a/module/build/view/create.html.php +++ b/module/build/view/create.html.php @@ -11,75 +11,76 @@ */ ?> - -
-
-
- icons['build']);?> - icons['create']);?> build->create;?> +
+
+
+

build->create;?>

-
-
- - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
build->product;?> -
- id, "onchange='loadBranches(this.value);' class='form-control chosen'");?> - type != 'normal') - { - if($product->branch) $branches = array($product->branch => $branches[$product->branch]); - echo "" . html::select('branch', $branches, $product->branch, "class='form-control' style='width:100px; display:inline-block;'"); - } - ?> -
-
build->noProduct, $this->createLink('project', 'manageproducts', "projectID=$projectID&from=buildCreate"));?>
build->name;?> - - - -
  build->last . ': ' . $lastBuild->name . '';?>
+ + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - -
build->product;?> +
+ id, "onchange='loadBranches(this.value);' class='form-control chosen' required");?> + type != 'normal') + { + if($product->branch) $branches = array($product->branch => $branches[$product->branch]); + echo "" . html::select('branch', $branches, $product->branch, "class='form-control chosen'"); + } + ?> +
+
build->noProduct, $this->createLink('project', 'manageproducts', "projectID=$projectID&from=buildCreate"));?>
build->builder;?>user->account, 'class="form-control chosen"');?>
build->date;?>
build->scmPath;?>build->placeholder->scmPath}' autocomplete='off'");?>
build->filePath;?>build->placeholder->filePath}' autocomplete='off'");?>
build->files;?>fetch('file', 'buildForm', array('fileCount' => 1));?>
build->desc;?>
- +
build->name;?> + +
  build->last . ': ' . $lastBuild->name . '';?>
+ +
build->builder;?>user->account, 'class="form-control chosen" required');?>
build->date;?>
build->scmPath;?>build->placeholder->scmPath}' autocomplete='off'");?>
build->filePath;?>build->placeholder->filePath}' autocomplete='off'");?>
build->files;?>fetch('file', 'buildForm');?>
build->desc;?>
+ + +
+ +
diff --git a/module/build/view/edit.html.php b/module/build/view/edit.html.php index f5d9c6c816..226c7daf9c 100644 --- a/module/build/view/edit.html.php +++ b/module/build/view/edit.html.php @@ -11,64 +11,71 @@ */ ?> - -
-
-
- icons['build']);?> id;?> - createLink('build', 'view', 'build=' . $build->id), $build->name, '_blank');?> - build->edit;?> icons['edit']);?> +
+
+
+

+ icons['build']);?> id;?> + createLink('build', 'view', 'build=' . $build->id), $build->name, '_blank');?> + build->edit;?> icons['edit']);?> +

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
build->product;?> +
+ product, "onchange='loadBranches(this.value);' class='form-control chosen' required");?> + productType != 'normal') + { + if($product->branch) $branches = array($product->branch => $branches[$product->branch]); + echo "" . html::select('branch', $branches, $build->branch, "class='form-control chosen'"); + } + ?> +
+
build->name;?>name, "class='form-control' autocomplete='off' required");?>
build->builder;?>builder, 'class="form-control chosen" required');?>
build->date;?>date, "class='form-control form-date' required");?>
build->scmPath;?>scmPath, "class='form-control' placeholder='{$lang->build->placeholder->scmPath}' autocomplete='off'");?>
build->filePath;?>filePath, "class='form-control' placeholder='{$lang->build->placeholder->filePath}' autocomplete='off'");?>
build->files;?>fetch('file', 'buildForm');?>
build->desc;?>desc), "rows='10' class='form-control kindeditor' hidefocus='true'");?>
+ + + config->global->flow != 'onlyTest' ? html::hidden('project', $build->project) : '';?> +
+
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
build->product;?> -
- product, "onchange='loadBranches(this.value);' class='form-control chosen'");?> - productType != 'normal') - { - if($product->branch) $branches = array($product->branch => $branches[$product->branch]); - echo html::select('branch', $branches, $build->branch, "class='form-control' style='width:100px'"); - } - ?> -
-
build->name;?>name, "class='form-control' autocomplete='off'");?>
build->builder;?>builder, 'class="form-control chosen"');?>
build->date;?>date, "class='form-control form-date'");?>
build->scmPath;?>scmPath, "class='form-control' placeholder='{$lang->build->placeholder->scmPath}' autocomplete='off'");?>
build->filePath;?>filePath, "class='form-control' placeholder='{$lang->build->placeholder->filePath}' autocomplete='off'");?>
build->files;?>fetch('file', 'buildForm', array('fileCount' => 1));?>
build->desc;?>desc), "rows='10' class='form-control'");?>
config->global->flow != 'onlyTest' ? html::hidden('project', $build->project) : '');?>
-