diff --git a/lib/dingapi/dingapi.class.php b/lib/dingapi/dingapi.class.php index 13daecea38..fad581588e 100644 --- a/lib/dingapi/dingapi.class.php +++ b/lib/dingapi/dingapi.class.php @@ -57,11 +57,12 @@ class dingapi $depts = $this->getAllDepts(); if($this->isError()) return array('result' => 'fail', 'message' => $this->errors); + set_time_limit(0); $users = array(); foreach($depts as $deptID => $deptName) { $response = $this->queryAPI($this->apiUrl . "user/simplelist?access_token={$this->token}&department_id={$deptID}"); - if($this->isError()) return array('result' => 'fail', 'message' => $this->errors); + if($this->isError()) continue; foreach($response->userlist as $user) $users[$user->name] = $user->userid; } diff --git a/module/product/config.php b/module/product/config.php index c99a915c58..e8b6a17d9c 100644 --- a/module/product/config.php +++ b/module/product/config.php @@ -4,6 +4,7 @@ $config->product->orderBy = 'isClosed,order_desc'; $config->product->customBatchEditFields = 'line,PO,QD,RD,status,type,desc'; +$config->product->browse = new stdclass(); $config->product->custom = new stdclass(); $config->product->custom->batchEditFields = 'line,PO,QD,RD,status'; diff --git a/module/product/control.php b/module/product/control.php index 50c21ab38e..ef0ff24d61 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -635,6 +635,40 @@ class product extends control $this->display(); } + /** + * Ajax set unfoldID. + * + * @param int $productID + * @param string $action + * @access public + * @return void + */ + public function ajaxSetUnfoldID($productID, $action = 'add') + { + $this->loadModel('setting'); + $setting = $this->setting->createDAO($this->setting->parseItemParam("owner={$this->app->user->account}&module=product§ion=browse&key=unfoldID"), 'select')->fetch(); + $newUnfoldID = $this->post->newUnfoldID; + if(empty($newUnfoldID)) die(); + + $newUnfoldID = json_decode($newUnfoldID); + $unfoldIdList = $setting ? json_decode($setting->value, true) : array(); + foreach($newUnfoldID as $unfoldID) + { + unset($unfoldIdList[$productID][$unfoldID]); + if($action == 'add') $unfoldIdList[$productID][$unfoldID] = $unfoldID; + } + + if(empty($setting)) + { + $this->setting->setItem($this->app->user->account . ".product.browse.unfoldID", json_encode($unfoldIdList)); + } + else + { + $this->dao->update(TABLE_CONFIG)->set('value')->eq(json_encode($unfoldIdList))->where('id')->eq($setting->id)->exec(); + } + die('success'); + } + /** * Update order. * diff --git a/module/product/js/browse.js b/module/product/js/browse.js index 918a88830d..095bd1e2a0 100644 --- a/module/product/js/browse.js +++ b/module/product/js/browse.js @@ -1,6 +1,14 @@ $(function() { if($('#storyList thead th.c-title').width() < 150) $('#storyList thead th.c-title').width(150); + $('#storyList td.has-child .story-toggle').each(function() + { + var $td = $(this).closest('td'); + var labelWidth = 0; + if($td.find('.label').length > 0) labelWidth = $td.find('.label').width(); + $td.find('a').eq(0).css('max-width', $td.width() - labelWidth - 60); + }); + $(document).on('click', '.story-toggle', function(e) { var $toggle = $(this); @@ -30,4 +38,95 @@ $(function() $this.addClass('dropup'); } }); + + if($('#productStoryForm td.has-child').length > 0) + { + $('#productStoryForm th.c-title').append(""); + var allUnfold = true; + $('#productStoryForm td.has-child').each(function() + { + var storyID = $(this).closest('tr').attr('data-id'); + if(typeof(unfoldID[storyID]) == 'undefined') + { + allUnfold = false; + $('#productStoryForm tr.parent-' + storyID).hide(); + $(this).find('a.story-toggle').addClass('collapsed') + } + + }) + + if(allUnfold) + { + $('#productStoryForm th.c-title #toggleFold').html(foldAll).removeClass('collapsed'); + } + else + { + $('#productStoryForm th.c-title #toggleFold').html(unfoldAll).addClass('collapsed'); + } + + $(document).on('click', '#toggleFold', function() + { + var newUnfoldID = []; + var url = ''; + if($(this).hasClass('collapsed')) + { + $('#productStoryForm td.has-child').each(function() + { + var storyID = $(this).closest('tr').attr('data-id'); + $('#productStoryForm tr.parent-' + storyID).show(); + $(this).find('a.story-toggle').removeClass('collapsed') + newUnfoldID.push(storyID); + }) + $(this).html(foldAll).removeClass('collapsed'); + url = createLink('product', 'ajaxSetUnfoldID', 'productID=' + productID); + } + else + { + $('#productStoryForm td.has-child').each(function() + { + var storyID = $(this).closest('tr').attr('data-id'); + $('#productStoryForm tr.parent-' + storyID).hide(); + $(this).find('a.story-toggle').addClass('collapsed'); + newUnfoldID.push(storyID); + }) + $(this).html(unfoldAll).addClass('collapsed'); + url = createLink('product', 'ajaxSetUnfoldID', 'productID=' + productID + '&action=delete'); + } + $.post(url, {'newUnfoldID': JSON.stringify(newUnfoldID)}); + }); + + $('#productStoryForm td.has-child a.story-toggle').click(function() + { + var newUnfoldID = []; + var url = ''; + if($(this).hasClass('collapsed')) + { + var storyID = $(this).closest('tr').attr('data-id'); + $('#productStoryForm tr.parent-' + storyID).show(); + newUnfoldID.push(storyID); + url = createLink('product', 'ajaxSetUnfoldID', 'productID=' + productID); + } + else + { + var storyID = $(this).closest('tr').attr('data-id'); + $('#productStoryForm tr.parent-' + storyID).hide(); + newUnfoldID.push(storyID); + url = createLink('product', 'ajaxSetUnfoldID', 'productID=' + productID + '&action=delete'); + } + + setTimeout(function() + { + if($('#productStoryForm td.has-child a.story-toggle.collapsed').length == 0) + { + $('#toggleFold').html(foldAll).removeClass('collapsed'); + } + else + { + $('#toggleFold').html(unfoldAll).addClass('collapsed'); + } + }, 100); + + $.post(url, {'newUnfoldID': JSON.stringify(newUnfoldID)}); + }); + } }); diff --git a/module/product/view/browse.html.php b/module/product/view/browse.html.php index 25b585c81b..5782fe305e 100644 --- a/module/product/view/browse.html.php +++ b/module/product/view/browse.html.php @@ -15,6 +15,15 @@ +app->loadLang('project'); +$config->product->browse->unfoldID = isset($config->product->browse->unfoldID) ? json_decode($config->product->browse->unfoldID, true) : array(); +$config->product->browse->unfoldID = zget($config->product->browse->unfoldID, $productID, array()); +js::set('unfoldID', $config->product->browse->unfoldID); +js::set('unfoldAll', $lang->project->treeLevel['all']); +js::set('foldAll', $lang->project->treeLevel['root']); +?>