From: Frank Brehm Date: Sun, 22 Nov 2009 09:13:04 +0000 (+0000) Subject: Weiteres Session-Attribut dazu X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=2b0bfa9ef35f5b879b42895cf1590ca5c49f6b97;p=books.git Weiteres Session-Attribut dazu --- diff --git a/frbr_books.yml b/frbr_books.yml index 0ad7f6a..50b6a8d 100644 --- a/frbr_books.yml +++ b/frbr_books.yml @@ -10,9 +10,15 @@ debug_level: 0 log_level: info # Soll die Log-Ausgabe farbig erfolgen ? colored_log: 0 + # # Standard-Listenlaenge default_list_length: 20 + +# +# Anzahl der angezeigten zugeordneten Bücher in einer anderen Liste +default_count_books_in_other_list: 10 + # # Sitzungsparameter session: diff --git a/lib/FrBr/Books.pm b/lib/FrBr/Books.pm index 0f7aea2..b9595e7 100644 --- a/lib/FrBr/Books.pm +++ b/lib/FrBr/Books.pm @@ -227,7 +227,9 @@ sub auto : Private { # Listenlaenge festlegen $c->stash->{'list_length'} = $c->session->{'list_length'} || $c->config->{'default_list_length'} || 20; - + + # Anzahl der angezeigten zugeordneten Bücher in einer anderen Liste + $c->stash->{'books_in_other_list'} = $c->session->{'books_in_other_list'} || $c->config->{'default_count_books_in_other_list'} || 10; 1; @@ -292,6 +294,8 @@ it under the same terms as Perl itself. =item I: die aktuelle Listenlaenge +=item I: Anzahl der angezeigten zugeordneten Bücher in einer anderen Liste + =back =cut diff --git a/lib/FrBr/Books/Controller/Logout.pm b/lib/FrBr/Books/Controller/Logout.pm index 27ecf2f..be3ef27 100644 --- a/lib/FrBr/Books/Controller/Logout.pm +++ b/lib/FrBr/Books/Controller/Logout.pm @@ -43,6 +43,7 @@ sub index : Private { book_data_edit book_list_page book_order_criteria + books_in_other_list category_data_edit delete_book_id from_book_list diff --git a/lib/FrBr/Books/Controller/SessionOpts.pm b/lib/FrBr/Books/Controller/SessionOpts.pm index 6f5c355..eb62870 100644 --- a/lib/FrBr/Books/Controller/SessionOpts.pm +++ b/lib/FrBr/Books/Controller/SessionOpts.pm @@ -73,6 +73,16 @@ sub index : Private { delete $c->session->{'book_list_page'} if exists $c->session->{'book_list_page'}; } + # Anzahl der angezeigten zugeordneten Bücher in einer anderen Liste festlegen + $length = $c->request->params->{'books_in_other_list'}; + if ( $length and to_int( $length ) ) { + $length = to_int( $length ); + $length = 2 if $length < 2; + $length = 100 if $length > 100; + $c->session->{'books_in_other_list'} = $length; + $c->stash->{'books_in_other_list'} = $length; + } + save_user_prefs($c) if $c->user_exists(); } diff --git a/lib/FrBr/Books/Util/User.pm b/lib/FrBr/Books/Util/User.pm index c60c9b6..addb7f3 100644 --- a/lib/FrBr/Books/Util/User.pm +++ b/lib/FrBr/Books/Util/User.pm @@ -64,9 +64,15 @@ sub save_user_prefs { my $prefs = {}; + # allgemeine Listenlänge $prefs->{'list_length'} = $c->stash->{'list_length'}; + + # Sortierkriterien der Buchliste $prefs->{'book_order_criteria'} = $c->session->{'book_order_criteria'} if $c->session->{'book_order_criteria'}; + # Anzahl der angezeigten zugeordneten Bücher in einer anderen Liste + $prefs->{'books_in_other_list'} = $c->stash->{'books_in_other_list'}; + my $dump = Dump($prefs); $c->model('Schema::UserAdd')->search( { 'user_id' => $user_id } )->update( { 'prefs' => $dump } ) ; @@ -109,11 +115,25 @@ sub restore_user_prefs { return unless $prefs; if ( $prefs->{'list_length'} ) { + + # Seite der Buchliste delete $c->session->{'book_list_page'} if exists $c->session->{'book_list_page'}; - $c->stash->{'list_length'} = $prefs->{'list_length'}; - $c->session->{'list_length'} = $prefs->{'list_length'}; + + # allgemeine Listenlänge + if ( $prefs->{'list_length'} ) { + $c->stash->{'list_length'} = $prefs->{'list_length'}; + $c->session->{'list_length'} = $prefs->{'list_length'}; + } + + # Anzahl der angezeigten zugeordneten Bücher in einer anderen Liste + if ( $prefs->{'books_in_other_list'} ) { + $c->stash->{'books_in_other_list'} = $prefs->{'books_in_other_list'}; + $c->session->{'books_in_other_list'} = $prefs->{'books_in_other_list'}; + } + } + # Sortierkriterien der Buchliste $c->session->{'book_order_criteria'} = $prefs->{'book_order_criteria'} if $prefs->{'book_order_criteria'}; return 1;