From fb365f1203aa2c4acbceb26ec16bea3415d164b7 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 15 Sep 2014 23:41:44 +0100 Subject: [PATCH] Setting for items in number of records per table page menu --- Netdisco/Changes | 6 ++++++ .../lib/App/Netdisco/Manual/Configuration.pod | 20 +++++++++++++++++++ Netdisco/lib/App/Netdisco/Web.pm | 4 ++++ Netdisco/share/config.yml | 11 ++++++++++ .../share/views/ajax/datatabledefaults.tt | 2 +- 5 files changed, 42 insertions(+), 1 deletion(-) diff --git a/Netdisco/Changes b/Netdisco/Changes index 8170f6c0..4a63b7e2 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -1,3 +1,9 @@ +2.029008 + + [ENHANCEMENTS] + + * Setting for items in number of records per table page menu (table_showrecordsmenu). + 2.029007 - 2014-09-12 [ENHANCEMENTS] diff --git a/Netdisco/lib/App/Netdisco/Manual/Configuration.pod b/Netdisco/lib/App/Netdisco/Manual/Configuration.pod index e82228ec..966f8b68 100644 --- a/Netdisco/lib/App/Netdisco/Manual/Configuration.pod +++ b/Netdisco/lib/App/Netdisco/Manual/Configuration.pod @@ -314,6 +314,26 @@ Value: Number. Default: 10. The number of rows in a table page. +=head3 C + +Value: Number. Default: + + - - 10 + - 25 + - 50 + - 100 + - '-1' + - - 10 + - 25 + - 50 + - 100 + - 'All' + +The choices available to users for selecting the number of rows per page. The +format is two lists: one of the values and one of the labels in the web +interface. You can see in the default that a value of "C<-1>" means Show All +Records. Take care of the YAML formatting and indenting for the double list. + =head2 Netdisco Core =head3 C diff --git a/Netdisco/lib/App/Netdisco/Web.pm b/Netdisco/lib/App/Netdisco/Web.pm index 711b10d1..07c403c2 100644 --- a/Netdisco/lib/App/Netdisco/Web.pm +++ b/Netdisco/lib/App/Netdisco/Web.pm @@ -76,6 +76,10 @@ hook 'before_template' => sub { # create date ranges from within templates $tokens->{to_daterange} = sub { interval_to_daterange(@_) }; + # data structure for DataTables records per page menu + $tokens->{table_showrecordsmenu} = + to_json( setting('table_showrecordsmenu') ); + # fix Plugin Template Variables to be only path+query $tokens->{$_} = $tokens->{$_}->path_query for qw/search_node search_device device_ports/; diff --git a/Netdisco/share/config.yml b/Netdisco/share/config.yml index 7710acc0..94d71dec 100644 --- a/Netdisco/share/config.yml +++ b/Netdisco/share/config.yml @@ -82,6 +82,17 @@ jobqueue_refresh: 10 safe_password_store: true reports: [] table_pagesize: 10 +table_showrecordsmenu: + - - 10 + - 25 + - 50 + - 100 + - '-1' + - - 10 + - 25 + - 50 + - 100 + - 'All' # ------------- # NETDISCO CORE diff --git a/Netdisco/share/views/ajax/datatabledefaults.tt b/Netdisco/share/views/ajax/datatabledefaults.tt index 1c463211..55b3ed82 100644 --- a/Netdisco/share/views/ajax/datatabledefaults.tt +++ b/Netdisco/share/views/ajax/datatabledefaults.tt @@ -2,7 +2,7 @@ "processing": true, "stateSave": true, "pageLength": [% settings.table_pagesize %], - "lengthMenu": [ [10, 25, 50, 100, -1], [10, 25, 50, 100, "All"] ], + "lengthMenu": [% table_showrecordsmenu %], "dom": '<"top"l<"nd_datatables-pager"p>f>rt<"bottom"><"clear">', "language": { "search": '_INPUT_',