This commit is contained in:
wangyuting
2023-06-09 13:40:05 +08:00
6 changed files with 63 additions and 30 deletions
+25 -5
View File
@@ -6,13 +6,15 @@ class floatToolbar extends wg
protected static $defineProps = array(
'prefix?:array',
'main?:array',
'suffix?:array'
'suffix?:array',
'object?:object'
);
protected static $defineBlocks = array(
'prefix' => array(),
'main' => array(),
'suffix' => array()
'suffix' => array(),
'object' => null
);
public static function getPageCSS(): string|false
@@ -20,7 +22,7 @@ class floatToolbar extends wg
return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css');
}
private function buildDivider(wg|array|null $wg): wg|null
private function buildDivider(wg|array|null|bool $wg): wg|null
{
if(empty($wg)) return null;
@@ -31,8 +33,26 @@ class floatToolbar extends wg
{
if(empty($items)) return null;
$object = $this->prop('object');
if($object)
{
/* Set url template string replacement rules. */
$urlReplaceName = array();
$urlReplaceValue = array();
foreach($object as $key => $value)
{
$urlReplaceName[] = "{{$key}}";
$urlReplaceValue[] = $value;
}
}
$btns = array();
foreach ($items as $item) $btns[] = btn(set($item), setClass('ghost text-white'));
foreach ($items as $item)
{
if($object && isset($item['url'])) $item['url'] = str_replace($urlReplaceName, $urlReplaceValue, $item['url']);
$btns[] = btn(set($item), setClass('ghost text-white'));
}
return $btns;
}
@@ -66,7 +86,7 @@ class floatToolbar extends wg
$prefixBtns,
$this->buildDivider($prefixBtns),
$mainBtns,
$this->buildDivider($suffixBtns),
$this->buildDivider($mainBtns && $suffixBtns),
$suffixBtns,
);
}
+4 -4
View File
@@ -979,10 +979,10 @@ class execution extends control
/* Set the product drop-down and search fields. */
$productOption = array();
$branchOption = array();
$showBranch = false;
$showBranch = $this->loadModel('branch')->showBranch($productID);
if($execution->hasProduct)
{
list($productOption, $branchOption, $showBranch) = $this->executionZen->buildProductSwitcher($productID, $products);
list($productOption, $branchOption) = $this->executionZen->buildProductSwitcher($productID, $products);
unset($this->config->bug->search['fields']['product']);
unset($this->config->bug->search['params']['product']);
if($project->model != 'scrum')
@@ -1119,10 +1119,10 @@ class execution extends control
$execution = $this->execution->getByID($executionID);
$productOption = array();
$branchOption = array();
$showBranch = false;
$showBranch = $this->loadModel('branch')->showBranch($productID);
if($execution->hasProduct)
{
list($productOption, $branchOption, $showBranch) = $this->executionZen->buildProductSwitcher($productID, $products);
list($productOption, $branchOption) = $this->executionZen->buildProductSwitcher($productID, $products);
}
/* Load pager. */
+2 -5
View File
@@ -63,8 +63,8 @@ class executionZen extends execution
*/
protected function buildProductSwitcher(int $productID, array $products)
{
$showBranch = false;
$productOption = array();
$branchOption = array();
$programIdList = array();
if(count($products) > 1) $productOption[0] = $this->lang->product->all;
foreach($products as $productData) $programIdList[$productData->program] = $productData->program;
@@ -81,9 +81,6 @@ class executionZen extends execution
$product = $this->product->getById((int)$productID);
if($product and $product->type != 'normal')
{
/* Display of branch label. */
$showBranch = $this->loadModel('branch')->showBranch($productID);
/* Display status of branch. */
$branches = $this->branch->getList($productID, $executionID, 'all');
foreach($branches as $branchInfo)
@@ -91,6 +88,6 @@ class executionZen extends execution
$branchOption[$branchInfo->id] = $branchInfo->name . ($branchInfo->status == 'closed' ? ' (' . $this->lang->branch->statusList['closed'] . ')' : '');
}
}
return array($productOption, $branchOption, $showBranch);
return array($productOption, $branchOption);
}
}
+28
View File
@@ -2,3 +2,31 @@ function resetDelta()
{
$(".radio-primary > input").attr("checked",false);
}
function computeEndDate()
{
var beginDate = $('#begin').val();
if(!beginDate) return;
console.log(beginDate);
var delta = parseInt(delta);
beginDate = convertStringToDate(beginDate);
if((delta == 7 || delta == 14) && (beginDate.getDay() == 1))
{
delta = (weekend == 2) ? (delta - 2) : (delta - 1);
}
var currentBeginDate = window.zui.formatDate(beginDate, 'yyyy-MM-dd');
var endDate = window.zui.formatDate(beginDate.addDays(delta - 1), 'yyyy-MM-dd');
$('#begin').val(currentBeginDate);
$('#end').val(endDate).datetimepicker('update');
}
function convertStringToDate(dateString)
{
dateString = dateString.split('-');
dateString = dateString[1] + '/' + dateString[2] + '/' + dateString[0];
return new Date(dateString);
}
+1
View File
@@ -64,6 +64,7 @@ formPanel
set::title($title),
on::change('#begin', 'resetDelta'),
on::change('#end', 'resetDelta'),
on::change('.radio-primary > input', 'computeEndDate'),
$formHeader,
$parentForm,
formGroup
+3 -16
View File
@@ -17,28 +17,15 @@ detailHeader
common::hasPriv('task', 'create') ? to::suffix(btn(set::icon('plus'), set::url(createLink('task', 'create', "executionID={$task->execution}")), set::type('primary'), $lang->task->create)) : null
);
/* Build replace url param, replace {id} to $task->id. */
$urlReplaceName = array();
$urlReplaceValue = array();
foreach($task as $key => $value)
{
$urlReplaceName[] = "{{$key}}";
$urlReplaceValue[] = $value;
}
/* Construct suitable actions for the current task. */
$operateMenus = array();
foreach($config->task->view->operateList['main'] as $operate)
{
if(!common::hasPriv('task', $operate)) continue;
if(!$this->task->isClickable($task, $operate)) continue;
if($operate == 'batchCreate' && (!empty($task->team) || !empty($task->children))) continue;
$settings = $config->task->actionList[$operate];
$settings['url'] = str_replace($urlReplaceName, $urlReplaceValue, $settings['url']);
$operateMenus[] = $settings;
$operateMenus[] = $config->task->actionList[$operate];
}
/* Construct common actions for task. */
@@ -49,7 +36,6 @@ foreach($config->task->view->operateList['common'] as $operate)
if($operate == 'view' && $task->parent <= 0) continue;
$settings = $config->task->actionList[$operate];
$settings['url'] = str_replace($urlReplaceName, $urlReplaceValue, $settings['url']);
$settings['text'] = '';
$commonActions[] = $settings;
@@ -95,7 +81,8 @@ detailBody
array(array('icon' => 'back', 'text' => $lang->goback))
),
set::main($operateMenus),
set::suffix($commonActions)
set::suffix($commonActions),
set::object($task)
),
detailSide
(