From 522cde2aa22ac67e12fa0005a1a04b40d0ba16b5 Mon Sep 17 00:00:00 2001 From: mattab Date: Thu, 26 Nov 2015 17:13:53 +1300 Subject: Add 'all' in the Row count selector to be able to display all rows, and optionally export them all --- plugins/CoreHome/CoreHome.php | 1 + plugins/CoreHome/javascripts/dataTable.js | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/CoreHome/CoreHome.php b/plugins/CoreHome/CoreHome.php index 7cf82cfd3b..ba0f3edd82 100644 --- a/plugins/CoreHome/CoreHome.php +++ b/plugins/CoreHome/CoreHome.php @@ -252,6 +252,7 @@ class CoreHome extends \Piwik\Plugin $translationKeys[] = 'Intl_Day_Min_StandAlone_6'; $translationKeys[] = 'Intl_Day_Min_StandAlone_7'; $translationKeys[] = 'General_And'; + $translationKeys[] = 'General_All'; $translationKeys[] = 'General_Search'; $translationKeys[] = 'General_Clear'; $translationKeys[] = 'General_MoreDetails'; diff --git a/plugins/CoreHome/javascripts/dataTable.js b/plugins/CoreHome/javascripts/dataTable.js index 0232d91ec6..56837809fc 100644 --- a/plugins/CoreHome/javascripts/dataTable.js +++ b/plugins/CoreHome/javascripts/dataTable.js @@ -506,13 +506,20 @@ $.extend(DataTable.prototype, UIControl.prototype, { }; } + function getFilterLimitAsString(limit) { + if (limit == '-1') { + return _pk_translate('General_All').toLowerCase(); + } + return limit; + } + // setup limit control - $('.limitSelection', domElem).append('
' + self.param[limitParamName] + '
'); + $('.limitSelection', domElem).append('
' + getFilterLimitAsString(self.param[limitParamName]) + '
'); if (self.props.show_limit_control) { $('.limitSelection ul', domElem).hide(); for (var i = 0; i < numbers.length; i++) { - $('.limitSelection ul', domElem).append('
  • ' + numbers[i] + '
  • '); + $('.limitSelection ul', domElem).append('
  • ' + getFilterLimitAsString(numbers[i]) + '
  • '); } $('.limitSelection ul li:last', domElem).addClass('last'); @@ -535,12 +542,12 @@ $.extend(DataTable.prototype, UIControl.prototype, { $('.limitSelection', domElem).is('.visible') ? hide() : show(); }); $('.limitSelection ul li', domElem).on('click', function (event) { - var limit = parseInt($(event.target).text()); + var limit = parseInt($(event.target).closest('li').attr('value')); hide(); if (limit != self.param[limitParamName]) { setLimitValue(self.param, limit); - $('.limitSelection>div>span', domElem).text(limit); + $('.limitSelection>div>span', domElem).text( getFilterLimitAsString(limit)).attr('value', limit); self.reloadAjaxDataTable(); var data = {}; @@ -1045,7 +1052,7 @@ $.extend(DataTable.prototype, UIControl.prototype, { $(this).attr('href', function () { var url = $(this).attr('href') + '&token_auth=' + piwik.token_auth; - var limit = $('.limitSelection>div>span', domElem).text(); + var limit = $('.limitSelection>div>span', domElem).attr('value'); var defaultLimit = $(this).attr('filter_limit'); if (!limit || 'undefined' === limit || defaultLimit == -1) { limit = defaultLimit; -- cgit v1.2.3