diff --git a/config/zentaopms.php b/config/zentaopms.php index d5e393d381..e6243b125a 100644 --- a/config/zentaopms.php +++ b/config/zentaopms.php @@ -289,6 +289,7 @@ $config->objectTables['kanbancolumn'] = TABLE_KANBANCOLUMN; $config->objectTables['kanbanlane'] = TABLE_KANBANLANE; $config->objectTables['kanbanorder'] = TABLE_KANBANORDER; $config->objectTables['kanbangroup'] = TABLE_KANBANGROUP; +$config->objectTables['kanbancard'] = TABLE_KANBANCARD; $config->newFeatures = array('introduction', 'tutorial', 'youngBlueTheme'); diff --git a/module/kanban/config.php b/module/kanban/config.php index 307d3fb096..e64c8c5b10 100644 --- a/module/kanban/config.php +++ b/module/kanban/config.php @@ -15,6 +15,8 @@ $config->kanban->edit = new stdclass(); $config->kanban->createspace = new stdclass(); $config->kanban->editspace = new stdclass(); +$config->kanban->editcard = new stdclass(); + $config->kanban->setwip->requiredFields = 'limit'; $config->kanban->setlane->requiredFields = 'name,type'; $config->kanban->setlaneColumn->requiredFields = 'name'; @@ -23,6 +25,8 @@ $config->kanban->edit->requiredFields = 'space,name'; $config->kanban->createspace->requiredFields = 'name,owner'; $config->kanban->editspace->requiredFields = 'name,owner'; +$config->kanban->editcard->requiredFields = 'name'; + $config->kanban->editor = new stdclass(); $config->kanban->editor->create = array('id' => 'desc', 'tools' => 'simpleTools'); $config->kanban->editor->edit = array('id' => 'desc', 'tools' => 'simpleTools'); @@ -30,6 +34,8 @@ $config->kanban->editor->createspace = array('id' => 'desc', 'tools' => 'simpleT $config->kanban->editor->editspace = array('id' => 'desc', 'tools' => 'simpleTools'); $config->kanban->editor->close = array('id' => 'comment', 'tools' => 'simpleTools'); +$config->kanban->editor->editcard = array('id' => 'desc', 'tools' => 'simpleTools'); + $config->kanban->default = new stdclass(); $config->kanban->default->story = new stdclass(); $config->kanban->default->story->name = $lang->SRCommon; diff --git a/module/kanban/control.php b/module/kanban/control.php index bde47c5507..26612c2181 100644 --- a/module/kanban/control.php +++ b/module/kanban/control.php @@ -263,6 +263,35 @@ class kanban extends control $this->display(); } + /** + * Edit a card. + * + * @param int $cardID + * @access public + * @return void + */ + public function editCard($cardID) + { + $this->loadModel('action'); + if(!empty($_POST)) + { + $changes = $this->kanban->updateCard($cardID); + + if(dao::isError()) die(js::error(dao::getError())); + + $actionID = $this->action->create('kanbanCard', $cardID, 'edited'); + $this->action->logHistory($actionID, $changes); + + die(js::reload('parent.parent')); + } + + $this->view->card = $this->kanban->getCardByID($cardID); + $this->view->actions = $this->action->getList('kanbancard', $cardID); + $this->view->users = $this->loadModel('user')->getPairs('noletter'); + + $this->display(); + } + /** * Set WIP. * diff --git a/module/kanban/lang/en.php b/module/kanban/lang/en.php index 28573676f1..7805e68509 100644 --- a/module/kanban/lang/en.php +++ b/module/kanban/lang/en.php @@ -216,4 +216,6 @@ $lang->kanbanregion->default = 'Default Region'; $lang->kanbancard = new stdclass(); $lang->kanbancard->create = 'Create Card'; -$lang->kanbancard->name = 'Card Name'; +$lang->kanbancard->name = 'Card Name'; +$lang->kanbancard->legendBasicInfo = 'Basic Info'; +$lang->kanbancard->legendLifeTime = 'Card Life'; diff --git a/module/kanban/lang/zh-cn.php b/module/kanban/lang/zh-cn.php index 4694c34278..c0fbaa9bf8 100644 --- a/module/kanban/lang/zh-cn.php +++ b/module/kanban/lang/zh-cn.php @@ -216,4 +216,6 @@ $lang->kanbanregion->default = '默认区域'; $lang->kanbancard = new stdclass(); $lang->kanbancard->create = '创建卡片'; -$lang->kanbancard->name = '卡片名称'; +$lang->kanbancard->name = '卡片名称'; +$lang->kanbancard->legendBasicInfo = '基本信息'; +$lang->kanbancard->legendLifeTime = '卡片的一生'; diff --git a/module/kanban/model.php b/module/kanban/model.php index 381a1d269c..09256e0073 100644 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -316,7 +316,10 @@ class kanbanModel extends model */ public function getByID($kanbanID) { - return $this->dao->findByID($kanbanID)->from(TABLE_KANBAN)->fetch(); + $kanban = $this->dao->findByID($kanbanID)->from(TABLE_KANBAN)->fetch(); + $kanban = $this->loadModel('file')->replaceImgURL($kanban, 'desc'); + + return $kanban; } /** @@ -727,6 +730,8 @@ class kanbanModel extends model if(strpos(",{$space->team},", ",$account,") === false and $space->owner != $account) $space->team .= ",$account"; + $space = $this->loadModel('file')->processImgURL($space, $this->config->kanban->editor->createspace['id'], $this->post->uid); + $this->dao->insert(TABLE_KANBANSPACE)->data($space) ->autoCheck() ->batchCheck($this->config->kanban->createspace->requiredFields, 'notempty') @@ -736,6 +741,8 @@ class kanbanModel extends model { $spaceID = $this->dao->lastInsertID(); $this->saveOrder(0, '', $spaceID, 'space', '', $spaceID); + $this->file->saveUpload('kanbanspace', $spaceID); + $this->file->updateObjectID($this->post->uid, $spaceID, 'kanbanspace'); return $spaceID; } @@ -760,13 +767,20 @@ class kanbanModel extends model ->remove('uid,contactListMenu') ->get(); + $space = $this->loadModel('file')->processImgURL($space, $this->config->kanban->editor->editspace['id'], $this->post->uid); + $this->dao->update(TABLE_KANBANSPACE)->data($space) ->autoCheck() ->batchCheck($this->config->kanban->editspace->requiredFields, 'notempty') ->where('id')->eq($spaceID) ->exec(); - if(!dao::isError()) return common::createChanges($oldSpace, $space); + if(!dao::isError()) + { + $this->file->saveUpload('kanbanspace', $spaceID); + $this->file->updateObjectID($this->post->uid, $spaceID, 'kanbanspace'); + return common::createChanges($oldSpace, $space); + } } /** @@ -852,6 +866,8 @@ class kanbanModel extends model if(strpos(",{$kanban->team},", ",$account,") === false and $kanban->owner != $account) $kanban->team .= ",$account"; + $kanban = $this->loadModel('file')->processImgURL($kanban, $this->config->kanban->editor->create['id'], $this->post->uid); + $this->dao->insert(TABLE_KANBAN)->data($kanban) ->autoCheck() ->batchCheck($this->config->kanban->create->requiredFields, 'notempty') @@ -863,6 +879,8 @@ class kanbanModel extends model $this->saveOrder(0, '', $kanbanID, 'kanban', '', $kanbanID); $this->initKanban($kanbanID); + $this->file->saveUpload('kanban', $kanbanID); + $this->file->updateObjectID($this->post->uid, $kanbanID, 'kanban'); return $kanbanID; } @@ -888,13 +906,21 @@ class kanbanModel extends model ->remove('uid,contactListMenu') ->get(); + $kanban = $this->loadModel('file')->processImgURL($kanban, $this->config->kanban->editor->edit['id'], $this->post->uid); + $this->dao->update(TABLE_KANBAN)->data($kanban) ->autoCheck() ->batchCheck($this->config->kanban->edit->requiredFields, 'notempty') ->where('id')->eq($kanbanID) ->exec(); - if(!dao::isError()) return common::createChanges($oldKanban, $kanban); + if(!dao::isError()) + { + $this->file->saveUpload('kanban', $kanbanID); + $this->file->updateObjectID($this->post->uid, $kanbanID, 'kanban'); + + return common::createChanges($oldKanban, $kanban); + } } /** @@ -1402,6 +1428,58 @@ class kanbanModel extends model ->exec(); } + /** + * Update a card. + * + * @param int $cardID + * @access public + * @return array + */ + public function updateCard($cardID) + { + if($this->post->estimate < 0) + { + dao::$errors[] = $this->lang->kanbancard->error->recordMinus; + return false; + } + + if($this->post->begin > $this->post->end) + { + dao::$errors[] = $this->lang->kanbancard->error->endSmall; + return false; + } + + $cardID = (int)$cardID; + $oldCard = $this->getCardById($cardID); + + $now = helper::now(); + $card = fixer::input('post') + ->add('lastEditedBy', $this->app->user->account) + ->add('createdDate', $now) + ->setDefault('estimate', $oldCard->estimate) + ->setIF(!empty($this->post->assignedTo) and $oldCard->assignedTo != $this->post->assignedTo, 'assignedDate', $now) + ->setIF(is_numeric($this->post->estimate), 'estimate', (float)$this->post->estimate) + ->remove('uid') + ->get(); + + $card = $this->loadModel('file')->processImgURL($card, $this->config->kanban->editor->editcard['id'], $this->post->uid); + + $this->dao->update(TABLE_KANBANCARD)->data($card) + ->autoCheck() + ->checkIF($card->estimate != '', 'estimate', 'float') + ->batchcheck($this->config->kanban->editcard->requiredFields, 'notempty') + ->where('id')->eq($cardID) + ->exec(); + + if(!dao::isError()) + { + $this->file->saveUpload('kanbancard', $cardID); + $this->file->updateObjectID($this->post->uid, $cardID, 'kanbancard'); + + return common::createChanges($oldCard, $card); + } + } + /** * Set WIP limit. * @@ -1586,7 +1664,9 @@ class kanbanModel extends model */ public function getSpaceById($spaceID) { - return $this->dao->findById($spaceID)->from(TABLE_KANBANSPACE)->fetch(); + $space = $this->dao->findById($spaceID)->from(TABLE_KANBANSPACE)->fetch(); + $space = $this->loadModel('file')->replaceImgURL($space, 'desc'); + return $space; } /** @@ -1719,6 +1799,21 @@ class kanbanModel extends model return $groupList; } + /** + * Get card by id. + * + * @param int $cardID + * @access public + * @return object + */ + public function getCardByID($cardID) + { + $card = $this->dao->select('*')->from(TABLE_KANBANCARD)->where('id')->eq($cardID)->fetch(); + $card = $this->loadModel('file')->replaceImgURL($card, 'desc'); + + return $card; + } + /** * Get Kanban cards menus by execution id. * diff --git a/module/kanban/view/close.html.php b/module/kanban/view/close.html.php index 231875aa7f..d963128b0f 100644 --- a/module/kanban/view/close.html.php +++ b/module/kanban/view/close.html.php @@ -29,6 +29,7 @@