From ac03f67bdbf5546dd8bad4e8fa6efed8b179224d Mon Sep 17 00:00:00 2001 From: tianshujie Date: Wed, 5 Jan 2022 11:02:34 +0800 Subject: [PATCH] * Fix problems in code review. --- module/kanban/model.php | 2 +- module/productplan/control.php | 4 +- module/productplan/js/browse.js | 103 ++++++++++++++++-------------- module/productplan/lang/en.php | 28 ++++---- module/productplan/lang/zh-cn.php | 28 ++++---- 5 files changed, 87 insertions(+), 78 deletions(-) diff --git a/module/kanban/model.php b/module/kanban/model.php index b54ee994b2..e3edc42ed7 100644 --- a/module/kanban/model.php +++ b/module/kanban/model.php @@ -591,7 +591,7 @@ class kanbanModel extends model $lane->order = $laneOrder; $lane->items = $planList; - $lanes[] = $lane; + $lanes[] = $lane; $laneOrder ++; $colorIndex ++; if($colorIndex == count($this->config->productplan->laneColorList)) $colorIndex = 0; diff --git a/module/productplan/control.php b/module/productplan/control.php index 55fdfcfcbd..70b1ef80c6 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -280,9 +280,9 @@ class productplan extends control foreach($branches as $id => $name) { - $plans = isset($planGroup[$product->id][$id]) ? array_filter($planGroup[$product->id][$id]) : array(); + $plans = isset($planGroup[$product->id][$id]) ? array_filter($planGroup[$product->id][$id]) : array(); $branchPairs[$id] = $name . ' ' . count($plans); - $planCount += count($plans); + $planCount += count($plans); } $this->view->branches = array('all' => $this->lang->productplan->allAB . ' ' . $planCount) + $branchPairs; diff --git a/module/productplan/js/browse.js b/module/productplan/js/browse.js index 38a2ce5f1f..9e3797cdca 100644 --- a/module/productplan/js/browse.js +++ b/module/productplan/js/browse.js @@ -56,18 +56,18 @@ $(function() $('#branch_chosen .chosen-single span').prepend(''); $('#kanban').kanban( { - data: kanbanData, - minColWidth: 290, - maxColWidth: 290, - maxColHeight: 460, - minColHeight: 190, - cardHeight: 80, - itemRender: renderKanbanItem, - virtualize: true, + data: kanbanData, + minColWidth: 290, + maxColWidth: 290, + maxColHeight: 460, + minColHeight: 190, + cardHeight: 80, + itemRender: renderKanbanItem, + virtualize: true, droppable: { - target: findDropColumns, - finish: handleFinishDrop, + target: findDropColumns, + finish: handleFinishDrop, mouseButton: 'left' } }); @@ -77,7 +77,7 @@ $(function() $.zui.ContextMenu.hide(); }); - /* Init contextmenu */ + /* Init contextmenu. */ $('#kanban').on('click', '[data-contextmenu]', function(event) { var $trigger = $(this); @@ -86,30 +86,27 @@ $(function() if(!menuCreator) return; var options = $.extend({event: event, $trigger: $trigger}, $trigger.data()); - var items = menuCreator(options); + var items = menuCreator(options); if(!items || !items.length) return; $.zui.ContextMenu.show(items, items.$options || {event: event}); }); } - /* Hide contextmenu when page scroll */ + /* Hide contextmenu when page scroll. */ $(window).on('scroll', function() { $.zui.ContextMenu.hide(); }); }); -/* Define menu creators */ -window.menuCreators = -{ - card: createCardMenu -}; +/* Define menu creators. */ +window.menuCreators = {card: createCardMenu}; /** * Create card menu. * - * @param object $options + * @param object options * @access public * @return array */ @@ -194,11 +191,14 @@ $(document).on('click', 'td.content .more', function(e) } }); -/* -* Find drop columns -* @param {JQuery} $element Drag element -* @param {JQuery} $root Dnd root element -*/ +/** + * Find drop columns. + * + * @param object $element Drag element + * @param object $root Dnd root element + * @access public + * @return object|bool + */ function findDropColumns($element, $root) { var $col = $element.closest('.kanban-col'); @@ -216,42 +216,46 @@ function findDropColumns($element, $root) if(colRules === true) return true; var $newCol = $(this); - var newCol = $newCol.data(); + var newCol = $newCol.data(); if(newCol.id === col.id) return false; var $newLane = $newCol.closest('.kanban-lane'); - var newLane = $newLane.data('lane'); + var newLane = $newLane.data('lane'); return colRules.indexOf(newCol.type) > -1 && newLane.id === lane.id; }); } /** - * Handle finish drop task - * @param {Object} event Event object - * @returns {void} + * Handle finish drop card. + * + * @param object event + * @access public + * @return void */ function handleFinishDrop(event) { - var $card = $(event.element); // The drag card + var $card = $(event.element); // The drag card. var $dragCol = $card.closest('.kanban-lane-col'); var $dropCol = $(event.target); - /* Get d-n-d(drag and drop) infos 获取拖放操作相关信息 */ - var card = $card.data('item'); + /* Get d-n-d(drag and drop) info. */ + var card = $card.data('item'); var fromColType = $dragCol.data('type'); - var toColType = $dropCol.data('type'); - var kanbanID = $card.closest('.kanban').data('id'); + var toColType = $dropCol.data('type'); + var kanbanID = $card.closest('.kanban').data('id'); changeCardColType(card, fromColType, toColType, kanbanID); } /** - * Change column type for a card - - * @param {Object} card Card object - * @param {String} fromColType The column type before change - * @param {String} toColType The column type after change - * @param {String} kanbanID Kanban ID + * Change column type for a card. + * + * @param object card + * @param string fromColType The column type before change + * @param string toColType The column type after change + * @param int kanbanID + * @access public + * @return void */ function changeCardColType(card, fromColType, toColType, kanbanID) { @@ -303,7 +307,12 @@ function changeCardColType(card, fromColType, toColType, kanbanID) } /** - * The function for rendering kanban item + * The function for rendering kanban item. + * + * @param object item + * @param object $item + * @access public + * @return void */ function renderKanbanItem(item, $item) { @@ -387,10 +396,10 @@ function renderKanbanItem(item, $item) } /** - * Get planID + * Get planID. * - * @param object $obj - * @param int $branch + * @param object obj + * @param int branch * @access public * @return void */ @@ -428,9 +437,9 @@ if(!window.kanbanDropRules) { window.kanbanDropRules = { - wait: ['doing'], - doing: ['done'], - done: ['doing', 'closed'], + wait: ['doing'], + doing: ['done'], + done: ['doing', 'closed'], closed: ['doing'] } } diff --git a/module/productplan/lang/en.php b/module/productplan/lang/en.php index a7c1cfaf1b..029115340e 100644 --- a/module/productplan/lang/en.php +++ b/module/productplan/lang/en.php @@ -111,20 +111,20 @@ $lang->productplan->endList[93] = '3 Months'; $lang->productplan->endList[186] = '6 Months'; $lang->productplan->endList[365] = '1 Year'; -$lang->productplan->errorNoTitle = 'ID %s title should not be empty.'; -$lang->productplan->errorNoBegin = 'ID %s begin time should not be empty.'; -$lang->productplan->errorNoEnd = 'ID %s end time should not be empty.'; -$lang->productplan->beginGeEnd = 'ID %s begin time should not be >= end time.'; -$lang->productplan->beginLetterParent = "The start date of the parent plan: %s, the start date cannot be less than the start date of the parent plan."; -$lang->productplan->endGreaterParent = "The completion date of the parent plan: %s, the completion date cannot be greater than the completion date of the parent plan."; -$lang->productplan->beginGreaterChild = "The start date of the child plan: %s, the start date cannot be greater than the start date of the child plan."; -$lang->productplan->endLetterChild = "The completion date of the child plan: %s, the completion date cannot be less than the completion date of the child plan."; -$lang->productplan->noLinkedProject = "The current product has not been linked with a project. Please enter the list of the product to link or create a project."; -$lang->productplan->enterProjectList = "Enter the list of the product"; -$lang->productplan->beginGreaterChildTip = "The start date of the parent plan[%s]: %s, cannot be greater than the start date of the child plan: %s."; -$lang->productplan->endLetterChildTip = "The completion date of the parent plan[%s]: %s, cannot be less than the completion date of the child plan: %s.", ; -$lang->productplan->beginLetterParentTip = "The start date of the child plan[%s]: %s, cannot be less than the start date of the parent plan: %s."; -$lang->productplan->endGreaterParentTip = "The completion date of the child plan[%s]: %s, cannot be greater than the completion date of the parent plan: %s."; +$lang->productplan->errorNoTitle = 'ID %s title should not be empty.'; +$lang->productplan->errorNoBegin = 'ID %s begin time should not be empty.'; +$lang->productplan->errorNoEnd = 'ID %s end time should not be empty.'; +$lang->productplan->beginGeEnd = 'ID %s begin time should not be >= end time.'; +$lang->productplan->beginLetterParent = "The start date of the parent plan: %s, the start date cannot be less than the start date of the parent plan."; +$lang->productplan->endGreaterParent = "The completion date of the parent plan: %s, the completion date cannot be greater than the completion date of the parent plan."; +$lang->productplan->beginGreaterChild = "The start date of the child plan: %s, the start date cannot be greater than the start date of the child plan."; +$lang->productplan->endLetterChild = "The completion date of the child plan: %s, the completion date cannot be less than the completion date of the child plan."; +$lang->productplan->noLinkedProject = "The current product has not been linked with a project. Please enter the list of the product to link or create a project."; +$lang->productplan->enterProjectList = "Enter the list of the product"; +$lang->productplan->beginGreaterChildTip = "The start date of the parent plan[%s]: %s, cannot be greater than the start date of the child plan: %s."; +$lang->productplan->endLetterChildTip = "The completion date of the parent plan[%s]: %s, cannot be less than the completion date of the child plan: %s.", ; +$lang->productplan->beginLetterParentTip = "The start date of the child plan[%s]: %s, cannot be less than the start date of the parent plan: %s."; +$lang->productplan->endGreaterParentTip = "The completion date of the child plan[%s]: %s, cannot be greater than the completion date of the parent plan: %s."; $lang->productplan->featureBar['browse']['all'] = 'All'; $lang->productplan->featureBar['browse']['wait'] = 'Waiting'; diff --git a/module/productplan/lang/zh-cn.php b/module/productplan/lang/zh-cn.php index 282f7b296e..46f523b6c9 100644 --- a/module/productplan/lang/zh-cn.php +++ b/module/productplan/lang/zh-cn.php @@ -111,20 +111,20 @@ $lang->productplan->endList[93] = '三个月'; $lang->productplan->endList[186] = '半年'; $lang->productplan->endList[365] = '一年'; -$lang->productplan->errorNoTitle = 'ID %s 标题不能为空'; -$lang->productplan->errorNoBegin = 'ID %s 开始时间不能为空'; -$lang->productplan->errorNoEnd = 'ID %s 结束时间不能为空'; -$lang->productplan->beginGeEnd = 'ID %s 开始时间不能大于结束时间'; -$lang->productplan->beginLetterParent = "父计划的开始日期:%s,开始日期不能小于父计划的开始日期"; -$lang->productplan->endGreaterParent = "父计划的完成日期:%s,完成日期不能大于父计划的完成日期"; -$lang->productplan->beginGreaterChild = "子计划的开始日期:%s,开始日期不能大于子计划的开始日期"; -$lang->productplan->endLetterChild = "子计划的完成日期:%s,完成日期不能小于子计划的完成日期"; -$lang->productplan->noLinkedProject = "当前产品还未关联项目,请进入产品的项目列表关联或创建一个项目"; -$lang->productplan->enterProjectList = "进入产品的项目列表"; -$lang->productplan->beginGreaterChildTip = "父计划[%s]的开始日期:%s,不能大于子计划的开始日期: %s"; -$lang->productplan->endLetterChildTip = "父计划[%s]的完成日期:%s,不能小于子计划的完成日期: %s"; -$lang->productplan->beginLetterParentTip = "子计划[%s]的开始日期:%s,不能小于父计划的开始日期: %s"; -$lang->productplan->endGreaterParentTip = "子计划[%s]的完成日期:%s,不能大于父计划的完成日期: %s"; +$lang->productplan->errorNoTitle = 'ID %s 标题不能为空'; +$lang->productplan->errorNoBegin = 'ID %s 开始时间不能为空'; +$lang->productplan->errorNoEnd = 'ID %s 结束时间不能为空'; +$lang->productplan->beginGeEnd = 'ID %s 开始时间不能大于结束时间'; +$lang->productplan->beginLetterParent = "父计划的开始日期:%s,开始日期不能小于父计划的开始日期"; +$lang->productplan->endGreaterParent = "父计划的完成日期:%s,完成日期不能大于父计划的完成日期"; +$lang->productplan->beginGreaterChild = "子计划的开始日期:%s,开始日期不能大于子计划的开始日期"; +$lang->productplan->endLetterChild = "子计划的完成日期:%s,完成日期不能小于子计划的完成日期"; +$lang->productplan->noLinkedProject = "当前产品还未关联项目,请进入产品的项目列表关联或创建一个项目"; +$lang->productplan->enterProjectList = "进入产品的项目列表"; +$lang->productplan->beginGreaterChildTip = "父计划[%s]的开始日期:%s,不能大于子计划的开始日期: %s"; +$lang->productplan->endLetterChildTip = "父计划[%s]的完成日期:%s,不能小于子计划的完成日期: %s"; +$lang->productplan->beginLetterParentTip = "子计划[%s]的开始日期:%s,不能小于父计划的开始日期: %s"; +$lang->productplan->endGreaterParentTip = "子计划[%s]的完成日期:%s,不能大于父计划的完成日期: %s"; $lang->productplan->featureBar['browse']['all'] = '所有'; $lang->productplan->featureBar['browse']['wait'] = '未开始';