diff --git a/config/filter.php b/config/filter.php index bc8f6b2d2a..89ee1296f0 100755 --- a/config/filter.php +++ b/config/filter.php @@ -109,6 +109,7 @@ $filter->program->default = new stdclass(); $filter->program->pgmproject = new stdclass(); $filter->program->prjbrowse = new stdclass(); $filter->program->project = new stdclass(); +$filter->program->product = new stdclass(); $filter->program->browse = new stdclass(); $filter->program->export = new stdclass(); $filter->program->pgmbrowse = new stdclass(); @@ -254,6 +255,7 @@ $filter->program->default->cookie['lastPRJ'] = 'int'; $filter->program->prjbrowse->cookie['programType'] = 'code'; $filter->program->project->cookie['involved'] = 'code'; $filter->program->project->cookie['showProjectBatchEdit'] = 'int'; +$filter->program->product->cookie['showProductBatchEdit'] = 'int'; $filter->program->browse->cookie['showClosed'] = 'code'; $filter->program->export->cookie['checkedItem'] = 'reg::checked'; $filter->program->ajaxgetdropmenu->cookie['showClosed'] = 'code'; diff --git a/module/product/js/all.js b/module/product/js/all.js index 6f75f1b1f3..9aed531aa3 100644 --- a/module/product/js/all.js +++ b/module/product/js/all.js @@ -1,9 +1,6 @@ $("#" + browseType + "Tab").addClass('btn-active-text'); $(function() { - $('#productListForm .c-checkbox, #productListForm .check-all').hide(); - $('.c-name').css('border-left', 'none'); - $('input[name^="showEdit"]').click(function() { $.cookie('showProductBatchEdit', $(this).is(':checked') ? 1 : 0, {expires: config.cookieLife, path: config.webRoot}); @@ -46,6 +43,12 @@ $(function() } }); + /** + * Set batch edit checkbox. + * + * @access public + * @return void + */ function setCheckbox() { $('#productListForm .c-checkbox, #productListForm .check-all').hide(); diff --git a/module/program/control.php b/module/program/control.php index 2a15648ef4..e8fc64c7e6 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -163,14 +163,15 @@ class program extends control $this->view->program = $program; } - $this->view->title = $this->lang->program->product; - $this->view->position[] = $this->lang->program->product; - $this->view->programID = $programID; - $this->view->browseType = $browseType; - $this->view->orderBy = $orderBy; - $this->view->pager = $pager; - $this->view->users = $this->loadModel('user')->getPairs('noletter'); - $this->view->products = $this->loadModel('product')->getStats($orderBy, $pager, $browseType, '', 'story', $programID); + $this->view->title = $this->lang->program->product; + $this->view->position[] = $this->lang->program->product; + $this->view->programID = $programID; + $this->view->browseType = $browseType; + $this->view->orderBy = $orderBy; + $this->view->pager = $pager; + $this->view->users = $this->loadModel('user')->getPairs('noletter'); + $this->view->products = $this->loadModel('product')->getStats($orderBy, $pager, $browseType, '', 'story', $programID); + $this->view->showBatchEdit = $this->cookie->showProductBatchEdit; $this->display(); } diff --git a/module/program/css/product.css b/module/program/css/product.css index 3d4a43d6f9..2cae287e69 100644 --- a/module/program/css/product.css +++ b/module/program/css/product.css @@ -3,3 +3,4 @@ tbody.sortable > tr > td > span.sort-handler {color: #999;} .icon-move {color: #16a8f8;} .table.has-sort-head thead>tr>th>a:after, .table.has-sort-head thead>tr>th>a:before {top: -4px;} +.statistic {margin-left: 10px; color: #838a9d; float: left; position: relative; line-height: 28px;} diff --git a/module/program/js/product.js b/module/program/js/product.js new file mode 100644 index 0000000000..4322900ef2 --- /dev/null +++ b/module/program/js/product.js @@ -0,0 +1,105 @@ +$(function() +{ + $('input[name^="showEdit"]').click(function() + { + $.cookie('showProductBatchEdit', $(this).is(':checked') ? 1 : 0, {expires: config.cookieLife, path: config.webRoot}); + setCheckbox(); + }); + setCheckbox(); + + $(":checkbox[name^='productIDList']").on('click', function() + { + updateStatistic() + }); + + $(".check-all").on('click', function() + { + if($(":checkbox[name^='productIDList']:not(:checked)").length == 0) + { + $(":checkbox[name^='productIDList']").prop('checked', false); + } + else + { + $(":checkbox[name^='productIDList']").prop('checked', true); + } + updateStatistic() + }); +}); + + +/** + * Set batch edit checkbox. + * + * @access public + * @return void + */ +function setCheckbox() +{ + $('#productListForm .checkbox-primary, #productListForm .check-all').hide(); + $('#productListForm .product-id').addClass('hidden'); + if($.cookie('showProductBatchEdit') == 1) + { + $('#productListForm .checkbox-primary, #productListForm .check-all').show(); + } + else + { + $('#productListForm .product-id').removeClass('hidden'); + } +} + +/** + * Add a statistics prompt statement after the Edit button. + * + * @access public + * @return void + */ +function addStatistic() +{ + var checkedLength = $(":checkbox[name^='productIDList']:checked").length; + if(checkedLength > 0) + { + var summary = checkedProducts.replace('%s', checkedLength); + if(cilentLang == "en" && checkedLength < 2) summary = summary.replace('products', 'product'); + + var statistic = "
" + summary + "
"; + $('#productsCount').hide(); + $('#productsSummary').remove(); + $('#editBtn').after(statistic); + $('.table-actions').show(); + } + else + { + $('.table-actions').hide(); + $('#productsCount').show(); + $('#productsSummary').addClass('hidden'); + } +} + +/** + * Anti shake operation for jquery. + * + * @param fn $fn + * @param delay $delay + * @access public + * @return void + */ +function debounce(fn, delay) +{ + var timer = null; + return function() + { + if(timer) clearTimeout(timer); + timer = setTimeout(fn, delay) + } +} + +/** + * Update statistics. + * + * @access public + * @return void + */ +function updateStatistic() +{ + debounce(addStatistic(), 200) +} diff --git a/module/program/view/product.html.php b/module/program/view/product.html.php index c666a8ee4b..bedea18fbd 100644 --- a/module/program/view/product.html.php +++ b/module/program/view/product.html.php @@ -11,14 +11,18 @@ ?> +product->checkedProducts);?> +app->getClientLang());?> +