From 80da12fc7db3600b69d73cd163e558c9f22eb150 Mon Sep 17 00:00:00 2001 From: liumengyi Date: Fri, 21 Jan 2022 13:49:47 +0800 Subject: [PATCH] * Finish task#48008 and fix bug for 48011. --- module/execution/control.php | 60 ++++++++++++++++++++++----- module/execution/js/kanban.js | 45 ++++++++++++++++++++ module/execution/view/kanban.html.php | 10 ++--- module/kanban/control.php | 4 +- 4 files changed, 102 insertions(+), 17 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index bf3528b314..6a7798ec9c 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1709,10 +1709,11 @@ class execution extends control * Start execution. * * @param int $executionID + * @param string $from * @access public * @return void */ - public function start($executionID) + public function start($executionID, $from = 'execution') { $execution = $this->commonAction($executionID); $executionID = $execution->id; @@ -1732,7 +1733,14 @@ class execution extends control $this->loadModel('common')->syncPPEStatus($executionID); $this->executeHooks($executionID); - die(js::reload('parent.parent')); + if(isonlybody() and $from == 'kanban') + { + return print(js::closeModal('parent.parent', '', "parent.parent.changeStatus('doing')")); + } + else + { + return print(js::reload('parent.parent')); + } } $this->view->title = $this->view->execution->name . $this->lang->colon .$this->lang->execution->start; @@ -1747,10 +1755,11 @@ class execution extends control * Delay execution. * * @param int $executionID + * @param string $from * @access public * @return void */ - public function putoff($executionID) + public function putoff($executionID, $from = 'execution') { $execution = $this->commonAction($executionID); $executionID = $execution->id; @@ -1767,7 +1776,14 @@ class execution extends control $this->action->logHistory($actionID, $changes); } $this->executeHooks($executionID); - die(js::reload('parent.parent')); + if(isonlybody() and $from == 'kanban') + { + return print(js::closeModal('parent.parent', '', "parent.parent.changeStatus('doing')")); + } + else + { + return print(js::reload('parent.parent')); + } } $this->view->title = $this->view->execution->name . $this->lang->colon .$this->lang->execution->putoff; @@ -1782,10 +1798,11 @@ class execution extends control * Suspend execution. * * @param int $executionID + * @param string $from * @access public * @return void */ - public function suspend($executionID) + public function suspend($executionID, $from = 'execution') { $execution = $this->commonAction($executionID); $executionID = $execution->id; @@ -1803,7 +1820,14 @@ class execution extends control $this->action->logHistory($actionID, $changes); } $this->executeHooks($executionID); - die(js::reload('parent.parent')); + if(isonlybody() and $from == 'kanban') + { + return print(js::closeModal('parent.parent', '', "parent.parent.changeStatus('suspended')")); + } + else + { + return print(js::reload('parent.parent')); + } } $this->view->title = $this->view->execution->name . $this->lang->colon .$this->lang->execution->suspend; @@ -1818,10 +1842,11 @@ class execution extends control * Activate execution. * * @param int $executionID + * @param string $frim * @access public * @return void */ - public function activate($executionID) + public function activate($executionID, $from = 'execution') { $execution = $this->commonAction($executionID); $executionID = $execution->id; @@ -1839,7 +1864,14 @@ class execution extends control $this->action->logHistory($actionID, $changes); } $this->executeHooks($executionID); - die(js::reload('parent.parent')); + if(isonlybody() and $from == 'kanban') + { + return print(js::closeModal('parent.parent', '', "parent.parent.changeStatus('doing')")); + } + else + { + return print(js::reload('parent.parent')); + } } $newBegin = date('Y-m-d'); @@ -1861,10 +1893,11 @@ class execution extends control * Close execution. * * @param int $executionID + * @param string $from * @access public * @return void */ - public function close($executionID) + public function close($executionID, $from = 'execution') { $execution = $this->commonAction($executionID); $executionID = $execution->id; @@ -1882,7 +1915,14 @@ class execution extends control $this->action->logHistory($actionID, $changes); } $this->executeHooks($executionID); - die(js::reload('parent.parent')); + if(isonlybody() and $from == 'kanban') + { + return print(js::closeModal('parent.parent', '', "parent.parent.changeStatus('closed')")); + } + else + { + return print(js::reload('parent.parent')); + } } $this->view->title = $this->view->execution->name . $this->lang->colon .$this->lang->execution->close; diff --git a/module/execution/js/kanban.js b/module/execution/js/kanban.js index 77120f7d19..cd3fb4643b 100644 --- a/module/execution/js/kanban.js +++ b/module/execution/js/kanban.js @@ -1,3 +1,46 @@ +/** + * When execution status change. + * + * @param stirng executionStatus + * @access public + * @return void + */ +function changeStatus(executionStatus) +{ + if(executionStatus == 'wait') + { + $('.startButton').removeClass('hidden'); + $('.putoffButton').removeClass('hidden'); + $('.suspendButton').removeClass('hidden'); + $('.closeButton').removeClass('hidden'); + $('.activateButton').addClass('hidden'); + } + else if(executionStatus == 'doing') + { + $('.startButton').addClass('hidden'); + $('.putoffButton').removeClass('hidden'); + $('.suspendButton').removeClass('hidden'); + $('.closeButton').removeClass('hidden'); + $('.activateButton').addClass('hidden'); + } + else if(executionStatus == 'suspended') + { + $('.startButton').addClass('hidden'); + $('.putoffButton').addClass('hidden'); + $('.suspendButton').addClass('hidden'); + $('.closeButton').removeClass('hidden'); + $('.activateButton').removeClass('hidden'); + } + else if(executionStatus == 'closed') + { + $('.startButton').addClass('hidden'); + $('.putoffButton').addClass('hidden'); + $('.suspendButton').addClass('hidden'); + $('.closeButton').addClass('hidden'); + $('.activateButton').removeClass('hidden'); + } +} + /** * Display the kanban in full screen. * @@ -1046,6 +1089,8 @@ function initKanban($kanban) */ $(function() { + changeStatus(execution.status); + window.kanbanScaleSize = +$.zui.store.get('executionKanbanScaleSize', 1); $('#kanbanScaleSize').text(window.kanbanScaleSize); $('#kanbanScaleControl .btn[data-type="+"]').attr('disabled', window.kanbanScaleSize >= 4 ? 'disabled' : null); diff --git a/module/execution/view/kanban.html.php b/module/execution/view/kanban.html.php index bb28bde6e2..425f0e7350 100644 --- a/module/execution/view/kanban.html.php +++ b/module/execution/view/kanban.html.php @@ -126,11 +126,11 @@ js::set('hasTaskButton', $hasTaskButton); if(common::hasPriv('kanban', 'setLaneHeight')) $actions .= '
  • ' . html::a(helper::createLink('kanban', 'setLaneHeight', "kanbanID=$execution->id&from=execution", '', true), '' . $lang->kanban->laneHeight, '', "class='iframe btn btn-link text-left' data-width=$width") . '
  • '; $kanbanActions = ''; if(common::hasPriv('execution', 'edit')) $kanbanActions .= '
  • ' . html::a(helper::createLink('execution', 'edit', "executionID=$execution->id", '', true), '' . $lang->kanban->edit, '', "class='iframe btn btn-link text-left' data-width='75%'") . '
  • '; - if(in_array('start', $executionActions)) $kanbanActions .= '
  • ' . html::a(helper::createLink('execution', 'start', "executionID=$execution->id", '', true), '' . $lang->execution->start, '', "class='iframe btn btn-link text-left' data-width='75%'") . '
  • '; - if(in_array('putoff', $executionActions)) $kanbanActions .= '
  • ' . html::a(helper::createLink('execution', 'putoff', "executionID=$execution->id", '', true), '' . $lang->execution->putoff, '', "class='iframe btn btn-link text-left' data-width='75%'") . '
  • '; - if(in_array('suspend', $executionActions)) $kanbanActions .= '
  • ' . html::a(helper::createLink('execution', 'suspend', "executionID=$execution->id", '', true), '' . $lang->execution->suspend, '', "class='iframe btn btn-link text-left' data-width='75%'") . '
  • '; - if(in_array('close', $executionActions)) $kanbanActions .= '
  • ' . html::a(helper::createLink('execution', 'close', "executionID=$execution->id", '', true), '' . $lang->execution->close, '', "class='iframe btn btn-link text-left' data-width='75%'") . '
  • '; - if(in_array('activate', $executionActions)) $kanbanActions .= '
  • ' . html::a(helper::createLink('execution', 'activate', "executionID=$execution->id", '', true), '' . $lang->execution->activate, '', "class='iframe btn btn-link text-left' data-width='75%'") . '
  • '; + if(common::hasPriv('execution', 'start')) $kanbanActions .= ''; + if(common::hasPriv('execution', 'putoff')) $kanbanActions .= ''; + if(common::hasPriv('execution', 'suspend')) $kanbanActions .= ''; + if(common::hasPriv('execution', 'close')) $kanbanActions .= ''; + if(common::hasPriv('execution', 'activate')) $kanbanActions .= ''; if(common::hasPriv('execution', 'delete')) $kanbanActions .= '
  • ' . html::a(helper::createLink('execution', 'delete', "executionID=$execution->id"), '' . $lang->delete, 'hiddenwin', "class='btn btn-link text-left'") . '
  • '; if($kanbanActions) { diff --git a/module/kanban/control.php b/module/kanban/control.php index 2ad001cfd7..d768bf78d6 100644 --- a/module/kanban/control.php +++ b/module/kanban/control.php @@ -941,7 +941,7 @@ class kanban extends control { if(dao::isError()) return $this->sendError(dao::getError()); $regionID = $column->region; - $kanbanData = $this->loadModel('kanban')->getRDKanban($executionID, 'all', 'id_desc', $regionID); + $kanbanData = $this->loadModel('kanban')->getRDKanban($executionID, $this->session->execLaneType ? $this->session->execLaneType : 'all', 'id_desc', $regionID); $kanbanData = json_encode($kanbanData); return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => "parent.updateKanban($kanbanData, $regionID)")); @@ -1022,7 +1022,7 @@ class kanban extends control { if(dao::isError()) return $this->sendError(dao::getError()); $regionID = $column->region; - $kanbanData = $this->loadModel('kanban')->getRDKanban($executionID, 'all', 'id_desc', $regionID); + $kanbanData = $this->loadModel('kanban')->getRDKanban($executionID, $this->session->execLaneType ? $this->session->execLaneType : 'all', 'id_desc', $regionID); $kanbanData = json_encode($kanbanData); return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => "parent.updateKanban($kanbanData, $regionID)"));