* Rewrite create and edit page of build.

This commit is contained in:
daitingting
2018-04-24 15:46:45 +08:00
parent 9fc1cfb5a2
commit 6b4a7348de
4 changed files with 135 additions and 126 deletions
+4 -4
View File
@@ -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);
+2 -1
View File
@@ -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();
}
});
}
+67 -66
View File
@@ -11,75 +11,76 @@
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php include '../../common/view/datepicker.html.php';?>
<?php include '../../common/view/kindeditor.html.php';?>
<div class='container'>
<div id='titlebar'>
<div class='heading'>
<span class='prefix'><?php echo html::icon($lang->icons['build']);?></span>
<strong><small class='text-muted'><?php echo html::icon($lang->icons['create']);?></small> <?php echo $lang->build->create;?></strong>
<div id='mainContent' class='main-content'>
<div class='center-block'>
<div class='main-header'>
<h2><?php echo $lang->build->create;?></h2>
</div>
</div>
<form class='form-condensed' method='post' target='hiddenwin' id='dataform' enctype='multipart/form-data'>
<table class='table table-form'>
<tr>
<th class='w-110px'><?php echo $lang->build->product;?></th>
<?php if($products):?>
<td>
<div class='input-group'>
<?php echo html::select('product', $products, $product->id, "onchange='loadBranches(this.value);' class='form-control chosen'");?>
<?php
if($product->type != 'normal')
{
if($product->branch) $branches = array($product->branch => $branches[$product->branch]);
echo "<span class='input-group-addon fix-padding fix-border'></span>" . html::select('branch', $branches, $product->branch, "class='form-control' style='width:100px; display:inline-block;'");
}
?>
</div>
</td>
<td></td>
<?php else:?>
<td colspan='2'><?php if(empty($products)) printf($lang->build->noProduct, $this->createLink('project', 'manageproducts', "projectID=$projectID&from=buildCreate"));?></td>
<?php endif;?>
</tr>
<tr>
<th><?php echo $lang->build->name;?></th>
<td class='w-p25-f'>
<?php echo html::input('name', '', "class='form-control' autocomplete='off'");?>
</td>
<td>
<?php if($lastBuild):?>
<div class='help-block'> &nbsp; <?php echo $lang->build->last . ': <strong>' . $lastBuild->name . '</strong>';?></div>
<form class='load-indicator main-form form-ajax' id='dataform' method='post' enctype='multipart/form-data'>
<table class='table table-form'>
<tr>
<th><?php echo $lang->build->product;?></th>
<?php if($products):?>
<td>
<div class='input-group'>
<?php echo html::select('product', $products, $product->id, "onchange='loadBranches(this.value);' class='form-control chosen' required");?>
<?php
if($product->type != 'normal')
{
if($product->branch) $branches = array($product->branch => $branches[$product->branch]);
echo "<span class='input-group-addon fix-padding fix-border'></span>" . html::select('branch', $branches, $product->branch, "class='form-control chosen'");
}
?>
</div>
</td>
<td></td>
<?php else:?>
<td class='text-muted' colspan='2'><?php if(empty($products)) printf($lang->build->noProduct, $this->createLink('project', 'manageproducts', "projectID=$projectID&from=buildCreate"));?></td>
<?php endif;?>
</td>
</tr>
<tr>
<th><?php echo $lang->build->builder;?></th>
<td><?php echo html::select('builder', $users, $app->user->account, 'class="form-control chosen"');?></td>
</tr>
<tr>
<th><?php echo $lang->build->date;?></th>
<td><?php echo html::input('date', helper::today(), "class='form-control form-date'");?></td>
</tr>
<tr>
<th><?php echo $lang->build->scmPath;?></th>
<td colspan='2'><?php echo html::input('scmPath', '', "class='form-control' placeholder='{$lang->build->placeholder->scmPath}' autocomplete='off'");?></td>
</tr>
<tr>
<th><?php echo $lang->build->filePath;?></th>
<td colspan='2'><?php echo html::input('filePath', '', "class='form-control' placeholder='{$lang->build->placeholder->filePath}' autocomplete='off'");?></td>
</tr>
<tr>
<th><?php echo $lang->build->files;?></th>
<td colspan='2'><?php echo $this->fetch('file', 'buildForm', array('fileCount' => 1));?></td>
</tr>
<tr>
<th><?php echo $lang->build->desc;?></th>
<td colspan='2'><?php echo html::textarea('desc', '', "rows='10' class='form-control'");?></td>
</tr>
<tr><td></td><td colspan='2'><?php echo html::submitButton() . html::backButton();?></td></tr>
</table>
</form>
</tr>
<tr>
<th><?php echo $lang->build->name;?></th>
<td><?php echo html::input('name', '', "class='form-control' autocomplete='off' required");?></td>
<td class='text-muted'>
<?php if($lastBuild):?>
<div class='help-block'> &nbsp; <?php echo $lang->build->last . ': <strong>' . $lastBuild->name . '</strong>';?></div>
<?php endif;?>
</td>
</tr>
<tr>
<th><?php echo $lang->build->builder;?></th>
<td><?php echo html::select('builder', $users, $app->user->account, 'class="form-control chosen" required');?></td>
</tr>
<tr>
<th><?php echo $lang->build->date;?></th>
<td><?php echo html::input('date', helper::today(), "class='form-control form-date' required");?></td>
</tr>
<tr>
<th><?php echo $lang->build->scmPath;?></th>
<td colspan='2'><?php echo html::input('scmPath', '', "class='form-control' placeholder='{$lang->build->placeholder->scmPath}' autocomplete='off'");?></td>
</tr>
<tr>
<th><?php echo $lang->build->filePath;?></th>
<td colspan='2'><?php echo html::input('filePath', '', "class='form-control' placeholder='{$lang->build->placeholder->filePath}' autocomplete='off'");?></td>
</tr>
<tr>
<th><?php echo $lang->build->files;?></th>
<td colspan='2'><?php echo $this->fetch('file', 'buildForm');?></td>
</tr>
<tr>
<th><?php echo $lang->build->desc;?></th>
<td colspan='2'><?php echo html::textarea('desc', '', "rows='10' class='form-control kindeditor' hidefocus='true'");?></td>
</tr>
<tr>
<td colspan="3" class="text-center">
<?php echo html::submitButton('', '', 'btn btn-wide btn-primary');?>
<?php echo html::backButton('', '', 'btn btn-wide btn-gray');?>
</td>
</tr>
</table>
</form>
</div>
</div>
<?php js::set('productGroups', $productGroups)?>
<?php include '../../common/view/footer.html.php';?>
+62 -55
View File
@@ -11,64 +11,71 @@
*/
?>
<?php include '../../common/view/header.html.php';?>
<?php include '../../common/view/datepicker.html.php';?>
<?php include '../../common/view/kindeditor.html.php';?>
<div class='container'>
<div id='titlebar'>
<div class='heading'>
<span class='prefix'><?php echo html::icon($lang->icons['build']);?> <strong><?php echo $build->id;?></strong></span>
<strong><?php echo html::a($this->createLink('build', 'view', 'build=' . $build->id), $build->name, '_blank');?></strong>
<small class='text-muted'> <?php echo $lang->build->edit;?> <?php echo html::icon($lang->icons['edit']);?></small>
<div id='mainContent' class='main-content'>
<div class='center-block'>
<div class='main-header'>
<h2>
<span class='prefix'><?php echo html::icon($lang->icons['build']);?> <strong><?php echo $build->id;?></strong></span>
<strong><?php echo html::a($this->createLink('build', 'view', 'build=' . $build->id), $build->name, '_blank');?></strong>
<small class='text-muted'> <?php echo $lang->build->edit;?> <?php echo html::icon($lang->icons['edit']);?></small>
</h2>
</div>
<form class='load-indicator main-form form-ajax' method='post' id='dataform' enctype='multipart/form-data'>
<table class='table table-form'>
<tr>
<th><?php echo $lang->build->product;?></th>
<td>
<div class='input-group'>
<?php echo html::select('product', $products, $build->product, "onchange='loadBranches(this.value);' class='form-control chosen' required");?>
<?php
if($build->productType != 'normal')
{
if($product->branch) $branches = array($product->branch => $branches[$product->branch]);
echo "<span class='input-group-addon fix-padding fix-border'></span>" . html::select('branch', $branches, $build->branch, "class='form-control chosen'");
}
?>
</div>
</td><td></td>
</tr>
<tr>
<th><?php echo $lang->build->name;?></th>
<td><?php echo html::input('name', $build->name, "class='form-control' autocomplete='off' required");?></td>
</tr>
<tr>
<th><?php echo $lang->build->builder;?></th>
<td><?php echo html::select('builder', $users, $build->builder, 'class="form-control chosen" required');?></td>
</tr>
<tr>
<th><?php echo $lang->build->date;?></th>
<td><?php echo html::input('date', $build->date, "class='form-control form-date' required");?></td>
</tr>
<tr>
<th><?php echo $lang->build->scmPath;?></th>
<td colspan='2'><?php echo html::input('scmPath', $build->scmPath, "class='form-control' placeholder='{$lang->build->placeholder->scmPath}' autocomplete='off'");?></td>
</tr>
<tr>
<th><?php echo $lang->build->filePath;?></th>
<td colspan='2'><?php echo html::input('filePath', $build->filePath, "class='form-control' placeholder='{$lang->build->placeholder->filePath}' autocomplete='off'");?></td>
</tr>
<tr>
<th><?php echo $lang->build->files;?></th>
<td colspan='2'><?php echo $this->fetch('file', 'buildForm');?></td>
</tr>
<tr>
<th><?php echo $lang->build->desc;?></th>
<td colspan='2'><?php echo html::textarea('desc', htmlspecialchars($build->desc), "rows='10' class='form-control kindeditor' hidefocus='true'");?></td>
</tr>
<tr>
<td colspan="3" class="text-center">
<?php echo html::submitButton('', '', 'btn btn-wide btn-primary');?>
<?php echo html::backButton('', '', 'btn btn-wide btn-gray');?>
<?php echo $this->config->global->flow != 'onlyTest' ? html::hidden('project', $build->project) : '';?>
</td>
</tr>
</table>
</form>
</div>
<form class='form-condensed' method='post' target='hiddenwin' id='dataform' enctype='multipart/form-data'>
<table class='table table-form'>
<tr>
<th class='w-110px'><?php echo $lang->build->product;?></th>
<td class='w-p25-f'>
<div class='input-group'>
<?php echo html::select('product', $products, $build->product, "onchange='loadBranches(this.value);' class='form-control chosen'");?>
<?php
if($build->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'");
}
?>
</div>
</td><td></td>
</tr>
<tr>
<th><?php echo $lang->build->name;?></th>
<td><?php echo html::input('name', $build->name, "class='form-control' autocomplete='off'");?></td>
</tr>
<tr>
<th><?php echo $lang->build->builder;?></th>
<td><?php echo html::select('builder', $users, $build->builder, 'class="form-control chosen"');?></td>
</tr>
<tr>
<th><?php echo $lang->build->date;?></th>
<td><?php echo html::input('date', $build->date, "class='form-control form-date'");?></td>
</tr>
<tr>
<th><?php echo $lang->build->scmPath;?></th>
<td colspan='2'><?php echo html::input('scmPath', $build->scmPath, "class='form-control' placeholder='{$lang->build->placeholder->scmPath}' autocomplete='off'");?></td>
</tr>
<tr>
<th><?php echo $lang->build->filePath;?></th>
<td colspan='2'><?php echo html::input('filePath', $build->filePath, "class='form-control' placeholder='{$lang->build->placeholder->filePath}' autocomplete='off'");?></td>
</tr>
<tr>
<th><?php echo $lang->build->files;?></th>
<td colspan='2'><?php echo $this->fetch('file', 'buildForm', array('fileCount' => 1));?></td>
</tr>
<tr>
<th><?php echo $lang->build->desc;?></th>
<td colspan='2'><?php echo html::textarea('desc', htmlspecialchars($build->desc), "rows='10' class='form-control'");?></td>
</tr>
<tr><td></td><td colspan='2'><?php echo html::submitButton() . html::backButton() . ($this->config->global->flow != 'onlyTest' ? html::hidden('project', $build->project) : '');?></td></tr>
</table>
</form>
</div>
<?php js::set('productGroups', $productGroups)?>
<?php include '../../common/view/footer.html.php';?>